PDA

View Full Version : Resizing a child GL window?



Sephiroth
09-26-2002, 10:03 PM
OK, having some trouble in my world editor with the 3D view, an OpenGL window. It doesn't want to resize at all! Here is the source.



//Called in the window's callback
//whenever it gets resized
void ResizeGLScene()
{
if(Temp.Y_Res == 0)
Temp.Y_Res = 1;

glViewport(0, 0, Temp.X_Res, Temp.Y_Res);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat)Temp.X_Res / (GLfloat)Temp.Y_Res, 0.1f, 4096.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

return;
}

Temp.X_Res and Temp.Y_Res are "short int" variables that can be set anywhere in the program. I have tried setting them to the LO/HI order words of the window's callback, which does nothing. I've tried getting the parent window's client area (RECT) and giving it that right/bottom values divided by two (which is what it should be) and that fails. It stays as a TINY window in the upper-left of the parent window. What's going on?

Deiussum
09-27-2002, 04:23 AM
Not sure I completely understand what you are asking, but it sounds like maybe you expect the window to resize with those commands? If that's so, I'm sorry to tell you that those commands will not resize the window. They will only set the area of that window that OpenGL will draw to. If you want to programmatically size the window, you'll have to use Win32 API calls if you're using Windows.

Sephiroth
09-27-2002, 09:00 AM
I do resize it with MoveWindow.



MoveWindow(GL_Data.hwnd, sr.left, sr.top. ((sr.right / 2) - 1), ((sr.bottom / 2) - 1), TRUE);

However, right after this is called, I call the function in my first post. Somehow the window stays super-tiny. I can't figure it out. There are three other windows (top/front/side views like in UnrealEd) that use the same RECT structure (sr) and they resize perfectly. It's like I can't move my GL window.

Sephiroth
09-27-2002, 09:10 AM
OK, you can flame me now. See last night I optimized over half the source to my editor, and I forgot ONE minor thing. Before optimization I got the 3D GL window handle using "GetDlgItem()" with the parent window handle and the window defined name. Now however, the 3D window actually gets it's own handle, but I had changed the code to try to find a child window of the actual OpenGL window, which doesn't exist. I removed the "GetDlgItem()" and replaced it with the GL window handle and it works 100%! Thanks for the help though :P!

nexusone
09-27-2002, 11:14 AM
The resize routine is only to be called by windows, when the user changes the window size. glViewport only tells openGL what the new size is and sets the screen rendering area.

To change the window size you will have to use something like glutReshapeWindow.


I use this to keep my window from being resized by the user.....

void reshape (int w, int h)
{

if (( w != 500 ) | | ( h != 250 ))
{
glutReshapeWindow( 500, 250);
w = 500;
h = 250;
}

glViewport (0, 0, (GLsizei) w, (GLsizei) h);

}


Originally posted by Sephiroth:
OK, having some trouble in my world editor with the 3D view, an OpenGL window. It doesn't want to resize at all! Here is the source.



//Called in the window's callback
//whenever it gets resized
void ResizeGLScene()
{
if(Temp.Y_Res == 0)
Temp.Y_Res = 1;

glViewport(0, 0, Temp.X_Res, Temp.Y_Res);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat)Temp.X_Res / (GLfloat)Temp.Y_Res, 0.1f, 4096.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

return;
}

Temp.X_Res and Temp.Y_Res are "short int" variables that can be set anywhere in the program. I have tried setting them to the LO/HI order words of the window's callback, which does nothing. I've tried getting the parent window's client area (RECT) and giving it that right/bottom values divided by two (which is what it should be) and that fails. It stays as a TINY window in the upper-left of the parent window. What's going on?