GLUT, window not showing up

This is a discussion on GLUT, window not showing up within the C Programming forums, part of the General Programming Boards category; I'm following a tutorial to learn about GLUT and here's my code: Code: #include <GL/glut.h> void main(int argc, char **argv) ...

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    103

    GLUT, window not showing up

    I'm following a tutorial to learn about GLUT and here's my code:
    Code:
    #include <GL/glut.h> 
    
    void main(int argc, char **argv) {
    	glutInit(&argc, argv);
    	glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
    	glutInitWindowPosition(100,100);
    	glutInitWindowSize(320,320);
    	glutCreateWindow("3D Tech- GLUT Tutorial");
    	while(1) {
    	
    	}
    }
    void renderScene(void) {
    	glClear(GL_COLOR_BUFFER_BIT);
    	glBegin(GL_TRIANGLES);
    		glVertex3f(-0.5,-0.5,0.0);
    		glVertex3f(0.5,0.0,0.0);
    		glVertex3f(0.0,0.5,0.0);
    	glEnd();
    	glFlush();
    }
    And, it compiles fine. When I run it, I get a little thing that says 3D Tech-GLUT tutorial on the bottom panel just like its supposed to, but the window doesn't show up! Btw, I use Ubuntu Linux. What could be the problem?

  2. #2
    Registered User
    Join Date
    Jan 2009
    Posts
    103
    anyone?

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Sorry Poincare, I missed this earlier or I would have said something. If I wasn't already crazy, I would say this post actually did not appear in the C forum earlier.

    Anyway, I use GLUT with OGL in linux (that's how I did the avatar*). What's the deal with the empty while(1) loop? Also, your "renderScene" function needs to be registered via glutDisplayFunc() in main. Basically this looks *very* wrong to me...please post the address of this tutorial you are using.**
    Here is a typical main():
    Code:
    int main(int argc, char** argv) {
            glutInit(&argc, argv);
            glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
            glutInitWindowSize(1200,800);
            glutInitWindowPosition(100, 100);
            glutCreateWindow(argv[0]);
            init();
            glutDisplayFunc(scene);
            glutSpecialFunc(controls);
            glutReshapeFunc(change);
            glutMainLoop();
            return 0; 
    }
    That's more than a bare minimum. I'm going offline soon, but I will look for this thread tomorrow.

    * not the most efficient way to do such a thing, but I'd rather learn that than bryce
    ** [later] I found it at lighthouse: you need to read that whole page, there is an explanation of glutDisplayFunc() right after the code you have cut and pasted -- and inserted the crazy while(1) into...
    Last edited by MK27; 05-24-2009 at 10:47 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 10:06 AM
  3. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  4. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM
  5. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21