[SOLVED] Render 3d scene problem

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

hurricane
Not too shy to talk
Not too shy to talk
Posts: 25
Joined: Fri Nov 28, 2008 11:59

[SOLVED] Render 3d scene problem

Postby hurricane » Mon Dec 01, 2008 16:51

Hi all,

i use OpenGL and SDL to render a 3d scene. its work good but when i integrate it with CEGUI i can't see it more...

This is my code...

My render function:

Code: Select all

void Application::renderScene(){

   glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

   glMatrixMode (GL_MODELVIEW);
   glLoadIdentity ();

        // i draw here

   SDL_GL_SwapBuffers();

}


my cegui render:

Code: Select all

void Application::renderGui()
{
   /* clear the colour buffer */
   glClear( GL_COLOR_BUFFER_BIT );
   /* render the GUI :) */
   CEGUI::System::getSingleton().renderGUI();
   /* Update the screen */
   SDL_GL_SwapBuffers();
}


Code: Select all

void Application::start(){

   initSDL();
   initOGL();
   
   initGUI();
   setGUI();

   while (!end){

      renderScene();

      renderGUI();


   }

}



if i render GUI, i can't see the 3d...only the GUI....anymore can help me?

thx in adavance
Last edited by hurricane on Thu Dec 04, 2008 14:08, edited 1 time in total.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Mon Dec 01, 2008 19:39

Hi,

Is it because in this function:

Code: Select all

void Application::renderGui()
{
   /* clear the colour buffer */
   glClear( GL_COLOR_BUFFER_BIT );
   /* render the GUI :) */
   CEGUI::System::getSingleton().renderGUI();
   /* Update the screen */
   SDL_GL_SwapBuffers();
}


You call glClear( GL_COLOR_BUFFER_BIT ); thus clearing the scene you previously rendered? Also, calling SDL_GL_SwapBuffers in both drawing functions will probably mean you get the scene on one buffer and the GUI on the other, and never the twain shall meet ;)

HTH

CE.

hurricane
Not too shy to talk
Not too shy to talk
Posts: 25
Joined: Fri Nov 28, 2008 11:59

Postby hurricane » Mon Dec 01, 2008 19:41

some pic:

without CEGUI set:

Image

with CEGUI set:

Image

as you can see in the second pic, the scene is not more

hurricane
Not too shy to talk
Not too shy to talk
Posts: 25
Joined: Fri Nov 28, 2008 11:59

Postby hurricane » Mon Dec 01, 2008 19:48

CrazyEddie wrote:Hi,

Is it because in this function:

Code: Select all

void Application::renderGui()
{
   /* clear the colour buffer */
   glClear( GL_COLOR_BUFFER_BIT );
   /* render the GUI :) */
   CEGUI::System::getSingleton().renderGUI();
   /* Update the screen */
   SDL_GL_SwapBuffers();
}


You call glClear( GL_COLOR_BUFFER_BIT ); thus clearing the scene you previously rendered? Also, calling SDL_GL_SwapBuffers in both drawing functions will probably mean you get the scene on one buffer and the GUI on the other, and never the twain shall meet ;)

HTH

CE.


thx CE,

i fixed "glClear and double SDL_GL_SwapBuffers problems" but the same error remain :cry:

fixed functions:

Code: Select all

void Application::renderScene(){

   glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

   glMatrixMode (GL_MODELVIEW);
   glLoadIdentity ();

    // i draw here

}

void Application::renderGUI(){

   CEGUI::System::getSingleton().renderGUI();

}

void Application::start(){

   initSDL();
   initOGL();
   
   initGUI();
   setGUI();

   while (!end){

      renderScene();

      renderGUI();

      SDL_GL_SwapBuffers();

   }

}

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Dec 02, 2008 09:33

Looking at the modified code, I can't see any immediate reason why it should still exhibit the same incorrect behaviour.

What happens if you switch the renderScene and renderGUI calls around (just as a test to try and fathom what is going on)? If you do try this test, don't forget to switch the glClear call into whichever function gets called first ;)

If I get any sudden flashes of insight, I'll let you know.

CE.

hurricane
Not too shy to talk
Not too shy to talk
Posts: 25
Joined: Fri Nov 28, 2008 11:59

Postby hurricane » Tue Dec 02, 2008 19:47

CrazyEddie wrote:Looking at the modified code, I can't see any immediate reason why it should still exhibit the same incorrect behaviour.

What happens if you switch the renderScene and renderGUI calls around (just as a test to try and fathom what is going on)? If you do try this test, don't forget to switch the glClear call into whichever function gets called first ;)

If I get any sudden flashes of insight, I'll let you know.

CE.


Thanks CE,

i tried this "test", but nothing is change :cry: :cry:

if you can see my source, when you have time, this is the link:

http://rapidshare.com/files/169602705/hurricaneEngine.zip.html

It's a visual c++ 2008 express edition project. the main classes are Test01.cpp and Application.cpp, finally in gui.cpp there is the code for my GUI. other classes are not importants...

Thx in advance!!!

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Wed Dec 03, 2008 10:04

Hi,

I'll try to take a look either today or tomorrow - can't promise any thing though :)

CE.

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Postby Jamarr » Wed Dec 03, 2008 17:19

I don't see how "nothing could have changed" when you switch the order, because then you are rendering your 3d scene over your gui! There is no way it could "be the same" unless your renderScene() call doesn't actually do any drawing, or perhaps if you are not properly setting up the gl state. Did you do a clean->rebuild?

Also, why not just have a separate clearScene() function? If you need to do any rendering before renderScene() (who knows?) you'll have to keep moving that code around.

In your second post you said you get different results when CEGUI is "set" and when it is "not set" - what exactly does "set" mean? You are just not calling renderGUI() or you don't even initialize/setup CEGUI?

hurricane
Not too shy to talk
Not too shy to talk
Posts: 25
Joined: Fri Nov 28, 2008 11:59

Postby hurricane » Wed Dec 03, 2008 17:51

Jamarr wrote:I don't see how "nothing could have changed" when you switch the order, because then you are rendering your 3d scene over your gui! There is no way it could "be the same" unless your renderScene() call doesn't actually do any drawing, or perhaps if you are not properly setting up the gl state. Did you do a clean->rebuild?

Also, why not just have a separate clearScene() function? If you need to do any rendering before renderScene() (who knows?) you'll have to keep moving that code around.

In your second post you said you get different results when CEGUI is "set" and when it is "not set" - what exactly does "set" mean? You are just not calling renderGUI() or you don't even initialize/setup CEGUI?


hi, thx for reply

for "set and not set" i don't mean renderGUI() or initialize/setup CEGUI BUT setGUI()

setGUI() is a function to create my personal GUI....

Code: Select all

void Application::setGUI(){

   hurricane::gui *g = new hurricane::gui();
   g->init();
   g->assignHandlers();

}


and init() of gui class is:

Code: Select all

void gui::init(){

   CEGUI::DefaultResourceProvider* rp = (CEGUI::DefaultResourceProvider*)CEGUI::System::getSingleton().getResourceProvider();

   rp->setResourceGroupDirectory("schemes", "./datafiles/schemes/");
   rp->setResourceGroupDirectory("imagesets", "./datafiles/imagesets/");
   rp->setResourceGroupDirectory("fonts", "./datafiles/fonts/");
   rp->setResourceGroupDirectory("layouts", "./datafiles/layouts/");
   rp->setResourceGroupDirectory("looknfeels", "./datafiles/looknfeel/");
   rp->setResourceGroupDirectory("lua_scripts", "./datafiles/lua_scripts/");

   CEGUI::Imageset::setDefaultResourceGroup("imagesets");
   CEGUI::Font::setDefaultResourceGroup("fonts");
   CEGUI::Scheme::setDefaultResourceGroup("schemes");
   CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
   CEGUI::WindowManager::setDefaultResourceGroup("layouts");
   CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts");

   CEGUI::SchemeManager::getSingleton().loadScheme( "TaharezLook.scheme" );
   CEGUI::SchemeManager::getSingleton().loadScheme( "VanillaSkin.scheme" );

   if(! CEGUI::FontManager::getSingleton().isFontPresent( "Commonwealth-10" ) )
      CEGUI::FontManager::getSingleton().createFont( "Commonwealth-10.font" );

   CEGUI::System::getSingleton().setDefaultFont( "Commonwealth-10" );
   CEGUI::System::getSingleton().setDefaultMouseCursor( "TaharezLook", "MouseArrow" );

   CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();

   CEGUI::Window* myRoot = wmgr.loadWindowLayout( "skin01.layout" );
   CEGUI::System::getSingleton().setGUISheet( myRoot );

}

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Wed Dec 03, 2008 19:13

In Application::initGUI, did you already try to pass the screen size as an argument to the renderer? Just a guess.

Oh and when you get this issue solved, take a look at your CEGUI.log, there are lots of errors. (But none concerning this issue).

Also, you don't need to share that 20MB .ncb file, you may just delete it, visual studio re-creates it everytime if it's missing.

Else, i looked at it 5 minutes and didn't see any other obvious mistake. Have to go, sorry.

hurricane
Not too shy to talk
Not too shy to talk
Posts: 25
Joined: Fri Nov 28, 2008 11:59

Postby hurricane » Wed Dec 03, 2008 20:14

Pompei2 wrote:In Application::initGUI, did you already try to pass the screen size as an argument to the renderer? Just a guess.

Oh and when you get this issue solved, take a look at your CEGUI.log, there are lots of errors. (But none concerning this issue).

Also, you don't need to share that 20MB .ncb file, you may just delete it, visual studio re-creates it everytime if it's missing.

Else, i looked at it 5 minutes and didn't see any other obvious mistake. Have to go, sorry.


thx pompei2 for your reply and for your advices. Yes i controlled CEGUI's log and saw any errors.....

also i tried to pass the screen size to the renderer but nothing....

By, hurricane

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Thu Dec 04, 2008 11:09

Hi :D

What you have to do is add a call to glDisable( GL_TEXTURE_2D ); either in the renderScene, or anywhere after you have loaded imagesets (and maybe fonts).

I did not look at the CEGUI code yet, but somewhere in the GL renderer we're changing this setting when loading data to textures without saving the original state first. This is a pretty obscure and hard to find issue - nice one.

Hope the fix helps :)

CE.

hurricane
Not too shy to talk
Not too shy to talk
Posts: 25
Joined: Fri Nov 28, 2008 11:59

Postby hurricane » Thu Dec 04, 2008 14:00

CrazyEddie wrote:Hi :D

What you have to do is add a call to glDisable( GL_TEXTURE_2D ); either in the renderScene, or anywhere after you have loaded imagesets (and maybe fonts).

I did not look at the CEGUI code yet, but somewhere in the GL renderer we're changing this setting when loading data to textures without saving the original state first. This is a pretty obscure and hard to find issue - nice one.

Hope the fix helps :)

CE.


thx CE, with this fix all work good and now i can play (and study) with physic engine :D :D :D :D

also thx to all peoples that have tried to help me!


Return to “Help”

Who is online

Users browsing this forum: Baidu [Spider] and 25 guests