So, I'm trying to move my OpenGL code from Main () to a specific class that will only process 3D graphics if necessary. Previously, the top of my main.cpp file looked like this:
#define GLEW_STATIC #include <GL/glew.h> #include <SFML/Graphics.hpp> #include <cstdlib> #include <iostream> #include <fstream> #include "Game.h"
This worked quite well. What I was trying to do was move all the code that corresponds to OpenGL into the methods of the Game class. So I removed #define GLEW_STATIC and #include <GL/glew.h> from the above and put them in Game.h, so the top of Game.h now looks like this:
#define GLEW_STATIC #include <GL/glew.h> #include <SFML/Graphics.hpp> #include <cstdlib> #include <iostream> #include <fstream> #include "Environment.h"
When I try to compile, I get a header error, #error gl.h included before glew.h
Why is this happening, and how can I make full use of OpenGL code (almost) inside functions of a particular class without this?
EDIT:
I also tried this configuration in main.cpp, trying to make sure that nothing included SFML before GLEW.
#include <cstdlib> #include <iostream> #include <fstream> #include "Game.h" #include <SFML/Graphics.hpp>
Unfortunately, this does not help (there is nothing else that I do not mention here).
c ++ include codeblocks opengl sfml
Garrickw
source share