a newbie question about GLUT

This is a discussion on a newbie question about GLUT within the Game Programming forums, part of the General Programming Boards category; Hi guys, I've just started learning OpenGL and I just wrote a very simple program that draws a triangle. The ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    2

    a newbie question about GLUT

    Hi guys, I've just started learning OpenGL and I just wrote a very simple program that draws a triangle. The problem is that if I use GLUT_DOUBLE instead of GLUT_SINGLE in glutInitDisplayMode(), nothing shows up in the window. I don't know why that is and that's why I'm posting here. I don't quite understand the difference between GLUT_SINGLE and GLUT_DOUBLE.

    here's my code:

    Code:
    void draw()
    {
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    	glMatrixMode(GL_MODELVIEW);
    	glLoadIdentity();
    	glBegin(GL_TRIANGLES);
    	glVertex3f(0,1,0);
    	glVertex3f(.5,0,0);
    	glVertex3f(1,1,0);
    	glEnd();
    	glFlush();
    }
    
    int main(int argc, char** argv)
    {
    	glutInit(&argc, argv);
    	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA | GLUT_DEPTH);  // <--- if I change the GLUT_SINGLE to GLUT_DOUBLE then nothing shows up
    	glutInitWindowSize(400, 400);
        glutInitWindowPosition(100,100);
    	glutCreateWindow("Testing");
    	glutDisplayFunc(draw);
    	
    	glutMainLoop();
    	return 0;
    	
    }
    Any help would be greatly appreciated, thank you!

  2. #2
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    I think you need glutSwapBuffers(); in your draw function. Put it at the end.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stupid Newbie question
    By TimL in forum C++ Programming
    Replies: 4
    Last Post: 07-22-2008, 04:43 AM
  2. Newbie with Very Newbie Question
    By Jedi_Mediator in forum C++ Programming
    Replies: 18
    Last Post: 07-01-2008, 08:00 AM
  3. DrawText() and TextOut() newbie question
    By Cardassian in forum Windows Programming
    Replies: 3
    Last Post: 02-23-2003, 09:09 AM
  4. C prog newbie question
    By Draginzuzu in forum C Programming
    Replies: 1
    Last Post: 02-03-2003, 05:45 PM
  5. newbie class templates question
    By daysleeper in forum C++ Programming
    Replies: 2
    Last Post: 09-18-2001, 09:50 AM

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