[fpc-pascal] dglOpenGL <-> GL, GLu, GLExt

Marco van de Voort marcov at stack.nl
Sun Feb 17 22:12:41 CET 2013


In our previous episode, Juha Manninen said:
> There is an OpenGL unit named dglOpenGL, maintained by
> www.delphigl.com, and used by many projects.
> 
> I want to use the units provided by FPC instead, namely GL, GLu and GLext.
> Mostly everything can be found from those units, except for one function:
>   InitOpenGL;
> It finds OpenGL functions from shared libs and maps them to function pointers.
 
> Q: how am I supposed to initialize OpenGL when using units provided by FPC?

The unit does it at startup. That has as disadvantage that the filename
can't be changed (or at least that first try can't be avoided).
 
After that, you iirc need to do load<something with glversion> from unit
glext to load the extensions for later versions.

I only used basic functionality from FPC opengl, (I mostly use dglopengl),
but, like dglopengl's readextension, you need to probably call those only after
you created an appropriately versioned context. At least for opengl versions
>=3

> I am also using the TOpenGLControl component provided by LCL, for
> cross-platform OpenGL context.
> I understand it basically takes care of the drawing window for OpenGL.
> The OpenGL initialization must be done before that. (?)

Importing functions is not opengl initialization. The reason is the dynamic
loading of DLLs, which requires extra action.

And even when dynamic, any form of initialization can be done in the unit
startup code, but it is often hard to parameterize then. (which defeats the
purpose of making it dynamic in the first place)

> In fact the dglOpenGL unit is cross-platform, too, but I would like to
> use the built-in units as much as possible.

Most of my opengl code is Delphi in origin, but based on original demoes
from Ales that were afaik ported from FPC to Delphi :_)

Now parts work with FPC again (though with dglopengl).



More information about the fpc-pascal mailing list