@@ -42,15 +42,15 @@ using namespace omega;
4242class GLFWDisplaySystem : public DisplaySystem
4343{
4444public:
45- GLFWDisplaySystem ();
46- virtual void run ();
45+ GLFWDisplaySystem ();
46+ virtual void run ();
4747 virtual void cleanup ();
4848
4949private:
50- bool myInitialized;
51- Ref<GpuContext> myGpuContext;
52- Ref<Renderer> myRenderer;
53- Ref<Engine> myEngine;
50+ bool myInitialized;
51+ Ref<GpuContext> myGpuContext;
52+ Ref<Renderer> myRenderer;
53+ Ref<Engine> myEngine;
5454};
5555
5656#define HANDLE_KEY_FLAG (keycode, flag ) \
@@ -148,7 +148,7 @@ void mouse_button_callback(GLFWwindow* window, int key, int action, int mods)
148148// /////////////////////////////////////////////////////////////////////////////
149149static void errorCallback (int error, const char * description)
150150{
151- oferror (" [GLFW] %1% " , %description);
151+ oferror (" [GLFW] %1% " , %description);
152152}
153153
154154// /////////////////////////////////////////////////////////////////////////////
@@ -159,105 +159,105 @@ GLFWDisplaySystem::GLFWDisplaySystem()
159159// /////////////////////////////////////////////////////////////////////////////
160160void GLFWDisplaySystem::run ()
161161{
162- GLFWwindow* window;
162+ GLFWwindow* window;
163163
164- glfwSetErrorCallback (errorCallback);
164+ glfwSetErrorCallback (errorCallback);
165165
166- if (!glfwInit ()) oexit (-1 );
166+ if (!glfwInit ()) oexit (-1 );
167167
168- DisplayConfig& dcfg = getDisplayConfig ();
169- ApplicationBase* app = SystemManager::instance ()->getApplication ();
170- myEngine = new Engine (app);
171- myRenderer = new Renderer (myEngine);
172- myEngine->initialize ();
168+ DisplayConfig& dcfg = getDisplayConfig ();
169+ ApplicationBase* app = SystemManager::instance ()->getApplication ();
170+ myEngine = new Engine (app);
171+ myRenderer = new Renderer (myEngine);
172+ myEngine->initialize ();
173173
174- // TODO: instead of guessing what API level to require, query the system and choose the
175- // best one.
174+ // TODO: instead of guessing what API level to require, query the system and choose the
175+ // best one.
176176#ifdef OMEGA_OS_OSX
177- if (dcfg.openGLCoreProfile )
178- {
179- // As of OSX 10.11, OpenGL 4.1 is the max spec supported.
180- glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 4 );
181- glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 1 );
182- glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
183- glfwWindowHint (GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
184- olog (Verbose, " [GLFWDisplaySystem::run]: OpenGL 4.1 core initializing" );
185- }
186- else
187- {
188- glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 2 );
189- glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 1 );
190- olog (Verbose, " [GLFWDisplaySystem::run]: OpenGL 2.1 core initializing" );
191- }
177+ if (dcfg.openGLCoreProfile )
178+ {
179+ // As of OSX 10.11, OpenGL 4.1 is the max spec supported.
180+ glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 4 );
181+ glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 1 );
182+ glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
183+ glfwWindowHint (GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
184+ olog (Verbose, " [GLFWDisplaySystem::run]: OpenGL 4.1 core initializing" );
185+ }
186+ else
187+ {
188+ glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 2 );
189+ glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 1 );
190+ olog (Verbose, " [GLFWDisplaySystem::run]: OpenGL 2.1 core initializing" );
191+ }
192192#else
193193 glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 4 );
194194 glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 2 );
195- if (dcfg.openGLCoreProfile )
196- {
197- glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
198- olog (Verbose, " [GLFWDisplaySystem::run]: OpenGL 4.2 core initializing" );
195+ if (dcfg.openGLCoreProfile )
196+ {
197+ glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
198+ olog (Verbose, " [GLFWDisplaySystem::run]: OpenGL 4.2 core initializing" );
199199 }
200200 else
201201 {
202- glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE);
203- olog (Verbose, " [GLFWDisplaySystem::run]: OpenGL 4.2 compatibility initializing" );
202+ glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE);
203+ olog (Verbose, " [GLFWDisplaySystem::run]: OpenGL 4.2 compatibility initializing" );
204204 }
205205#endif
206-
207- DisplayTileConfig* tile = dcfg.tileGrid [0 ][0 ];
208- Vector2i& ws = tile->pixelSize ;
206+
207+ DisplayTileConfig* tile = dcfg.tileGrid [0 ][0 ];
208+ Vector2i& ws = tile->pixelSize ;
209209
210210 if (tile->offscreen ) glfwWindowHint (GLFW_VISIBLE, GL_FALSE);
211211
212- window = glfwCreateWindow (ws[0 ], ws[1 ], app->getName (), NULL , NULL );
213- oassert (window != NULL );
212+ window = glfwCreateWindow (ws[0 ], ws[1 ], app->getName (), NULL , NULL );
213+ oassert (window != NULL );
214214
215- glfwMakeContextCurrent (window);
216- glfwSwapInterval (1 );
215+ glfwMakeContextCurrent (window);
216+ glfwSwapInterval (1 );
217217
218218 glfwSetKeyCallback (window, key_callback);
219219 glfwSetCursorPosCallback (window, mouse_position_callback);
220220 glfwSetMouseButtonCallback (window, mouse_button_callback);
221221 glfwSetInputMode (window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
222222
223- myGpuContext = new GpuContext ();
224- myRenderer->setGpuContext (myGpuContext);
225- myRenderer->initialize ();
226-
227- float lt = 0 .0f ;
228- uint64 frame = 0 ;
229- UpdateContext uc;
230- DrawContext dc;
231- dc.tile = tile;
232- dc.gpuContext = myGpuContext;
233- dc.renderer = myRenderer;
223+ myGpuContext = new GpuContext ();
224+ myRenderer->setGpuContext (myGpuContext);
225+ myRenderer->initialize ();
226+
227+ float lt = 0 .0f ;
228+ uint64 frame = 0 ;
229+ UpdateContext uc;
230+ DrawContext dc;
231+ dc.tile = tile;
232+ dc.gpuContext = myGpuContext;
233+ dc.renderer = myRenderer;
234234 Timer t;
235235 t.start ();
236- while (!SystemManager::instance ()->isExitRequested ())
237- {
236+ while (!SystemManager::instance ()->isExitRequested ())
237+ {
238238 uc.frameNum = frame;
239239 uc.time = t.getElapsedTimeInSec ();
240- uc.dt = uc.time - lt;
241- lt = uc.time ;
240+ uc.dt = uc.time - lt;
241+ lt = uc.time ;
242242
243243 glfwPollEvents ();
244244
245245 // Process events.
246- ServiceManager* im = SystemManager::instance ()->getServiceManager ();
247- int av = im->getAvailableEvents ();
248- if (av != 0 )
249- {
246+ ServiceManager* im = SystemManager::instance ()->getServiceManager ();
247+ int av = im->getAvailableEvents ();
248+ if (av != 0 )
249+ {
250250 im->lockEvents ();
251251 // ofmsg("evts = %1%", %av);
252- // Dispatch events to application server.
253- for (int evtNum = 0 ; evtNum < av; evtNum++)
254- {
252+ // Dispatch events to application server.
253+ for (int evtNum = 0 ; evtNum < av; evtNum++)
254+ {
255255 Event* evt = im->getEvent (evtNum);
256- myEngine->handleEvent (*evt);
257- }
256+ myEngine->handleEvent (*evt);
257+ }
258258 im->clearEvents ();
259259 im->unlockEvents ();
260- }
260+ }
261261
262262 // NULL here is needed so glfwMakeContextCurrent after update actually
263263 // resets the context instead of just being a NOP.
@@ -270,20 +270,20 @@ void GLFWDisplaySystem::run()
270270
271271 glfwMakeContextCurrent (window);
272272
273- // Handle window resize
274- int width, height;
275- glfwGetFramebufferSize (window, &width, &height);
276-
277- if (tile->activeRect .width () != width ||
278- tile->activeRect .height () != height)
279- {
280- Vector2i ws (width, height);
281- tile->activeRect .max = tile->activeRect .min + ws;
282- tile->pixelSize = ws;
283- tile->activeCanvasRect .max = ws;
284- tile->displayConfig .setCanvasRect (tile->activeCanvasRect );
285- }
286- myRenderer->prepare (dc);
273+ // Handle window resize
274+ int width, height;
275+ glfwGetFramebufferSize (window, &width, &height);
276+
277+ if (tile->activeRect .width () != width ||
278+ tile->activeRect .height () != height)
279+ {
280+ Vector2i ws (width, height);
281+ tile->activeRect .max = tile->activeRect .min + ws;
282+ tile->pixelSize = ws;
283+ tile->activeCanvasRect .max = ws;
284+ tile->displayConfig .setCanvasRect (tile->activeCanvasRect );
285+ }
286+ myRenderer->prepare (dc);
287287 oassert (!oglError);
288288
289289 // Enable lighting by default (expected by native osg applications)
@@ -292,13 +292,13 @@ void GLFWDisplaySystem::run()
292292 if (!dcfg.openGLCoreProfile ) glEnable (GL_LIGHTING);
293293
294294 dc.drawFrame (frame++);
295- glfwSwapBuffers (window);
295+ glfwSwapBuffers (window);
296296
297- // Poll the service manager for new events.
298- im->poll ();
299- }
300- glfwDestroyWindow (window);
301- glfwTerminate ();
297+ // Poll the service manager for new events.
298+ im->poll ();
299+ }
300+ glfwDestroyWindow (window);
301+ glfwTerminate ();
302302}
303303
304304// /////////////////////////////////////////////////////////////////////////////
@@ -313,7 +313,7 @@ void GLFWDisplaySystem::cleanup()
313313// Entry point
314314extern " C"
315315#ifdef OMEGA_OS_WIN
316- __declspec (dllexport)
316+ __declspec (dllexport)
317317#endif
318318DisplaySystem* createDisplaySystem ()
319319{ return new GLFWDisplaySystem (); }
0 commit comments