Resizing OpenGL Windows

How would I go about properly resizing an OpenGL window? Whenever I try
resizing the window, there is blank space and the OpenGL view doesn’t
resize.

Quoth Ashiedu Nwadiei , on Mon 02 Feb 2004:

How would I go about properly resizing an OpenGL window? Whenever I try
resizing the window, there is blank space and the OpenGL view doesn’t
resize.

Is glViewport() being re-called on resize? If not, the viewport will
remain the same despite the window size changing.

—> Drake Wilson
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040207/2d62a35b/attachment.pgp

Quoth Ashiedu Nwadiei <@Ashiedu_Nwadiei>, on Mon 02 Feb 2004:

How would I go about properly resizing an OpenGL window? Whenever I try
resizing the window, there is blank space and the OpenGL view doesn’t
resize.

Is glViewport() being re-called on resize? If not, the viewport will
remain the same despite the window size changing.

—> Drake Wilson

glViewPort is being called in the mainloop every time it is being drawn, but
still the same thing.On 2/2/04 6:09 PM, “Drake Wilson” wrote:

Ashiedu Nwadiei wrote:

How would I go about properly resizing an OpenGL window? Whenever I try
resizing the window, there is blank space and the OpenGL view doesn’t
resize.

I don’t know why exactly this is necessary, but anyway, calling
SDL_SetVideoMode() after a resize solves the problem. I thought SDL
always allocated a full-screen opengl-buffer to get around this.
Remember to re-upload everything, and set all states again.

Regards,
\Mikkel Gjoel

Ashiedu Nwadiei wrote:

How would I go about properly resizing an OpenGL window? Whenever I try
resizing the window, there is blank space and the OpenGL view doesn’t
resize.

this is a short piece of my code and handle a resize event:

void test_event(SDL_Event *event)
{
switch(event->type)
{
[…]
case SDL_VIDEORESIZE:
{
if(event->resize.w < 200) event->resize.w = 200;
if(event->resize.h < 200) event->resize.h = 200;
int bpp;
if((bpp = SDL_VideoModeOK(event->resize.w,event->resize.h,32,init_vflag)) == 0)
h_term_error("Requested video mode not supported please use another mode : ");
if((main_w = SDL_SetVideoMode(event->resize.w,event->resize.h,bpp,init_vflag))
== NULL)
h_term_error("Unable to open a surface : ");
at_resize_draw_scene();
simple_report(“Resize maked”);
break;
}
}}
[…]far far away
void at_resize_draw_scene(void)
{
glViewport(0,0,main_w->w,main_w->h);
glClearColor(0.3, 0.3, 0.3, 0.0);
glClearDepth(1.0);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.0,static_cast(main_w->w)/main_w->h, 0.1, 1000.0);
glPushMatrix();
}

Ashiedu Nwadiei wrote:

How would I go about properly resizing an OpenGL window? Whenever I try
resizing the window, there is blank space and the OpenGL view doesn’t
resize.

Could it be that you are on Mac OS X? Sending SDL_VIDEORESIZE events on
window resizes is not implemented in 1.2.6 on Mac OS X. I dind’t check if
it’s implemented in the CVS version.

That part is easy to fix (about two lines to add to some source file -
if I’m not doing anything wrong), but the problem then is that at each
SDL_SetVideoMode() the window is completely destroyed and a new one is
made, centered on the screen - with the effect that the window seems to
jump around after resizing.

-Christian

Ashiedu Nwadiei wrote:

How would I go about properly resizing an OpenGL window? Whenever I try
resizing the window, there is blank space and the OpenGL view doesn’t
resize.

Could it be that you are on Mac OS X? Sending SDL_VIDEORESIZE events on
window resizes is not implemented in 1.2.6 on Mac OS X. I dind’t check if
it’s implemented in the CVS version.

That part is easy to fix (about two lines to add to some source file -
if I’m not doing anything wrong), but the problem then is that at each
SDL_SetVideoMode() the window is completely destroyed and a new one is
made, centered on the screen - with the effect that the window seems to
jump around after resizing.

-Christian


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
I bet that would be it. I am using OS X. Thanks.On 2/8/04 2:23 AM, “Christian Walther” wrote: