Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:



C++
    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
Updated 14-Feb-12 9:52am
v2

1 solution

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900