SDL2/OpenGL in Golang: GLBind (SDL_GL_BindTexture) panic

Hi all,

After initializing SDL (INIT_EVERYTHING), setting my OpenGL version, creating a window (with WINDOW_OPENGL), creating a GLContext (and making it current), initializing GL, creating a renderer (with RENDERER_ACCELERATED), loading a font into a surface (with img.LoadPNGRW) and creating a texture from the font surface, I call font.GLBind(&width, &height) (which go-sdl2 binds to SDL_GL_BindTexture in C).

Everything works fine until that last step, which causes a panic (exception) with the message “That operation is not supported”, and I have no idea why. I can render filled rectangles, etc. just fine; it’s specifically the texture that appears to be the issue. I’ve tried various versions of OpenGL and searched everywhere for an answer to no avail.

I’m cross-compiling from Manjaro Linux to Windows 10.

Thanks for any insight.

I think it has something to do with the kind of video driver SDL2 is using behind the scenes.
Ran into the same problem. However, on my Windows 10 when I specify…

SDL_SetHint(SDL_HINT_RENDER_DRIVER,"opengles2");

…before calling SDL_Init then binding the texture works, albeit with the RGB channels swapped.
Also interesting, with and without the hint it answers it is using the windows driver when asked about (by calling SDL_GetCurrentVideoDriver).

I had the same problem after compiling in VSC on Win 11 with MinGW.
I added

SDL_SetHint(SDL_HINT_RENDER_DRIVER,“opengl”);
before SDL_Init(), which fixed the problem for me.
Notice I also was and am using “SDL_WINDOW_OPENGL” as a flag when creating the window.
Adding the “opengl” hint solved the problem for me, as for “edwinvp”. Thanks!