glew/glee usage?

Started by
3 comments, last by bjarnia 16 years, 3 months ago
Ok.. I'm missing something here.. I'll admit that my C++ skills aren't the best, but so far they have been good enough. Anyway... I'm using SDL and OpenGL, and need to use OpenGL extensions.. I've used them before, but without a library like glee or glew and it was horrible so that's why I'm trying to use them now. Here's my problem... I have a (rather) simple terrain renderer. main.cpp includes: #include <SDL.h> #include <GL/glew.h> (I was originally including SDL_opengl.h in place of glew.h but glew.h takes care of all that) because I need access to OpenGL functions to set up OpenGL. Allthough I suppose I could technically remove all OpenGL functions from main. I would still like to initialize glew in main though? main.cpp includes world.h which includes terrain.h which needs to render.. So it obviously needs OpenGL access.. and Access to extensions.. So now I need to include glew.. But when I try to include it it gives me #error : gl.h included before glew.h Because I already included SDL_opengl.h in main. I tried to change the include in main.cpp to glew but the problem persisted. Am I doing something really wrong here?
____________________________Bjarni Arnasonbjarni.us
Advertisement
#include <gl/glew.h>
#include <GL/GL.h>
#include <SDL.h>

and in the initialize function you must call glew Initialization function:

glewInit();
Quote:Original post by Pooya65
#include <gl/glew.h>
#include <GL/GL.h>
#include <SDL.h>

and in the initialize function you must call glew Initialization function:

glewInit();



Thanks for taking the time to reply... But I'm not sure you understood the problem..
I can import glew fine for initialization... But when I want to import it again in a sub sub class to actually use it, it gives me an error, as if you could only import glew.h once in your entire program.
____________________________Bjarni Arnasonbjarni.us
Quote:
But when I want to import it again in a sub sub class to actually use it, it gives me an error, as if you could only import glew.h once in your entire program.


You need to supply the error message (since the other is just about including glew.h/glee.h before gl.h) and maybe even some code (in case this is just an ordinary error, which is caused by something completely different; like a typo).
There should not be any problems with importing GLee in several files, since it contains a preprocessor guard and therefore will not be included more than once.
Quote:Original post by nife87
Quote:
But when I want to import it again in a sub sub class to actually use it, it gives me an error, as if you could only import glew.h once in your entire program.


You need to supply the error message (since the other is just about including glew.h/glee.h before gl.h) and maybe even some code (in case this is just an ordinary error, which is caused by something completely different; like a typo).
There should not be any problems with importing GLee in several files, since it contains a preprocessor guard and therefore will not be included more than once.


Thanks... I was actually going to prove you wrong and post all my code, and after iterating through all the includes I found that one of my external image loading classes imported gl.h, that has to be the problem.
____________________________Bjarni Arnasonbjarni.us

This topic is closed to new replies.

Advertisement