I'm trying to learn the basics of OpenGL, but is stuck trying to compile Sierpinski's Gasket program. I'm using Dev-cpp (latest version) and MingGW through it as compiler. When I try to compile I get the following error messages:
1 C:\Documents and Settings\Magnus Olsson\Mina dokument\Egna projekt\OpenGL\test.cpp In file included from test.cpp 43 C:\Program\Dev-Cpp\include\GL\glut.h redeclaration of C++ built-in type `short' 1 C:\Documents and Settings\Magnus Olsson\Mina dokument\Egna projekt\OpenGL\test.cpp In file included from test.cpp
I'm not sure how to resolve this as it seems like there's a conflict in glut.h and I'm not sure if I should alter anything in a header file I haven't written myself... Has anyone encountered this problem before or know how to deal with it?
This is the code I've written (copied from my graphics book) so far:
#include <GL/glut.h> using namespace std; void myinit(); void display(); int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); glutInitWindowSize(500,500); glutInitWindowPosition(0,0); glutCreateWindow("Simple OpenGL Example"); glutDisplayFunc(display); myinit(); glutMainLoop(); return 0; } void myinit(void) { /* Attributes */ glClearColor(1.0, 1.0, 1.0, 1.0); // White glColor3f(1.0, 0.0, 0.0); // Red /* Set up viewing */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0, 500.0, 0.0, 500.0); glMatrixMode(GL_MODELVIEW); } void display(void) { typedef GLfloat point2[2]; // Define a point data type point2 vertices[3]={{0.0, 0.0}, {250.0, 500.0}, {500.0, 0.0}}; // Triangle int i, j , k; int rand(); point2 p={75.0,75.0}; // Arbitrary point inside the triangle glClear(GL_COLOR_BUFFER_BIT); // Clear the window /* Compute and output 5000 new points */ for (k=0;k<5000;k++) { j = rand()%3; // Pick a random vertex /* Compute halfway between vertex and old point */ p[0]=(p[0]+vertices[j][0])/2.0; p[1]=(p[1]+vertices[j][1])/2.0; /* Plot point */ glBegin(GL_POINTS); glVertex2fv(p); glEnd(); } }
Edited by magnus80a, 11 December 2005 - 04:05 PM.