Unit KambiGLUtils

DescriptionusesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

Various OpenGL utilities.

Implements various low-level helpers for OpenGL programming. 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 GLWindow, Glut, SDL, or whatever).

uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Class EOpenGLError sprawdzanie bledow gl ———————————————————-
record TPixelStoreUnpack uproszczenia dla sejwowania / ladowania gl state : ———————————-
record TUnpackNotAlignedData  
Class EOpenGLNoMoreDisplayLists Utilities for display lists —————————————-

Functions and Procedures

function Vector2f(x, y: TGLfloat): TVector2f;
function Vector3f(x, y: TGLfloat; z: TGLfloat =0.0): TVector3f; overload;
function Vector3f(const v3: TVector3d): TVector3f; overload;
function Vector3f(const v3: TVector3ub): TVector3f; overload;
function Vector3d(x, y: TGLdouble; z: TGLdouble =0.0): TVector3d; overload;
function Vector3d(const v: TVector3f): TVector3d; overload;
function Vector4f(x, y: TGLfloat; z: TGLfloat =0; w: TGLfloat =1.0): TVector4f; overload;
function Vector4f(const v3: TVector3f; w: TGLfloat =1.0): TVector4f; overload;
function Vector4f(const ub: TVector4ub): TVector4f; overload;
function Vector3ub(x, y, z: TGLubyte): TVector3ub;
function Vector4ub(x, y, z, w: TGLubyte): TVector4ub; overload;
function Vector4ub(const f4: TVector4f): TVector4ub; overload;
function Normal3f(x, y: TGLfloat; z: TGLfloat =0): TVector3f; overload;
procedure LoadAllExtensions;
procedure CheckGLErrors(const AdditionalComment: string = '' ); overload;
procedure ReportGLError(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: TVector3b); overload;
procedure glColorv(const v: TVector3ub); overload;
procedure glColorv(const v: TVector4b); overload;
procedure glColorv(const v: TVector4ub); overload;
procedure glNormalv(const v: TVector3b); 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: 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 glNormalv(const v: TVector3d); overload;
procedure glNormalv(const v: TVector3f); overload;
procedure glNormalv(const v: TVector3i); overload;
procedure glNormalv(const v: TVector3s); overload;
procedure glColorv(const v: TVector3d); overload;
procedure glColorv(const v: TVector3f); overload;
procedure glColorv(const v: TVector3i); overload;
procedure glColorv(const v: TVector3s); overload;
procedure glColorv(const v: TVector3ui); overload;
procedure glColorv(const v: TVector3us); overload;
procedure glColorv(const v: TVector4d); overload;
procedure glColorv(const v: TVector4f); overload;
procedure glColorv(const v: TVector4i); overload;
procedure glColorv(const v: TVector4s); overload;
procedure glColorv(const v: TVector4ui); overload;
procedure glColorv(const v: TVector4us); overload;
procedure glMaterialv(face, pname: TGLEnum; const params: TVector4f); overload;
procedure glMaterialv(face, pname: TGLEnum; const params: TVector4i); overload;
procedure glVertexv(const v: TVector2d); overload;
procedure glVertexv(const v: TVector2f); overload;
procedure glVertexv(const v: TVector2i); overload;
procedure glVertexv(const v: TVector2s); overload;
procedure glVertexv(const v: TVector3d); overload;
procedure glVertexv(const v: TVector3f); overload;
procedure glVertexv(const v: TVector3i); overload;
procedure glVertexv(const v: TVector3s); overload;
procedure glVertexv(const v: TVector4d); overload;
procedure glVertexv(const v: TVector4f); overload;
procedure glVertexv(const v: TVector4i); overload;
procedure glVertexv(const v: TVector4s); 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: TVector1d); overload;
procedure glTexCoordv(const v: TVector1f); overload;
procedure glTexCoordv(const v: TVector1i); overload;
procedure glTexCoordv(const v: TVector1s); overload;
procedure glTexCoordv(const v: TVector2d); overload;
procedure glTexCoordv(const v: TVector2f); overload;
procedure glTexCoordv(const v: TVector2i); overload;
procedure glTexCoordv(const v: TVector2s); overload;
procedure glTexCoordv(const v: TVector3d); overload;
procedure glTexCoordv(const v: TVector3f); overload;
procedure glTexCoordv(const v: TVector3i); overload;
procedure glTexCoordv(const v: TVector3s); overload;
procedure glTexCoordv(const v: TVector4d); overload;
procedure glTexCoordv(const v: TVector4f); overload;
procedure glTexCoordv(const v: TVector4i); overload;
procedure glTexCoordv(const v: TVector4s); overload;
procedure glTexGenv(coord, pname: TGLenum; const params: TVector4d); overload;
procedure glTexGenv(coord, pname: TGLenum; const params: TVector4f); overload;
procedure glTexGenv(coord, pname: TGLenum; const params: TVector4i); overload;
procedure glLightv(light, pname: TGLEnum; const params: TVector4f); overload;
procedure glLightv(light, pname: TGLEnum; const params: TVector4i); overload;
procedure glLightv(light, pname: TGLEnum; const params: TVector3f); overload;
procedure glLightv(light, pname: TGLEnum; const params: TVector3i); overload;
procedure glLightModelv(pname: TGLenum; const params: TVector4f); overload;
procedure glLightModelv(pname: TGLenum; const params: TVector4i); overload;
procedure glFogv(pname: TGLEnum; const params: TVector4f); overload;
procedure glFogv(pname: TGLEnum; const params: TVector4i); 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 glTexEnvv(target, pname: TGLEnum; const params: TVector4i); 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: TImage);
procedure AfterUnpackImage(const unpackData: TUnpackNotAlignedData; image: TImage);
procedure ProjectionGLPerspective(const fovy, aspect, zNear, zFar: TGLdouble);
procedure ProjectionGLOrtho(const left, right, bottom, top, zNear, zFar: TGLdouble); overload;
procedure ProjectionGLOrtho(const left, right, bottom, top: TGLdouble); overload;
function RandomPolyStipple(const BlackChance: Extended): TPolygonStipple;
function RandomPolyStippleBy16(const BlackChance: Extended): TPolygonStipple;
function RandomPolyStippleBy8(const BlackChance: Extended): TPolygonStipple;
procedure SetGLEnabled(value: TGLenum; isEnabled: boolean);
procedure VerticalGLLine(x, y1, y2: TGLfloat);
procedure HorizontalGLLine(x1, x2, y: TGLfloat);
procedure DrawGLBorderedRectangle(const x1, y1, x2, y2: TGLfloat; const InsideCol, BorderCol: TVector4f); overload;
procedure DrawGLBorderedRectangle(const x1, y1, x2, y2: TGLfloat; const InsideCol, BorderCol: TVector4f; Stipple: PPolygonStipple); overload;
procedure DrawGLRectBorder(const x1, y1, x2, y2: TGLfloat); overload;
procedure DrawGLBorderedRectangle(const R: TIntRect; const InsideCol, BorderCol: TVector4f); overload;
procedure DrawGLBorderedRectangle(const R: TIntRect; const InsideCol, BorderCol: TVector4f; Stipple: PPolygonStipple); overload;
procedure DrawGLRectBorder(const R: TIntRect); overload;
function UnProjectGL(winx, winy, winz: TGLdouble): TVector3d;
procedure fullGLDiskSqueezedTex(radius: TGLdouble; slices: Cardinal);
procedure DrawArrow; overload;
procedure DrawArrow(grotThickness, grotLength: TGLfloat); overload;
function NewGLUQuadric( Texture: TGLboolean = GL_TRUE; Normals: TGLenum = GLU_NONE; Orientation: TGLenum = GLU_OUTSIDE; DrawStyle: TGLenum = GLU_FILL): PGLUQuadric; overload;
procedure KamGluSphere( const Radius: TGLdouble; const Slices, Stacks: TGLint; Texture: TGLboolean = GL_TRUE; Normals: TGLenum = GLU_NONE; Orientation: TGLenum = GLU_OUTSIDE; DrawStyle: TGLenum = GLU_FILL);
procedure DrawGLPlane(x1, y1, x2, y2: TGLfloat; constValue: TGLfloat; constCoord, DetailLevelX, DetailLevelY: integer; constCoordGivesNormal1: boolean);
procedure DrawGLPlaneSpecialTex(x1, y1, x2, y2: TGLfloat; constValue: TGLfloat; constCoord, DetailLevelX, DetailLevelY: integer; constCoordGivesNormal1: boolean; texX1, texY1, texX2, texY2: TGLfloat; order_ST_XYZ: boolean);
procedure DrawGLBox(const Box: TBox3d; DetailX, DetailY, DetailZ: integer; ccwOutside: boolean); overload;
procedure DrawGLBox(const x1, y1, z1, x2, y2, z2: TGLfloat; DetailX, DetailY, DetailZ: integer; ccwOutside: boolean); overload;
procedure glDrawBox3dWire(const Box: TBox3d);
procedure DrawGLTriangle(const p1, p2, p3: TVector3f; const Tex1, Tex2, Tex3: TVector2f; DetailLev: Cardinal);
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 DrawGLBlackOutRect(const BlackOutColor: TVector3f; const BlackOutIntensity, x1, y1, x2, y2: TGLfloat);
function GLCapsString: string;
procedure glClearColorv(const v: TVector3Single; alpha: Single);
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: TGLfloat); overload;
procedure SetWindowPos(const X, Y: TGLint); overload;
procedure SetWindowPosZero;

Types

TGLenum = GLenum;
TGLboolean = GLboolean;
TGLbitfield = GLbitfield;
TGLbyte = GLbyte;
TGLshort = GLshort;
TGLint = GLint;
TGLsizei = GLsizei;
TGLubyte = GLubyte;
TGLushort = GLushort;
TGLuint = GLuint;
TGLfloat = GLfloat;
TGLclampf = GLclampf;
TGLdouble = GLdouble;
TGLclampd = GLclampd;
PPointer = ˆPointer;
TDynGLuintArray = TDynLongWordArray;
TVector1ub = packed array [0..0] of TGLubyte;
PVector1ub = ˆTVector1ub;
TVector1s = packed array [0..0] of TGLshort;
PVector1s = ˆTVector1s;
TVector1i = packed array [0..0] of TGLint;
PVector1i = ˆTVector1i;
TVector1f = packed array [0..0] of TGLfloat;
PVector1f = ˆTVector1f;
TVector1d = packed array [0..0] of TGLDouble;
PVector1d = ˆTVector1d;
TVector1p = packed array [0..0] of Pointer;
PVector1p = ˆTVector1p;
TVector2f = TVector2Single;
PVector2f = PVector2Single;
TVector2d = TVector2Double;
PVector2d = PVector2Double;
TVector2ub = TVector2Byte;
PVector2ub = PVector2Byte;
TVector2s = packed array [0..1] of TGLshort;
PVector2s = ˆTVector2s;
TVector2i = packed array [0..1] of TGLint;
PVector2i = ˆTVector2i;
TVector2p = packed array [0..1] of Pointer;
PVector2p = ˆTVector2p;
TVector3f = TVector3Single;
PVector3f = PVector3Single;
TVector3d = TVector3Double;
PVector3d = PVector3Double;
TVector3ub = TVector3Byte;
PVector3ub = PVector3Byte;
TVector3us = TVector3Word;
PVector3us = PVector3Word;
TVector3b = packed array [0..2] of TGLbyte;
PVector3b = ˆTVector3b;
TVector3i = packed array [0..2] of TGLint;
PVector3i = ˆTVector3i;
TVector3s = packed array [0..2] of TGLshort;
PVector3s = ˆTVector3s;
TVector3ui = packed array [0..2] of TGLuint;
PVector3ui = ˆTVector3ui;
TVector3p = packed array [0..2] of Pointer;
PVector3p = ˆTVector3p;
TVector4f = TVector4Single;
PVector4f = PVector4Single;
TVector4d = TVector4Double;
PVector4d = PVector4Double;
TVector4ub = TVector4Byte;
PVector4ub = PVector4Byte;
TVector4us = TVector4Word;
PVector4us = PVector4Word;
TVector4b = packed array [0..3] of TGLbyte;
PVector4b = ˆTVector4b;
TVector4i = packed array [0..3] of TGLint;
PVector4i = ˆTVector4i;
TVector4s = packed array [0..3] of TGLshort;
PVector4s = ˆTVector4s;
TVector4ui = packed array [0..3] of TGLuint;
PVector4ui = ˆTVector4ui;
TVector4p = packed array [0..3] of Pointer;
PVector4p = ˆTVector4p;
TMatrix2i = TMatrix2Longint;
PMatrix2i = PMatrix2Longint;
TMatrix2f = TMatrix2Single;
PMatrix2f = PMatrix2Single;
TMatrix2d = TMatrix2Double;
PMatrix2d = PMatrix2Double;
TMatrix3i = TMatrix3Longint;
PMatrix3i = PMatrix3Longint;
TMatrix3f = TMatrix3Single;
PMatrix3f = PMatrix3Single;
TMatrix3d = TMatrix3Double;
PMatrix3d = PMatrix3Double;
TMatrix4i = TMatrix4Longint;
PMatrix4i = PMatrix4Longint;
TMatrix4f = TMatrix4Single;
PMatrix4f = PMatrix4Single;
TMatrix4d = TMatrix4Double;
PMatrix4d = PMatrix4Double;
TPoint2i = TVector2i;
TPoint2f = TVector2f;
TPoint2d = TVector2d;
TPoint3i = TVector3i;
TPoint3f = TVector3f;
TPoint3d = TVector3d;
TPoint4i = TVector4i;
TPoint4f = TVector4f;
TPoint4d = TVector4d;
TColor3ub = TVector3ub;
TColor3f = TVector3f;
TColor4ub = TVector4ub;
TColor4f = TVector4f;
TAVector2f = TVector2f;
TAVector2d = TVector2d;
TAVector3f = TVector3f;
TAVector3d = TVector3d;
THVector3f = TVector3f;
THVector3d = TVector3d;
TAVector4f = TVector4f;
TAVector4d = TVector4d;
THVector4f = TVector4f;
THVector4d = TVector4d;
TAPoint2f = TAVector2f;
TAPoint2d = TAVector2d;
TAPoint3f = TAVector3f;
TAPoint3d = TAVector3d;
THPoint3f = THVector3f;
THPoint3d = THVector3d;
THPoint4f = THVector4f;
THPoint4d = THVector4d;
TPolygonStipple = packed array[0..(32*32 div 8)-1]of TGLubyte;
PPolygonStipple = ˆTPolygonStipple;
TTriangle3f = TTriangle3Single;
TTriangle3d = TTriangle3Double;
TArray_GLuint = packed array[0..MaxInt div SizeOf(TGLuint)-1]of TGLuint;
PArray_GLuint = ˆTArray_GLuint;
TArray_Vector3d = packed array[0..MaxInt div SizeOf(TVector3d)-1]of TVector3d;
PArray_Vector3d = ˆTArray_Vector3d;
TArray_Vector3ub = packed array[0..MaxInt div SizeOf(TVector3ub)-1]of TVector3ub;
PArray_Vector3ub = ˆTArray_Vector3ub;
TDynVector2fArray = TDynVector2SingleArray;
TArray_Vector2f = TArray_Vector2Single;
PArray_Vector2f = PArray_Vector2Single;
TDynVector3fArray = TDynVector3SingleArray;
TArray_Vector3f = TArray_Vector3Single;
PArray_Vector3f = PArray_Vector3Single;
TPackNotAlignedData = TUnpackNotAlignedData;
TProcData = procedure (Data: Pointer);

Constants

NullVector2i : TVector2i = (0, 0);
NullVector2f : TVector2f = (0, 0);
NullVector2d : TVector2d = (0, 0);
NullVector2p : TVector2p = (nil, nil);
XVector2i : TVector2i = (1, 0);
XVector2f : TVector2f = (1, 0);
XVector2d : TVector2d = (1, 0);
YVector2i : TVector2i = (0, 1);
YVector2f : TVector2f = (0, 1);
YVector2d : TVector2d = (0, 1);
NullVector3i : TVector3i = (0, 0, 0);
NullVector3f : TVector3f = (0, 0, 0);
NullVector3d : TVector3d = (0, 0, 0);
NullVector3p : TVector3p = (nil, nil, nil);
XVector3i : TVector3i = (1, 0, 0);
XVector3f : TVector3f = (1, 0, 0);
XVector3d : TVector3d = (1, 0, 0);
YVector3i : TVector3i = (0, 1, 0);
YVector3f : TVector3f = (0, 1, 0);
YVector3d : TVector3d = (0, 1, 0);
ZVector3i : TVector3i = (0, 0, 1);
ZVector3f : TVector3f = (0, 0, 1);
ZVector3d : TVector3d = (0, 0, 1);
NullVector4i : TVector4i = (0, 0, 0, 0);
NullVector4f : TVector4f = (0, 0, 0, 0);
NullVector4d : TVector4d = (0, 0, 0, 0);
NullVector4p : TVector4p = (nil, nil, nil, nil);
NullMatrix2f: TMatrix2f = ((0, 0), (0, 0));
NullMatrix2d: TMatrix2d = ((0, 0), (0, 0));
NullMatrix2i: TMatrix2i = ((0, 0), (0, 0));
NullMatrix3f: TMatrix3f = ((0, 0, 0), (0, 0, 0), (0, 0, 0));
NullMatrix3d: TMatrix3d = ((0, 0, 0), (0, 0, 0), (0, 0, 0));
NullMatrix3i: TMatrix3i = ((0, 0, 0), (0, 0, 0), (0, 0, 0));
NullMatrix4f: TMatrix4f = ((0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0));
NullMatrix4d: TMatrix4d = ((0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0));
NullMatrix4i: TMatrix4i = ((0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0));
IdentityMatrix2f: TMatrix2f = ((1, 0), (0, 1));
IdentityMatrix2d: TMatrix2d = ((1, 0), (0, 1));
IdentityMatrix2i: TMatrix2i = ((1, 0), (0, 1));
IdentityMatrix3f: TMatrix3f = ((1, 0, 0), (0, 1, 0), (0, 0, 1));
IdentityMatrix3d: TMatrix3d = ((1, 0, 0), (0, 1, 0), (0, 0, 1));
IdentityMatrix3i: TMatrix3i = ((1, 0, 0), (0, 1, 0), (0, 0, 1));
IdentityMatrix4f: TMatrix4f = ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1));
IdentityMatrix4d: TMatrix4d = ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1));
IdentityMatrix4i: TMatrix4i = ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1));
DefaultMatAmbientColor4ub : TColor4ub = (51, 51, 51, 255);
DefaultMatAmbientColor4f : TColor4f = (0.2, 0.2, 0.2, 1.0);
DefaultMatDiffuseColor4ub : TColor4ub = (204, 204, 204, 255);
DefaultMatDiffuseColor4f : TColor4f = (0.8, 0.8, 0.8, 1.0);
DefaultMatSpecularColor4ub : TColor4ub = (0, 0, 0, 255);
DefaultMatSpecularColor4f : TColor4f = (0, 0, 0, 1.0);
NullHVector3f : THVector3f = (0, 0, 1);
NullHVector3d : THVector3d = (0, 0, 1);
XHVector3f : THVector3f = (1, 0, 1);
XHVector3d : THVector3d = (1, 0, 1);
YHVector3f : THVector3f = (0, 1, 1);
YHVector3d : THVector3d = (0, 1, 1);
NullHVector4f : THVector4f = (0, 0, 0, 1);
NullHVector4d : THVector4d = (0, 0, 0, 1);
XHVector4f : THVector4f = (1, 0, 0, 1);
XHVector4d : THVector4d = (1, 0, 0, 1);
YHVector4f : THVector4f = (0, 1, 0, 1);
YHVector4d : THVector4d = (0, 1, 0, 1);
ZHVector4f : THVector4f = (0, 0, 1, 1);
ZHVector4d : THVector4d = (0, 0, 1, 1);
Vector3fPoint: function(const v: TVector4f): TVector3f = VectorMath.Vector3SinglePoint;
Vector3fCut: function(const v: TVector4f): TVector3f = VectorMath.Vector3SingleCut;
Vector3fFromStr: function (const s: string): TVector3Single = VectorMath.Vector3SingleFromStr;
Vector3dFromStr: function (const s: string): TVector3Double = VectorMath.Vector3DoubleFromStr;
Triangle3d: function(const t: TTriangle3Single): TTriangle3Double = VectorMath.Triangle3Double;
BWColor3fvTo1st: procedure(v: PVector3Single) = VectorMath.BWColor3SinglevTo1st;
BWColor3ubvTo1st: procedure(v: PVector3Byte) = VectorMath.BWColor3BytevTo1st;
OpenGLDLL = 'libGL.so.1' ;
GluDLL = 'libGLU.so.1' ;
HalftoneStipple: TPolygonStipple= ( $AA, $AA, $AA, $AA, $55, $55, $55, $55, $AA, $AA, $AA, $AA, $55, $55, $55, $55, $AA, $AA, $AA, $AA, $55, $55, $55, $55, $AA, $AA, $AA, $AA, $55, $55, $55, $55, $AA, $AA, $AA, $AA, $55, $55, $55, $55, $AA, $AA, $AA, $AA, $55, $55, $55, $55, $AA, $AA, $AA, $AA, $55, $55, $55, $55, $AA, $AA, $AA, $AA, $55, $55, $55, $55, $AA, $AA, $AA, $AA, $55, $55, $55, $55, $AA, $AA, $AA, $AA, $55, $55, $55, $55, $AA, $AA, $AA, $AA, $55, $55, $55, $55, $AA, $AA, $AA, $AA, $55, $55, $55, $55, $AA, $AA, $AA, $AA, $55, $55, $55, $55, $AA, $AA, $AA, $AA, $55, $55, $55, $55, $AA, $AA, $AA, $AA, $55, $55, $55, $55, $AA, $AA, $AA, $AA, $55, $55, $55, $55 );
ThreeQuartersStipple: TPolygonStipple= ( $DD, $DD, $DD, $DD, $77, $77, $77, $77, $EE, $EE, $EE, $EE, $BB, $BB, $BB, $BB, $DD, $DD, $DD, $DD, $77, $77, $77, $77, $EE, $EE, $EE, $EE, $BB, $BB, $BB, $BB, $DD, $DD, $DD, $DD, $77, $77, $77, $77, $EE, $EE, $EE, $EE, $BB, $BB, $BB, $BB, $DD, $DD, $DD, $DD, $77, $77, $77, $77, $EE, $EE, $EE, $EE, $BB, $BB, $BB, $BB, $DD, $DD, $DD, $DD, $77, $77, $77, $77, $EE, $EE, $EE, $EE, $BB, $BB, $BB, $BB, $DD, $DD, $DD, $DD, $77, $77, $77, $77, $EE, $EE, $EE, $EE, $BB, $BB, $BB, $BB, $DD, $DD, $DD, $DD, $77, $77, $77, $77, $EE, $EE, $EE, $EE, $BB, $BB, $BB, $BB, $DD, $DD, $DD, $DD, $77, $77, $77, $77, $EE, $EE, $EE, $EE, $BB, $BB, $BB, $BB );
GLDefaultLightModelAmbient: TVector4Single = (0.2, 0.2, 0.2, 1.0);

Variables

GL_version_1_2: boolean;
GL_version_1_3: boolean;
GL_version_1_4: boolean;
GL_version_1_5: boolean;
GL_version_2_0: boolean;
GL_ARB_imaging: boolean;
GL_ARB_multitexture: boolean;
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: 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_abgr: boolean;
GL_EXT_bgra: 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_texture3D: 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_fence: 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_SUN_vertex: boolean;
GL_ARB_fragment_program: boolean;
GL_ATI_text_fragment_shader: boolean;
GL_APPLE_client_storage: boolean;
GL_APPLE_element_array: boolean;
GL_APPLE_fence: 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;
glFogCoordfEXT: procedure(coord: GLfloat); cdecl;
glFogCoorddEXT: procedure(coord: GLdouble); cdecl;
glFogCoordfvEXT: procedure(coord: PGLfloat); cdecl;
glFogCoorddvEXT: procedure(coord: PGLdouble); cdecl;
KamGLPolygonStipple: procedure(mask: PPolygonStipple); cdecl;
glListIBase: procedure(base: TGLint); cdecl;

Description

Functions and Procedures

function Vector2f(x, y: TGLfloat): TVector2f;

Trivial operations on types below

function Vector3f(x, y: TGLfloat; z: TGLfloat =0.0): TVector3f; overload;
 
function Vector3f(const v3: TVector3d): TVector3f; overload;
 
function Vector3f(const v3: TVector3ub): TVector3f; overload;
 
function Vector3d(x, y: TGLdouble; z: TGLdouble =0.0): TVector3d; overload;
 
function Vector3d(const v: TVector3f): TVector3d; overload;
 
function Vector4f(x, y: TGLfloat; z: TGLfloat =0; w: TGLfloat =1.0): TVector4f; overload;
 
function Vector4f(const v3: TVector3f; w: TGLfloat =1.0): TVector4f; overload;
 
function Vector4f(const ub: TVector4ub): TVector4f; overload;
 
function Vector3ub(x, y, z: TGLubyte): TVector3ub;
 
function Vector4ub(x, y, z, w: TGLubyte): TVector4ub; overload;
 
function Vector4ub(const f4: TVector4f): TVector4ub; overload;
 
function Normal3f(x, y: TGLfloat; z: TGLfloat =0): TVector3f; overload;

Normal3f zwraca jak Vector3f ale od razu normalizuje wartosci x, y, z

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 TShadowVolumesHelper.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 = '' ); overload;

CheckGLErrors sprawdza czy sa jakies bledy OpenGL'a (glGetError), jesli tak - rzuca wyjatek EOpenGLError.

procedure ReportGLError(ErrorCode: TGLenum); cdecl;

ReportGLError = raise EOpenGLError.Create(ErroCode); ReportGLError jest dobra aby ja zerejestrowac jako GLU_TESS_ERROR przez gluTessCallback albo GLU_ERROR przez gluQuadricCallback.

function glGetFloat(pname: TGLEnum): TGLfloat;

—————————————————————————— wersje funkcyjne procedur glGet*. Moga byc uzywane tylko do zastepowania glGet* ktore zwracaja pojedyncze wartosci !

Przy okazji gwarantuja nastepujace zachowanie : jezeli odpowiednie glGet*v bedzie blednym wywolaniem (wiec wedlug specyfikacji OpenGL'a zostanie zignorowane i zostanie ustawione odpowiednie glGetError) to result bedzie jakby po FillChar(result, SizeOf(result), 0). Np. w GLCapsString robimy glGetInteger(GL_MAX_CLIENT_ATTRIB_STACK), jezeli aktualna wersja OpenGL'a w ogole nie ma czegos takiego jak client attrib stack to zapytanie glGetIntegerv(GL_MAX_CLIENT_ATTRIB_STACK, wynik) spowoduje blad i nie zwroci nic pod wskazanym wynik. Ale wlasnie niniejsze get'y najpierw inicjuja result na 0 wiec wynikem bedzie 0 (a nie cos nieokreslonego).

function glGetInteger(pname: TGLEnum): TGLint;
 
function glGetBoolean(pname: TGLEnum): TGLboolean;
 
function glGetDouble(pname: TGLEnum): TGLdouble;
 
procedure glColorv(const v: TVector3b); overload;

Some types should always behave like IMPLEMENT_OPENGL_STUBS was defined – because they are, both in FPC and Delphi, passed by value (not by reference) when they are used as constant parameters.

procedure glColorv(const v: TVector3ub); overload;
 
procedure glColorv(const v: TVector4b); overload;
 
procedure glColorv(const v: TVector4ub); overload;
 
procedure glNormalv(const v: TVector3b); 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: 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 glNormalv(const v: TVector3d); overload;
 
procedure glNormalv(const v: TVector3f); overload;
 
procedure glNormalv(const v: TVector3i); overload;
 
procedure glNormalv(const v: TVector3s); overload;
 
procedure glColorv(const v: TVector3d); overload;
 
procedure glColorv(const v: TVector3f); overload;
 
procedure glColorv(const v: TVector3i); overload;
 
procedure glColorv(const v: TVector3s); overload;
 
procedure glColorv(const v: TVector3ui); overload;
 
procedure glColorv(const v: TVector3us); overload;
 
procedure glColorv(const v: TVector4d); overload;
 
procedure glColorv(const v: TVector4f); overload;
 
procedure glColorv(const v: TVector4i); overload;
 
procedure glColorv(const v: TVector4s); overload;
 
procedure glColorv(const v: TVector4ui); overload;
 
procedure glColorv(const v: TVector4us); overload;
 
procedure glMaterialv(face, pname: TGLEnum; const params: TVector4f); overload;
 
procedure glMaterialv(face, pname: TGLEnum; const params: TVector4i); overload;
 
procedure glVertexv(const v: TVector2d); overload;
 
procedure glVertexv(const v: TVector2f); overload;
 
procedure glVertexv(const v: TVector2i); overload;
 
procedure glVertexv(const v: TVector2s); overload;
 
procedure glVertexv(const v: