GL_GLEXT_PROTOTYPES definition against getting function pointers

I am writing a program that depends on OpenGL 2.0 or higher. Looking at the GL 2.0 specifications, I see that the extension defined in ARB_shader_objects has been upgraded, which I suppose means that the ARB prefix is ​​no longer required for GL version 2.0 and above, and any implementation that supports> GL2.0 will to have it as part of the main implementation.

Having said that when compiling my program, gcc on Linux gives a warning: implicit function declaration. One way to get these functions is to declare them in the program itself, and then get function pointers through the GetProcAddress function.

Another way is to define GL_GLEXT_PROTOTYPES before including glext.h, which bypasses the problem of getting function pointers for each of the functions that are now present by default in GL2.0 or higher. Can anyone suggest if this is recommended right and right? The baseline is that my program requires OpenGL 2.0 or higher, and I don't want to support anything less than GL2.0.

Just in case someone suggests using glee or glew, I don’t want to use / be able to use glee or glew libraries to achieve the same.

+6
source share
1 answer

There are two problems here.

GL_ARB_shader_objects really was upgraded to the kernel in GL2.0, but the API was slightly changed for the base version, so these are not just the same function names without the ARB prefix, for example. instead of glCreateShaderObjectARB() there is glCreateShader() , and the two functions glGetShaderInfoLog() and glGetProgramInfoLog() replace glGetInfoLogARB() and some other minor differences of this type.

The second problem is that the GL library exports all the basic functions. On Linux, this is usually the case (not only for basic functions, but mostly for everything), but there is no standard to guarantee this. OpenGL ABI for Linux requires:

3.4. Libraries must export all entry points of OpenGL 1.2, GLU 1.3, GLX 1.3, and ARB_multitexture statically.

There are suggestions for updating , but I have not heard anything about this recently.

Only Windows exports the core of OpenGL 1.1, because opengl32.dll is part of the OS, and ICD is in a separate DLL. You should request function pointers for almost everyone.

Thus, the most portable way is to finally request the material, regardless of whether you are doing it manually or using some library, for example glew.

+9
source

Source: https://habr.com/ru/post/948934/


All Articles