( 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.
Code:
#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 );
glutMainLoop();
return 0;
}
void draw_Scene( void )
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glLoadIdentity();
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 );
glEnd();
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 );
glEnd();
glutSwapBuffers();
}