I start with OpenGL, and “my” first program is Sierpinski Gasket. I use Netbeans on my MacBook Pro, and I believe that I have libraries installed, but maybe they are not connected correctly.
#include <iostream>
#include <stdio.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#include <OpenGL/glext.h>
void myinit(){
glClearColor(1.0,1.0,1.0,1.0);
glColor3f(1.0,0.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,50.0,0.0,50.0);
glMatrixMode(GL_MODELVIEW);
}
void display(){
GLfloat vertices[3][2]={{0.0,0.0},{25.0,50.0},{50.0,0.0}};
int i, j, k;
int rand();
GLfloat p[2]={7.5,5.0};
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POINTS);
for(k=0; k<5000; k++){
j=rand()*3;
p[0]=(p[0]+vertices[j][0])/2.0;
p[1]=(p[1]+vertices[j][1])/2.0;
glVertex2fv(p);
}
glEnd();
glFlush();
}
int main(int argc, char** argv) {
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(0,0);
glutCreateWindow("Sierpinski Gasket");
glutDisplayFunc(display);
myinit();
glutMainLoop();
}
Here are the compilation errors:
Undefined characters for x86_64 architecture:
"_ glutInit" referenced by:
_main in main.o
"_ glutInitDisplayMode" referenced by:
_main in main.o
"_ glutInitWindowSize" referenced by:
_main in main.o
"_ glutInitWindowPosition" referenced:
_main in main.o
"_ glutCreateWindow" referenced by:
_main in main.o
"_ glutDisplayFunc" referenced by:
_main in main.o
"_ glutMainLoop" referenced by:
_main in main.o
ld: (), x86_64
collect2: ld 1
make [2]: * [dist/Debug/GNU-MacOSX/sierpinski] 1
make [1]: * [.build-conf] 2
make: * [.build-impl] 2