2011-02-12 62 views
0

当我尝试运行这个程序时,它启动,显示标题栏,但没有任何东西 - 它只停靠在底部任务行,当我点击它时 - 没有任何显示。程序没有窗口。任何想法 ?下面是一个使用OpenGL的东西代码:从终端Ubuntu 10.10的OpenGl问题

#include <GL/glut.h> // Header File For The GLUT Library 
#include <GL/gl.h> // Header File For The OpenGL32 Library 
#include <GL/glu.h> // Header File For The GLu32 Library 

void SetupRC(void); 
void RenderScene(void); 
void ChangeSize(GLsizei w, GLsizei h); 

// Called to draw scene 
void RenderScene(void) 
{ 
    // Clear the window with current clearing color 
glClearColor (0.f,0.f,0.f,0.f); 
glClear(GL_COLOR_BUFFER_BIT); 

// set the color to these values 
//   R G  B 
glColor3f(1.0f, 1.0f, 1.0f); 

// Draw a filled rectangle with current color 
glRectf(-25.0f, 25.0f, 25.0f, -25.0f); 

// Flush drawing commands 
glFlush(); 
glutSwapBuffers(); 
} 

int main(int argc, char* argv[]) 
{ 
    glutInit(&argc, argv); 
    glutInitDisplayMode (GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH); // color, buffer 
    glutCreateWindow("Simple"); 
    glutInitWindowPosition(400,200); 
    glutInitWindowSize(640,468); 
    glutDisplayFunc(RenderScene); 
    glutReshapeFunc(ChangeSize); 

    SetupRC(); 
    glutMainLoop(); 

    return 0; 
} 

// Setup the rendering state 
void SetupRC(void) 
{ 
    glClearColor(0.0f, 1.0f, 1.0f, 0.0f); 
} 

// Handling window resizing 
void ChangeSize(GLsizei w, GLsizei h) 
{ 
    GLfloat aspectRatio; 

    // Prevent divide by zero 
    if (h == 0) 
     h = 1; 

    // Set Viewport to window dimensions 
    glViewport(0, 0, w, h); 

    // Reset coordinate system 
    glMatrixMode(GL_PROJECTION); 
    glLoadIdentity(); 

    // Establish clipping volume (left, right, bottom, top, near, far) 
    aspectRatio = (GLfloat) w/(GLfloat) h; 
    if (w <= h) { 
     glOrtho(-100.0, 100.0, -100/aspectRatio, 100.0/aspectRatio, 1.0, -1.0); 
    } 
    else 
     glOrtho(-100.0 * aspectRatio, 100.0 * aspectRatio, -100.0, 100.0, 1.0, -1.0); 

    glMatrixMode(GL_MODELVIEW); 
    glLoadIdentity(); 
} 
+0

Freeglut是否将任何错误消息记录到应用程序的控制台? – Knowleech 2011-02-12 19:03:46

回答

1

运行glxinfo,看看有没有问题出现。 您可能必须安装台面-utils的以glxinfo

sudo apt-get install mesa-utils 

使用从你分享的内容,这似乎是一个图形卡的问题。您可以在Ubuntu论坛上获得更好的帮助。祝你好运。

0

只是改变双缓冲单缓冲,它会工作(而不是GLUT_SINGLE放GLUT_DOUBLE)。