本文介绍了这只是显示一个空白的黑色屏幕,如果我不把glutSwapBuffers()在两个地方,它显示一个空白的白色屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我编译它,它使一个空白的blac屏幕,如果我从任一位置,或两者同时取出过氧化物交换缓冲区,我得到一个空白的白色屏幕,什么问题?

When I compile it, it makes a blank blac screen, if I take out glut swap buffers from either location, or both at the same time I get a blank white screen, whats the problem?

#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

#include <stdlib.h>



 void ProcessSpecialKeys(int key, int x, int y){

    switch(key){

       case GLUT_KEY_RIGHT:

exit(0);

       case GLUT_KEY_LEFT:

exit(0);

       case GLUT_KEY_UP:

exit(0);

       case GLUT_KEY_DOWN:

exit(0);

       default:

exit(0);

    }

}




void renderPrimitive(void){

    glBegin(GL_QUADS);
    glVertex3f(-1.0f,-1.0f,0.0f);
    glVertex3f(-1.0f,1.0f,0.0f);
    glVertex3f(1.0f,1.0f,0.0f);
    glVertex3f(1.0f,-1.0f,0.0f);
    glEnd();
}

void display(void){

    glTranslatef(0.0f,0.0f,-0.5f);
    renderPrimitive();
    glutSwapBuffers();
}

int main(int argc, char **argv) {

glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow("Dimension");
glutDisplayFunc(display);

    glLoadIdentity();

    glutSpecialFunc(ProcessSpecialKeys);

glutMainLoop();

return 0;
}


推荐答案

0.5f,0.5f);并删除glClearColor(0.5,0.5,0.5,1);

Try glColor3f(0.5f, 0.5f, 0.5f); And remove glClearColor(0.5, 0.5, 0.5, 1);

这篇关于这只是显示一个空白的黑色屏幕,如果我不把glutSwapBuffers()在两个地方,它显示一个空白的白色屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 13:52