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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 195
1 Peter Leow 130
2 Zoltán Zörgő 120
3 BillWoodruff 85
4 bling 70
0 Sergey Alexandrovich Kryukov 9,568
1 OriginalGriff 6,901
2 Peter Leow 4,737
3 Zoltán Zörgő 4,404
4 CHill60 2,932


Advertise | Privacy | Mobile
Web02 | 2.8.150129.1 | Last Updated 15 Feb 2012
Copyright © CodeProject, 1999-2015
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