Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opengl GLUT窗口未在Eclipse中显示_Opengl_Window_Glut - Fatal编程技术网

Opengl GLUT窗口未在Eclipse中显示

Opengl GLUT窗口未在Eclipse中显示,opengl,window,glut,Opengl,Window,Glut,我是一个初学者,我根据在线教程下载GLUT并安装MinGW等 教程为我提供了一些示例代码,但是当我运行它时,什么都没有显示。我已经构建了项目(Ctrl-B),并确保导入了所有库 #include <windows.h> #include <GL/glut.h> const int WIDTH = 600; const int HEIGHT = 480; /* Prototypes */ void init(); void display(); /* Definit

我是一个初学者,我根据在线教程下载GLUT并安装MinGW等

教程为我提供了一些示例代码,但是当我运行它时,什么都没有显示。我已经构建了项目(Ctrl-B),并确保导入了所有库

#include <windows.h>
#include <GL/glut.h>


const int WIDTH = 600;
const int HEIGHT = 480;

/* Prototypes */
void init();
void display();

/* Definitions */

/* Initializes the OpenGL state */
void init() {
    glClearColor(1.0, 0.0, 0.0, 1.0 ); /* Set the clear color */
}

/* Displays a black clear screen */
void display() {
    glClear( GL_COLOR_BUFFER_BIT ); /* Clear the screen with the clear color */
    glutSwapBuffers(); /* Double buffering */
}

/* The main function */
int main( int argc, char *argv[] ) {
    /* Glut setup function calls */
    glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB ); /* Use double buffering and RGB            
        colors */
    glutInitWindowPosition( 100, 100 );
    glutInitWindowSize( WIDTH, HEIGHT );
    glutCreateWindow(argv[0]);
    init();
    glutDisplayFunc( display );  /* Call back display function */
    glutMainLoop(); /* Continue drawing the scene */
    return 0;
}
#包括
#包括
常数int宽度=600;
const int HEIGHT=480;
/*原型*/
void init();
void display();
/*定义*/
/*初始化OpenGL状态*/
void init(){
glClearColor(1.0,0.0,0.0,1.0);/*设置清晰的颜色*/
}
/*显示黑色透明屏幕*/
无效显示(){
glClear(GL_COLOR_BUFFER_BIT);/*用清除颜色清除屏幕*/
glutSwapBuffers();/*双缓冲*/
}
/*主要功能*/
int main(int argc,char*argv[]){
/*Glut设置函数调用*/
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);/*使用双缓冲和RGB
颜色*/
位置(100100);
glutInitWindowSize(宽度、高度);
glutCreateWindow(argv[0]);
init();
glutDisplayFunc(显示);/*回调显示功能*/
glutMainLoop();/*继续绘制场景*/
返回0;
}
我按run,它说“启动GLUTDemo.exe”,然后什么也没发生