Forcing Core Profile in GLEW?

I’m trying to use the core profile of OpenGL 3.2. I’ve got SDL from SVN and the latest GLEW, both of which support OpenGL 3.2. However, I don’t see a way to force the core profile with GLEW. All my deprecated functions like glRotatef are still legal at both compile and runtime. Using gl3.h directly without GLEW results in compile time errors on the deprecated functions as expected.

Has anyone gotten the core profile to work in GLEW?

  • Chris

I don’t think this feature have been implemented yet in GLEW … I wish!

I realize now that deprecated functions trigger an GL error, which I can query. SDL 1.3 appears to create a context with the core profile automatically if I request OpenGL 3.2. If I need compatibility, I can ask SDL for OpenGL 3.1.

Armed with an error-querying debugger I should be able to track down incompatible code.

  • Chris

It’s not implemented in GLEW yet. But we’d welcome a well tested patch.

No volunteers yet.
Be a hero and become famous and popular.

  • Nigel

Hi Kaerimasu,

Context Creation has nothing to do with GLEW. That is the job of SDL which i believe the latest version (1.3?) supports OpenGL3.2 context creation. GLEW’s job is just to retrieve the function pointers available from the current context. If you successfully create a 3.2 core context, GLEW will not be able to load depreceated functions.

However id like to point out that at this point, GLEW only works until OpenGL 3.1 or OpenGL 3.2 with compatibility profile. It will not load your extensions on a 3.2 core profile.

I have tracked down the bug to be caused by GLEW using a depreceated glGetString(GL_EXTENSIONS) in it’s init code which fails on a 3.2 core context. A simple fix is to modify the init code to use glGetStringi instead if glGetString == 0.

Hi nigel,

At least 3 similar patches have been contributed on your own bugtracker, eagerly waiting to be integrated.
For those who can’t wait, here’s a possible one :

in glew.c, line 7953, replace the glewGetExtension function with the following :

GLboolean glewGetExtension (const char* name)
	GLubyte* p;
	GLubyte* end;
	GLuint len = _glewStrLen((const GLubyte*)name);
	if (glGetStringi){
		GLint i, num_extensions;
		glGetIntegerv (GL_NUM_EXTENSIONS, &num_extensions);
		for (i = 0; i < num_extensions; i++){
			p = (GLubyte*) glGetStringi (GL_EXTENSIONS, i);
			if (0 == p) return GL_FALSE;
			if (len == _glewStrLen (p)){
				if (_glewStrSame ((const GLubyte*)name, p, len)) return GL_TRUE;
		p = (GLubyte*)glGetString(GL_EXTENSIONS);
		if (0 == p) return GL_FALSE;
		end = p + _glewStrLen(p);
		while (p < end){
			GLuint n = _glewStrCLen(p, ' ');
			if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE;
			p += n+1;
	return GL_FALSE;

I have applied this patch from Monsieur Masserann and put the archive up for download:
Hope you don’t mind. :slight_smile: Credits are given, in Code and description.