OpenGL 4.1 core profile with SDL 1.3

Is it possible? Currently SDL_GL_SetAttribute lets me set 4.1 but I
also had to use GLEW (another library) so that the newer functions of
GL weren’t undefined.

A #define GL_GLEXT_PROTOTYPES on top of it let it find the functions
in the opengl SDL header but there were still undefined on linking.

Hello Michael,

Yes I think that this is possible, but you have to retrieve the function
pointers manually. I have a small project using Opengl 3.3 core and that’s
what i’m using right now:

REMEMBER TO DOWNLOAD THE gl3.h file from
http://www.opengl.org/registry/api/gl3.h

#include <GL3/gl3.h>
#include <SDL.h>

extern PFNGLCLEARCOLORPROC glClearColor;
extern PFNGLGETSTRINGPROC glGetString;
extern PFNGLGETINTEGERVPROC glGetIntegerv;
extern PFNGLGETSTRINGIPROC glGetStringi;
extern PFNGLCLEARPROC glClear;
extern PFNGLVIEWPORTPROC glViewport;
extern PFNGLENABLEPROC glEnable;
extern PFNGLPOLYGONMODEPROC glPolygonMode;



PFNGLCLEARCOLORPROC glClearColor = NULL;
PFNGLGETSTRINGPROC glGetString = NULL;
PFNGLGETINTEGERVPROC glGetIntegerv = NULL;
PFNGLGETSTRINGIPROC glGetStringi = NULL;
PFNGLCLEARPROC glClear = NULL;
PFNGLVIEWPORTPROC glViewport= NULL;
PFNGLENABLEPROC glEnable=NULL;
PFNGLPOLYGONMODEPROC glPolygonMode=NULL;


Now retrieve the function pointers using SDL:

glClearColor = (PFNGLCLEARCOLORPROC) SDL_GL_GetProcAddress(“glClearColor”);
glGetString = (PFNGLGETSTRINGPROC)SDL_GL_GetProcAddress(“glGetString”);
glGetIntegerv = (PFNGLGETINTEGERVPROC)SDL_GL_GetProcAddress(“glGetIntegerv”);
glGetStringi = (PFNGLGETSTRINGIPROC)SDL_GL_GetProcAddress(“glGetStringi”);
glClear = (PFNGLCLEARPROC)SDL_GL_GetProcAddress(“glClear”);
glViewport = (PFNGLVIEWPORTPROC)SDL_GL_GetProcAddress(“glViewport”);
glEnable = (PFNGLENABLEPROC)SDL_GL_GetProcAddress(“glEnable”);
glPolygonMode=(PFNGLPOLYGONMODEPROC)SDL_GL_GetProcAddress(“glPolygonMode”);


Now you can use the functions in your program :slight_smile:

I don’t know if there is another way to do it, but that one works well for
me.

Salut!

2011/1/17 Michael Menegakis

Is it possible? Currently SDL_GL_SetAttribute lets me set 4.1 but I
also had to use GLEW (another library) so that the newer functions of
GL weren’t undefined.

A #define GL_GLEXT_PROTOTYPES on top of it let it find the functions
in the opengl SDL header but there were still undefined on linking.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org