Jump to content
  • Advertisement
Sign in to follow this  
dnaxx

Changing size of 2D controls

This topic is 4522 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Did you reset the viewport/projection matrix when processing WM_SIZE message (assuming you're using plain Win32 window processing code) ?.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!