opening window using glut

This is a discussion on opening window using glut within the Game Programming forums, part of the General Programming Boards category; how do you open a window in 1-2 lines using glut?. Do the drawing commands have to be in int ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    12

    opening window using glut

    how do you open a window in 1-2 lines using glut?. Do the drawing commands have to be in

    int DrawGLScene(GLvoid)

    or can you just put them in any function?

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    i figure this is about as simple as it gets...

    Code:
    #include <windows.h>
    #include <gl/glut.h>
    
    GLvoid Render(GLvoid)
    {
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
                    // do your drawing here
    }
    
    GLvoid Initialize(GLvoid)
    {
    	glClearColor(0.0f,0.0f,0.0f,1.0f);
    	glClearDepth(1.0f);
                    // do your initializing here
    }
    
    GLvoid Resize(GLint Width,GLint Height)
    {
    	if (Height == 0)
    	{
    		Height = 1;
    	}
    	
    	glViewport(0,0,Width,Height);
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity();
    		
    	gluPerspective(45,(float)Width/(float)Height,1.0f,100.0f);
    		
    	glMatrixMode(GL_MODELVIEW);
    	glLoadIdentity();
    }
    
    main()
    {
    	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
    	glutCreateWindow("OpenGL");
    	glutDisplayFunc(Render);
    	glutReshapeFunc(Resize);
    
    	Initialize();
    
    	glutMainLoop();
    	return 0;
    }
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

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. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM

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