I'm taking a graphics class, and we have just started using OpenGL. My professor gave us a simple program that draws a purple line, that we were supposed to compile. I took it home and tried to compile it, and i got a lot of undefined symbol errors. Any help as to why this won't compile would be appreciated.
Also, I've never written anything in C++, only C and Java, but I'm reading up on C++ now, so if theres something stupid that I'm doing because of not knowing the language, I'm sorry.
The argument i used at my command line was
g++ -o PurpleLine PurpleLine.cpp
// This is a very minimal demonstration of OpenGL. It draws a purple
// line from (-0.5,-0.5,-1) to (0.5,0.5,-1), thus exercising OpenGL
// color, lines, and vertices, but almost nothing else.
//
// Written September 3, 2010 by CSci 335.
#include <GLUT/glut.h>
// The display callback. This function clears the frame buffer (which
// in this program really just involves clearing the color portion),
// sets the drawing color to purple, draws the line, and flushes all
// OpenGL output to the display.
void display( void ) {
glClearColor( 1.0, 1.0, 1.0, 1.0 );
glClear( GL_COLOR_BUFFER_BIT );
glColor3d( 1.0, 0.0, 1.0 );
glBegin( GL_LINES );
glVertex3d( -0.5, -0.5, -1.0 );
glVertex3d( 0.5, 0.5, -1.0 );
glEnd();
glFlush();
}
// The main method. This initializes GLUT and creates a window,
// registers just one callback (the display function above), and
// then hands control over to GLUT.
int main( int argc, char* argv[] ) {
glutInit( &argc, argv );
glutInitWindowPosition( 0, 0 );
glutInitWindowSize( 600, 600 );
glutInitDisplayMode( GLUT_RGBA | GLUT_SINGLE );
glutCreateWindow( "Purple Line" );
glutDisplayFunc( display );
glutMainLoop();
return 0;
}