SDL 2.0 iOS openGL ES 2 context?

I’m really having trouble creating a GL ES 2 context (at least I think that’s the problem), or finding any good examples for that. I create a window and a context and then start to use gl specific functions. From what I gather this should be all I have to do right? Here’s some code, the glCreateShader function returns 0 and glGetString returns 0 to, which is bad news from what I gather.

I checked out yesterday so should be up to date.

#include “SDL.h”
#include “SDL_opengles2.h”

void App::init()
{
if(SDL_Init(0) != 0){
Assert(0, “Could not initialize SDL”);
}

if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
  Assert(0, "Could not initialize SDL Video");
}

if(SDL_InitSubSystem(SDL_INIT_TIMER) != 0){
  Assert(0, "Could not initialize SDL Timer");
}

SDL_Window *window = SDL_CreateWindow("Default", 0, 0, 480, 320, 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");



GLuint shaderHandle = glCreateShader(GL_VERTEX_SHADER);
Assert(shaderHandle, "Could not create shader handle");
Assert(glGetString(GL_SHADING_LANGUAGE_VERSION), "cant get string");


}

Add this before creating your window:

SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);Am 15.06.2013 um 12:01 schrieb “cboe” <christoph.boehler at antiloop.com>:

I’m really having trouble creating a GL ES 2 context (at least I think that’s the problem), or finding any good examples for that. I create a window and a context and then start to use gl specific functions. From what I gather this should be all I have to do right? Here’s some code, the glCreateShader function returns 0 and glGetString returns 0 to, which is bad news from what I gather.

I checked out yesterday so should be up to date.

#include “SDL.h”
#include “SDL_opengles2.h”

void App::init()
{
if(SDL_Init(0) != 0){
Assert(0, “Could not initialize SDL”);
}

if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
Assert(0, “Could not initialize SDL Video”);
}

if(SDL_InitSubSystem(SDL_INIT_TIMER) != 0){
Assert(0, “Could not initialize SDL Timer”);
}

SDL_Window *window = SDL_CreateWindow(“Default”, 0, 0, 480, 320, 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”);

GLuint shaderHandle = glCreateShader(GL_VERTEX_SHADER);
Assert(shaderHandle, “Could not create shader handle”);
Assert(glGetString(GL_SHADING_LANGUAGE_VERSION), “cant get string”);

}


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

a whole day wasted just for that :slight_smile: thanks a lot