[fpc-pascal] Announcement GLPT

Anthony Walter sysrpl at gmail.com
Mon Sep 24 23:57:58 CEST 2018


Well the big main thing about glut, or sdl, or whatever bare bones
framework used to create an OpenGL window are the following things:

1) Abstracting creating a window
2) Abstracting associating of a GL context with the widow
3) Abstracting the event loop
4) Abstracting reading mouse, keyboard, and terminate events

Regarding point #2, you really ought to consider allowing a specific
context type, or profile, to be created, given core or es profile and a

In Free Glut this is done through:

glutInitContextVersion(4, 1);

With SDL this is done through:


Both of these are done in either API before the GL context is created.
Essentially what they do is allow you the programmer to decide what type of
context you are creating. In the case of the Free Glut example I am asking
for an OpenGL 4.1 context. In the SDL example I am asking for an OpenGL ES
2.0 context.

These context profiles are important for a number of reasons. One reason is
that they frequently determine which vendor dll (shared object on Mac and
Linux) and implementation are loaded at runtime. Theses dlls not only
require their own specific and distinct functions to load extensions, but
they also operate differently. For example, the GLSL shader compiler on
OpenGL 2.1 context may operate totally differently than the GLSL shader
compiler on OpenGL 4.1.

Anyhow, the gist of all this is, you ought to provide the ability to allow
the programmer ask for a profile, major and minor version. You ought to
attempt to create the requested context type, load the API for the user
based on the requested profile and version, and provide an abstracted stub
that is filled out for properly to loading extensions for of the selected
profiles and version.

Finally, you ought to detect when a profile failed to load, and gracefully
fail when the context cannot be created. For example if the programmer
requests OpenGL 4.1, and either the drivers for that version are not
present, or the hardware doesn't Support 4.1, you should return 0 or nil
when trying to create the context, and possibly have an error system so
that the programmer can determine what went wrong. That is, an error
message returns as a string with the words "The request context version 4.1
could not be created".

if Context = 0 then
  S := GLPT_GetLastError;

Might result in this line written to the terminal:

The request context version 4.1 could not be created
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20180924/0858a42a/attachment.html>

More information about the fpc-pascal mailing list