Sign in to follow this  
dnaxx

Changing size of 2D controls

Recommended Posts

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,

Share this post


Link to post
Share on other sites
i am not sure but try this
b4 the drawing code use this
glScale*(1+(windowheight/windowwidth),1+(windowwidth/windowheight),1);
when windowheight < windowwidth

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
thanks. the only problem that remains is, that the quad can get deformed, when the window size is changed.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this