Horde3D http://horde3d.org/forums/ |
|
Integrating CEGUI with my engine [SOLVED - Solution Inside] http://horde3d.org/forums/viewtopic.php?f=2&t=1272 |
Page 1 of 1 |
Author: | Orm [ 16.10.2010, 21:09 ] | |||
Post subject: | Integrating CEGUI with my engine [SOLVED - Solution Inside] | |||
THIS PROBLEM HAS BEEN SOLVED To see the solution, skip down to the last post. I also added the solution to the snippets page on the wiki. ![]() The original post Name says it all. I know someone else went over this, but the solution he came up with doesn't seem to work for me. Here is the code I am using to render through CEGUI''s stock OpenGL renderer Code: void Engine::FinalizeGUI() { /*glBindBuffer(GL_ARRAY_BUFFER,0); glMatrixMode(GL_MODELVIEW); glLoadIdentity();*/ /*glBindBuffer(GL_ARRAY_BUFFER,0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0); glBindBuffer(GL_PIXEL_PACK_BUFFER,0); glBindBuffer(GL_PIXEL_UNPACK_BUFFER,0);*/ /*glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0, getWinWidth()/getWinHeight(), 0.1,100.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity();*/ CEGUI::System::getSingleton().renderGUI(); } All those that are commented out are things I tried to get it rendering properly. Some screenshots are attached. Anyone have any thoughts?
|
Author: | DarkAngel [ 17.10.2010, 05:19 ] |
Post subject: | Re: Integrating CEGUI with my engine. Horde causing trouble. |
Where do you call FinalizeGUI() relative to other Horde functions? |
Author: | Orm [ 18.10.2010, 15:53 ] |
Post subject: | Re: Integrating CEGUI with my engine. Horde causing trouble. |
Right at the end of the frame, where it should be called anyway. |
Author: | AlexL [ 18.10.2010, 19:18 ] |
Post subject: | Re: Integrating CEGUI with my engine. Horde causing trouble. |
Try to separate CeGUI and Horde as much as possible opengl-state wise. This means start by using glPushAttrib/PopAttrib pairs when calling h3dInit() and h3dRender(). Also make sure you use a rather latest Horde version, as it brings some fixes with respect to state resetting. We also mix Horde with different opengl rendering code-paths (SFML, etc.) and it works nicely. So should be doable for CEGUI as well. |
Author: | Orm [ 18.10.2010, 19:54 ] |
Post subject: | Re: Integrating CEGUI with my engine[SOLVED] |
Finally got it. It was a problem with the OpenGL state. Horde3D forgot to clean up after itself, so it left me to clean up the OpenGL state. Here is the working code in case anyone is interested. Code: void Engine::InitializeRenderer() { glPushAttrib(GL_ALL_ATTRIB_BITS); // save default attributes LOG("Initializing rendering engine...",INFO); if(!h3dInit()) { LOG("Error initializing Horde3D. Aborting.",FATAL); Kill(); } //m2dInit(window_width,window_height,window_width,window_height); LOG("Running the game.",INFO); glClearDepth(1.f); glClearColor(0.f, 0.f, 0.5f, 0.f); glEnable(GL_DEPTH_TEST); } void Engine::FinalizeRenderer() { if(stage) { h3dRender(stage->active_camera); } h3dFinalizeFrame(); // attributes here are now fucked up } void Engine::FinalizeGUI() { glPopAttrib(); // pop back to default state since horde3d fucked them up glMatrixMode(GL_PROJECTION); //glBindBuffer(GL_ARRAY_BUFFER,0); glActiveTexture(0); glOrtho(0,getWinWidth(),0,getWinHeight(),-100,100); glMatrixMode(GL_MODELVIEW); //h3dClearOverlays(); CEGUI::System::getSingleton().renderGUI(); glPushAttrib(GL_ALL_ATTRIB_BITS); // save the default state again before horde3d fucks it up } void Engine::FinalizeFinally() { glfwSwapBuffers(); } And then the relevant snippet from my rendering loop Code: while(run)
{ glClear(GL_COLOR_BUFFER_BIT); allow_event_injection=true; time=glfwGetTime(); if(time >= min_framerate) { /*boost::thread t(&Stage::Update,stage,time); // On an unrelated note, does this look right to anyone or am I being a thread noob?*/ if(stage) stage->Update(time); real_framerate = 1.f/time; glfwSetTime(0.0); time=0.0; } SCOPE_LOCK(RendererMutex()); FinalizeRenderer(); FinalizeGUI(); FinalizeFinally(); ESCOPE_LOCK //asGC_FULL_CYCLE|asGC_DESTROY_GARBAGE); // asGC_ONE_STEP);//asGC_FULL_CYCLE|asGC_DESTROY_GARBAGE); } |
Author: | Volker [ 19.10.2010, 07:03 ] |
Post subject: | Re: Integrating CEGUI with my engine [SOLVED - Solution Inside] |
Quote: glClearDepth(1.f); glClearColor(0.f, 0.f, 0.5f, 0.f); glEnable(GL_DEPTH_TEST); Should be done using the pipeline commands. I won't say Horde "Fucks up" the states. If you have special requirements for your renderer, the renderer is responsible to create the states, it expects. So I would say, CEGUI does not set the states it expects correctly before doing the rendering. But the important thing is that it's finally working for you. |
Author: | Orm [ 22.10.2010, 16:29 ] |
Post subject: | Re: Integrating CEGUI with my engine [SOLVED - Solution Inside] |
Volker wrote: Quote: glClearDepth(1.f); glClearColor(0.f, 0.f, 0.5f, 0.f); glEnable(GL_DEPTH_TEST); Should be done using the pipeline commands. I won't say Horde "Fucks up" the states. If you have special requirements for your renderer, the renderer is responsible to create the states, it expects. So I would say, CEGUI does not set the states it expects correctly before doing the rendering. But the important thing is that it's finally working for you. Especially considering that I am no longer using CEGUI. I'm opting instead for libRocket... once they get it working right on linux... |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |