Horde3D

Next-Generation Graphics Engine
It is currently 14.05.2024, 02:10

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: 16.10.2010, 21:09 
Offline

Joined: 09.09.2009, 18:58
Posts: 107
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. :D

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?


Attachments:
File comment: Cegui acting like an ass.
cegui_screenshot2_horde.png
cegui_screenshot2_horde.png [ 354.51 KiB | Viewed 9985 times ]
File comment: Cegui working properly without Horde in the loop.
cegui_screenshot1.png
cegui_screenshot1.png [ 20.44 KiB | Viewed 9985 times ]


Last edited by Orm on 18.10.2010, 21:01, edited 3 times in total.
Top
 Profile  
Reply with quote  
PostPosted: 17.10.2010, 05:19 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
Where do you call FinalizeGUI() relative to other Horde functions?


Top
 Profile  
Reply with quote  
PostPosted: 18.10.2010, 15:53 
Offline

Joined: 09.09.2009, 18:58
Posts: 107
Right at the end of the frame, where it should be called anyway.


Top
 Profile  
Reply with quote  
PostPosted: 18.10.2010, 19:18 
Offline

Joined: 24.03.2010, 10:17
Posts: 55
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.


Top
 Profile  
Reply with quote  
PostPosted: 18.10.2010, 19:54 
Offline

Joined: 09.09.2009, 18:58
Posts: 107
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);
    }


Top
 Profile  
Reply with quote  
PostPosted: 19.10.2010, 07:03 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
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.


Top
 Profile  
Reply with quote  
PostPosted: 22.10.2010, 16:29 
Offline

Joined: 09.09.2009, 18:58
Posts: 107
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...


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group