Glad - http://glad.dav1d.de/ now supports generating opengl loaders for Pascal.
The loader is always generated from opengl's xml specs, so it's up to date and you can define exactly the subset of opengl/extensions that you need. This means that your binaries can get smaller just by swapping the loader - especially when you switch to OpenGL 3+ core.
It uses a bit different approach to function loading than other loaders like Freepascal's gl/glext or dglOpenGL - which can be seen either as disadvantage or advantage: you pass your own function loader code as a parameter, instead of directly using GetProcAddress/wglGetProcAddress. So for example if you use SDL2 for OpenGL, you can use SDL_GL_GetProcAddress. This allows for custom error handling on function loading as well. On the other hand, it's a little bit more work to setup.
Example:
Code:
function GLFuncLoad(proc: Pchar): Pointer;
begin
result := SDL_GL_GetProcAddress(proc);
Assert(result <> nil, 'couldn''t load ' + proc);
end;
var
window: PSDL_Window;
context: TSDL_GLContext;
procedure InitRenderingContext();
begin
context := SDL_GL_CreateContext(window);
gladLoadGL(@GLFuncLoad);
glClearColor(0.0, 0.0, 0.0, 0.0); { call opengl functions as usual }
...
end;
Bookmarks