简体   繁体   English

如何修复 Mac OS X OpenGL/glut 上的 window 大小问题?

[英]How can I fix window size problem on Mac OS X OpenGL/glut?

I printed 4 dots using following code on renderScene:我在 renderScene 上使用以下代码打印了 4 个点:

glColor3f(0, 0, 0);
glPointSize(4.0f);
glBegin(GL_POINTS);
glVertex2f(0.9, 0.9);
glVertex2f(0.9, -0.9);
glVertex2f(-0.9, 0.9);
glVertex2f(-0.9, -0.9);
glEnd();

and this shows up:这显示:

four dots show up at corner四个点出现在角落

and if I try to draw triangles, 3/4 of it does not show on screen如果我尝试绘制三角形,其中 3/4 不会显示在屏幕上

like this:像这样:

3/4 of screen not shown 3/4 的屏幕未显示

how can I fix this problem?我该如何解决这个问题? thanks.谢谢。

You have to adjust the viewport to the size of the default framebuffer (window).您必须将视口调整为默认帧缓冲区(窗口)的大小。 See glViewport :glViewport

glViewport(0, 0, width, height);

try downloading this fix.尝试下载此修复程序。 http://iihm.imag.fr/blanch/software/glut-macosx/ . http://iihm.imag.fr/blanch/software/glut-macosx/ Finally add this line to your code:最后将此行添加到您的代码中:

#ifdef __APPLE__
    glutInitDisplayString("rgba double depth hidpi");
#endif

This should fix your problem, it worked for me.这应该可以解决您的问题,它对我有用。

I had to do glViewport(0, 0, width*2, height*2) .我必须做glViewport(0, 0, width*2, height*2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM