Extending TOpenGLControl

From Free Pascal wiki
Revision as of 05:17, 18 September 2014 by Skalogryz (talk | contribs) (categories)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Some information that may a useful starting point for someone willing to create a patch to add ColorBits and AuxBuffers and other similar properties to TOpenGLControl:

1. For GLX (GTK), there are two ways to choose context attributes (both have to be supported for now, to support older GLX versions, and to allow multi-sampling on modern GLX versions):

They are both handled by common CreateOpenGLContextAttrList inside glgtkglxcontext.pas, they both support values GLX_RED/GREEN/BLUE_SIZE and GLX_AUX_BUFFERS.

Current implementation sets minimum red/green/blue bits to 1.

2. For WGL (WinAPI), also two ways of choosing context attributes are available, for similar reasons (the modern way has more features, but the older way is 100% universally supported):

Current implementation sets color bits = 24.

Note that you cannot request complete colorbits for GLX (only separate r/g/b bits), and you cannot request separate r/g/b bits for WinAPI with ChoosePixelFormat. Probably we should make separate ColorBitsRed, ColorBitsGreen, ColorBitsBlue properties (as these are more flexible), and for ChoosePixelFormat just pass PIXELFORMATDESCRIPTOR.cColorBits := ColorBitsRed + ColorBitsGreen + ColorBitsBlue.

I hope this information helps anyone willing to create a patch :) The job is fairly easy, you can grep e.g. for AlphaBits inside lazarus/trunk/components/opengl/ to see where you need to insert your code. You basically pass down the information to appropriate WGL/GLX routines.