Page 1 of 1
Resizing render area
Posted: Fri Aug 26, 2005 11:31
by renchap
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
Re: Resizing render area
Posted: Fri Aug 26, 2005 12:47
by CrazyEddie
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
Re: Resizing render area
Posted: Sat Aug 27, 2005 10:59
by scriptkid
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!
Re: Resizing render area
Posted: Sat Aug 27, 2005 15:16
by _mental_
The thread that CE supplied a link to explains it quite well.
Re: Resizing render area
Posted: Sat Aug 27, 2005 20:55
by renchap
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 ?
Re: Resizing render area
Posted: Mon Aug 29, 2005 07:44
by CrazyEddie
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.
Re: Resizing render area
Posted: Mon Sep 19, 2005 18:10
by renchap
no news about this ?

Re: Resizing render area
Posted: Tue Sep 20, 2005 13:06
by lindquist
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.