[fpc-pascal] dglOpenGL <-> GL, GLu, GLExt
Sven Barth
pascaldragon at googlemail.com
Sat Feb 23 15:20:12 CET 2013
On 23.02.2013 14:45, Juha Manninen wrote:
> On Sun, Feb 17, 2013 at 11:12 PM, Marco van de Voort <marcov at stack.nl> wrote:
>>> 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.
>
>
> Thanks Marco.
>
> I didn't quite understand what is load<something with glversion>.
In unit GLext you have functions like Load_GL_version_1_3 which will
load all core functions provided in OpenGL 1.3 or
Load_GL_ARB_multitexture which will load all ARB functions related to
multitexturing (of course you should only do this if your version
supports/needs this). This is necessary, because in different OpenGL
versions different APIs were either part of the "core API" or where at
least standardized, but still optional in the "ARB API" or where
provided by specific vendors only "Ext API". So you need to decide first
which OpenGL version you want to support where you might need to test
first whether the version is supported at all at your client's computer
by creating an approbiate context (Note: I don't know how this can be
influenced with TOpenGLControl).
E.g. for current computer graphics you'll most likely want to have
support for shaders for which you need to have at least OpenGL 2.0. If
you want to have geometry shaders as well you need to use OpenGL 3.0 or
newer. With newer versions you also can't use the fixed function
pipeline anymore (glBegin() ... glEnd() ) [with the capabilities of
shaders this isn't feasible anymore]
>
> My experiments advance slowly. The original DeleD code validate OpenGL
> by checking if
> @glActiveTextureARB, @glClientActiveTextureARB and @glMultiTexCoord2fARB
> are assigned.
>
The Load_GL_... return a Boolean to tell you whether the functions could
be loaded. I just checked the code of e.g. Load_GL_ARB_multitexture and
it does even check for you whether the extension is supported.
> I create fOpenGLControl1 the same way than in the Lazarus example, but
> I don't know what to put into the OnPaint and OnResize event handlers.
> Now the code does not crash but obviously does not draw anything either.
OnResize can be used to recalculate the projection matrix if the Window
with the OpenGL control was resized.
OnPaint is the event where you do your rendering (and AFAIK call
OpenGLControl.SwapBuffers at the end).
> constructor TOGLForm.Create(AOwner: TComponent);
> //var PixelFormat: Integer;
> // our windows pixel format
> // PFD: PixelFormatDescriptor;
> // describes the pixel format
> begin
> inherited;
> Initialize;
> Set8087CW($133f); // disable fpu exceptions when doing OpenGL rendering
Note: If you really want to disable FPU exceptions you should use
SetExceptionMask (
http://www.freepascal.org/docs-html/rtl/math/setexceptionmask.html )
instead as Set8087CW is supported on x86 only.
Regards,
Sven
More information about the fpc-pascal
mailing list