As far as I know there is no cross platform way to get a context.
That's not true. In trunk there is a cross platform way. I explained that before (as did Maciej a.k.a. HNB).
The case is the driver has a record that it maintains by itself. For FPC it is sufficient to know that is it is a record being passed around.
This was usually solved by using an untyped pointer (or type "pointer"). I fixed that to point to a structure, so the compiler knows it is a structure (record, class, object).
Introduced is:
OpaquePointer = type ^TEmptyRecord;
TEmpyRecord = record end;
Note the record is not really empty, it is opaque, because you do not access it directly. You pass it around.
Hence you can now obtain a context in a cross-platform way.
The context is solely handled by the underlying library, but by using OpaquePointer as pointer type it is now type safe.
In C(++) this is resolved in a much less elegant way. using macro's.
I can elaborate on this if you do not fully understand this. Basically OpaquePointer is a new root type (like untyped pointer, but now fully types) which you can use to create things like so:
type TContext = type OpaquePointer; // compiler now knows....It is not just a raw pointer
Which takes most difficulties out of making such a pointer to a structure cross-platform. After all: it is the library that needs the structure, not your own code....
Examples are still rare, but expect them to be multiple soon. E.g. upcoming new headers for OpenGL, EGL, OpenVG, loads of library interfaces. And mOrmOt uses it already! And the latest rtl-generics updates from this week.
In the case of OpenGLES2, I could remove the current dependency on X in seconds..... And unify code for Unix and Windows platforms by removing a lot of ifdef's.