[fpc-pascal] SDL 2.0 Test, Need Advice

Anthony Walter sysrpl at gmail.com
Mon Apr 8 08:53:19 CEST 2013

On Mon, Apr 8, 2013 at 1:59 AM, Sven Barth <pascaldragon at googlemail.com>wrote:

> Am 08.04.2013 01:37 schrieb "Anthony Walter" <sysrpl at gmail.com>:
> >
> > In addition I have been writing a OpenGL which creates stubs for loading
> the correct OpenGL library and loading the OpenGL core functions and
> extensions for every platform.
> >
> Don't we have that already? And even if not in my opinion it would be
> better to extend the existing GL units...
> Regards,
> Sven

I don't want my three questions to get too side tracked, but I'll give you
my reasoning on this point.

SDL 2.0 adds improved support and unified (all platforms/architectures,
android, ios, osx, linux, windows, ect) for OpenGL extension querying,
library loading/unloading, context management, but in cases only if you
allow SDL to handle the management of OpenGL resources (modules, windows,
contexts). Valve brought hired the original SDL author to manage the
development of this 2.0 version. The licensing of 2.0 is friendlier (there
are no restrictions to static linking), and I believe when it's done, it's
going to be a very strong/popular API, especially given how they've added a
basic 2D drawing system and much better window management (multiple
windows, more event types like touch, full screen toggling without context
destruction, and more).

The current Jedi GL unit doesn't mesh well with this. It uses hard coded
OpenGL module names, splits extensions into a separate unit (anything
beyond OpenGL 1.X), uses an extension loading system which might be
incompatible on some platforms when using the SDL 2.0 such as
SDL_GL_ExtensionSupported. I think it would be better to have one OpenGL
pascal unit which only lists types, constants, function stubs, and leave
the actual OpenGL module picking/loading/unloading and extension
querying/loading available for other libraries to manage, and dispense of
code like:


  {$IFDEF Windows}
  {$ifdef darwin}



{$IFDEF Windows}
{ Declared in Windows unit as well in FPC; but declared here as well, to be
  fully compatible to upstream version  - sg }
function wglGetProcAddress(proc: PChar): Pointer; extdecl; external
function wglGetProcAddress(proc: PChar): Pointer;

And instead have something like this in an OpenGL.pas unit:

  OpenGLManager: record
    Load: function: Boolean;
    GetProcAddress: function(ProcName: PAnsiChar): Pointer;
    ExtensionSupported: function(Extension: PAnsiChar): Boolean;

And allow other units to control how the OpenGL unit manages some
functions. Essentially what this involves is a rewrite of the GL unit,
which is what I am doing. See every one of the function Load_XXX: Boolean
in GLext.pas.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130408/ea48a8de/attachment.html>

More information about the fpc-pascal mailing list