cboe
cboe

Reputation: 477

SDL 2.0 - OpenGL ES context problems

I'm assuming that it is a context problem, but I can't figure out what the problem is...

SDL_Window *window = SDL_CreateWindow("Default", 0, 0, 480, 320, SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL);
Assert(window, "Could not create window");

SDL_GLContext context = SDL_GL_CreateContext(window);
Assert(context, "Could not create context");


glViewport(0, 0, 480, 320);
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE){
  Assert(0, "Failure with framebuffer generation");
}

glClearColor(0, 104.0/255.0, 55.0/255.0, 1.0);
if(glGetError() != GL_NO_ERROR){
  Assert(0, "Could not set clear color");
}
glClear(GL_COLOR_BUFFER_BIT);


GLuint shaderHandle = glCreateShader(GL_VERTEX_SHADER);
Assert(shaderHandle, "Could not create shader handle");
Assert(glGetString(GL_SHADING_LANGUAGE_VERSION), "Cant get glstring, somethings wrong");

The shader handle is 0, which means it didn't work and from what I've read it's a bad sign when glGetString returns NULL. What's wrong?

Upvotes: 1

Views: 1544

Answers (1)

cboe
cboe

Reputation: 477

The fine folks at forums.libsdl.org gave me the answer. A call to both

SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);

is necessary.

Upvotes: 4

Related Questions