PDA

View Full Version : Not sure what im doing wrong, GL/Glew.h and GL/freeglut.h problem



moonbeamer2234
07-27-2012, 11:26 AM
I use windows 7 and codeblocks






#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <GL/glew.h>
#include <GL/freeglut.h>
#define WINDOW_TITLE_PREFIX "Chapter 1"

int CurrentWidth = 800,
CurrentHeight = 600,
WindowHandle = 0;

void Initialize(int, char*[]);
void InitWindow(int, char*[]);
void ResizeFunction(int, int);
void RenderFunction(void);

int main(int argc, char* argv[])
{
Initialize(argc, argv);

glutMainLoop();

exit(EXIT_SUCCESS);
}

void Initialize(int argc, char* argv[])
{
InitWindow(argc, argv);

fprintf(
stdout,
"INFO: OpenGL Version: %s\n",
glGetString(GL_VERSION)
&nbsp;);

glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}

void InitWindow(int argc, char* argv[])
{
glutInit(&argc, argv);

glutInitContextVersion(4, 0);
glutInitContextFlags(GLUT_FORWARD_COMPATIBLE);
glutInitContextProfile(GLUT_CORE_PROFILE);

glutSetOption(
GLUT_ACTION_ON_WINDOW_CLOSE,
GLUT_ACTION_GLUTMAINLOOP_RETURNS
&nbsp;);

glutInitWindowSize(CurrentWidth, CurrentHeight);

glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);

WindowHandle = glutCreateWindow(WINDOW_TITLE_PREFIX);

if(WindowHandle < 1) {
fprintf(
stderr,
"ERROR: Could not create a new rendering window.\n"
&nbsp;);
exit(EXIT_FAILURE);
}

glutReshapeFunc(ResizeFunction);
glutDisplayFunc(RenderFunction);
}

void ResizeFunction(int Width, int Height)
{
CurrentWidth = Width;
CurrentHeight = Height;
glViewport(0, 0, CurrentWidth, CurrentHeight);
}

void RenderFunction(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glutSwapBuffers();
glutPostRedisplay();
}



Main errors:C:\Users\Owner\Desktop\xxx.cpp\xxx\aaa\sdf\ Cube_Spin\main.cpp:4:21: error: GL/glew.h: No such file or directory

C:\Users\Owner\Desktop\xxx.cpp\xxx\aaa\sdf\Cube_Sp in\main.cpp:5:25: error: GL/freeglut.h: No such file or directory



I think that if i could fix these everything else would go away. I dont understand what im doing wrong and im a complete begginer with OpenGL. :)

Dark Photon
07-28-2012, 05:00 PM
Main errors:C:\Users\Owner\Desktop\xxx.cpp\xxx\aaa\sdf\ Cube_Spin\main.cpp:4:21: error: GL/glew.h: No such file or directory

C:\Users\Owner\Desktop\xxx.cpp\xxx\aaa\sdf\Cube_Sp in\main.cpp:5:25: error: GL/freeglut.h: No such file or directory

...I dont understand what im doing wrong and im a complete begginer with OpenGL.

Looks like you need to install GLEW and FreeGLUT (if not already installed). If you still get these errors after install, you should provide an include path to your compiler to tell it where to look for these header files.

moonbeamer2234
07-29-2012, 10:56 AM
Looks like you need to install GLEW and FreeGLUT (if not already installed). If you still get these errors after install, you should provide an include path to your compiler to tell it where to look for these header files.

where do i install these?

kiwon0905
07-29-2012, 08:54 PM
GLEW http://glew.sourceforge.net/
GLUT http://freeglut.sourceforge.net/index.php#download
you must put .dll .lib and .h files in appropriate places
to do that watch this
http://www.youtube.com/watch?v=TH_hA_Sru6Q