Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: OpenGL
If window’s size change, GLRecti rectlange’s size will scalings of viewport (Rectlange created with glRecti).
 
How to make constant size GLRecti reclangle in resizable window handle?
 
And images:
 

Before changing window's size (initialization size):
 
http://imageshack.us/photo/my-images/812/001paf.png/[^]
 

After changing window's size:
 
http://imageshack.us/photo/my-images/14/002pie.png/[^]
 

but I want this:
 
http://imageshack.us/photo/my-images/822/003pu.png/[^]
 

And Code:
 

 
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glMatrixMode(GL_PROJECTION);
      glPushMatrix();
      glLoadIdentity();
      glOrtho(0, r.right, r.bottom, 0, -1, 1);
      glMatrixMode(GL_MODELVIEW);
 
  //  glFrustum(-zoom * 1, zoom * 1, -zoom * 1, zoom * 1,1,-1);
      gluPerspective(1, 1, 1, 1);
 
      glEnable(GL_COLOR_LOGIC_OP);
      glLogicOp(GL_XOR);
      glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	
 
      glRecti( 10,10,lright-200,lbottom-200);
      glBegin (GL_LINES);
		glVertex2i (30,30);
		glVertex2i (70,30);
      glEnd();
      glDisable(GL_COLOR_LOGIC_OP);
	glMatrixMode(GL_PROJECTION);
        glPopMatrix();
        glMatrixMode(GL_MODELVIEW);
        SwapBuffers(DeviceContext);
 
Thanks.
Posted 14-Feb-12 10:50am
Edited 14-Feb-12 10:52am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

hi,
you are drawing the rectangle with window width and widow height -200, this will increase the rectangle width every time you re-size the window. you must have to give a hard coded value for it to keep it same.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 15 Feb 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100