OpenGl problem with Ubuntu 10.10

1.1k views Asked by At

When i try to run this program it starts, shows the title bar but there is nothing - it only docks for the bottom task line and when i click it - nothing shows. There is no window with the program. Any idea ? Here's the code that uses OpenGL stuff :

#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();
}
2

There are 2 answers

0
Eddie Flores On

Run glxinfo from the terminal and see if any issues show up. You might have to install mesa-utils to use glxinfo

sudo apt-get install mesa-utils

From what you've shared, it seems like a graphics card issue. You might be able to get better help over at the Ubuntu Forums. Good luck.

0
alan On

Just change single buffering with double buffering and it will work (instead of GLUT_SINGLE put GLUT_DOUBLE).