Click here to Skip to main content
11,577,258 members (51,744 online)
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 9:50am
Edited 14-Feb-12 9: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 DamithSL 155
1 Afzaal Ahmad Zeeshan 125
2 OriginalGriff 115
3 Richard MacCutchan 100
4 Abhinav S 90
0 OriginalGriff 820
1 Sergey Alexandrovich Kryukov 676
2 Abhinav S 528
3 F-ES Sitecore 420
4 Suvendu Shekhar Giri 375


Advertise | Privacy | Mobile
Web04 | 2.8.150603.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