2

I have GLUT installed, this is the code that I am compiling with GCC:

#include <GL/glut.h>

void display()
{
    glClearColor(1.0,1.0,1.0,1.0);
    glClear(GL_COLOR_BUFFER_BIT);
    glFlush();
}

int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
    glutInitWindowSize(500,500);
    glutCreateWindow("test");
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
}

This is how I compile it:

gcc -Wall -o test -lGL -lGLU -lglut test.c

And I get no errors/warnings.

But when I execute it the window doesn't appear. In the panel below I see that there is an application alive named "test", but with no window. It freezes the shell for few seconds and then I press ctrl+c and kill it.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Ramy Al Zuhouri
  • 21,580
  • 26
  • 105
  • 187
  • I've just tested this very same code and it worked fine (Archlinux). Did you try to debug it to see if it hangs in any of these functions calls? Does it call `display()` at all? – rodrigo Jan 28 '13 at 00:05
  • Yes, I tried with gdb and it does step inside the display function. I also notice that when I step inside the function gdb gets frozen for 2-3 seconds. – Ramy Al Zuhouri Jan 28 '13 at 00:16
  • I have no such delay... You may have something misconfigured. Did you tried `glxgears`? Or maybe your window manager is hiding the window for some reason, you can try killing it and see what happens. – rodrigo Jan 28 '13 at 00:23

1 Answers1

2

I've found the answer here:

http://ubuntuforums.org/showthread.php?t=1156705

I had to temporarily disable compiz to render the window.

metacity --replace &   # Disables compiz temporarily
./your_prog
compiz --replace &     # Enables compiz again
Thor
  • 45,082
  • 11
  • 119
  • 130
Ramy Al Zuhouri
  • 21,580
  • 26
  • 105
  • 187