Hello, I’m trying to create my OpenGL context in a core profile mode, which I’m doing with this code:
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
char _title[16];
snprintf(_title, 10, "%d", (int)_free_window_index);
_window->sdl_window = SDL_CreateWindow(_title, 0, 0, 1280, 720, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
rde_critical_error(_window->sdl_window == NULL, RDE_ERROR_SDL_WINDOW, SDL_GetError());
_window->sdl_gl_context = SDL_GL_CreateContext(_window->sdl_window);
rde_critical_error(_window->sdl_gl_context == NULL, RDE_ERROR_SDL_OPENGL, SDL_GetError());
SDL_GL_MakeCurrent(_window->sdl_window, _window->sdl_gl_context);
rde_critical_error(!gladLoadGLLoader((GLADloadproc)SDL_GL_GetProcAddress), RDE_ERROR_GLAD_INIT);
rde_log_level(RDE_LOG_LEVEL_INFO, "GLAD and SDL2 loaded successfully for windows");
SDL_GL_SetSwapInterval(1);
The thing is that when I run my program, the compatibility mode is used, and I checked the following:
int num_ext = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &num_ext);
for(int i=0; i<num_ext; i++) {
printf("Extension %d = %s\n", i, glGetStringi(GL_EXTENSIONS, i));
if(!strcmp((char*)glGetStringi(GL_EXTENSIONS,i), "GL_ARB_compatibility"))
printf("2 - Compatiblity Profile\n");
}
It prints 402 extensions of OpenGL, and it triggers the ‘2 - Compatiblity Profile’ log. I’m using Glad as OpenGL lib and I compile it with my source code (from here, https://glad.dav1d.de/ profile → core, gl → 4.0).
I searched in the whole project for the ‘GL_ARB_compatibility’ and it is defined in ‘SDL_opengl_glext.h’ and it is always being included, I don’t know why. I tried to compile from source code defining ‘NO_SDL_GLEXT’ so the extensions are not included, but this creates so many undefined references:
C:\Users\vazqu\Documents\SDL\src\render\opengl\SDL_render_gl.c(97,5): error C2061: syntax error: identifier 'GLDEBUGPROCARB'
1>C:\Users\vazqu\Documents\SDL\src\render\opengl\SDL_glfuncs.h(33,1): error C2365: 'glBegin': redefinition; previous definition was 'function'
1>C:\Users\vazqu\Documents\SDL\include\SDL_opengl.h(984): message : see declaration of 'glBegin'
1>C:\Users\vazqu\Documents\SDL\src\render\opengl\SDL_glfuncs.h(34,1): error C2365: 'glBindTexture': redefinition; previous definition was 'function'
...
1>C:\Users\vazqu\Documents\SDL\src\render\opengl\SDL_render_gl.c(117,33): error C2061: syntax error: identifier 'glGenFramebuffersEXT'
1>C:\Users\vazqu\Documents\SDL\src\render\opengl\SDL_render_gl.c(117,33): error C2059: syntax error: ';'
1>C:\Users\vazqu\Documents\SDL\src\render\opengl\SDL_render_gl.c(118,36): error C2061: syntax error: identifier 'glDeleteFramebuffersEXT'
1>C:\Users\vazqu\Documents\SDL\src\render\opengl\SDL_render_gl.c(118,36): error C2059: syntax error: ';'
1>C:\Users\vazqu\Documents\SDL\src\render\opengl\SDL_render_gl.c(119,38): error C2061: syntax error: identifier 'glFramebufferTexture2DEXT'
1>C:\Users\vazqu\Documents\SDL\src\render\opengl\SDL_render_gl.c(119,38): error C2059: syntax error: ';'
...
1>C:\Users\vazqu\Documents\SDL\src\render\opengl\SDL_shaders_gl.c(508,9): error C2037: left of 'GL_ARB_texture_rectangle_supported' specifies undefined struct/union 'GL_ShaderContext'
1>C:\Users\vazqu\Documents\SDL\src\render\opengl\SDL_shaders_gl.c(517,9): error C2037: left of 'glGetError' specifies undefined struct/union 'GL_ShaderContext'
1>C:\Users\vazqu\Documents\SDL\src\render\opengl\SDL_shaders_gl.c(518,9): error C2037: left of 'glAttachObjectARB' specifies undefined struct/union 'GL_ShaderContext'
1>C:\Users\vazqu\Documents\SDL\src\render\opengl\SDL_shaders_gl.c(518,59): error C2065: 'PFNGLATTACHOBJECTARBPROC': undeclared identifier
Among others. My platform is Windows 11, with SDL version 2.26.5.
The current libs I’m using are built from vcpkg (both lib and dll). I also tried with the pre-built libs on the release section of SDL github repo, getting the same result (tried several versions).
Do anyone of you guys know what can I do so the extensions are not included and I can finally create a Core Profile instead of a compatibility profile?