Ok, I have recently started learning C++ and OpenGL so I can start making my owns games which something I have always wanted to do since I starting taking computer programming classes in High School. I have a pretty good grasps on the basics of C++ and enough to follow the basics of OpenGL. I know that I should really learn a lot more C++ before I dabble to far into OpenGL but after a while, making useless console programs after useless console programs, you get a little bored and you start asking yourself what the heck does this have to do with making video games. So I starting looking at graphical APIs, that I was going to have to learn at some point and decided to look at openGL and I hope it works out but I have a lot of questions and issue that I would really appreciate it if you guys could help me out.
First of all, I have tried many different tutorials and tried to use their code and it never ends up compiling. first it was the header files but I fixed that, then it was windows.h messing things up, then apprently it was the compiler but then I switched compilers and I was getting the same messages. Anyway I have finally settled for a tutorial that I want to use and here is the inital code that wont compile. (I'm using Dev-C++ on Windows XP)
#include <GL/gl.h>
#include <GL/glut.h>
void display(void)
{
/* clear all pixels */
glClear (GL_COLOR_BUFFER_BIT);
/* draw white polygon (rectangle) with corners at
* (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
*/
glColor3f (1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0);
glVertex3f (0.75, 0.25, 0.0);
glVertex3f (0.75, 0.75, 0.0);
glVertex3f (0.25, 0.75, 0.0);
glEnd();
/* don't wait!
* start processing buffered OpenGL routines
*/
glFlush ();
}
void init (void)
{
/* select clearing (background) color */
glClearColor (0.0, 0.0, 0.0, 0.0);
/* initialize viewing values */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
/*
* Declare initial window size, position, and display mode
* (single buffer and RGBA). Open window with "hello"
* in its title bar. Call initialization routines.
* Register callback function to display graphics.
* Enter main loop and process events.
*/
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (250, 250);
glutInitWindowPosition (100, 100);
glutCreateWindow ("hello");
init ();
glutDisplayFunc(display);
glutMainLoop();
return 0; /* ISO C requires main to return int. */
}
When compiled I get this error
[Linker error] undefined reference to `gluPerspective@32'
ld returned 1 exit status
C:\Dev-Cpp\Makefile.win [Build Error] [LearninGL.exe] Error 1
I did switch compilers a few times and yet I got the same error each time. However I did see that in DevC++ you can open an openGL template base where code can be modified and used bti it is much more complicated than the code above, and I will no be able to follow this tutorial correctly if I can not use the code above
Ill prolly post some more questions in here once I start working on it again, so thanks to anyone who can help me set this up!