Project

General

Profile

SO3Engine
SO3Window.cpp
Go to the documentation of this file.
1
16
17#include "OgreMemoryAllocatorConfig.h"
18
19#ifdef _WIN32
20# ifndef SO3_USE_DX11
21#include "OgreD3D9RenderWindow.h"
22#include "OgreD3D9DeviceManager.h"
23# endif
24#else
25char* itoa(int val, char* buf, int base){
26 int i = 14;
27 for (; val && i; --i, val /= base)
28 buf[i] = "0123456789abcdef"[val % base];
29 return &buf[i + 1];
30 }
31#endif
32
33#ifdef APPLE_IOS
34#include <QGuiApplication>
35#include <QScreen>
36#endif
37
46extern int getBufferPreRenderEvent(struct Mmachine*, SCOL_PTR_TYPE, SCOL_PTR_TYPE);
47extern int getBufferPostRenderEvent(struct Mmachine*, SCOL_PTR_TYPE, SCOL_PTR_TYPE);
48
49extern int iLastMousePos[2];
50
51namespace SO3
52{
53SWindow::SWindow() : SData("")
54{
55 // Forbiden constructor (private).
56}
57
58SWindow::SWindow(SRoot* parent, const ScolWindowHandle& windowHandle, const std::string& windowName, const int& width, const int& height, const std::string& fsaa) : SData(windowName)
59{
60 scolRoot = parent;
61 bBeginFrame = false;
62 bSizeDirty = true;
63 subEntitySelector = 0;
65
66#if defined(ANDROID) || defined(APPLE_IOS) || defined(OSX) || defined(RPI)
67 mSelectorMode = SO3_SELECTOR_LIMITED;
68#else
69 mSelectorMode = SO3_SELECTOR_FAST;
70#endif
71
72 //update config
73 scolRoot->ParseConfigFile();
74
75 int awidth = width;
76 int aheight = height;
77
78 // Retrieve the parent window handle.
79 hwnd = (ScolWindowHandle)windowHandle;
80 Ogre::String winHandle = Ogre::StringConverter::toString((size_t)(ScolWindowHandle)hwnd);
81
82#ifdef _WIN32
83 //add WS_CLIPCHILDREN flag for 3D content
84 SetWindowLongPtr(hwnd, GWL_STYLE, (GetWindowLongPtr(hwnd, GWL_STYLE))|WS_CLIPCHILDREN);
85#endif
86
87 // Setting render window options
88 Ogre::NameValuePairList viewConfig;
89#ifdef ANDROID
90 struct android_app* androidApp = (struct android_app*)SCgetExtra("this_inst");
91 ScolWindowHandle awindow = (ScolWindowHandle)SCgetExtra("hscol");
92 AConfiguration* config = AConfiguration_new();
93 if (androidApp)
94 {
95 AConfiguration_fromAssetManager(config, androidApp->activity->assetManager);
96 awidth = 0;
97 aheight = 0;
98
99 viewConfig["externalWindowHandle"] = Ogre::StringConverter::toString(SCOL_PTR awindow);
100 viewConfig["androidConfig"] = Ogre::StringConverter::toString(SCOL_PTR config);
101 viewConfig["minColourBufferSize"] = Ogre::StringConverter::toString(24);
102 viewConfig["preserveContext"] = "true";
103 viewConfig["MSAA"] = "2";
104
105 /*
106 float wScale = 1.0f;
107 int nwidth = (int)ANativeWindow_getWidth(awindow);
108 int nheight = (int)ANativeWindow_getHeight(awindow);
109
110 // portrait mode
111 if (nheight > nwidth)
112 {
113 nwidth = (int)ANativeWindow_getHeight(awindow);
114 nheight = (int)ANativeWindow_getWidth(awindow);
115 }
116
117 if (nwidth > 1920)
118 {
119 wScale = 2.0f;
120 }
121 else if (nwidth > 1280)
122 {
123 wScale = 1.5f;
124 }
125 //comment to avoid a bug on weird old tablets
126 else if (nwidth > 1024)
127 {
128 wScale = 1.2f;
129 }
130
131 viewConfig["contentScalingFactor"] = Ogre::StringConverter::toString(wScale);
132 */
133 }
134#elif defined(_WIN32)
135 viewConfig["externalWindowHandle"] = winHandle;
136 viewConfig["vsync"] = parent->GetVSyncEnable() ? "Yes" : "No";
137 //viewConfig["colourDepth"] = Ogre::StringConverter::toString(32);
138#elif defined(APPLE_IOS)
139 viewConfig["externalViewHandle"] = winHandle;
140 viewConfig["retainedBacking"] = "Yes";
141 QScreen* screen = QGuiApplication::primaryScreen();
142 QRect screenSize = screen->geometry();
143 awidth = screenSize.width();
144 aheight = screenSize.height();
145
146#elif defined(__APPLE__)
147 viewConfig["externalWindowHandle"] = winHandle;
148#elif defined(RPI)
149 viewConfig["externalWindowHandle"] = winHandle;
150#else //linux X11
151 viewConfig["parentWindowHandle"] = winHandle;
152#endif
153
154#ifdef _WIN32
155 #ifdef SO3_DEBUG
156 viewConfig["useNVPerfHUD"] = "Yes";
157 #endif
158#endif
159
160 /******************************************* Options Setting ***************************************/
161 if(scolRoot->checkFSAA(fsaa))
162 {
163 if(fsaa.find("[Quality]") != string::npos)
164 {
165 viewConfig["FSAAHint"] = "Quality";
166 viewConfig["FSAA"] = fsaa.substr(0, fsaa.find("[Quality]")-2);
167 }
168 else
169 {
170 viewConfig["FSAA"] = fsaa;
171 viewConfig["FSAAHint"] = "";
172 }
173 }
174
175 O3Window = Ogre::Root::getSingleton().createRenderWindow(windowName, awidth, aheight, false, &viewConfig);
176
177 O3Window->setPriority(0);
178 //O3Window->setDeactivateOnFocusChange(false);
179
180 if(O3Window->isPrimary())
181 scolRoot->InitRenderer(this);
182
183 O3Window->addListener(this);
184 stereoManager = new StereoManager(this);
185
186#ifdef _WIN32
187 hwndFullscreenOgre = NULL;
188 styleFullscreenOgre = NULL;
189 exstyleFullscreenOgre = NULL;
190 mLastWindowRegion = NULL;
191#endif
192
193#ifdef ANDROID
194 AConfiguration_delete(config);
195#endif
196
197
198 // For subentity picking
199#if !defined(OSX) && !defined(APPLE_IOS)
200 Ogre::PixelFormat rttformat;
201 bool pfsupport = SRoot::getSingleton().GetRttPixelFormat(rttformat, true);
202 if (pfsupport)
203 {
204 subEntitySelector = new SSubEntitySelectorBuffer(this, (mSelectorMode == SO3_SELECTOR_FAST) ? true : false);
205 }
206#endif
207
209
210 //update to create ressources
211 Update();
212}
213
215{
216 SetFullScreen(false);
217 O3Window->removeListener(this);
218 SO3_SAFE_DELETE(subEntitySelector);
219 SO3_SAFE_DELETE(stereoManager);
220
221 MMechostr(0, "Destroy window name : %s\n", GetName().c_str());
222 if(!O3Window->isPrimary())
223 {
224 SRoot::getSingleton().GetOgreRenderSystem()->destroyRenderWindow(GetName());
225 }
226
227 O3Window = 0;
228
229#ifdef _WIN32
230 //remove WS_CLIPCHILDREN flag for 3D content
231 SetWindowLongPtr(hwnd, GWL_STYLE, (GetWindowLongPtr(hwnd, GWL_STYLE))& ~(WS_CLIPCHILDREN));
232#endif
233}
234
235void SWindow::preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
236{
237 if (evt.source == O3Window)
238 {
239 if (!SRoot::getSingletonPtr()->isDeviceLost())
240 {
241 getBufferPreRenderEvent(mm, SCOL_PTR this, 0);
242 }
243 }
244}
245
247{
248#ifdef _WIN32
249 POINT screenPoint;
250 screenPoint.x = 0;
251 screenPoint.y = 0;
252 ClientToScreen(hwnd, &screenPoint);
253
254 screenPos.x = (Ogre::Real)screenPoint.x;
255 screenPos.y = (Ogre::Real)screenPoint.y;
256#endif
257}
258
260{
261 return screenPos;
262}
263
265{
266#ifdef _WIN32
267 RECT rc;
268 BOOL result;
269
270 // width and height represent drawable area only
271 result = GetClientRect(hwnd, &rc);
272 if (result == FALSE)
273 return;
274
275 unsigned int width = rc.right - rc.left;
276 unsigned int height = rc.bottom - rc.top;
277
278 if ((width > 4) && (height > 4))
279 {
280 bSizeDirty = true;
281
282 //update viewports to get the correct pixel size
283 try
284 {
285 O3Window->windowMovedOrResized();
286 }
287 catch (Ogre::Exception&) //error can appen on compositor resources creation if the device is not ready
288 {
289 }
290 }
291#else
292 bSizeDirty = true;
293
294 //update viewports to get the correct pixel size
295 try
296 {
297 O3Window->windowMovedOrResized();
298 }
299 catch (Ogre::Exception&) //error can appen on compositor resources creation if the device is not ready
300 {
301 }
302#endif
303}
304
306{
307 return bSizeDirty;
308}
309
310void SWindow::postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
311{
312 if (evt.source == O3Window)
313 {
314 //MMechostr(MSKDEBUG, "postRenderTargetUpdate raycast : %i:%i\n", iLastMousePos[0], iLastMousePos[1]);
315 if (iLastMousePos[0] > 0)
316 {
317 int x = iLastMousePos[0];
318 int y = iLastMousePos[1];
319 ToPixelPos(x, y);
320 RayCast(x, y);
321 }
322
323 getBufferPostRenderEvent(mm, SCOL_PTR this, 0);
324 }
325}
326
327void SWindow::RefreshSelector(const bool& forceRefresh)
328{
329 // Check texture size
330 if (subEntitySelector)
331 subEntitySelector->UpdateBufferSize(forceRefresh);
332}
333
334void SWindow::SetSelectorEnable(const bool& state)
335{
336#if !defined(OSX) && !defined(APPLE_IOS)
337 Ogre::PixelFormat rttformat;
338 bool pfsupport = SRoot::getSingleton().GetRttPixelFormat(rttformat, true);
339 if (pfsupport)
340 {
341 if (state && !subEntitySelector)
342 {
343 subEntitySelector = new SSubEntitySelectorBuffer(this, (mSelectorMode == SO3_SELECTOR_FAST) ? true : false);
344 SViewPortList::iterator iViewport = listOfViewPort.begin();
345 while (iViewport != listOfViewPort.end())
346 {
347 subEntitySelector->AddViewport(iViewport->second);
348 iViewport++;
349 }
350
351 subEntitySelector->UpdateBufferSize(true);
352 }
353 else if (!state && subEntitySelector)
354 SO3_SAFE_DELETE(subEntitySelector);
355 }
356#endif
357}
358
360{
361 if (mSelectorMode != mode)
362 {
363#if defined(ANDROID) || defined(APPLE_IOS) || defined(OSX) || defined(RPI)
364 mSelectorMode = (mode == SO3_SELECTOR_FAST) ? SO3_SELECTOR_LIMITED : mode;
365#else
366 mSelectorMode = mode;
367#endif
368
369#if !defined(OSX) && !defined(APPLE_IOS)
370 bool reload = false;
371
372 if (subEntitySelector)
373 {
374 SO3_SAFE_DELETE(subEntitySelector);
375 reload = true;
376 }
377
378 if (reload)
379 {
380 Ogre::PixelFormat rttformat;
381 bool pfsupport = SRoot::getSingleton().GetRttPixelFormat(rttformat, true);
382 if (pfsupport)
383 {
384 bool useDepth = false;
385 if (mSelectorMode == SO3_SELECTOR_FAST)
386 useDepth = true;
387
388 subEntitySelector = new SSubEntitySelectorBuffer(this, useDepth);
389 SViewPortList::iterator iViewport = listOfViewPort.begin();
390 while (iViewport != listOfViewPort.end())
391 {
392 subEntitySelector->AddViewport(iViewport->second);
393 iViewport++;
394 }
395
396 subEntitySelector->UpdateBufferSize(true);
397 }
398 }
399#endif
400 }
401}
402
404{
405 return mSelectorMode;
406}
407
409{
410 // Reinit stereo
411 if (mStereoMode != StereoManager::SO3_NONE_STEREO)
413
414 if (subEntitySelector)
415 subEntitySelector->DestroyBuffers();
416}
417
419{
420 SetSizeDirty();
421
422 if (subEntitySelector)
423 subEntitySelector->CreateBuffers();
424}
425
426ScolWindowHandle SWindow::GetWindowHandle() const
427{
428 return hwnd;
429}
430
431void SWindow::SetWindowHandle(ScolWindowHandle win)
432{
433 hwnd = win;
434}
435
437{
438 return scolRoot;
439}
440
442{
443 return O3Window;
444}
445
446SViewPort* SWindow::CreateViewport(SCamera* camera, int priority, const float& x, const float& y, const float& w, const float& h)
447{
448 SViewPort* newViewport = new SViewPort(this, camera, priority, x, y, w, h);
449 AddViewport(newViewport);
451
452 if (stereoManager)
453 stereoManager->RegisterViewport(newViewport);
454
455 RefreshSelector(true);
456 return newViewport;
457}
458
459void SWindow::DeleteViewport(SViewPort* existingViewport)
460{
461 if (scolRoot->IsUpdating())
462 {
463 if (std::find(mViewportsToDel.begin(), mViewportsToDel.end(), existingViewport) == mViewportsToDel.end())
464 mViewportsToDel.push_back(existingViewport);
465 }
466 else
467 {
468 //remove stereo first since it can use shadows or other compositors
469 if (stereoManager)
470 stereoManager->UnregisterViewport(existingViewport);
471
472 //remove viewports from shadows system
473 //the viewport is added by the shadow system or by the viewport set camera
474 SSceneMap sceneList = scolRoot->GetSceneList();
475 SSceneMap::iterator iScene = sceneList.begin();
476 while (iScene != sceneList.end())
477 {
478 //unregister environment
479 iScene->second->UnregisterViewport(existingViewport);
480 iScene++;
481 }
482
483 RemoveViewport(existingViewport);
484 SRoot::getSingleton().UnregisterViewport(existingViewport);
485 SO3_SAFE_DELETE(existingViewport);
486 RefreshSelector(true);
487 }
488}
489
491{
492 for (unsigned int i = 0; i < mViewportsToDel.size(); i++)
493 {
494 DeleteViewport(mViewportsToDel[i]);
495 }
496 mViewportsToDel.clear();
497}
498
499bool SWindow::UpdateStereoCompositorState(SViewPort* viewport, const Ogre::String compname, bool state)
500{
501 return stereoManager->UpdateStereoCompositorState(viewport->GetOgreViewPortPointer(), compname, state);
502}
503
505{
506 if (stereoManager)
507 stereoManager->RestoreStereoCamera(viewport->GetOgreViewPortPointer());
508}
509
510void SWindow::UpdateStereoCamera(SViewPort* viewport, Ogre::Camera* camera)
511{
512 if (stereoManager)
513 stereoManager->UpdateStereoCamera(viewport->GetOgreViewPortPointer(), camera);
514}
515
516void SWindow::UpdateStereoCameraMatrix(SViewPort* viewport, Ogre::Camera* camera)
517{
518 if (stereoManager)
519 stereoManager->UpdateStereoCameraMatrix(viewport->GetOgreViewPortPointer(), camera);
520}
521
523{
524 if (stereoManager)
525 stereoManager->UnregisterViewport(viewport);
526}
527
529{
530 if (stereoManager)
531 stereoManager->RegisterViewport(viewport);
532}
533
534void SWindow::SynchStereoViewportSetup(SViewPort* viewport, bool overlay, bool shadow)
535{
536 if (stereoManager)
537 stereoManager->SynchViewportSetup(viewport, overlay, shadow);
538}
539
541{
542 if (!stereoManager)
543 return false;
544
545 return stereoManager->IsViewportRegistered(viewport->GetOgreViewPortPointer());
546}
547
548void SWindow::AddViewport(SViewPort* existingViewport)
549{
550 SViewPortList::iterator iViewportSearched = listOfViewPort.find(existingViewport->GetPriority());
551 if(iViewportSearched == listOfViewPort.end())
552 {
553 listOfViewPort.insert(SViewPortList::value_type(existingViewport->GetPriority(), existingViewport));
554 if (subEntitySelector != 0)
555 subEntitySelector->AddViewport(existingViewport);
556 }
557 else
558 {
559 // Viewport already exist in the handled scenes list.
560 OGRE_EXCEPT(Ogre::Exception::ERR_DUPLICATE_ITEM, "Can not add Viewport, an identical element with the same priority already exist!", "SWindow::AddViewport");
561 }
562}
563
564void SWindow::RemoveViewport(SViewPort* existingViewport)
565{
566 SViewPortList::iterator iViewportSearched = listOfViewPort.find(existingViewport->GetPriority());
567 if(iViewportSearched != listOfViewPort.end())
568 {
569 listOfViewPort.erase(iViewportSearched);
570 if (subEntitySelector != 0)
571 subEntitySelector->RemoveViewport(existingViewport);
572 }
573 else
574 {
575 // Viewport not found in the handled viewports list
576 OGRE_EXCEPT(Ogre::Exception::ERR_ITEM_NOT_FOUND, "Can not remove Viewport, element not found!", "SWindow::RemoveViewport");
577 }
578}
579
581{
582 return listOfViewPort;
583}
584
585SViewPort* SWindow::GetViewport(const int& priority) const
586{
587 SViewPort* existingViewport = 0;
588 SViewPortList::const_iterator iViewportSearched = listOfViewPort.find(priority);
589 if(iViewportSearched != listOfViewPort.end())
590 {
591 existingViewport = iViewportSearched->second;
592 }
593 else
594 {
595 // Viewport not found in the handled viewports list
596 OGRE_EXCEPT(Ogre::Exception::ERR_ITEM_NOT_FOUND, "Can not find Viewport with this priority, windows do not have such element!", "SWindow::GetViewport");
597 }
598 return existingViewport;
599}
600
601SViewPort* SWindow::GetViewport(const int& x, const int& y)
602{
603 int highestZ = 0;
604 SViewPort* resultViewport = 0;
605
606 SViewPortList::iterator iViewport = listOfViewPort.begin();
607 while(iViewport != listOfViewPort.end())
608 {
609 int curZ = iViewport->second->GetPriority();
610 int left = iViewport->second->GetLeftPixels();
611 int top = iViewport->second->GetTopPixels();
612 int width = iViewport->second->GetWidthPixels();
613 int height = iViewport->second->GetHeightPixels();
614
615 if(((x >= left)&&(y >= top)&&(x <= left + width)&&(y <= top + height)) && curZ >= highestZ)
616 {
617 resultViewport = iViewport->second;
618 highestZ = curZ;
619 }
620
621 iViewport++;
622 }
623
624 return resultViewport;
625}
626
627void SWindow::windowMoved(Ogre::RenderWindow* rw)
628{
629}
630
631void SWindow::windowResized(Ogre::RenderWindow* rw)
632{
633}
634
635void SWindow::windowClosed(Ogre::RenderWindow* rw)
636{
637}
638
639void SWindow::windowFocusChange(Ogre::RenderWindow* rw)
640{
641}
642
643int SWindow::Size(const int& x, const int& y, const int& w, const int& h, const int& ext)
644{
645 try
646 {
647 int iw = w;
648 int ih = h;
649 O3Window->resize(std::max(4, iw) , std::max(4, ih));
650
651 //hack to avoid the window to be moved in screen view
652#if !defined(LINUX) && !defined(OSX)
653 O3Window->reposition(x, y);
654#endif
655 O3Window->windowMovedOrResized();
656 }
657 catch(Ogre::Exception &)
658 {
659 //nothing, the window is too small
660 return 0;
661 }
662 bSizeDirty = true;
663
664 //re-apply custom camera matrix and compositors
665 SViewPortList::iterator iViewport = listOfViewPort.begin();
666 while(iViewport != listOfViewPort.end())
667 {
668 SViewPort* vp = (iViewport->second);
669 SCamera* camera = vp->GetCamera();
670 if (camera != 0)
671 {
672 // last render target set the camera ratio, we need this to restore to the main viewport ratio
673 float cRatio = camera->GetAspectRatio();
674 if (camera->GetOgreCameraPointer()->getAutoAspectRatio())
675 cRatio = (float)vp->GetOgreViewPortPointer()->getActualWidth() / (float)vp->GetOgreViewPortPointer()->getActualHeight();
676
677 camera->GetOgreCameraPointer()->setAspectRatio(cRatio);
678
679 if (camera->GetOgreCameraPointer()->isCustomViewMatrixEnabled())
680 camera->GetOgreCameraPointer()->setCustomViewMatrix(true, camera->GetViewMatrix());
681
682 if (camera->GetOgreCameraPointer()->isCustomProjectionMatrixEnabled())
683 camera->GetOgreCameraPointer()->setCustomProjectionMatrix(true, camera->GetProjectionMatrix());
684 }
685
686 try
687 {
688 vp->GetOgreViewPortPointer()->_updateDimensions();
689 }
690 catch(Ogre::Exception&) //error can appen on compositor resources creation if the device is not ready
691 {
692 }
693
694 iViewport++;
695 }
696
697 return 0;
698}
699
701{
702 bool valid = true;
703
704#ifdef _WIN32
705# ifndef SO3_USE_DX11
706 if (SRoot::getSingleton().GetRenderSystem() == SRoot::SO3_DIRECTX9_RENDERER)
707 {
708 try
709 {
710 Ogre::D3D9Device* device = static_cast<Ogre::D3D9RenderSystem*>(SRoot::getSingleton().GetOgreRenderSystem())->getDeviceManager()->getActiveDevice();
711 valid = (device != 0) ? !device->isDeviceLost() : false;
712 }
713 catch(Ogre::Exception&)
714 {
715 valid = false;
716 }
717 }
718# endif
719#endif
720
721 if (SRoot::getSingleton().isDeviceLost() || !valid)
722 return;
723
724 try
725 {
726#ifdef _WIN32
727 RECT rc;
728 BOOL result;
729
730 // width and height represent drawable area only
731 result = GetClientRect(hwnd, &rc);
732 if (result == FALSE)
733 return;
734
735 unsigned int width = rc.right - rc.left;
736 unsigned int height = rc.bottom - rc.top;
737
738 if ((width > 3) && (height > 3))
739 {
740 try
741 {
742 O3Window->windowMovedOrResized();
743 }
744 catch (Ogre::Exception&) //error can appen on compositor resources creation if the device is not ready
745 {
746 return;
747 }
748 }
749#else
750 try
751 {
752 O3Window->windowMovedOrResized();
753 }
754 catch (Ogre::Exception&) //error can appen on compositor resources creation if the device is not ready
755 {
756 return;
757 }
758#endif
759
760 Ogre::CompositorManager &compositorManager = Ogre::CompositorManager::getSingleton();
761
762 // Reinit stereo
763 if (mStereoMode != StereoManager::SO3_NONE_STEREO)
764 {
766 }
767
768 //re-apply custom camera matrix and compositors
769 SViewPortList::iterator iViewport = listOfViewPort.begin();
770 while(iViewport != listOfViewPort.end())
771 {
772 SViewPort* vp = (iViewport->second);
773 SCamera* camera = vp->GetCamera();
774 if (camera != 0)
775 {
776 SScene* scene = camera->GetParentScene();
777
778 // last render target set the camera ratio, we need this to restore to the main viewport ratio
779 float cRatio = camera->GetAspectRatio();
780 if (camera->GetOgreCameraPointer()->getAutoAspectRatio())
781 cRatio = (float)vp->GetOgreViewPortPointer()->getActualWidth() / (float)vp->GetOgreViewPortPointer()->getActualHeight();
782
783 camera->GetOgreCameraPointer()->setAspectRatio(cRatio);
784
785 if (camera->GetOgreCameraPointer()->isCustomViewMatrixEnabled())
786 camera->GetOgreCameraPointer()->setCustomViewMatrix(true, camera->GetViewMatrix());
787
788 if (camera->GetOgreCameraPointer()->isCustomProjectionMatrixEnabled())
789 camera->GetOgreCameraPointer()->setCustomProjectionMatrix(true, camera->GetProjectionMatrix());
790
791 if (scene->GetEnvironment() && scene->GetEnvironment()->IsRegisteredViewport(vp))
792 {
794 scene->GetEnvironment()->RegisterViewport(vp);
795 }
796 }
797
798 try
799 {
800 vp->GetOgreViewPortPointer()->_updateDimensions();
801 }
802 catch(Ogre::Exception&) //error can appen on compositor resources creation if the device is not ready
803 {
804 }
805
806 iViewport++;
807 }
808
809 try
810 {
812 }
813 catch(Ogre::Exception&) //error can appen on compositor resources creation if the device is not ready
814 {
815 }
816
817 // Reinit stereo
818 if (mStereoMode != StereoManager::SO3_NONE_STEREO)
819 {
820 stereoManager->SetStereoMode(mStereoMode);
821 }
822 }
823 catch (Ogre::Exception& e)
824 {
825 MMechostr(MSKDEBUG, "SO3Engine error on window resize : %s", e.what());
826 return;
827 }
828 bSizeDirty = false;
829}
830
831unsigned int SWindow::GetWidth() const
832{
833 return O3Window->getWidth();
834}
835
836unsigned int SWindow::GetHeight() const
837{
838 return O3Window->getHeight();
839}
840
842{
843 unsigned int nullUintPtr;
844 int left, nullIntPtr;
845 O3Window->getMetrics(nullUintPtr, nullUintPtr, nullIntPtr, left);
846 return left;
847}
848
850{
851 unsigned int nullUintPtr;
852 int top, nullIntPtr;
853 O3Window->getMetrics(nullUintPtr, nullUintPtr, nullIntPtr, top);
854 return top;
855}
856
857bool SWindow::SetFullScreen(const bool& fullscreen, const int& width, const int& height)
858{
859 bool success = false;
860 int nwidth = width;
861 int nheight = height;
862
863#ifdef _WIN32
864 //DO NOT CHANGE ANYTHING UNTIL YOU TEST BOTH OPENGL AND DIRECTX, WINDOWED AND FULLSCREEN SWITCHING
865 if(!fullscreen && O3Window->isFullScreen())
866 {
867 O3Window->setVSyncEnabled(scolRoot->GetVSyncEnable());
868 success = SRoot::getSingleton().SetFullScreenState(this, fullscreen, mLastPos.rcNormalPosition.right - mLastPos.rcNormalPosition.left, mLastPos.rcNormalPosition.bottom - mLastPos.rcNormalPosition.top);
869
870 SetWindowPos(hwnd, HWND_NOTOPMOST, mLastPos.rcNormalPosition.left, mLastPos.rcNormalPosition.top, mLastPos.rcNormalPosition.right - mLastPos.rcNormalPosition.left -1, mLastPos.rcNormalPosition.bottom - mLastPos.rcNormalPosition.top -1, SWP_FRAMECHANGED | SWP_SHOWWINDOW);
871
872 // force a screen change on update
873 screenPos = Ogre::Vector2(0.0f, 0.0f);
874
875 //restore window style and parent
876 SetParent(hwnd, (ScolWindowHandle)hwndFullscreenOgre);
877 SetWindowLongPtr(hwnd, GWL_STYLE, styleFullscreenOgre);
878 SetWindowLongPtr(hwnd, GWL_EXSTYLE, exstyleFullscreenOgre);
879 //reset the windows client rect since a Ogre DirectX bug forget to handle that
880 SetWindowRgn(hwnd, mLastWindowRegion, FALSE);
881
882 //hack force a size change to force Ogre DX render to update viewports
883 Size(mLastPos.rcNormalPosition.left, mLastPos.rcNormalPosition.top, mLastPos.rcNormalPosition.right - mLastPos.rcNormalPosition.left -1, mLastPos.rcNormalPosition.bottom - mLastPos.rcNormalPosition.top -1, 0);
884
885 // restore last position
886 Size(mLastPos.rcNormalPosition.left, mLastPos.rcNormalPosition.top, mLastPos.rcNormalPosition.right - mLastPos.rcNormalPosition.left, mLastPos.rcNormalPosition.bottom - mLastPos.rcNormalPosition.top, 0);
887
888 bSizeDirty = true;
889 }
890 else if(fullscreen && !O3Window->isFullScreen())
891 {
892 // check inverted size for rotated screens
893 if (!CheckVideoMode(width, height) && !CheckVideoMode(height, width))
894 {
895 bSizeDirty = true;
896
897 //try to find a valid resolution
898 if (CheckVideoMode(1920, 1080))
899 {
900 nwidth = 1920;
901 nheight = 1080;
902 }
903 else if (CheckVideoMode(1280, 720))
904 {
905 nwidth = 1280;
906 nheight = 720;
907 }
908 else if (CheckVideoMode(1024, 768))
909 {
910 nwidth = 1024;
911 nheight = 768;
912 }
913 else
914 {
915 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Invalid resolution parameters, fullscreen not setted", "SWindow::SetFullScreen");
916 return false;
917 }
918 }
919
920 // get current windows parameters
921 hwndFullscreenOgre = GetWindowLongPtr(hwnd, GWLP_HWNDPARENT);
922 styleFullscreenOgre = GetWindowLongPtr(hwnd, GWL_STYLE);
923 exstyleFullscreenOgre = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
924 GetWindowPlacement(hwnd, &mLastPos);
925 GetWindowRgn(hwnd, mLastWindowRegion);
926
927 POINT screenPoint;
928 screenPoint.x = 0;
929 screenPoint.y = 0;
930 ClientToScreen(hwnd, &screenPoint);
931
932 //reset window style and parent
933 SetParent(hwnd, NULL);
934
935 SetWindowPos(hwnd, HWND_TOPMOST, mLastPos.rcNormalPosition.left + screenPoint.x, mLastPos.rcNormalPosition.top + screenPoint.y, mLastPos.rcNormalPosition.right - mLastPos.rcNormalPosition.left -1, mLastPos.rcNormalPosition.bottom - mLastPos.rcNormalPosition.top -1, SWP_NOZORDER | SWP_FRAMECHANGED);
936
937 MONITORINFOEX minfos;
938 minfos.cbSize = sizeof(minfos);
939 GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST), &minfos);
940
941 //force vsync for oculus
942 O3Window->setVSyncEnabled(true);
943
944 //TODO test current root fullscreen state before
945 success = SRoot::getSingleton().SetFullScreenState(this, fullscreen, nwidth, nheight);
946
947 if (!success)
948 {
949 SetWindowLongPtr(hwnd, GWL_STYLE, styleFullscreenOgre);
950 SetWindowLongPtr(hwnd, GWL_EXSTYLE, exstyleFullscreenOgre);
951 SetParent(hwnd, (ScolWindowHandle)hwndFullscreenOgre);
952 //reset the windows client rect since a Ogre DirectX bug forget to handle that
953 SetWindowRgn(hwnd, mLastWindowRegion, FALSE);
954
955 SetWindowPos(hwnd, HWND_TOPMOST, mLastPos.rcNormalPosition.left, mLastPos.rcNormalPosition.top, mLastPos.rcNormalPosition.right - mLastPos.rcNormalPosition.left, mLastPos.rcNormalPosition.bottom - mLastPos.rcNormalPosition.top, SWP_FRAMECHANGED | SWP_SHOWWINDOW);
956 // restore last position
957 Size(mLastPos.rcNormalPosition.left, mLastPos.rcNormalPosition.top, mLastPos.rcNormalPosition.right - mLastPos.rcNormalPosition.left, mLastPos.rcNormalPosition.bottom - mLastPos.rcNormalPosition.top, 0);
958 bSizeDirty = true;
959 return success;
960 }
961
962 SetWindowPos(hwnd, HWND_TOPMOST, minfos.rcMonitor.left, minfos.rcMonitor.top, nwidth, nheight, SWP_NOZORDER | SWP_FRAMECHANGED | SWP_SHOWWINDOW);
963 Size(minfos.rcMonitor.left, minfos.rcMonitor.top, nwidth, height, 0);
964
965 //FORCE Async message to avoid error (needed what ever you think)
966 LPARAM wsize = ((WORD)nheight<<16) | (WORD)nwidth;
967 PostMessage(hwnd, WM_SIZE, 0, wsize);
968 bSizeDirty = true;
969 }
970#elif defined(ANDROID) || defined(APPLE_IOS) || defined(RPI)
971 //return true for other platform and manage special cases like the menu bar for android
972 success = true;
973#else
974 success = SRoot::getSingleton().SetFullScreenState(this, fullscreen, nwidth, nheight);
975#endif //
976
977 return success;
978}
979
981{
982#if defined(ANDROID) || defined(APPLE_IOS) || defined(RPI)
983 return true;
984#else
985 return O3Window->isFullScreen();
986#endif
987}
988
989bool SWindow::CheckVideoMode(const int width, const int height)
990{
991 bool vmc = false;
992 char strW[16];
993 char strH[16];
994
995 Ogre::ConfigOptionMap m_system_caps = SRoot::getSingleton().GetOgreRenderSystem()->getConfigOptions();
996 Ogre::ConfigOptionMap::iterator itr = m_system_caps.begin();
997 while(itr != m_system_caps.end() && !vmc)
998 {
999 if((itr)->first == "Video Mode" )
1000 {
1001 Ogre::StringVector possible_values = (itr)->second.possibleValues;
1002 Ogre::StringVector::iterator pv_itr = possible_values.begin();
1003 while(pv_itr != possible_values.end() && !vmc)
1004 {
1005 if (pv_itr->find(itoa((int)width, strW, 10)) != string::npos && pv_itr->find(itoa((int)height, strH, 10)) != string::npos && pv_itr->find(itoa((int)width, strW, 10))<pv_itr->find(itoa((int)height, strH, 10)))
1006 vmc = true;
1007
1008 pv_itr ++;
1009 }
1010 }
1011 itr ++;
1012 }
1013 return vmc;
1014}
1015
1017{
1018 try
1019 {
1020 O3Window->update(true);
1021 }
1022 catch(Ogre::Exception &e)
1023 {
1024 Ogre::LogManager::getSingleton().getDefaultLog()->logMessage("An exception has occurred: "+ e.getDescription());
1025 }
1026}
1027
1029{
1030 unsigned int bcount = 0;
1031
1032 SViewPortList::iterator iViewport = listOfViewPort.begin();
1033 while (iViewport != listOfViewPort.end())
1034 {
1035 bcount += iViewport->second->GetNumRenderedBatches();
1036 iViewport++;
1037 }
1038
1039 return bcount;
1040}
1041
1043{
1044 unsigned int tcount = 0;
1045 SViewPortList::iterator iViewport = listOfViewPort.begin();
1046 while (iViewport != listOfViewPort.end())
1047 {
1048 tcount += iViewport->second->GetNumRenderedFaces();
1049 iViewport++;
1050 }
1051
1052 return tcount;
1053}
1054
1056{
1057 return O3Window->getStatistics().bestFrameTime;
1058}
1059
1061{
1062 return O3Window->getStatistics().worstFrameTime;
1063}
1064
1066{
1067 return O3Window->getStatistics().bestFPS;
1068}
1069
1071{
1072 return O3Window->getStatistics().worstFPS;
1073}
1074
1076{
1077 return O3Window->getStatistics().avgFPS;
1078}
1079
1080unsigned int SWindow::GetFSAA() const
1081{
1082 return O3Window->getFSAA();
1083}
1084
1086{
1087 mStereoMode = stereoMode;
1088
1089 //if(!bSizeDirty || (mStereoMode == StereoManager::StereoMode::SO3_NONE_STEREO))
1090 stereoManager->SetStereoMode(mStereoMode);
1091}
1092
1094{
1095 return mStereoMode;
1096}
1097
1099{
1100 return stereoManager->GetEyesSpacing();
1101}
1102
1103void SWindow::SetStereoEyesSpacing(const float& eyesSpacing)
1104{
1105 stereoManager->SetEyesSpacing(eyesSpacing);
1106}
1107
1108void SWindow::SetStereoRotateView(const bool state)
1109{
1110 stereoManager->SetRotateView(state);
1111}
1112
1114{
1115 return stereoManager->GetRotateView();
1116}
1117
1118void SWindow::SetStereoProjectionOffset(const float& offset)
1119{
1120 stereoManager->SetStereoProjectionOffset(offset);
1121}
1122
1123void SWindow::SetStereoAspectRatio(const float& ratio)
1124{
1125 stereoManager->SetStereoAspectRatio(ratio);
1126}
1127
1128void SWindow::SetStereoFOVy(const float& fov)
1129{
1130 stereoManager->SetStereoFOVy(fov);
1131}
1132
1133void SWindow::SetStereoDistortion(bool enable, Ogre::Vector4 dist)
1134{
1135 stereoManager->SetStereoDistortion(enable, dist);
1136}
1137
1138void SWindow::SetStereoChromaticAbCorrection(bool enable, Ogre::Vector4 chromAbC)
1139{
1140 stereoManager->SetStereoChromaticAbCorrection(enable, chromAbC);
1141}
1142
1143void SWindow::SetStereoCustomProjectonMatrix(bool enable, const Ogre::Matrix4 &leftMatrix, const Ogre::Matrix4 &rightMatrix)
1144{
1145 stereoManager->SetCustomProjectonMatrices(enable, leftMatrix, rightMatrix);
1146}
1147
1148void SWindow::GetStereoCustomProjectonMatrix(bool &enabled, Ogre::Matrix4 &leftMatrix, Ogre::Matrix4 &rightMatrix) const
1149{
1150 stereoManager->GetCustomProjectonMatrices(enabled, leftMatrix, rightMatrix);
1151}
1152
1153void SWindow::SetStereoTimeWarpMatrix(const Ogre::Matrix4 &leftStartMatrix, const Ogre::Matrix4 &leftEndMatrix, const Ogre::Matrix4 &rightStartMatrix, const Ogre::Matrix4 &rightEndMatrix)
1154{
1155 stereoManager->SetTimeWarpMatrix(leftStartMatrix, leftEndMatrix, rightStartMatrix, rightEndMatrix);
1156}
1157
1158void SWindow::SetStereoMeshUVConfig(Ogre::Vector2 leftuvscale, Ogre::Vector2 leftuvoffset, Ogre::Vector2 rightuvscale, Ogre::Vector2 rightuvoffset)
1159{
1160 stereoManager->SetStereoMeshUVConfig(leftuvscale, leftuvoffset, rightuvscale, rightuvoffset);
1161}
1162
1164{
1165 stereoManager->SetStereoMeshRttSize(leftsize, rightsize);
1166}
1167
1168void SWindow::SetStereoWindow(SO3::SPoint<int> pos, SO3::SPoint<int> size, int index, bool state)
1169{
1170 stereoManager->SetStereoWindow(pos, size, index,state);
1171}
1172
1173void SWindow::SetStereoMeshLeft(std::vector<Ogre::Vector3> vertices, std::vector<std::vector<Ogre::Vector2> > uvs, std::vector<Ogre::Real> vignetteColor, std::vector<Ogre::Real> warp, std::vector<int> indexs)
1174{
1175 stereoManager->SetStereoMeshLeft(vertices, uvs, vignetteColor, warp, indexs);
1176}
1177
1178void SWindow::SetStereoMeshRight(std::vector<Ogre::Vector3> vertices, std::vector<std::vector<Ogre::Vector2> > uvs, std::vector<Ogre::Real> vignetteColor, std::vector<Ogre::Real> warp, std::vector<int> indexs)
1179{
1180 stereoManager->SetStereoMeshRight(vertices, uvs, vignetteColor, warp, indexs);
1181}
1182
1183std::array<SCOL_PTR_TYPE, 2> SWindow::GetStereoTextures()
1184{
1185 return stereoManager->GetStereoTextures();
1186}
1187
1188std::array<SO3::SPoint<int>, 2> SWindow::GetStereoViewportSize()
1189{
1190 return stereoManager->GetStereoViewportSize();
1191}
1192
1193void SWindow::ToPixelPos(int& px, int& py)
1194{
1195#if defined(ANDROID)
1196 ScolWindowHandle awindow = (ScolWindowHandle)SCgetExtra("hscol");
1197 int nwidth = (int)ANativeWindow_getWidth(awindow);
1198 int nheight = (int)ANativeWindow_getHeight(awindow);
1199
1200 px = (int)(((float)GetWidth() / (float)nwidth) * (float)px);
1201 py = (int)(((float)GetHeight() / (float)nheight) * (float)py);
1202#elif defined(APPLE_IOS)
1203 float ratio = GetOgreRenderWindowPointer()->getViewPointToPixelScale();
1204
1205 px *= ratio;
1206 py *= ratio;
1207#endif
1208}
1209
1210SRaycastResult SWindow::RayCast(const int& pixelsX, const int& pixelsY)
1211{
1212 // Getting Under Mouse Viewport
1213 SViewPort* resultViewport = GetViewport(pixelsX, pixelsY);
1214 if (resultViewport != 0)
1215 {
1216 // Call the raycast.
1217 lastRaycast = resultViewport->RayCast(pixelsX, pixelsY, subEntitySelector);
1218 }
1219
1220 return lastRaycast;
1221}
1222
1223SRaycastResult SWindow::IndRayCast(const int& pixelsX, const int& pixelsY)
1224{
1225 SRaycastResult raycastReturn;
1226
1227 // Getting Under Mouse Viewport
1228 SViewPort* resultViewport = GetViewport(pixelsX, pixelsY);
1229 if (resultViewport != 0)
1230 {
1231 // Call the raycast.
1232 raycastReturn = resultViewport->RayCast(pixelsX, pixelsY, subEntitySelector);
1233 }
1234
1235 return raycastReturn;
1236}
1237
1239{
1240 // Invalidate lastRaycast.
1241 lastRaycast = SRaycastResult();
1242}
1243
1245{
1246 try
1247 {
1248 if(lastRaycast.sceneName != "")
1249 {
1250 Ogre::SceneManager* sceneManager = Ogre::Root::getSingleton().getSceneManager(lastRaycast.sceneName);
1251 Ogre::Entity* entity = sceneManager->getEntity(lastRaycast.entityName);
1252 // If no error occurs, then no need to invalidate lastRaycast
1253 }
1254 else
1255 {
1256 // Invalidate lastRaycast.
1258 }
1259 }
1260 catch(Ogre::Exception&)
1261 {
1262 // Invalidate lastRaycast.
1264
1265 // Catching Exception::ERR_ITEM_NOT_FOUND in case sceneManager or entity was deleted since last rtt update. Forwarding other errors.
1266 /*if(e.getNumber() != Ogre::Exception::ERR_ITEM_NOT_FOUND)
1267 {
1268 Ogre::LogManager::getSingletonPtr()->logMessage(e.getFullDescription(), Ogre::LML_CRITICAL, true);
1269 throw e;
1270 }*/
1271 }
1272
1273 return lastRaycast;
1274}
1275
1276void SWindow::WriteContentsToFile(const std::string& path)
1277{
1278#ifdef _WIN32
1279 O3Window->writeContentsToFile(path);
1280#else
1281 Ogre::PixelFormat pf = Ogre::PixelFormat::PF_BYTE_RGBA;
1282
1283 uchar *data = OGRE_ALLOC_T(uchar, O3Window->getWidth() * O3Window->getHeight() * Ogre::PixelUtil::getNumElemBytes(pf), Ogre::MEMCATEGORY_RENDERSYS);
1284 Ogre::PixelBox pb(O3Window->getWidth(), O3Window->getHeight(), 1, pf, data);
1285 Ogre::Box pbs(0, 0, O3Window->getWidth(), O3Window->getHeight());
1286 O3Window->copyContentsToMemory(pbs, pb);
1287
1288 Ogre::Image().loadDynamicImage(data, O3Window->getWidth(), O3Window->getHeight(), 1, pf, false, 1, 0).save(path);
1289
1290 OGRE_FREE(data, Ogre::MEMCATEGORY_RENDERSYS);
1291#endif
1292}
1293
1294}
MMechostr(MSKDEBUG, " > Start loading Plugin SO3Engine dll\n")
int iLastMousePos[2]
Definition SO3SCOL.cpp:136
int nheight
Definition SO3SCOL.cpp:5095
SCOL_EXPORT int cbmachine w
Definition SO3SCOL.cpp:5150
ScolWindowHandle win
Definition SO3SCOL.cpp:5092
int getBufferPostRenderEvent(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
Definition SO3SCOL.cpp:4582
int nwidth
Definition SO3SCOL.cpp:5094
int getBufferPreRenderEvent(mmachine m, SCOL_PTR_TYPE id, SCOL_PTR_TYPE param)
Definition SO3SCOL.cpp:4567
SRoot * scolRoot
Shared data.
Definition SO3SCOL.cpp:186
mmachine mm
Definition SO3SCOL.cpp:109
char * itoa(int val, char *buf, int base)
Definition SO3Window.cpp:25
int BUFFER_STEREO_BEFORE_UPDATE_EVENT
Definition SO3SCOL.cpp:198
int iLastMousePos[2]
Definition SO3SCOL.cpp:136
int BUFFER_STEREO_UPDATED_EVENT
Definition SO3SCOL.cpp:200
int BUFFER_PRE_RENDER_EVENT
Declaration of the global instance for the virtual Machine.
Definition SO3SCOL.cpp:196
int getBufferPostRenderEvent(struct Mmachine *, SCOL_PTR_TYPE, SCOL_PTR_TYPE)
int BUFFER_POST_RENDER_EVENT
Definition SO3SCOL.cpp:197
int BUFFER_STEREO_UPDATE_PARAMS_EVENT
Definition SO3SCOL.cpp:199
int getBufferPreRenderEvent(struct Mmachine *, SCOL_PTR_TYPE, SCOL_PTR_TYPE)
float GetAspectRatio()
Definition SO3Camera.cpp:84
Ogre::Camera * GetOgreCameraPointer()
Definition SO3Camera.cpp:50
const Ogre::Matrix4 & GetProjectionMatrix()
const Ogre::Affine3 & GetViewMatrix()
std::string GetName() const
void UnregisterViewport(SViewPort *targetViewport)
void RegisterViewport(SViewPort *targetViewport)
bool IsRegisteredViewport(SViewPort *targetViewport)
SScene * GetParentScene()
std::string sceneName
Definition SO3RayCast.h:44
std::string entityName
Definition SO3RayCast.h:47
bool GetRttPixelFormat(Ogre::PixelFormat &format, bool alpha=false, bool floattex=false)
Definition SO3Root.cpp:650
void UnregisterViewport(SViewPort *viewport)
Definition SO3Root.cpp:1611
bool SetFullScreenState(SWindow *window, const bool &state, const int &width, const int &height)
Definition SO3Root.cpp:1493
void RegisterViewport(SViewPort *viewport)
Definition SO3Root.cpp:1601
@ SO3_DIRECTX9_RENDERER
Definition SO3Root.h:78
bool GetVSyncEnable()
Definition SO3Root.cpp:2013
bool isDeviceLost()
Definition SO3Root.cpp:1633
Ogre::RenderSystem * GetOgreRenderSystem()
Definition SO3Root.cpp:865
static SRoot & getSingleton()
Definition SO3Root.cpp:116
static SRoot * getSingletonPtr()
Definition SO3Root.cpp:111
void ParseConfigFile()
Definition SO3Root.cpp:2018
SEnvironment * GetEnvironment() const
void UpdateBufferSize(const bool &forceRefresh)
void RemoveViewport(SViewPort *existingViewport)
void AddViewport(SViewPort *newViewport)
SCamera * GetCamera()
SRaycastResult RayCast(const int &pixelsX, const int &pixelsY, SSubEntitySelectorBuffer *subEntitySelector)
Ogre::Viewport * GetOgreViewPortPointer()
void windowFocusChange(Ogre::RenderWindow *rw)
bool GetSizeDirty()
void SetStereoTimeWarpMatrix(const Ogre::Matrix4 &leftStartMatrix, const Ogre::Matrix4 &leftEndMatrix, const Ogre::Matrix4 &rightStartMatrix, const Ogre::Matrix4 &rightEndMatrix)
void SetStereoAspectRatio(const float &ratio)
void ToPixelPos(int &px, int &py)
void RegisterStereoViewport(SViewPort *viewport)
bool UpdateStereoCompositorState(SViewPort *viewport, const Ogre::String compname, bool state)
Ogre::Vector2 GetScreenPos()
void SetStereoProjectionOffset(const float &offset)
void UpdateStereoCameraMatrix(SViewPort *viewport, Ogre::Camera *camera)
void ResumeWindow()
void SetStereoMeshRight(std::vector< Ogre::Vector3 > vertices, std::vector< std::vector< Ogre::Vector2 > > uvs, std::vector< Ogre::Real > vignetteColor, std::vector< Ogre::Real > warp, std::vector< int > indexs)
void UpdateStereoCamera(SViewPort *viewport, Ogre::Camera *camera)
void SetStereoChromaticAbCorrection(bool enable, Ogre::Vector4 chromAbC)
float GetBestFrameTime() const
ScolWindowHandle GetWindowHandle() const
virtual void postRenderTargetUpdate(const Ogre::RenderTargetEvent &evt)
std::array< SCOL_PTR_TYPE, 2 > GetStereoTextures()
Ogre::RenderWindow * GetOgreRenderWindowPointer()
void WindowMovedOrResized()
void RemoveViewport(SViewPort *existingViewport)
float GetAverageFPS() const
SRoot * GetParentRoot()
float GetStereoEyesSpacing()
void SetStereoCustomProjectonMatrix(bool enable, const Ogre::Matrix4 &leftMatrix, const Ogre::Matrix4 &rightMatrix)
void RestoreStereoCamera(SViewPort *viewport)
void SynchStereoViewportSetup(SViewPort *viewport, bool overlay=false, bool shadow=false)
void DeleteViewport(SViewPort *existingViewport)
void SetWindowHandle(ScolWindowHandle win)
void SetStereoMeshLeft(std::vector< Ogre::Vector3 > vertices, std::vector< std::vector< Ogre::Vector2 > > uvs, std::vector< Ogre::Real > vignetteColor, std::vector< Ogre::Real > warp, std::vector< int > indexs)
void SetStereoWindow(SO3::SPoint< int > pos, SO3::SPoint< int > size, int index, bool state)
unsigned int GetFSAA() const
void WriteContentsToFile(const std::string &path)
void InvalidateRayCast()
SelectorMode GetSelectorMode()
float GetBestFPS() const
void SetStereoDistortion(bool enable, Ogre::Vector4 dist)
void UnregisterStereoViewport(SViewPort *viewport)
bool IsStereoViewportRegistered(SViewPort *viewport)
const SViewPortList & GetViewportList() const
void SetStereoFOVy(const float &fov)
bool CheckVideoMode(const int width, const int height)
unsigned int GetTriangleCount()
int Size(const int &x, const int &y, const int &w, const int &h, const int &ext)
void windowResized(Ogre::RenderWindow *rw)
void UpdateScreenPos()
unsigned int GetHeight() const
void SetSelectorEnable(const bool &state)
unsigned int GetBatchCount()
void CleanViewports()
void SetStereoEyesSpacing(const float &eyesSpacing)
float GetWorstFPS() const
void SetStereoMeshRttSize(SO3::SPoint< int > leftsize, SO3::SPoint< int > rightsize)
void PauseWindow()
void SetSizeDirty()
StereoManager::StereoMode GetStereoMode()
void SetStereoRotateView(const bool state)
@ SO3_SELECTOR_LIMITED
Definition SO3Window.h:50
@ SO3_SELECTOR_FAST
Definition SO3Window.h:49
SRaycastResult RayCast(const int &pixelsX, const int &pixelsY)
SViewPort * GetViewport(const int &priority) const
bool GetFullScreen()
virtual void preRenderTargetUpdate(const Ogre::RenderTargetEvent &evt)
void AddViewport(SViewPort *existingViewport)
unsigned int GetWidth() const
void windowMoved(Ogre::RenderWindow *rw)
std::array< SO3::SPoint< int >, 2 > GetStereoViewportSize()
void RefreshSelector(const bool &forceRefresh=false)
float GetWorstFrameTime() const
void windowClosed(Ogre::RenderWindow *rw)
void SetStereoMode(const StereoManager::StereoMode &stereoMode)
SRaycastResult IndRayCast(const int &pixelsX, const int &pixelsY)
SViewPort * CreateViewport(SCamera *camera, int priority, const float &x, const float &y, const float &w, const float &h)
void SetStereoMeshUVConfig(Ogre::Vector2 leftuvscale, Ogre::Vector2 leftuvoffset, Ogre::Vector2 rightuvscale, Ogre::Vector2 rightuvoffset)
void SetSelectorMode(SelectorMode mode)
bool GetStereoRotateView()
void GetStereoCustomProjectonMatrix(bool &enabled, Ogre::Matrix4 &leftMatrix, Ogre::Matrix4 &rightMatrix) const
bool SetFullScreen(const bool &fullscreen, const int &width=0, const int &height=0)
SRaycastResult & GetLastRayCast()
void SetStereoMeshLeft(std::vector< Ogre::Vector3 > vertices, std::vector< std::vector< Ogre::Vector2 > > uvs, std::vector< Ogre::Real > vignetteColor, std::vector< Ogre::Real > warp, std::vector< int > indexs)
void SetStereoFOVy(Ogre::Real fov)
std::array< SCOL_PTR_TYPE, 2 > GetStereoTextures()
void SetCustomProjectonMatrices(bool enable, const Ogre::Matrix4 &leftMatrix, const Ogre::Matrix4 &rightMatrix)
bool UpdateStereoCompositorState(Ogre::Viewport *ogreViewportInstance, const Ogre::String compname, bool state)
void SetStereoProjectionOffset(Ogre::Real offset)
void SetStereoDistortion(bool enable, Ogre::Vector4 dist)
void GetCustomProjectonMatrices(bool &enabled, Ogre::Matrix4 &leftMatrix, Ogre::Matrix4 &rightMatrix) const
void SetStereoMeshRttSize(SO3::SPoint< int > leftsize, SO3::SPoint< int > rightsize)
bool IsViewportRegistered(Ogre::Viewport *ogreViewportInstance)
void SetStereoChromaticAbCorrection(bool enable, Ogre::Vector4 chromAbC)
void SetStereoMode(const StereoMode &newStereoMode)
void SetStereoWindow(SO3::SPoint< int > pos, SO3::SPoint< int > size, int index, bool state)
Ogre::Real GetEyesSpacing() const
void UnregisterViewport(SViewPort *viewportInstance)
void SetTimeWarpMatrix(const Ogre::Matrix4 &leftStartMatrix, const Ogre::Matrix4 &leftEndMatrix, const Ogre::Matrix4 &rightStartMatrix, const Ogre::Matrix4 &rightEndMatrix)
std::array< SO3::SPoint< int >, 2 > GetStereoViewportSize()
void SetStereoMeshRight(std::vector< Ogre::Vector3 > vertices, std::vector< std::vector< Ogre::Vector2 > > uvs, std::vector< Ogre::Real > vignetteColor, std::vector< Ogre::Real > warp, std::vector< int > indexs)
void SetStereoMeshUVConfig(Ogre::Vector2 leftuvscale, Ogre::Vector2 leftuvoffset, Ogre::Vector2 rightuvscale, Ogre::Vector2 rightuvoffset)
void UpdateStereoCamera(Ogre::Viewport *ogreViewportInstance, Ogre::Camera *camera)
void RestoreStereoCamera(Ogre::Viewport *ogreViewportInstance)
void RegisterViewport(SViewPort *viewportInstance)
void SynchViewportSetup(SViewPort *viewportInstance, bool overlay=false, bool shadow=false)
void SetEyesSpacing(Ogre::Real l)
void SetStereoAspectRatio(Ogre::Real ratio)
void UpdateStereoCameraMatrix(Ogre::Viewport *ogreViewportInstance, Ogre::Camera *camera)
void SetRotateView(bool state)
std::unordered_map< int, SViewPort * > SViewPortList
std::unordered_map< std::string, SScene * > SSceneMap