-
Just started with OpenGL
This is the tutorial I am looking at for Open GL.
http://fly.srk.fer.hr/~unreal/theredbook/chapter01.html
Here is the program I'm trying to get to work
Code:
#include <iostream>
#include <gl.h>
using namespace std;
int main() {
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();
glFlush();
cin.get();
}
But I get a list of errors that stem, seemingly, from the same source. One such example is the following.
" undefined reference to 'glClearColor@16' "
I just started to look into OpenGL recently, and some help is greatly appreciated. And if anyone knows a better tutorial, other than cprogramming.com, then please do tell.
-
You'll have to compile your program with the OpenGL library.
-
Yeah it looks like you havent linked to the library
-
I suggest you go over to http://nehe.gamedev.net
That code you have there will never work.
-
the original code from your link looks like this.
Code:
#include <whateverYouNeed.h>
main() {
OpenAWindowPlease();
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();
glFlush();
KeepTheWindowOnTheScreenForAWhile();
}
you cant just strip out the windowing parts ;)
also, you should #include <GL/gl.h>