I am new to odin, sdl and opengl for that matter, but this bug was hard to find, maybe I was using these values incorrectly, if someone can explain to me. Are they not supposed to be used interchangeably?
odin version: odin-windows-amd64-dev-2025-04
fmt.println(u32(sdl.GL_CONTEXT_PROFILE_CORE), u32(sdl.GLProfileFlag.CORE))
Output: 1 0
(i32 cast gives same results)
So these two lines set different profiles
sdl.GL_SetAttribute(.CONTEXT_PROFILE_MASK, i32(sdl.GLProfileFlag.CORE))
sdl.GL_SetAttribute(.CONTEXT_PROFILE_MASK, i32(sdl.GL_CONTEXT_PROFILE_CORE))
here is source code from sdl3_video.odin:
...
@(default_calling_convention="c", link_prefix="SDL_")
foreign lib {
...
GL_SetAttribute :: proc(attr: GLAttr, value: c.int) -> bool ---
...
}
...
GLProfile :: distinct bit_set[GLProfileFlag; Uint32]
GLProfileFlag :: enum Uint32 {
CORE = 0, /**< OpenGL Core Profile context */
COMPATIBILITY = 1, /**< OpenGL Compatibility Profile context */
ES = 2, /**< GLX_CONTEXT_ES2_PROFILE_BIT_EXT */
}
GL_CONTEXT_PROFILE_CORE :: GLProfile{.CORE} /**< OpenGL Core Profile context */
GL_CONTEXT_PROFILE_COMPATIBILITY :: GLProfile{.COMPATIBILITY} /**< OpenGL Compatibility Profile context */
GL_CONTEXT_PROFILE_ES :: GLProfile{.ES} /**< GLX_CONTEXT_ES2_PROFILE_BIT_EXT */
...
edit: found this issue Invalid values for GLProfileFlag , that linked to sdl docs (my mistake, should have checked earlier):
typedef Uint32 SDL_GLProfile;
#define SDL_GL_CONTEXT_PROFILE_CORE 0x0001 /**< OpenGL Core Profile context */
#define SDL_GL_CONTEXT_PROFILE_COMPATIBILITY 0x0002 /**< OpenGL Compatibility Profile context */
#define SDL_GL_CONTEXT_PROFILE_ES 0x0004 /**< GLX_CONTEXT_ES2_PROFILE_BIT_EXT */
I guess the GLProfileFlag enum should not be used. I don’t know if I should delete this post.