Changing size of 2D controls

Started by
4 comments, last by dnaxx 18 years, 1 month ago
Hello! I do the following:

	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

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,
Advertisement
Did you reset the viewport/projection matrix when processing WM_SIZE message (assuming you're using plain Win32 window processing code) ?.
--> The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones <--
i am not sure but try this
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);
thanks. the only problem that remains is, that the quad can get deformed, when the window size is changed.

This topic is closed to new replies.

Advertisement