Thread: openGL problems (glut)

  1. #1
    Registered User
    Join Date
    Dec 2006

    openGL problems (glut)

    ( this program was made for os x )

    this is basically my first opengl program, and ive been having lots of problems with it. i looked up tons of websites and tutorials and read them all untill i could make my own program and not just copy one straight out of a tutorial. its just something simple, drawing a triangle and square on the screen. at first i couldnt get it to compile but after fixing a bunch of small errors and stuff i thought it was going to finally work. but when i run it its only bringing up a black window. i thought at first it might just be color problems and it was putting black and black so i added code to make the shapes red but still nothing, i dont know if maybe its skipping the draw_scene() function call all together or what. i saw a couple sites that used GLvoid instead of void what is the difference anyway, if there is one. im pretty sure i understand the code pretty good, concidering its pretty simple stuff and im almost positive its got to be something dumb cause i think my codes right. if someone could help thatd be really great cause even my computer science teacher doesnt know whats wrong with it.

    #include <OpenGL/gl.h>
    #include <OpenGL/glu.h>
    #include <GLUT/glut.h>
    #define kWindowWidth	400
    #define kWindowHeight	300
    void draw_Scene( void );
    int main( int argc, char** argv )
    	glutInit( &argc, argv );
    	glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
    	glutInitWindowSize( kWindowWidth, kWindowHeight );
    	glutInitWindowPosition( 100, 100 );
    	glutCreateWindow( argv[ 0 ] );
    	glutDisplayFunc( draw_Scene );
    	return 0;
    void draw_Scene( void )
    	glTranslatef( -1.5f, 0.0f, -6.0f );
    	glColor3f( 1.0f, 0.0f, 0.0f );
    	glBegin( GL_TRIANGLES );
    		glVertex3f( 0.0f, 1.0f, 0.0f );
    		glVertex3f( -1.0f, -1.0f, 0.0f );
    		glVertex3f( 0.0f, -1.0f, 0.0f );
    	glTranslatef( -3.0f, 0.0f, -6.0f );
    	glColor3f( 1.0f, 0.0f, 0.0f );
    	glBegin( GL_QUADS );
    		glVertex3f( -1.0f, 1.0f, 0.0f );
    		glVertex3f( 1.0f, 1.0f, 0.0f );
    		glVertex3f( 1.0f, -1.0f, 0.0f );
    		glVertex3f( -1.0f, -1.0f, 0.0f );

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    This should probably be in the game programming forum. Or at least the C forum because it doesn't look like C++.

    Check out -- there's a special tutorial for Mac OS X; perhaps it mentions your problem.

    Come to think of it, I had the same problem, but I was using MPW (a Mac OS 9 program) compiling an SDL program, Sail the Seas. I had to use a hardware screen buffer instead of a software one, or perhaps the other way around. I have no idea how you would do this with OpenGL or if it's even relevant.

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    glFlush() at the end of your draw routine? Also, i think you might be missing some initialization. Have a look at

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems installing GLUT in .NET 2003
    By Kaminaga in forum Game Programming
    Replies: 4
    Last Post: 08-18-2005, 05:33 PM
  2. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  3. Opengl and Glut install for Borland
    By drdroid in forum Game Programming
    Replies: 3
    Last Post: 05-26-2003, 08:54 PM
  4. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM
  5. Problems with rotations with OpenGL and GLUT
    By darcome in forum Game Programming
    Replies: 13
    Last Post: 07-05-2002, 12:12 AM