Hi,
I am trying to get SDL2 to work with libANGLE for GLES on MacOS. This is what I have done so far:
- Built Angle and copied libGLESv2.dylib and libEGL.dylib to /usr/local/lib
- Also tested the angle build with the tests ./angle_deqp_khr_gles3_tests, most tests pass.
- Built my own SDL2 from sources with the EGL, GLES2 and GLES3 present on my system at /usr/local/include. Build options was with default configuration, thus on
make install
put the libs and headers in /usr/local.
Now, the code I use to create a GLES context with SDL, I have used the following:
if (SDL_Init(SDL_InitEverything) < 0)
{
std::cerr << "\nFailed on SDL_Init\n";
return -1;
}
m_window = SDL_CreateWindow("",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
m_width.value(),
m_height.value(),
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
if (m_window == nullptr)
{
std::cerr << "\nFailed on SDL_SetVideoMode\n";
return -1;
}
SDL_SetHint("SDL_HINT_OPENGL_ES_DRIVER", "1");
SDL_GL_SetAttribute(SDL_GL_CONTEXT_EGL, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
m_ctx = SDL_GL_CreateContext(m_window);
if (m_ctx == nullptr)
{
std::cerr << SDL_GetError() << "\n";
return -1;
}
when building the program, in addition to the flags from pkg-config, I’ve added the link -lEGL -lGLESv2
Program builds with no issue, otool -l
confirms that libSDL2.dylib, libEGL.dylib and libGLESv2.dylib are dependencies. However, running is sad:
- ANGLE_DEFAULT_PLATFORM=metal ./program gives “Could not create EGL context (call to eglCreateContext failed, reporting an error of EGL_BAD_CONFIG)”
- ANGLE_DEFAULT_PLATFORM=gl ./path_testGLES-debug gives “Could not get EGL display”
- ./program gives “Could not create EGL context (call to eglCreateContext failed, reporting an error of EGL_BAD_CONFIG)”
so what am I doing wrong?