glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D (0, windowwidth, 0, windowheight);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex2i(10,10);
glTexCoord2f(1,0);
glVertex2i(210,10);
glTexCoord2f(1,1);
glVertex2i(210,210);
glTexCoord2f(0,1);
glVertex2i(10,210);
glEnd();
// Reset matrices here
Changing size of 2D controls
Hello!
I do the following:
The size of the quad does not change, when I change the window size. How can I change the quad so, that it scales with the window and is still a quad with equal-length edges?
thank you,
Did you reset the viewport/projection matrix when processing WM_SIZE message (assuming you're using plain Win32 window processing code) ?.
i am not sure but try this
b4 the drawing code use this
glScale*(1+(windowheight/windowwidth),1+(windowwidth/windowheight),1);
when windowheight < windowwidth
b4 the drawing code use this
glScale*(1+(windowheight/windowwidth),1+(windowwidth/windowheight),1);
when windowheight < windowwidth
Quote:Original post by Skeleton_V@T
Did you reset the viewport/projection matrix when processing WM_SIZE message (assuming you're using plain Win32 window processing code) ?.
yes.
Quote:
glScale*(1+(windowheight/windowwidth),1+(windowwidth/windowheight),1);
nope. does not work.
u want the quad size changes with the window size ?
if yes then use static values for height and width
like
gluOrtho2D (0, 640, 0, 480);
if yes then use static values for height and width
like
gluOrtho2D (0, 640, 0, 480);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement