Check are any OpenGL errors recorded (in glGetError). If there are errors, our behavior depends on whether we were compiled with -dRELEASE. With -dRELEASE, we make OnWarning. This way eventual errors in release builds don't completely abort your program.
Note that the behavior on GL_OUT_OF_MEMORY is different. -dRELEASE does not matter here. Only GLOutOfMemoryError boolean dictates if we should raise an exception or merely make warning, regardless of -dRELEASE state.
Without -dRELEASE, we raise EOpenGLError. So a developer is strongly suggested to fix the code to not produce OpenGL errors, never ever.
Raise EOpenGLError for given OpenGL error code. This has calling convention suitable for registering this procedure as GLU_TESS_ERROR for gluTessCallback, or GLU_ERROR for gluQuadricCallback.
Save/restore OpenGL pixel store for unpacking TRGBImage. Before you pass an TRGBImage to glDrawPixels, glTexImage1D, glTexImage2D, glBitmap, glPolygonStipple and such, call BeforeUnpackNotAlignedRGBImage, and later call AfterUnpackNotAlignedRGBImage to restore original state.
Save/restore OpenGL pixel store for unpacking / packing given TCastleImage. Before you pass this image to some OpenGL procedures (like glDrawPixels for unpacking, glReadPixels for packing), call BeforeXxx, and later call AfterXxx to restore original state. These will take care of setting/restoring pixel alignment.
For PerspectiveProjection, ZFar may have special ZFarInfinity value to create a perspective projection with far plane set at infinity. Useful e.g. for z-fail shadow volumes.
function OrthoProjection(const left, right, bottom, top: Single; const zNear: Single = -1; const zFar: Single = 1): TMatrix4Single;
Render sphere in OpenGL. Radius, Slices, Stacks have the same meaning as for gluSphere (in case they are not self-explanatory...). Other parameters set glu quadric parameters, see glu quadric documentation.
Draw simple box. Nothing is generated besides vertex positions — no normal vectors, no texture coords, nothing. Order is CCW outside (so if you want, you can turn on backface culling yourself).
You must enable GL_VERTEX_ARRAY before using this. (It's not done automatically, as it's much faster to do it once for many glDrawBox3DSimple calls. Example — bzwgen city view behind building 1, with occlusion query used: FPC 150 vs 110 when GL_VERTEX_ARRAY is activated once in OcclusionBoxStateBegin, not here. Tested on fglrx on Radeon X1600 (chantal).)
Call glColor, taking Opacity as separate Single argument. Deprecated, do not use colors like that, instead pass TCastleColor to appropriate routines like TCastleFont.Print.
Draw a rectangle that modulates colors underneath, suddenly changing it to FadeColor and then fading to blackness and then fading back to normal, as FadeIntensity goes down from 1.0 to 0.0. This is nice to use for a screen effect when player is hurt.
Draw a simple rectangle filled with a color. Blending is automatically used if Color alpha < 1.
ForceBlending forces the usage of blending. When it is False, we use blending only if Color[3] (alpha) < 1.
function GLInformationString: string;
Multiline string describing attributes of current OpenGL library. This simply queries OpenGL using glGet* functions about many things. Does not change OpenGL state in any way.
Note that the last line of returned string does not terminate with a newline character (so e.g. you may want to do Writeln(GLInformationString) instead of just Write(GLInformationString)).
function glGenListsCheck(range: TGLsizei; const Place: string): TGLuint;
When glGenLists(Range) returned zero for non-zero Range. The exception's Message shows Place, which may describe where this is called — makes it easier to debug.
Draw the 2D GUI stuff (like following GUI images and TCastleFont) with lower-left corner in the X,Y pixel. It's not adviced to use this, better use TGLImage.Draw(X,Y) or TCastleFont.Print(X,Y,string) methods.
Enable exactly one (or none, for Target=etNone) OpenGL texture target. Use this instead of manually calling glDisable(GL_TEXTURE_2D), glEnable(GL_TEXTURE_2D) and such. This makes sure to have at most one texture target enabled, and disable others.
Remember that this state is different for every texture unit in OpenGL, in case you use multi-texturing.
Remember that not all texture targets are guaranteed to be supported by OpenGL. Target=etNone and Target=et2D are always supported. For the rest, check appropriate GLFeatures property (before even creating a texture with such type). If you pass an unsupported target type to this procedure, it will be ignored (all targets will be disabled, like for Target=etNone).
Note that this is only for fixed-function OpenGL pipeline. Shader pipeline completely ignores the enabled state of texture units.
Enable or disable scissor. Always do it using these procedures, do not call glScissor or glEnable(GL_SCISSOR_TEST) / glDisable(GL_SCISSOR_TEST) yourself, or push/pop attrib.
When GPU runs out of memory, raise exception (EOpenGLOutOfMemoryError) or merely make a warning. Merely making a warning is very risky (you risk all kinds of rendering artifacts), but sometimes the rendering is actually smooth even though GPU complains.
Current color, set by glColorv and used for TCastleFont font printing (in case you use deprecated TCastleFont.Print overloads without explicit colors). You should not depend on this in new programs, rather use TCastleFont.Print with explicit Color parameter.
For OpenGLES, this is merely a global ProjectionMatrix variable. It must be passed to various shaders to honour the projection.
For desktop OpenGL, setting this also sets fixed-function projection matrix. The OpenGL matrix mode is temporarily changed to GL_PROJECTION, then changed back to GL_MODELVIEW.
Global ambient lighting. This is added to every 3D object color, multiplied by material ambient.
The default value is (0.2, 0.2, 0.2). It matches default GL_LIGHT_MODEL_AMBIENT in fixed-function OpenGL. It also matches the required value of VRML 1.0 specification. For VRML 2.0 / X3D, lighting equations suggest that it should be zero.