Extending TOpenGLControl: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Extending TOpenGLControl
| Old | New | Line | |
|---|---|---|---|
| 1 | + | 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: | |
| 2 | + | ||
| 3 | + | 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): | |
| 4 | + | ||
| 5 | + | - glXChooseFBConfig. Docs on <http://www.opengl.org/sdk/docs/man/xhtml/glXChooseFBConfig.xml> . | |
| 6 | + | - glXChooseVisual. Docs on <http://www.glprogramming.com/blue/ch07.html> . | |
| 7 | + | ||
| 8 | + | They are both handled by common CreateOpenGLContextAttrList inside glgtkglxcontext.pas, they both support values GLX_RED/GREEN/BLUE_SIZE and GLX_AUX_BUFFERS. | |
| 9 | + | ||
| 10 | + | Current implementation sets minimum red/green/blue bits to 1. | |
| 11 | + | ||
| 12 | + | 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): | |
| 13 | + | ||
| 14 | + | - wglChoosePixelFormatARB. See values WGL_COLOR_BITS_ARB, WGL_RED/GREEN/BLUE_BITS_ARB, WGL_AUX_BUFFERS_ARB. See docs on <http://www.opengl.org/registry/specs/ARB/wgl_pixel_format.txt> . | |
| 15 | + | - The older ChoosePixelFormat. See fields cColorBits, cAuxBuffers in PIXELFORMATDESCRIPTOR. There are also cRed/Green/BlueBits, but they are documented as unused. Docs on <http://msdn.microsoft.com/en-us/library/dd318284%28v=vs.85%29.aspx> . | |
| 16 | + | ||
| 17 | + | Current implementation sets color bits = 24. | |
| 18 | + | ||
| 19 | + | 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. | |
| 20 | + | ||
| 21 | + | 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. | |
| 22 | + | ||
| 23 | + | --- | |
| 24 | + | *From the Free Pascal wiki, page "Extending TOpenGLControl", as it stood on 2014-09-18 after a change by Skalogryz, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 25 | + | Category: Graphics | |
| 26 | + | Category: OpenGL |
