Reputation: 80
I'm currently trying to program a litte game in c++ using SDL and glew. My problem is that whenever I try to use on of glew's functions (for example: glMatrixMode(GL_PROJECTION)), I get this error: GL_INVALID_ENUM.
That is how I create the window:
SDL_Init(SDL_INIT_EVERYTHING);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
context = SDL_GL_CreateContext(window);
SDL_GL_SetSwapInterval(1);
That's the way how I initialize glew:
glewExperimental = GL_TRUE;
GLenum res = glewInit();
if (res != GLEW_OK) fprintf(stderr, "Error: '%s'\n", glewGetErrorString(res));
I tried to disable glewExperimental aswell but it changed nothing.
Upvotes: 0
Views: 181
Reputation: 80
The problem was that I was using the core profile of OpenGL instead of using the compatibility profile to use deprecated parts of API. To solve this should replace
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
with:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
Upvotes: 1