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);
}