View Full Version : Problems reshaping window in Glut
03-28-2005, 11:38 AM
I wrote the following function to reshape two subwindows (2 and 3) when the parent window is reshaped. What I wanted was to maintain the proportion of the second subwindow (3) but some how it's not working! I checked and the viewport is O.K. at the end of this function, but when the screen is redisplayed itís not what Iím expecting, for example if then main window has 200x600 pixels, the viewport of the subwindow should have 150X150, but itís being displayed with 150x600. Whatís wrong here?
CALL glViewport (0, 0,larg/4,alt)
IF ((3*larg/4)>alt) THEN
CALL glViewport (0, 0,alt,alt)
CALL glViewport (0, 0,3*larg/4,3*larg/4)
03-30-2005, 02:44 AM
Try using gluOrtho2D or glOrtho instead using glViewport. Glviewport is to draw to a portion of a window, and I understood you want to do a reshaping of your object against the same portion of a window (subwindow in its case).
03-30-2005, 02:57 AM
NO NO,,,, forget it!!!
Is this a problem on the size of the window or how the objects appear in it?
Read the specs to understand better what each function does.
Usually when you change (reshape) the window, glViewport is placed in the reshape callback. I don't think you do it that way. The callback should have the proper information regarding its own window and then you can call glViewport
(usually glViewport(0, 0, windowWidth, windowHeight); )
03-30-2005, 07:54 AM
Sorry, I didn't make it clear!
In my program I reshaped the sub window to the size that I waned, after that I tried to redefine the viewport, so the window (Glut) is working properly, what is not working is the viewport that a want to maintain in a square shape! When the program leaves the subroutine, the viewport is o.k., squared as I wanted, but when the program enters the display function, the viewport is changed!
Because when you call glutReshapeWindow, the reshape callback function (usually reshape) will be called, before display gets called. That's what I'm telling you, you shouldn't call glViewport outside the reshape callback. For example, this is a proper reshape callback routine:
void reshape(int w, int h)
glViewport(0, 0, w, h);
glOrtho(..) or whatever suits you
}This piece of code will be called whenever you call glutReshapeWindow or whenever you resize the window with your mouse. Hope I made it clear (and I hope I understood you!)
Wooww, just had a better look :rolleyes:
Ok, I think you should create a reshape function callback for every subwindow you create. So when it is resized it gets the proper dimensions.
03-30-2005, 08:25 AM
I just call glViewport when I create the window and when itís reshaped! As I saw that the draw was wrong so I went to the display function and called glGetIntegerv(GL_VIEWPORT,aux) to see what was the viewport there.
I forgot to say: larg => window width
alt => window height
One thing that I saw in your reshape callback is that you reshape your viewing area with glOrtho(). I donít want to do that, so I create the window, define the viewing area (gluOrtho2D() ) and after I donít touch it, I just reshape my viewport!
P.S.: All right I'm going to start studding C !
I think it's neccesary to change the view frustum in each reshape.
03-30-2005, 09:39 AM
Maybe... I donít have a clue of what frustum is! :confused: :(
"The 3D world". You define a volume. Anything in it is drawn (if the camera sees it), anything outside is clipped. Do a search in google.
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.