Make sure you're using a recent version of SDL; the latest is 2.0.3, and I think you need at least 2.0.2.
You'll also need to grab libEGL.dll and libGLESv2.dll (or build them). The easiest option is to grab the copies installed with Google Chrome. You also need d3dcompiler_46.dll, either the copy with Chrome or the one that ships with the D3D SDK (they're the same file).
Copy those DLLs along with the SDL2 DLL into your binary build directory like normal. When you build your app, do _not_ link to OpenGL32.lib like you would for a normal Windows GL application. When creating your window/context in SDL2, do (and this is from memory, so probably some small mistakes):
// helper, not strictly necessary
#include <SDL_opengles2.h>
#include <SDL.h>
void setup() {
// must be done _before_ creating the window - this tells SDL to create an ES context instead of a GL one.
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
// not necessary, but I like being pedantic
// ANGLE will support ES 3 very soon, so you might bump this up after if you want to target new mobiles and Firefox's WebGL2 experiment
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
// create window with OpenGL flag
SDL_Window* window = SDL_CreateWindow("test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_OPENGL);
// create the context
SDL_GLContext ctx = SDL_GL_CreateContext(window);
|
void clear_example() {
// you need to grab the pointers since you didn't link directly with libGLESv2; or you could use a helper glue library, glew or glee or something, not sure which of them support ES
// you also want to do all these lookups once and not do them every frame
using ClearFunctionT = void(KHRONOS_APIENTRY*)(GLbitfield);
ClearFunctionT fClear = (ClearFunctionT)SDL_GL_GetProcAddress("glClear");
fClear(GL_COLOR_BUFFER_BIT);
}