GLRecti缩放问题 [英] GLRecti scaling problem

查看:161
本文介绍了GLRecti缩放问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果窗口的大小发生变化,则GLRecti rectlange的大小将缩放视口(使用glRecti创建的Rectlange).

如何在可调整大小的窗口句柄中使大小不变的GLRecti隐居?
和图片:


更改窗口大小(初始化大小)之前:

http://imageshack.us/photo/my-images/812/001paf.png/ [ ^ ]


更改窗口大小后:

http://imageshack.us/photo/my-images/14/002pie.png/ [ ^ ]


但我想要这个:

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


和代码:



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.

推荐答案


您正在绘制窗口宽度和寡妇高度为-200的矩形,那么每次您调整窗口大小时,都会增加矩形的宽度.您必须为其提供硬编码值以使其保持不变.

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.


这篇关于GLRecti缩放问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆