Castle Game EngineIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers |
Unit CastleGLUtils
Description
Various low-level utilities for working with OpenGL.
This unit contains a mixture of useful utilities. Simple wrappers for OpenGL procedures (like glVertexv, that is overloaded for various vector types, and calls appropriate version like glVertex3fv based on parameter type). Also simple drawing routines for basic primitives (boxes etc.). This unit does not assume that you initialized OpenGL in any particular way (e.g. using CastleWindow, Glut, SDL, or whatever).
Uses
Overview
Classes, Interfaces, Objects and Records
Functions and Procedures
procedure LoadAllExtensions; |
procedure CheckGLErrors(const AdditionalComment: string = ''); |
procedure GLErrorRaise(ErrorCode: TGLenum); cdecl; |
function glGetFloat(pname: TGLEnum): TGLfloat; |
function glGetInteger(pname: TGLEnum): TGLint; |
function glGetBoolean(pname: TGLEnum): TGLboolean; |
function glGetDouble(pname: TGLEnum): TGLdouble; |
procedure glColorv(const v: TVector3ub); overload; |
procedure glColorv(const v: TVector4ub); overload; |
procedure glTranslatev(const V: TVector3f); overload; |
procedure glTranslatev(const V: TVector3d); overload; |
procedure glTranslatev(const V: TVector3_Single); overload; |
procedure glTranslatev(const V: TVector3_Double); overload; |
procedure glScalev(const V: Single); overload; |
procedure glScalev(const V: TVector3f); overload; |
procedure glScalev(const V: TVector3d); overload; |
procedure glScalev(const V: TVector3_Single); overload; |
procedure glScalev(const V: TVector3_Double); overload; |
procedure glRotatev(const Angle: TGLfloat; const V: TVector3f); overload; |
procedure glRotatev(const Angle: TGLdouble; const V: TVector3d); overload; |
procedure glClipPlane(plane: GLenum; const V: TVector4d); overload; |
procedure gluLookAtv(const Eye, Center, Up: TVector3Single); |
procedure gluLookDirv(const Eye, Dir, Up: TVector3Single); |
procedure glMultiTexCoordv(const Target: TGLEnum; const v: TVector2d); overload; |
procedure glMultiTexCoordv(const Target: TGLEnum; const v: TVector2f); overload; |
procedure glMultiTexCoordv(const Target: TGLEnum; const v: TVector3d); overload; |
procedure glMultiTexCoordv(const Target: TGLEnum; const v: TVector3f); overload; |
procedure glMultiTexCoordv(const Target: TGLEnum; const v: TVector4d); overload; |
procedure glMultiTexCoordv(const Target: TGLEnum; const v: TVector4f); overload; |
procedure glClearColorv(const v: TVector3f; alpha: Single); |
procedure glNormalv(const v: TVector3d); overload; |
procedure glNormalv(const v: TVector3f); overload; |
procedure glColorv(const v: TVector3d); overload; |
procedure glColorv(const v: TVector3f); overload; |
procedure glColorv(const v: TVector4d); overload; |
procedure glColorv(const v: TVector4f); overload; |
procedure glMaterialv(face, pname: TGLEnum; const params: TVector4f); overload; |
procedure glVertexv(const v: TVector2d); overload; |
procedure glVertexv(const v: TVector2f); overload; |
procedure glVertexv(const v: TVector2i); overload; |
procedure glVertexv(const v: TVector3d); overload; |
procedure glVertexv(const v: TVector3f); overload; |
procedure glVertexv(const v: TVector3i); overload; |
procedure glVertexv(const v: TVector4d); overload; |
procedure glVertexv(const v: TVector4f); overload; |
procedure glVertexv(const v: TVector4i); overload; |
procedure glVertexv(const v: TVector2_Double); overload; |
procedure glVertexv(const v: TVector2_Single); overload; |
procedure glVertexv(const v: TVector3_Double); overload; |
procedure glVertexv(const v: TVector3_Single); overload; |
procedure glVertexv(const v: TVector4_Double); overload; |
procedure glVertexv(const v: TVector4_Single); overload; |
procedure glTexCoordv(const v: TVector2d); overload; |
procedure glTexCoordv(const v: TVector2f); overload; |
procedure glTexCoordv(const v: TVector3d); overload; |
procedure glTexCoordv(const v: TVector3f); overload; |
procedure glTexCoordv(const v: TVector4d); overload; |
procedure glTexCoordv(const v: TVector4f); overload; |
procedure glTexGenv(coord, pname: TGLenum; const params: TVector4d); overload; |
procedure glTexGenv(coord, pname: TGLenum; const params: TVector4f); overload; |
procedure glLightv(light, pname: TGLEnum; const params: TVector4f); overload; |
procedure glLightv(light, pname: TGLEnum; const params: TVector3f); overload; |
procedure glLightModelv(pname: TGLenum; const params: TVector4f); overload; |
procedure glFogv(pname: TGLEnum; const params: TVector4f); overload; |
procedure glMultMatrix(const m: TMatrix4f); overload; |
procedure glMultMatrix(const m: TMatrix4d); overload; |
procedure glLoadMatrix(const m: TMatrix4f); overload; |
procedure glLoadMatrix(const m: TMatrix4d); overload; |
procedure glTexEnvv(target, pname: TGLEnum; const params: TVector4f); overload; |
procedure SavePixelStoreUnpack(out pixUnpack: TPixelStoreUnpack); |
procedure LoadPixelStoreUnpack(const pixUnpack: TPixelStoreUnpack); |
procedure BeforeUnpackNotAlignedRGBImage(out unpackdata: TUnpackNotAlignedData; imageWidth: cardinal); |
procedure AfterUnpackNotAlignedRGBImage(const unpackData: TUnpackNotAlignedData; imageWidth: cardinal); |
procedure BeforePackNotAlignedRGBImage(out packdata: TPackNotAlignedData; imageWidth: cardinal); |
procedure AfterPackNotAlignedRGBImage(const packData: TPackNotAlignedData; imageWidth: cardinal); |
procedure BeforeUnpackImage(out unpackdata: TUnpackNotAlignedData; image: TCastleImage); |
procedure AfterUnpackImage(const unpackData: TUnpackNotAlignedData; image: TCastleImage); |
procedure BeforePackImage(out packdata: TPackNotAlignedData; image: TCastleImage); |
procedure AfterPackImage(const packData: TPackNotAlignedData; image: TCastleImage); |
function PerspectiveProjection(const fovy, aspect, zNear, zFar: Single): TMatrix4Single; |
function OrthoProjection(const left, right, bottom, top: Single; const zNear: Single = -1; const zFar: Single = 1): TMatrix4Single; |
procedure GLSetEnabled(value: TGLenum; isEnabled: boolean); |
procedure GLVerticalLine(x, y1, y2: TGLfloat); |
procedure GLHorizontalLine(x1, x2, y: TGLfloat); |
procedure GLRectangleWithBorder(const x1, y1, x2, y2: TGLfloat; const InsideColor, BorderColor: TVector4f; const BorderWidth: Single = 1.0); |
procedure GLRectangleBorder(const x1, y1, x2, y2: TGLfloat; const Color: TVector4f; const BorderWidth: Single = 1.0); overload; |
procedure GLDrawArrow(HeadThickness: TGLfloat = 0.4; HeadLength: TGLfloat = 0.5); |
function NewGLUQuadric( Texture: boolean = true; Normals: TGLenum = GLU_NONE; Orientation: TGLenum = GLU_OUTSIDE; DrawStyle: TGLenum = GLU_FILL): PGLUQuadric; overload; |
procedure CastleGluSphere( const Radius: TGLdouble; const Slices, Stacks: TGLint; Texture: boolean = true; Normals: TGLenum = GLU_NONE; Orientation: TGLenum = GLU_OUTSIDE; DrawStyle: TGLenum = GLU_FILL); |
procedure glDrawAxisWire(const Position: TVector3Single; Size: Single); |
procedure glDrawBox3DWire(const Box: TBox3D); |
procedure glDrawBox3DSimple(const Box: TBox3D); |
procedure glProjectionPushPop2D(proc: TProcData; Data: Pointer); |
procedure glProjectionPushPopOrtho(proc: TProcData; Data: Pointer; const Left, Right, Bottom, Top, ZNear, ZFar: TGLdouble); |
procedure glProjectionPushPopOrtho2D(proc: TProcData; Data: Pointer; const Left, Right, Bottom, Top: TGLdouble); |
procedure glProjectionPushPopPerspective(proc: TProcData; Data: Pointer; const FovyDeg, Aspect, ZNear, ZFar: TGLdouble); |
procedure glProjectionPushPop(proc: TProcData; Data: Pointer; const projMatrix: TMatrix4f); |
procedure GLFadeRectangle(const X1, Y1, X2, Y2: Integer; const FadeColor: TVector3Single; const FadeIntensity: Single); |
procedure GLBlendRectangle(const X1, Y1, X2, Y2: Integer; const SourceFactor, DestinationFactor: TGLenum; const Color: TVector4Single); |
function GLInformationString: string; |
function glGenListsCheck(range: TGLsizei; const Place: string): TGLuint; |
procedure glFreeDisplayList(var list: TGLuint); |
procedure glFreeTexture(var Tex: TGLuint); |
procedure glSetDepthAndColorWriteable(Writeable: TGLboolean); |
procedure SetWindowPos(const X, Y: TGLint); overload; |
procedure SetWindowPosF(const X, Y: TGLfloat); overload; |
procedure SetWindowPosZero; |
function CastleGL_CLAMP_TO_EDGE: TGLenum; |
procedure glColorOpacity(const Color: TVector3Single; const Opacity: Single); |
procedure glColorOpacity(const Color: TVector3Byte; const Opacity: Single); |
function GetDepthRange: TDepthRange; |
procedure SetDepthRange(const Value: TDepthRange); |
Types
Constants
Variables
Description
Functions and Procedures
procedure LoadAllExtensions; |
Initialize all extensions and OpenGL versions.
Calls all Load_GLXxx routines from glext unit, so tries to init
all GL 1.2, 1.3, 2.0 etc. function addresses and
all gl extensions function addresses and
inits all boolean extensions variables.
Note that variables GL_version_x_x, like GL_version_2_0, are initialized by checking both version string (glGetString(GL_VERSION) etc) and by actually checking whether all entry points are non-nil. This is important because with buggy OpenGL implementations (see shitty ATI Linux closed drivers) version number in version string may be untrue: version string reports OpenGL 2.0, but actually lack entry points for pretty much all OpenGL 2.0 functions. So GLVersion.AtLeast(2, 0) returns True , but in fact you can't have OpenGL 2.0 functions.
Implementation: Load_GL_version_x_x from GLExt unit actually always checks whether all entry points are <> nil, that's good. GLVersion.AtLeast by definition only checks version string, so this is used to check version string.
Note that it would be an error to check only whether entry points are non-nil, I should always check version string too. For example see glStencilOpSeparate := nil in TGLShadowVolumeRenderer.InitGLContext fix, on Mesa 6.x and NVidia legacy 96xx on Linux this is non-nil (i.e. entry point exists in GL library), but doesn't work (I didn't use GLExt back then, but OpenGLh). And OpenGL version string indicates gl 1.x version. This is OK, I think: and it means I should always check version string (not depend that all library entry points are actually implemented).
So when e.g. GL_version_2_0 is True , you are actually sure that all GL 2.0 entry points are really non-nil and they really should work.
Inits also GLVersion and GLUVersion from GLVersionUnit.
|
procedure CheckGLErrors(const AdditionalComment: string = ''); |
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.
Without -dRELEASE, we raise EOpenGLError. So a developer is strongly suggested to fix the code to not produce OpenGL errors, never ever.
Exceptions raised
- EOpenGLError
|
procedure GLErrorRaise(ErrorCode: TGLenum); cdecl; |
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.
|
function glGetFloat(pname: TGLEnum): TGLfloat; |
Comfortable wrappers for OpenGL glGet* that return a single value.
Guarantee that result is zero in case of OpenGL error. (Otherwise, OpenGL could leave them undefined and only set glGetError.)
|
procedure glColorv(const v: TVector3ub); overload; |
|
procedure glColorv(const v: TVector4ub); overload; |
|
procedure glTranslatev(const V: TVector3f); overload; |
|
procedure glTranslatev(const V: TVector3d); overload; |
|
procedure glTranslatev(const V: TVector3_Single); overload; |
|
procedure glTranslatev(const V: TVector3_Double); overload; |
|
procedure glScalev(const V: Single); overload; |
|
procedure glScalev(const V: TVector3f); overload; |
|
procedure glScalev(const V: TVector3d); overload; |
|
procedure glScalev(const V: TVector3_Single); overload; |
|
procedure glScalev(const V: TVector3_Double); overload; |
|
procedure glClipPlane(plane: GLenum; const V: TVector4d); overload; |
|
procedure glMultiTexCoordv(const Target: TGLEnum; const v: TVector2d); overload; |
|
procedure glMultiTexCoordv(const Target: TGLEnum; const v: TVector2f); overload; |
|
procedure glMultiTexCoordv(const Target: TGLEnum; const v: TVector3d); overload; |
|
procedure glMultiTexCoordv(const Target: TGLEnum; const v: TVector3f); overload; |
|
procedure glMultiTexCoordv(const Target: TGLEnum; const v: TVector4d); overload; |
|
procedure glMultiTexCoordv(const Target: TGLEnum; const v: TVector4f); overload; |
|
procedure glClearColorv(const v: TVector3f; alpha: Single); |
|
procedure glNormalv(const v: TVector3d); overload; |
|
procedure glNormalv(const v: TVector3f); overload; |
|
procedure glColorv(const v: TVector3d); overload; |
|
procedure glColorv(const v: TVector3f); overload; |
|
procedure glColorv(const v: TVector4d); overload; |
|
procedure glColorv(const v: TVector4f); overload; |
|
procedure glVertexv(const v: TVector2d); overload; |
|
procedure glVertexv(const v: TVector2f); overload; |
|
procedure glVertexv(const v: TVector2i); overload; |
|
procedure glVertexv(const v: TVector3d); overload; |
|
procedure glVertexv(const v: TVector3f); overload; |
|
procedure glVertexv(const v: TVector3i); overload; |
|
procedure glVertexv(const v: TVector4d); overload; |
|
procedure glVertexv(const v: TVector4f); overload; |
|
procedure glVertexv(const v: TVector4i); overload; |
|
procedure glVertexv(const v: TVector2_Double); overload; |
|
procedure glVertexv(const v: TVector2_Single); overload; |
|
procedure glVertexv(const v: TVector3_Double); overload; |
|
procedure glVertexv(const v: TVector3_Single); overload; |
|
procedure glVertexv(const v: TVector4_Double); overload; |
|
procedure glVertexv(const v: TVector4_Single); overload; |
|
procedure glTexCoordv(const v: TVector2d); overload; |
|
procedure glTexCoordv(const v: TVector2f); overload; |
|
procedure glTexCoordv(const v: TVector3d); overload; |
|
procedure glTexCoordv(const v: TVector3f); overload; |
|
procedure glTexCoordv(const v: TVector4d); overload; |
|
procedure glTexCoordv(const v: TVector4f); overload; |
|
procedure glMultMatrix(const m: TMatrix4f); overload; |
|
procedure glMultMatrix(const m: TMatrix4d); overload; |
|
procedure glLoadMatrix(const m: TMatrix4f); overload; |
|
procedure glLoadMatrix(const m: TMatrix4d); overload; |
|
procedure BeforeUnpackNotAlignedRGBImage(out unpackdata: TUnpackNotAlignedData; imageWidth: cardinal); |
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.
|
procedure BeforePackNotAlignedRGBImage(out packdata: TPackNotAlignedData; imageWidth: cardinal); |
Save/restore OpenGL pixel store for packing TRGBImage. Use around glReadPixels and such with TRGBImage.
|
procedure AfterPackNotAlignedRGBImage(const packData: TPackNotAlignedData; imageWidth: cardinal); |
|
procedure BeforeUnpackImage(out unpackdata: TUnpackNotAlignedData; image: TCastleImage); |
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.
|
function PerspectiveProjection(const fovy, aspect, zNear, zFar: Single): TMatrix4Single; |
Load projection matrix to OpenGL GL_PROJECTION matrix.
At the end, these unconditionally change matrix mode to GL_MODELVIEW.
ZFar is allowed to have special ZFarInfinity value for PerspectiveProjection . Then we set special perspective matrix, that has far plane set at infinity — useful for z-fail shadow volumes.
|
function OrthoProjection(const left, right, bottom, top: Single; const zNear: Single = -1; const zFar: Single = 1): TMatrix4Single; |
|
procedure GLSetEnabled(value: TGLenum; isEnabled: boolean); |
|
procedure GLVerticalLine(x, y1, y2: TGLfloat); |
Draw vertical line using OpenGL. Uses current OpenGL color.
|
procedure GLHorizontalLine(x1, x2, y: TGLfloat); |
Draw horizontal line using OpenGL. Uses current OpenGL color.
|
procedure GLRectangleWithBorder(const x1, y1, x2, y2: TGLfloat; const InsideColor, BorderColor: TVector4f; const BorderWidth: Single = 1.0); |
Draw rectangle, filled with one color and framed with other color.
The vertex order is the same as for glRectf, so it's CCW from standard view. We assume that OpenGL polygon fill mode is "fill". Changes OpenGL current color and line width.
|
procedure GLRectangleBorder(const x1, y1, x2, y2: TGLfloat; const Color: TVector4f; const BorderWidth: Single = 1.0); overload; |
Draw rectangle border.
The vertex order is the same as for glRectf, so it's CCW from standard view. Changes OpenGL current color and line width.
|
procedure GLDrawArrow(HeadThickness: TGLfloat = 0.4; HeadLength: TGLfloat = 0.5); |
Draw arrow shape. Arrow is placed on Z = 0 plane, points to the up, has height = 2 (from y = 0 to y = 2) and width 1 (from x = -0.5 to 0.5).
Everything is drawn CCW when seen from standard view (x grows right, y up). Uses current OpenGL color.
|
function NewGLUQuadric( Texture: boolean = true; Normals: TGLenum = GLU_NONE; Orientation: TGLenum = GLU_OUTSIDE; DrawStyle: TGLenum = GLU_FILL): PGLUQuadric; overload; |
Comfortable wrapper for gluNewQuadric. Sets all quadric parameters. Sets also the GLU_ERROR callback to ReportGLerror.
Exceptions raised
Exception
- If gluNewQuadric fails (returns nil).
|
procedure CastleGluSphere( const Radius: TGLdouble; const Slices, Stacks: TGLint; Texture: boolean = true; Normals: TGLenum = GLU_NONE; Orientation: TGLenum = GLU_OUTSIDE; DrawStyle: TGLenum = GLU_FILL); |
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.
|
procedure glDrawAxisWire(const Position: TVector3Single; Size: Single); |
Draw axis (3 lines) around given position. Nothing is generated besides vertex positions — no normal vectors, no texture coords, nothing.
|
procedure glDrawBox3DWire(const Box: TBox3D); |
Draw the wireframe box. Nothing is generated besides vertex positions — no normal vectors, no texture coords, nothing.
|
procedure glDrawBox3DSimple(const Box: TBox3D); |
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).)
It can be safely placed in a display list.
|
procedure glProjectionPushPop2D(proc: TProcData; Data: Pointer); |
Temporarily switch to 2D OpenGL projection, call given callback, then restore original projection.
2D projection is like gluOrtho2d(0, Viewport.width, 0, Viewport.height). Use more general glProjectionPushPop to provide any projection matrix.
The current matrix mode doesn't have to be GL_PROJECTION at call time. We will take care to have the original matrix mode when calling Proc callback.
|
procedure glProjectionPushPopOrtho(proc: TProcData; Data: Pointer; const Left, Right, Bottom, Top, ZNear, ZFar: TGLdouble); |
|
procedure glProjectionPushPopOrtho2D(proc: TProcData; Data: Pointer; const Left, Right, Bottom, Top: TGLdouble); |
|
procedure glProjectionPushPopPerspective(proc: TProcData; Data: Pointer; const FovyDeg, Aspect, ZNear, ZFar: TGLdouble); |
|
procedure glProjectionPushPop(proc: TProcData; Data: Pointer; const projMatrix: TMatrix4f); |
|
procedure GLFadeRectangle(const X1, Y1, X2, Y2: Integer; const FadeColor: TVector3Single; const FadeIntensity: Single); |
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.
The rectangle is affected by current modelview matrix. Requires one attrib stack place.
|
procedure GLBlendRectangle(const X1, Y1, X2, Y2: Integer; const SourceFactor, DestinationFactor: TGLenum; const Color: TVector4Single); |
Draw a rectangle with blending.
The rectangle is affected by current modelview matrix. Requires one attrib stack place.
|
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; |
Call glGenLists(range) and checks the result.
Exceptions raised
- EOpenGLNoMoreDisplayLists
- 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.
|
procedure glFreeDisplayList(var list: TGLuint); |
If List <> 0 then it does glDeleteList on List and sets List to 0. In other words this is simply glDeleteList but
only if List really should be deleted
sets List to 0 after deletion
|
procedure glFreeTexture(var Tex: TGLuint); |
If Tex <> 0 then it does glDeleteTextures on Tex and sets Tex to 0. In other words, this is a simple wrapper over glDeleteTextures that
checks if Tex really should be deleted
sets Tex to 0 to not free it once again
|
procedure glSetDepthAndColorWriteable(Writeable: TGLboolean); |
Set color and depth buffers writeable or not. This is just a shortcut for
glDepthMask(Writeable);
glColorMask(Writeable, Writeable, Writeable, Writeable);
|
procedure SetWindowPos(const X, Y: TGLint); overload; |
Set raster position in window coordinates, and the raster position is never clipped.
This is similar to glWindowPos and actually will simply call glWindowPos if available (if OpenGL version >= 1.4 or ARB_window_pos or MESA_window_pos are available).
If not available, it will fall back on a simple implementation that sets identity to projection and modelview and sets a special viewport (setting special viewport means that we can avoid clipping the raster pos, also it means that you don't have to pass here parameters like window width/height — viewport will appropriately map to your window coordinates).
What with the depth value of raster is undefined (although OpenGL ARB_window_pos specifies it, we don't want to specify it, to be able to pull our simple implementation when ARB_window_pos is not available).
SetWindowPosZero is equivalent to SetWindowPos (0, 0), but may be slightly optimized.
|
procedure SetWindowPosF(const X, Y: TGLfloat); overload; |
|
procedure SetWindowPosZero; |
|
function CastleGL_CLAMP_TO_EDGE: TGLenum; |
Return GL_CLAMP_TO_EDGE, if available in current OpenGL version. Otherwise returns GL_CLAMP.
Use this (insteaf of direct GL_CLAMP_TO_EDGE) to work with really ancient OpenGL versions before 1.2. Note that our engine officially supports only OpenGL >= 1.2, so don't expect everything to work smootly with such ancient OpenGL anyway!
|
procedure glColorOpacity(const Color: TVector3Single; const Opacity: Single); |
Call glColor, taking Opacity as separate Single argument.
|
procedure glColorOpacity(const Color: TVector3Byte; const Opacity: Single); |
|
Types
TGLSupport = (...); |
Values
-
gsNone:
-
gsExtension:
-
gsStandard:
|
TGLbitfield = GLbitfield; |
|
TProcData = procedure (Data: Pointer); |
|
TDepthRange = (...); |
Values
|
Constants
GLSupportNames: array [TGLSupport] of string =
( 'None', 'Extension', 'Standard' ); |
|
OpenGLDLL =
'libGL.so.1'
; |
|
Variables
GL_version_1_2: boolean; |
OpenGL versions supported. Checked by looking at GL version string and by checking whether actual entry points are available.
|
GL_ARB_transpose_matrix: boolean; |
|
GL_ARB_multisample: boolean; |
|
GL_ARB_texture_env_add: boolean; |
|
GL_ARB_texture_cube_map: boolean; |
|
GL_ARB_depth_texture: boolean; |
|
GL_ARB_point_parameters: boolean; |
|
GL_ARB_shadow_ambient: boolean; |
|
GL_ARB_texture_border_clamp: boolean; |
|
GL_ARB_texture_compression: boolean; |
|
GL_ARB_texture_env_combine: boolean; |
|
GL_ARB_texture_env_crossbar: boolean; |
|
GL_ARB_texture_env_dot3: boolean; |
|
GL_ARB_texture_mirrored_repeat: boolean; |
|
GL_ARB_vertex_blend: boolean; |
|
GL_ARB_vertex_program: boolean; |
|
GL_ARB_window_pos: boolean; |
|
GL_EXT_422_pixels: boolean; |
|
GL_EXT_blend_color: boolean; |
|
GL_EXT_blend_func_separate: boolean; |
|
GL_EXT_blend_logic_op: boolean; |
|
GL_EXT_blend_minmax: boolean; |
|
GL_EXT_blend_subtract: boolean; |
|
GL_EXT_clip_volume_hint: boolean; |
|
GL_EXT_color_subtable: boolean; |
|
GL_EXT_compiled_vertex_array: boolean; |
|
GL_EXT_convolution: boolean; |
|
GL_EXT_fog_coord: boolean; |
|
GL_EXT_histogram: boolean; |
|
GL_EXT_multi_draw_arrays: boolean; |
|
GL_EXT_packed_pixels: boolean; |
|
GL_EXT_paletted_texture: boolean; |
|
GL_EXT_point_parameters: boolean; |
|
GL_EXT_polygon_offset: boolean; |
|
GL_EXT_secondary_color: boolean; |
|
GL_EXT_separate_specular_color: boolean; |
|
GL_EXT_shadow_funcs: boolean; |
|
GL_EXT_shared_texture_palette: boolean; |
|
GL_EXT_stencil_two_side: boolean; |
|
GL_EXT_stencil_wrap: boolean; |
|
GL_EXT_subtexture: boolean; |
|
GL_EXT_texture_compression_s3tc: boolean; |
|
GL_EXT_texture_env_add: boolean; |
|
GL_EXT_texture_env_combine: boolean; |
|
GL_EXT_texture_env_dot3: boolean; |
|
GL_EXT_texture_filter_anisotropic: boolean; |
|
GL_EXT_texture_lod_bias: boolean; |
|
GL_EXT_texture_object: boolean; |
|
GL_EXT_vertex_array: boolean; |
|
GL_EXT_vertex_shader: boolean; |
|
GL_EXT_vertex_weighting: boolean; |
|
GL_HP_occlusion_test: boolean; |
|
GL_NV_blend_square: boolean; |
|
GL_NV_copy_depth_to_color: boolean; |
|
GL_NV_depth_clamp: boolean; |
|
GL_NV_evaluators: boolean; |
|
GL_NV_fog_distance: boolean; |
|
GL_NV_light_max_exponent: boolean; |
|
GL_NV_multisample_filter_hint: boolean; |
|
GL_NV_occlusion_query: boolean; |
|
GL_NV_packed_depth_stencil: boolean; |
|
GL_NV_point_sprite: boolean; |
|
GL_NV_register_combiners: boolean; |
|
GL_NV_register_combiners2: boolean; |
|
GL_NV_texgen_emboss: boolean; |
|
GL_NV_texgen_reflection: boolean; |
|
GL_NV_texture_compression_vtc: boolean; |
|
GL_NV_texture_env_combine4: boolean; |
|
GL_NV_texture_rectangle: boolean; |
|
GL_NV_texture_shader: boolean; |
|
GL_NV_texture_shader2: boolean; |
|
GL_NV_texture_shader3: boolean; |
|
GL_NV_vertex_array_range: boolean; |
|
GL_NV_vertex_array_range2: boolean; |
|
GL_NV_vertex_program: boolean; |
|
GL_NV_vertex_program1_1: boolean; |
|
GL_ATI_element_array: boolean; |
|
GL_ATI_envmap_bumpmap: boolean; |
|
GL_ATI_fragment_shader: boolean; |
|
GL_ATI_pn_triangles: boolean; |
|
GL_ATI_texture_mirror_once: boolean; |
|
GL_ATI_vertex_array_object: boolean; |
|
GL_ATI_vertex_streams: boolean; |
|
GL_3DFX_texture_compression_FXT1: boolean; |
|
GL_IBM_cull_vertex: boolean; |
|
GL_IBM_multimode_draw_arrays: boolean; |
|
GL_IBM_raster_pos_clip: boolean; |
|
GL_IBM_texture_mirrored_repeat: boolean; |
|
GL_IBM_vertex_array_lists: boolean; |
|
GL_MESA_resize_buffers: boolean; |
|
GL_MESA_window_pos: boolean; |
|
GL_OML_interlace: boolean; |
|
GL_OML_resample: boolean; |
|
GL_OML_subsample: boolean; |
|
GL_SGIS_generate_mipmap: boolean; |
|
GL_SGIS_multisample: boolean; |
|
GL_SGIS_pixel_texture: boolean; |
|
GL_SGIS_texture_border_clamp: boolean; |
|
GL_SGIS_texture_color_mask: boolean; |
|
GL_SGIS_texture_edge_clamp: boolean; |
|
GL_SGIS_texture_lod: boolean; |
|
GL_SGIS_depth_texture: boolean; |
|
GL_SGIX_fog_offset: boolean; |
|
GL_SGIX_interlace: boolean; |
|
GL_SGIX_shadow_ambient: boolean; |
|
GL_SGI_color_matrix: boolean; |
|
GL_SGI_color_table: boolean; |
|
GL_SGI_texture_color_table: boolean; |
|
GL_ARB_fragment_program: boolean; |
|
GL_ATI_text_fragment_shader: boolean; |
|
GL_APPLE_client_storage: boolean; |
|
GL_APPLE_element_array: boolean; |
|
GL_APPLE_vertex_array_object: boolean; |
|
GL_APPLE_vertex_array_range: boolean; |
|
GL_ARB_matrix_palette: boolean; |
|
GL_NV_element_array: boolean; |
|
GL_NV_float_buffer: boolean; |
|
GL_NV_fragment_program: boolean; |
|
GL_NV_primitive_restart: boolean; |
|
GL_NV_vertex_program2: boolean; |
|
GL_ATI_separate_stencil: boolean; |
|
GL_ARB_texture_non_power_of_two: boolean; |
|
GL_ARB_vertex_buffer_object: boolean; |
|
GL_ARB_occlusion_query: boolean; |
|
GL_EXT_packed_depth_stencil: boolean; |
|
GL_ATI_texture_float: boolean; |
|
GL_ARB_texture_float: boolean; |
|
GL_ARB_texture_rectangle: boolean; |
|
GLMaxTextureSize: Cardinal; |
Constant (for given context) OpenGL limits. Initialized once by LoadAllExtensions, this is usually most comfortable. Initialized to 0 if appropriate OpenGL extension is not available.
|
GLMaxCubeMapTextureSizeARB: Cardinal; |
|
GLMax3DTextureSize: Cardinal; |
|
GLMaxTextureMaxAnisotropyEXT: Single; |
|
GLMaxRectangleTextureSize: Cardinal; |
|
GLMaxClipPlanes: Cardinal; |
|
GLMaxTextureUnits: Cardinal; |
Numer of texture units available. Equal to glGetInteger(GL_MAX_TEXTURE_UNITS_ARB), if multi-texturing available. Equal to 1 (OpenGL supports always 1 texture) otherwise.
|
GLUseMultiTexturing: boolean; |
Are all OpenGL multi-texturing extensions for VRML/X3D MultiTexture support available.
This used to check a couple of multitexturing extensions, like ARB_multitexture. Right now, it simply checks for OpenGL 1.3 version. It is supported by virtually all existing GPUs. So it's acceptable to just check it, and write your code for 1.3, and eventual fallback code (when this is false) write only for really ancient GPUs.
|
GLUseARBGLSL: boolean; |
Are all OpenGL ARB extensions for GLSL available.
|
GL3DTextures: TGLSupport; |
Are 3D textures supported by OpenGL. If they are, note that GL_TEXTURE_3D and GL_TEXTURE_3D_EXT are equal, so often both GL3DTextures = gsStandard and GL3DTextures = gsExtension cases may be handled by the same code.
|
GLFramebuffer: TGLSupport; |
Is Framebuffer supported. Value gsExtension means that EXT_framebuffer_object is used, gsStandard means that ARB_framebuffer_object (which is a "core extesion", present the same way in OpenGL 3 core) is available.
|
GLFBOMultiSampling: boolean; |
Is multisampling possible for FBO buffers and textures. Although these are two orthogonal features of OpenGL, in practice you want to use multisample for both FBO buffers and textures, or for none — otherwise, FBO can not be initialized correctly when you mix various multisample settings.
|
GLCurrentMultiSampling: Cardinal; |
How multi-sampling was initialized for this OpenGL context. Value = 1 means that no multi-sampling is initialized. Values > 1 mean that you have multi-sampling, with given number of samples per pixel. Contrast this with TCastleWindowBase.MultiSampling or TOpenGLControl.MultiSampling, that say how many samples you wanted to get.
|
GLPackedDepthStencil: boolean; |
Does OpenGL context have depth buffer packed with stencil buffer. See EXT_packed_depth_stencil extension for explanation.
This is important for FBOs, as the depth/stencil have to be set up differently depending on GLPackedDepthStencil value. This is also important for all code using TGLRenderToTexture with TGLRenderToTexture.Buffer equal tbDepth or tbColorAndDepth: your depth texture must be prepared differently, to include both depth+stencil data, to work.
For now, this is simply equal to GL_EXT_packed_depth_stencil. (TODO: for core OpenGL 3, how to detect should we use packed version? http://www.opengl.org/registry/specs/ARB/framebuffer_object.txt incorporates EXT_packed_depth_stencil, so forward-compatible contexts do not need to declare it. Should we assume that forward-compatible gl 3 contexts always have depth/stencil packed?)
|
GLShadowVolumesPossible: boolean; |
Does OpenGL context support shadow volumes. This simply checks do we have stencil buffer with at least 4 bits for now.
|
glListIBase: procedure(base: TGLint); cdecl; |
Equivalent to glListBase but it's parameter is a signed integer.
Original declararations of glListBase take unsigned integer, while actually a signed integer is also allowed. Actually, you should always call gListBase with range/overflow checking turned off. That's because argument to glListBase is used by OpenGL only in an expression like
Base + CurrentListNumber
so it's the "CurrentListNumber" that determines what Base actually means — e.g. if Base = LongWord(-100) and CurrentListNumber = 1000 then the actual list number is 900, and this is all that matters. So you can say that Base was nagative. But if Base = LongWord(-100) and CurrentListNumber = 0 then the actual list number is LongWord(-100) = <some big integer around 4 * 10ˆ9>. So you can say that Base was positive.
|
Generated by PasDoc 0.12.1 on 2013-02-04 20:26:50
|