SO3Engine
SO3Window.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
31#ifndef __SO3WINDOW_H__
32#define __SO3WINDOW_H__
33
36#include "SO3Utils/SO3RayCast.h"
38
39namespace SO3
40{
41
42class SWindow : public Ogre::RenderTargetListener,
43 public Ogre::FrameListener,
44 public SData
45{
46public:
53protected:
54private:
55 SRoot* scolRoot;
56 SViewPortList listOfViewPort;
57 Ogre::RenderWindow* O3Window;
58 ScolWindowHandle hwnd;
59 StereoManager::StereoMode mStereoMode;
60 SelectorMode mSelectorMode;
61 std::vector<SViewPort*> mViewportsToDel;
62
63#ifdef _WIN32
64 LONG_PTR hwndFullscreenOgre;
65 LONG_PTR styleFullscreenOgre;
66 LONG_PTR exstyleFullscreenOgre;
67 HRGN mLastWindowRegion;
68 WINDOWPLACEMENT mLastPos;
69#endif
70 StereoManager* stereoManager;
71 SSubEntitySelectorBuffer* subEntitySelector;
72 SRaycastResult lastRaycast;
73 bool bBeginFrame;
74 bool bSizeDirty;
75 Ogre::Vector2 screenPos;
76
77public:
81 SWindow(SRoot* parent, const ScolWindowHandle& windowHandle, const std::string& windowName, const int& width, const int& height, const std::string& fsaa);
82
85 Ogre::RenderWindow* GetOgreRenderWindowPointer();
86
90 ~SWindow();
91
94 void UpdateScreenPos();
95
98 Ogre::Vector2 GetScreenPos();
99
103
106 ScolWindowHandle GetWindowHandle() const;
107
110 void SetWindowHandle(ScolWindowHandle win);
111
114 void RefreshSelector(const bool& forceRefresh = false);
115
118 void SetSelectorEnable(const bool& state);
119
122 void SetSelectorMode(SelectorMode mode);
123
127
130 void PauseWindow();
131
134 void ResumeWindow();
135
139 SViewPort* CreateViewport(SCamera* camera, int priority, const float& x, const float& y, const float& w, const float& h);
140
144 void DeleteViewport(SViewPort* existingViewport);
145
149 const SViewPortList& GetViewportList() const;
150
154 SViewPort* GetViewport(const int& priority) const;
155
159 SViewPort* GetViewport(const int& x, const int& y);
160
163 void windowMoved(Ogre::RenderWindow* rw);
164
167 void windowResized(Ogre::RenderWindow* rw);
168
171 void windowClosed(Ogre::RenderWindow* rw);
172
175 void windowFocusChange(Ogre::RenderWindow* rw);
176
179 int Size(const int& x, const int& y, const int& w, const int& h, const int& ext);
180
184
187 unsigned int GetWidth() const;
188
191 unsigned int GetHeight() const;
192
195 int GetLeft();
196
199 int GetTop();
200
203 void SetSizeDirty();
204
207 bool GetSizeDirty();
208
211 bool GetFullScreen();
212
216 bool SetFullScreen(const bool& fullscreen, const int& width = 0, const int& height = 0);
217
220 bool CheckVideoMode(const int width, const int height);
221
225 void Update();
226
230 unsigned int GetBatchCount();
231
235 unsigned int GetTriangleCount();
236
240 float GetBestFrameTime() const;
241
245 float GetWorstFrameTime() const;
246
250 float GetBestFPS() const;
251
252 /*
253 Gets the worst frames per second (FPS) since the start of the rendering.
254 */
255 float GetWorstFPS() const;
256
260 float GetAverageFPS() const;
261
265 unsigned int GetFSAA() const;
266
269 void SetStereoMode(const StereoManager::StereoMode& stereoMode);
270
274
277 float GetStereoEyesSpacing();
278
281 void SetStereoEyesSpacing(const float& eyesSpacing);
282
285 void SetStereoRotateView(const bool state);
286
289 bool GetStereoRotateView();
290
293 void SetStereoProjectionOffset(const float& offset);
294
297 void SetStereoAspectRatio(const float& ratio);
298
301 void SetStereoFOVy(const float& fov);
302
305 void SetStereoDistortion(bool enable, Ogre::Vector4 dist);
306
309 void SetStereoChromaticAbCorrection(bool enable, Ogre::Vector4 chromAbC);
310
311 void SetStereoCustomProjectonMatrix(bool enable, const Ogre::Matrix4 &leftMatrix, const Ogre::Matrix4 &rightMatrix);
312 void GetStereoCustomProjectonMatrix(bool &enabled, Ogre::Matrix4 &leftMatrix, Ogre::Matrix4 &rightMatrix) const;
313 void SetStereoTimeWarpMatrix(const Ogre::Matrix4 &leftStartMatrix, const Ogre::Matrix4 &leftEndMatrix, const Ogre::Matrix4 &rightStartMatrix, const Ogre::Matrix4 &rightEndMatrix);
314
315 void SetStereoMeshUVConfig(Ogre::Vector2 leftuvscale, Ogre::Vector2 leftuvoffset, Ogre::Vector2 rightuvscale, Ogre::Vector2 rightuvoffset);
317 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);
318 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);
319 void SetStereoWindow(SO3::SPoint<int> pos, SO3::SPoint<int> size, int index, bool state);
320 std::array<SCOL_PTR_TYPE, 2> GetStereoTextures();
321 std::array<SO3::SPoint<int>, 2> GetStereoViewportSize();
322
325 SRaycastResult RayCast(const int& pixelsX, const int& pixelsY);
326
329 SRaycastResult IndRayCast(const int& pixelsX, const int& pixelsY);
330
334
337 void InvalidateRayCast();
338
341 void WriteContentsToFile(const std::string& path);
342
345 bool UpdateStereoCompositorState(SViewPort* viewport, const Ogre::String compname, bool state);
346
349 void RestoreStereoCamera(SViewPort* viewport);
350
353 void UpdateStereoCamera(SViewPort* viewport, Ogre::Camera* camera);
354
357 void UpdateStereoCameraMatrix(SViewPort* viewport, Ogre::Camera* camera);
358
361 void UnregisterStereoViewport(SViewPort* viewport);
362
365 void RegisterStereoViewport(SViewPort* viewport);
366
369 void SynchStereoViewportSetup(SViewPort* viewport, bool overlay = false, bool shadow = false);
370
374
377 void ToPixelPos(int& px, int& py);
378
382 void CleanViewports();
383
384protected:
388 void AddViewport(SViewPort* existingViewport);
389
393 void RemoveViewport(SViewPort* existingViewport);
394
397 virtual void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
398
401 virtual void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt);
402
403private:
407 SWindow();
408};
409
410}
411
412#endif
librairies include
SCOL_EXPORT int cbmachine w
Definition SO3SCOL.cpp:5150
ScolWindowHandle win
Definition SO3SCOL.cpp:5092
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_PRECISE
Definition SO3Window.h:51
@ 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()
std::unordered_map< int, SViewPort * > SViewPortList