It seems that calling SDL_GL_* functions before context creation can mess things up (which makes sense if you think about it). I get the same error as you if I run your code.
However, if I move the SDL_GL_* calls after the context creation, I don't get any errors from glewInit().
#include <SDL2/SDL.h>
#include <GL/glew.h>
#include <iostream>
int main(int argc, char *argv[])
{
SDL_Window* _window;
SDL_GLContext _glcontext;
SDL_Init(SDL_INIT_EVERYTHING);;
_window = SDL_CreateWindow("My Game Window",
0,
0,
1024, 768,
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
_glcontext = SDL_GL_CreateContext(_window);
// Now that the context is created, we can call our SDL_GL_ functions
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32);
GLenum err = glewInit();
if (err != GLEW_OK)
{
std::cout << "Glew Error: -> " << glewGetErrorString(err) << std::endl;
return -1;
}
SDL_Quit();
}
It might be an even better idea to fiddle with the context after glewInit(), so glewInit() has a clean context to work with, but I don't know anything about how glewInit() works.
shogun1234, that's odd... that's not included in any of my examples. The DEPTH_SIZE also shouldn't affect OpenGL initialization from GLEW... Just remove that line and a sane default will be chosen, especially if you don't know what that is or don't use it.
Anyways, I would suggest setting the variable "glewExperimental" to "true". You also need to set the OpenGL version wanted.
Or else you'll get a rather old compatibility version, regardless of platform or headers used. You should set attributes before creating a context or window!
Remember that SDL is a C library. In this case, none of its structures have constructors so using something like "new" on them is really, really bad and asking for a memory leak somewhere. You must use their facilities to initialize and close out a structure!