Resizing render area

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
renchap
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Sun Mar 06, 2005 11:22
Location: France
Contact:

Resizing render area

Postby renchap » Fri Aug 26, 2005 11:31

I have made a little project with CEGUI, OpenGl Renderer (with DevIL for texture loading) and SDL. You can check the source here : http://s-project.renchap.com/snapshots/

I have a very nice GUI in windowed mode (800x600) : http://s-project.renchap.com/cegui/Image%2014.png
But when i switch to fullscreen (1024x768), the textures disappears : http://s-project.renchap.com/cegui/Image%2015.png

i use this to change the resolution :

Code: Select all

   SDL_videoFlags |= SDL_FULLSCREEN;
   SDL_spSurface = SDL_SetVideoMode(1024,768,SP_SCREEN_BPP,SDL_videoFlags);
   resizeWindow(1024,768);
   GUI::getSingleton().changeDisplaySize(1024.0,768.0);


with :

Code: Select all

   void GUI::changeDisplaySize(float width,float height) {
      d_renderer->setDisplaySize(CEGUI::Size(width,height));

   }


i dont know if my code is good, or if it is (again) a problem in the opengl renderer

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

Re: Resizing render area

Postby CrazyEddie » Fri Aug 26, 2005 12:47

I'm not certain what's going on, but scriptkid has used the exact same method to resize the render area within the up and coming version of the CELayoutEditor and reported it works fine.

This is not explicity an issue with the OpenGL GUI renderer, but is related to the way the SDL does the re-size and, in fact, the OpenGL implementation itself. For further information, read here: http://www.devolution.com/pipermail/sdl ... 69038.html

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Re: Resizing render area

Postby scriptkid » Sat Aug 27, 2005 10:59

Hi,

i'm not sure how SDL does the openGL setup internally, but here's my openGL code for wxWidget's wxGlCanvas, *without* modifying the CEGUI openGL renderer:

Here's what i do initially (only once):

Code: Select all

glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
 
// Set the clear color to a grey value
glClearColor (0.75, 0.75, 0.75, 1.0);

// Depth buffer setup
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);


And this on resizing or initial post-init call:

Code: Select all

// Tell openGL
glViewport(0, 0, (GLsizei)newWidth, (GLsizei)newHeight);
 
// Select & reset the Projection Matrix
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

// Calculate aspect ratio
gluPerspective(45.0f,(GLfloat)newWidth/(GLfloat)newHeight,0.1f,100.0f);

// Select & reset the Modelview Matrix
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();



And after that, i call the renderer's setDisplaySize, just like you did :-)

But according to the problem you have with the missing textures, my answer might be useless ;-) I hope you find your answers in CrazyEddie's link then.

Good luck!

User avatar
_mental_
CEGUI Team (Retired)
Posts: 157
Joined: Wed Jan 12, 2005 12:06
Contact:

Re: Resizing render area

Postby _mental_ » Sat Aug 27, 2005 15:16

The thread that CE supplied a link to explains it quite well.

User avatar
renchap
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Sun Mar 06, 2005 11:22
Location: France
Contact:

Re: Resizing render area

Postby renchap » Sat Aug 27, 2005 20:55

ok, so the textures are deleted by sdl. is it a way to tell the renderer to reload them ? or can i delete the renderer, create another one, and tell cegui to use the new ?
or must i save all my gui, delete the cegui system object, the renderer, init a new renderer, a new system and reload all the ui ?

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

Re: Resizing render area

Postby CrazyEddie » Mon Aug 29, 2005 07:44

The main thing is re-creating all the textures; though no facility currently exists for this. You could just delete and re-load the Imagesets and fonts, however most of the widgets store local copies of the Image objects which would be inavlidated by such an action.

In the Direct3D renderers we have to perform actions to recover from device lost situations; the code for that could be translated over for OpenGL - this is pretty simple for loaded textures, however, there are will be issues for fonts and other generated textures.

For generated textures in D3D we use the managed pool, which enables us to not worry about those, but in OpenGL I think there is no equivalent. This makes the situation a bit more complicated.

Another possibility would be to add a "regenerate" or "reload" methods to Imageset and Font, which would do the minimal amount of work required to re-load or re-create the underlying texture - this would leave Image objects and the like in tact, and might be the way to go.

I'll need to think quite a bit more about this before making any final decisions.

User avatar
renchap
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Sun Mar 06, 2005 11:22
Location: France
Contact:

Re: Resizing render area

Postby renchap » Mon Sep 19, 2005 18:10

no news about this ? :)

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Re: Resizing render area

Postby lindquist » Tue Sep 20, 2005 13:06

It should be possible to fix this by only modifying the OpenGL renderer. I use SDL myself, and have been quite annoyed by this "feature".

If you had two methods: preResize, postResize, you could could go through d_texturelist in preResize and use OpenGL to grab the texture data. Save this in heap memory. Do the resize. And recreate the textures in postResize.

I have not tried implementing it, but I it should'nt take that much work.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 12 guests