I recently purchased a book on OpenGl to learn with c++. The only problem is i am absolutely terrible with all the crazy options that go along with code::blocks and installing lib's(installing SFML took about a week of headaches for me, thats how bad i am). Right now this is what im getting:
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|1|error: GL/glut.h: No such file or directory|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp||In function 'int main(int, char**)':|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|13|error: 'glutInit' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|14|error: 'GLUT_DOUBLE' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|14|error: 'GLUT_RGB' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|14|error: 'GLUT_DEPTH' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|14|error: 'glutInitDisplayMode' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|17|error: 'glutInitWindowSize' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|18|error: 'glutInitWindowPosition' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|19|error: 'glutCreateWindow' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|24|error: 'glutDisplayFunc' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|25|error: 'glutReshapeFunc' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|26|error: 'glutMouseFunc' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|27|error: 'glutKeyboardFunc' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|28|error: 'glutIdleFunc' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|30|error: 'glutMainLoop' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp||In function 'void Initialize()':|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|36|error: 'glutCreateMenu' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|38|error: 'glutSetMenu' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|39|error: 'glutAddMenuEntry' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|40|error: 'GLUT_RIGHT_BUTTON' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|40|error: 'glutAttachMenu' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|42|error: 'GL_DEPTH_TEST' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|42|error: 'glEnable' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp||In function 'void MouseHandler(int, int, int, int)':|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|48|error: 'GLUT_LEFT_BUTTON' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|50|error: 'exit' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|57|error: 'glutPostRedisplay' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp||In function 'void MainMenuHandler(int)':|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|65|error: 'exit' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|70|error: 'glutPostRedisplay' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp||In function 'void Animate()':|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|74|error: 'glutPostRedisplay' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp||In function 'void Reshape(int, int)':|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|81|error: 'GLsizei' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|81|error: expected ')' before 'height'|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|81|error: 'glViewport' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|82|error: 'GL_PROJECTION' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|82|error: 'glMatrixMode' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|83|error: 'glLoadIdentity' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|84|error: 'gluPerspective' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|86|error: 'GL_MODELVIEW' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp||In function 'void Display()':|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|91|error: 'glLoadIdentity' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|94|error: 'gluLookAt' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|97|error: 'GL_COLOR_BUFFER_BIT' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|97|error: 'GL_DEPTH_BUFFER_BIT' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|97|error: 'glClear' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|100|error: 'GL_TRIANGLES' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|100|error: 'glBegin' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|101|error: 'glColor3f' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|102|error: 'glVertex3f' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|107|error: 'glEnd' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|110|error: 'GL_POLYGON' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|124|error: 'glutSwapBuffers' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp||In function 'void KeyboardHandler(unsigned char, int, int)':|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|132|error: 'exit' was not declared in this scope|
F:\OpenGl\GLUT_OpenGl_Simple\main.cpp|138|error: 'glutPostRedisplay' was not declared in this scope|
||=== Build finished: 50 errors, 0 warnings ===|
#include <GL/glut.h>
void Initialize();
void MouseHandler(int button, int state, int x, int y);
void MainMenuHandler(int option);
void Animate();
void Reshape(int width, int height);
void Display();
void KeyboardHandler(unsigned char key, int x, int y);
int main(int argc, char **argv)
{
//set up basic GLUT
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
//create window
glutInitWindowSize(1024,768);
glutInitWindowPosition(100,150);
glutCreateWindow("BOGLGP CHAPTER 1");
Initialize();
//register even callback function
glutDisplayFunc(Display);
glutReshapeFunc(Reshape);
glutMouseFunc(MouseHandler);
glutKeyboardFunc(KeyboardHandler);
glutIdleFunc(Animate);
glutMainLoop();
}
void Initialize()
{
int mainMenu;
mainMenu = glutCreateMenu(MainMenuHandler);
glutSetMenu(mainMenu);
glutAddMenuEntry("Exit",0);
glutAttachMenu(GLUT_RIGHT_BUTTON);
glEnable(GL_DEPTH_TEST);
}
void MouseHandler(int button, int state, int x, int y)
{
switch (button)
{
case GLUT_LEFT_BUTTON:
{
exit(0);
} break;
default:
break;
}
// force a screen redraw
glutPostRedisplay();
}
void MainMenuHandler(int option)
{
switch(option)
{
case 0:
{
exit(0);
} break;
default:
break;
}
glutPostRedisplay();
}
void Animate()
{
glutPostRedisplay();
}
void Reshape(int width, int height)
{
if (height == 0)
return;
glViewport(0, 0, (GLsizei) width, (GLsizei) height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.0, width/height, 1.0, 100.0);
glMatrixMode(GL_MODELVIEW);
}
void Display()
{
// set up the camera
glLoadIdentity();
gluLookAt(0.0, 1.0, 6.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);
// clear the screen
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// draw a triangle
glBegin(GL_TRIANGLES);
glColor3f(1.0, 0.0, 0.0);
glVertex3f(2.0, 2.5, -1.0);
glColor3f(0.0, 1.0, 0.0);
glVertex3f(-3.5, -2.5, -1.0);
glColor3f(0.0, 0.0, 1.0);
glVertex3f(2.0, -4.0, 0.0);
glEnd();
// draw a polygon
glBegin(GL_POLYGON);
glColor3f(1.0, 1.0, 1.0);
glVertex3f(-1.0, 2.0, 0.0);
glColor3f(1.0, 1.0, 0.0);
glVertex3f(-3.0, -0.5, 0.0);
glColor3f(0.0, 1.0, 1.0);
glVertex3f(-1.5, -3.0, 0.0);
glColor3f(0.0, 0.0, 0.0);
glVertex3f(1.0, -2.0, 0.0);
glColor3f(1.0, 0.0, 1.0);
glVertex3f(1.0, 1.0, 0.0);
glEnd();
// draw everything and swap the display buffer
glutSwapBuffers();
}
void KeyboardHandler(unsigned char key, int x, int y)
{
switch (key)
{
case 'q': // exit
{
exit(0);
} break;
default:
{
} break;
}
glutPostRedisplay();
}
Could someone please explain to me in a SIMPLE way what is wrong and what i need to do? keep in mind i dont know much at all about code blocks, so telling me to do simple tasks for you might sound like a different language to me. I would appreciate the help a TON, thanks!