• Recent Tutorials

  • Delphi / Object Pascal OpenGL 4.2 Headers Released

    High on the heels of the just announced OpenGL 4.2 specifications, the Delphi / Pascal headers from the German Delphi OpenGL Community have been updated to reflect the latest changes. So you can now use the most cutting-edge OpenGL features with Delphi or Free Pascal, as long as you've got the hardware.


    You can grab the header over at wiki.delphigl.com. They work with Delphi (obviously Windows-only, for now) and Free Pascal. (Windows, Linux, Mac OS X)


    Here is a message from DelphiGL to all the Delphi users that are registered over at the Embarcadero Developer Network:
    "For a long time now the Delphi OpenGL headers haven't been updated and lack roughly the last 10 years or more of OpenGL advancements and even include errors. So I've set up a report over at the quality central of the EDN that should make Embarcadero aware of this (you can find the report here) and hopefully, if enough people vote on this they may rethink this and add our headers (that have become a de-facto standard among Delphi / Object Pascal OpenGL devs) to Delphi so that Delphi users can use current OpenGL functionality right out of the box"
    - Sascha Willems / DelphiGL
    News Source: Sascha Willems at DelphiGL.com
    Comments 9 Comments
    1. paul_nicholls's Avatar
      paul_nicholls -
      So, if I use this OpenGL header file, can I do OpenGL graphics on Windows/Linux/Mac OSX?

      Oh, and am I forced to use the latest OpenGL specifications, or can I use a lower version, like 1.2 or similar if I wanted to support older hardware?

      cheers,
      Paul
    1. vgo's Avatar
      vgo -
      It's up to the drivers to decide what versions are actually supported, you have to check for those yourself, the headers have boolean variables for supported versions / extensions. You have to check the actual header comments for the supported OS too.
    1. Sascha Willems's Avatar
      Sascha Willems -
      Well, as vgo said OpenGL is usually backwards compatible. With the exception of creating a forward-compatible context that's been availbale for very new OpenGL versions (3.x). So if you create such a forward-compatible context you get a very streamlined API that drops legacy stuff like immediate drawcalls and matrices. But if you you just create a normale context you get one that supports all features up to the one of your GPU.

      And our headers have been tested with several differen platforms. I have them running on Win32, Win64 and Linux, and they should work with Mac OSX too, and some people used them on even rarer plattforms. The only things that differ from platform to platform are specific extensions (WGL only for windows, GLX only for linux, etc.) and the way you create a rendering context. For windows our header has a special function (CreateRenderingContext), for other OSes like linux it's not so simple so that you have to create them on your own. Or if you use Lazarus, there is a TOpenglControl package that you can install and use that creates contexts for all kinds of OSes. Then just make it current, call ReadExtensions and ReadImplementationProperties and you can use our headers too.
    1. Stoney's Avatar
      Stoney -
      Quote Originally Posted by Sascha Willems View Post
      ... and they should work with Mac OSX too...
      As I already pointed out in the delphiGL forums some while ago, by default the headers don't work on Mac OS X or at least not as confortable as they do on Windows and Linux.

      I created a gist on Github almost two months ago which describes how to make the 4.1 header work on Mac OS X just the way it works on Windows and Linux. I just added some comments to explain why the changes are needed.
      I believe the same steps are necessary for the current header.
    1. User137's Avatar
      User137 -
      dglOpenGL header is what i have been using in nxPascal. Works on high and lowend systems, windows and linux if programming with freepascal/lazarus. So commands like glBegin are still usable.
    1. phibermon's Avatar
      phibermon -
      Same here, I use the header in JenJin and I've never had a problem with it in Windows or Linux (Don't have a mac for development). I use only GL Versions 3.2 and higher so I can't speak for all the old fixed pipeline stuff but you can pretty much guarantee the maintainers have defined everything perfectly.

      Not a lot of people seem to know that the GL units that come with recent FPC releases are actually up to date to version 4.0 (and no doubt up to 4.2 in versioning system) Although I've personally not used them yet.
    1. User137's Avatar
      User137 -
      Quote Originally Posted by phibermon View Post
      Not a lot of people seem to know that the GL units that come with recent FPC releases are actually up to date to version 4.0 (and no doubt up to 4.2 in versioning system) Although I've personally not used them yet.
      But good thing is that dglOpenGL is also Delphi compatible. It is a clear benefit if you can reuse same code with Lazarus and Delphi.
    1. phibermon's Avatar
      phibermon -
      Quote Originally Posted by User137 View Post
      But good thing is that dglOpenGL is also Delphi compatible. It is a clear benefit if you can reuse same code with Lazarus and Delphi.
      Yes although I'd reccomend dglOpenGL even despite that merit. (I don't actually support Delphi at present as I have no copy with which to test. I make heavy use of overloaded operators (esp. in 3D maths unit) and correct me if I'm wrong but at least with Delphi 6/7 I don't see the support, I'd have to re-structure a lot of code)

      EDIT : All of the FPC OpenGL units are {$MODE Delphi} and I'm not seeing anything obvious that would prevent their use in Delphi. The file structure of the C headers is retained for the headers also (which I'm suprised to learn are based on Tom Nuydens (delphi3d.net) headers)
    1. paul_nicholls's Avatar
      paul_nicholls -
      Thanks all for the helpful comments - I have started using dglOpenGL now in my simple engine I am making and testing

      cheers,
      Paul