gpt4 book ai didi

c++ - GLUT 显示部分桌面而不是我的代码中的内容

转载 作者:行者123 更新时间:2023-11-28 03:33:38 25 4
gpt4 key购买 nike

上周,我尝试了几个在阅读 GLUT 教程时发现的示例,一切都运行良好。

现在,当我重试这些相同的示例时,我得到了一个奇怪的行为:我的 GLUT 窗口显示了窗口所在位置的桌面部分(所以如果 GLUT 窗口从 (100,100) 开始并且大小为 500px通过 500px,它显示桌面从 (100,100) 开始到 (600,600) 结束的部分。

我上周测试的以下示例应该在黑色背景上显示一个金属丝茶壶。我想知道我的代码是否有问题(因为我不记得更改过其中的任何内容)或者问题是否来自库未正确链接或者是否是其他我不知道的东西。

#include <GL/glut.h>

void displayFunc(void);

int glutWindow;

int main(int argc, char** argv){
glutInit(&argc, argv);

glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);

// define the size
glutInitWindowSize(500,500);

// the position where the window will appear
glutInitWindowPosition(100,100);

glutWindow = glutCreateWindow("UITest");
glClearColor(0.0, 0.0, 0.0, 0.0);

glutDisplayFunc(displayFunc);

glutMainLoop();

return EXIT_SUCCESS;
}

void displayFunc(void){
glClear(GL_COLOR_BUFFER_BIT);

glutWireTeapot(0.5);
}

最佳答案

您需要在 displayFunc() 的末尾添加对 glFlush() 的调用。

关于c++ - GLUT 显示部分桌面而不是我的代码中的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11820949/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com