From 5a2eeb45d528c5a2406b2ae5d73a4c711b2ea7dc Mon Sep 17 00:00:00 2001 From: Bergmann89 Date: Mon, 15 Dec 2014 22:31:56 +0100 Subject: [PATCH] * added OpenGL ES support --- glBitmap.pas | 541 +++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 451 insertions(+), 90 deletions(-) diff --git a/glBitmap.pas b/glBitmap.pas index ddee6ca..4986ed4 100644 --- a/glBitmap.pas +++ b/glBitmap.pas @@ -221,11 +221,17 @@ unit glBitmap; // Please uncomment the defines below to configure the glBitmap to your preferences. // If you have configured the unit you can uncomment the warning above. -{$MESSAGE error 'Hey. I''m the glBitmap.pas and i need to be configured. My master tell me your preferences! ;)'} +{.$MESSAGE error 'Hey. I''m the glBitmap.pas and i need to be configured. My master tell me your preferences! ;)'} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Preferences /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// enable OpenGL ES support +{.$DEFINE OPENGL_ES_1_1} +{.$DEFINE OPENGL_ES_2_0} +{.$DEFINE OPENGL_ES_3_0} +{.$DEFINE OPENGL_ES_EXT} + // activate to enable build-in OpenGL support with statically linked methods // use dglOpenGL.pas if not enabled {.$DEFINE GLB_NATIVE_OGL_STATIC} @@ -302,9 +308,19 @@ unit glBitmap; {$DEFINE GLB_LINUX} {$IFEND} +// OpenGL ES +{$IF DEFINED(OPENGL_ES_EXT)} {$DEFINE OPENGL_ES_1_1} {$IFEND} +{$IF DEFINED(OPENGL_ES_3_0)} {$DEFINE OPENGL_ES_2_0} {$IFEND} +{$IF DEFINED(OPENGL_ES_2_0)} {$DEFINE OPENGL_ES_1_1} {$IFEND} +{$IF DEFINED(OPENGL_ES_1_1)} {$DEFINE OPENGL_ES} {$IFEND} + // native OpenGL Support {$IF DEFINED(GLB_NATIVE_OGL_STATIC) OR DEFINED(GLB_NATIVE_OGL_DYNAMIC)} - {$DEFINE GLB_NATIVE_OGL} + {$IFDEF OPENGL_ES} + {$ERROR 'native OpenGL is not supported yet for OpenGL ES, please use dglOpenGLES.pas instead'} + {$ELSE} + {$DEFINE GLB_NATIVE_OGL} + {$ENDIF} {$IFEND} // checking define combinations @@ -441,7 +457,10 @@ unit glBitmap; interface uses - {$IFNDEF GLB_NATIVE_OGL} dglOpenGL, {$ENDIF} + {$IFNDEF GLB_NATIVE_OGL} + {$IFDEF OPENGL_ES} dglOpenGLES, + {$ELSE} dglOpenGL, {$ENDIF} + {$ENDIF} {$IF DEFINED(GLB_WIN) AND (DEFINED(GLB_NATIVE_OGL) OR DEFINED(GLB_DELPHI))} windows, {$IFEND} @@ -1018,7 +1037,9 @@ type fFreeDataOnDestroy: Boolean; fFreeDataAfterGenTexture: Boolean; fData: PByte; +{$IFNDEF OPENGL_ES} fIsResident: GLboolean; +{$ENDIF} fBorderColor: array[0..3] of Single; fDimension: TglBitmapPixelPosition; @@ -1038,8 +1059,10 @@ type fWrapT: GLenum; fWrapR: GLenum; +{$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_3_0)} //Swizzle fSwizzle: array[0..3] of GLenum; +{$IFEND} // CustomData fFilename: String; @@ -1068,7 +1091,7 @@ type procedure SetAnisotropic(const aValue: Integer); procedure CreateID; - procedure SetupParameters(out aBuildWithGlu: Boolean); + procedure SetupParameters({$IFNDEF OPENGL_ES}out aBuildWithGlu: Boolean{$ENDIF}); procedure SetDataPointer(var aData: PByte; const aFormat: TglBitmapFormat; const aWidth: Integer = -1; const aHeight: Integer = -1); virtual; //be careful, aData could be freed by this method procedure GenTexture(const aTestTextureSize: Boolean = true); virtual; abstract; @@ -1102,7 +1125,9 @@ type property Dimension: TglBitmapPixelPosition read fDimension; property Data: PByte read fData; +{$IFNDEF OPENGL_ES} property IsResident: GLboolean read fIsResident; +{$ENDIF} procedure AfterConstruction; override; procedure BeforeDestruction; override; @@ -1175,7 +1200,9 @@ type function Clone: TglBitmap; function ConvertTo(const aFormat: TglBitmapFormat): Boolean; virtual; procedure Invert(const aUseRGB: Boolean = true; const aUseAlpha: Boolean = false); +{$IFNDEF OPENGL_ES} procedure SetBorderColor(const aRed, aGreen, aBlue, aAlpha: Single); +{$ENDIF} procedure FreeData; //ColorFill @@ -1189,7 +1216,9 @@ type const S: GLenum = GL_CLAMP_TO_EDGE; const T: GLenum = GL_CLAMP_TO_EDGE; const R: GLenum = GL_CLAMP_TO_EDGE); +{$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_3_0)} procedure SetSwizzle(const r, g, b, a: GLenum); +{$IFEND} procedure Bind(const aEnableTextureUnit: Boolean = true); virtual; procedure Unbind(const aDisableTextureUnit: Boolean = true); virtual; @@ -1223,6 +1252,7 @@ type end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +{$IFNDEF OPENGL_ES} TglBitmap1D = class(TglBitmap) protected procedure SetDataPointer(var aData: PByte; const aFormat: TglBitmapFormat; @@ -1234,6 +1264,7 @@ type function FlipHorz: Boolean; override; procedure GenTexture(const aTestTextureSize: Boolean = true); override; end; +{$ENDIF} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TglBitmap2D = class(TglBitmap) @@ -1242,7 +1273,7 @@ type function GetScanline(const aIndex: Integer): Pointer; procedure SetDataPointer(var aData: PByte; const aFormat: TglBitmapFormat; const aWidth: Integer = - 1; const aHeight: Integer = - 1); override; - procedure UploadData(const aTarget: GLenum; const aBuildWithGlu: Boolean); + procedure UploadData(const aTarget: GLenum{$IFNDEF OPENGL_ES}; const aBuildWithGlu: Boolean{$ENDIF}); public property Width; property Height; @@ -1251,7 +1282,9 @@ type procedure AfterConstruction; override; procedure GrabScreen(const aTop, aLeft, aRight, aBottom: Integer; const aFormat: TglBitmapFormat); +{$IFNDEF OPENGL_ES} procedure GetDataFromTexture; +{$ENDIF} procedure GenTexture(const aTestTextureSize: Boolean = true); override; function FlipHorz: Boolean; override; @@ -1262,23 +1295,29 @@ type end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +{$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_2_0)} TglBitmapCubeMap = class(TglBitmap2D) protected + {$IFNDEF OPENGL_ES} fGenMode: Integer; + {$ENDIF} procedure GenTexture(const aTestTextureSize: Boolean = true); reintroduce; public procedure AfterConstruction; override; procedure GenerateCubeMap(const aCubeTarget: Cardinal; const aTestTextureSize: Boolean = true); - procedure Bind(const aEnableTexCoordsGen: Boolean = true; const aEnableTextureUnit: Boolean = true); reintroduce; virtual; - procedure Unbind(const aDisableTexCoordsGen: Boolean = true; const aDisableTextureUnit: Boolean = true); reintroduce; virtual; + procedure Bind({$IFNDEF OPENGL_ES}const aEnableTexCoordsGen: Boolean = true;{$ENDIF} const aEnableTextureUnit: Boolean = true); reintroduce; virtual; + procedure Unbind({$IFNDEF OPENGL_ES}const aDisableTexCoordsGen: Boolean = true;{$ENDIF} const aDisableTextureUnit: Boolean = true); reintroduce; virtual; end; +{$IFEND} +{$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_2_0)} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TglBitmapNormalMap = class(TglBitmapCubeMap) public procedure AfterConstruction; override; procedure GenerateNormalMap(const aSize: Integer = 32; const aTestTextureSize: Boolean = true); end; +{$IFEND} const NULL_SIZE: TglBitmapPixelPosition = (Fields: []; X: 0; Y: 0); @@ -2389,6 +2428,7 @@ begin end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +{$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_3_0)} procedure glBitmapSetDefaultSwizzle(const r: GLenum = GL_RED; g: GLenum = GL_GREEN; b: GLenum = GL_BLUE; a: GLenum = GL_ALPHA); begin glDefaultSwizzle[0] := r; @@ -2396,6 +2436,7 @@ begin glDefaultSwizzle[2] := b; glDefaultSwizzle[3] := a; end; +{$IFEND} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function glBitmapGetDefaultDeleteTextureOnFree: Boolean; @@ -2436,6 +2477,7 @@ begin R := glBitmapDefaultWrapR; end; +{$IFNDEF OPENGL_ES} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure glBitmapGetDefaultSwizzle(var r, g, b, a: GLenum); begin @@ -2444,6 +2486,7 @@ begin b := glDefaultSwizzle[2]; a := glDefaultSwizzle[3]; end; +{$ENDIF} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TFormatDescriptor/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -2936,12 +2979,16 @@ begin fBitsPerPixel := 8; fFormat := tfAlpha4ub1; fWithAlpha := tfAlpha4ub1; - fOpenGLFormat := tfAlpha4ub1; fPrecision := glBitmapRec4ub(0, 0, 0, 8); fShift := glBitmapRec4ub(0, 0, 0, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfAlpha4ub1; fglFormat := GL_ALPHA; fglInternalFormat := GL_ALPHA4; fglDataFormat := GL_UNSIGNED_BYTE; +{$ELSE} + fOpenGLFormat := tfAlpha8ub1; +{$ENDIF} end; procedure TfdAlpha8ub1.SetValues; @@ -2950,11 +2997,11 @@ begin fBitsPerPixel := 8; fFormat := tfAlpha8ub1; fWithAlpha := tfAlpha8ub1; - fOpenGLFormat := tfAlpha8ub1; fPrecision := glBitmapRec4ub(0, 0, 0, 8); fShift := glBitmapRec4ub(0, 0, 0, 0); + fOpenGLFormat := tfAlpha8ub1; fglFormat := GL_ALPHA; - fglInternalFormat := GL_ALPHA8; + fglInternalFormat := {$IFNDEF OPENGL_ES}GL_ALPHA8{$ELSE}GL_ALPHA{$ENDIF}; fglDataFormat := GL_UNSIGNED_BYTE; end; @@ -2964,12 +3011,16 @@ begin fBitsPerPixel := 16; fFormat := tfAlpha16us1; fWithAlpha := tfAlpha16us1; - fOpenGLFormat := tfAlpha16us1; fPrecision := glBitmapRec4ub(0, 0, 0, 16); fShift := glBitmapRec4ub(0, 0, 0, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfAlpha16us1; fglFormat := GL_ALPHA; fglInternalFormat := GL_ALPHA16; fglDataFormat := GL_UNSIGNED_SHORT; +{$ELSE} + fOpenGLFormat := tfAlpha8ub1; +{$ENDIF} end; procedure TfdLuminance4ub1.SetValues; @@ -2979,12 +3030,16 @@ begin fFormat := tfLuminance4ub1; fWithAlpha := tfLuminance4Alpha4ub2; fWithoutAlpha := tfLuminance4ub1; - fOpenGLFormat := tfLuminance4ub1; fPrecision := glBitmapRec4ub(8, 8, 8, 0); fShift := glBitmapRec4ub(0, 0, 0, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfLuminance4ub1; fglFormat := GL_LUMINANCE; fglInternalFormat := GL_LUMINANCE4; fglDataFormat := GL_UNSIGNED_BYTE; +{$ELSE} + fOpenGLFormat := tfLuminance8ub1; +{$ENDIF} end; procedure TfdLuminance8ub1.SetValues; @@ -2998,7 +3053,7 @@ begin fPrecision := glBitmapRec4ub(8, 8, 8, 0); fShift := glBitmapRec4ub(0, 0, 0, 0); fglFormat := GL_LUMINANCE; - fglInternalFormat := GL_LUMINANCE8; + fglInternalFormat := {$IFNDEF OPENGL_ES}GL_LUMINANCE8{$ELSE}GL_LUMINANCE{$ENDIF}; fglDataFormat := GL_UNSIGNED_BYTE; end; @@ -3009,12 +3064,16 @@ begin fFormat := tfLuminance16us1; fWithAlpha := tfLuminance16Alpha16us2; fWithoutAlpha := tfLuminance16us1; - fOpenGLFormat := tfLuminance16us1; fPrecision := glBitmapRec4ub(16, 16, 16, 0); fShift := glBitmapRec4ub( 0, 0, 0, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfLuminance16us1; fglFormat := GL_LUMINANCE; fglInternalFormat := GL_LUMINANCE16; fglDataFormat := GL_UNSIGNED_SHORT; +{$ELSE} + fOpenGLFormat := tfLuminance8ub1; +{$ENDIF} end; procedure TfdLuminance4Alpha4ub2.SetValues; @@ -3024,12 +3083,16 @@ begin fFormat := tfLuminance4Alpha4ub2; fWithAlpha := tfLuminance4Alpha4ub2; fWithoutAlpha := tfLuminance4ub1; - fOpenGLFormat := tfLuminance4Alpha4ub2; fPrecision := glBitmapRec4ub(8, 8, 8, 8); fShift := glBitmapRec4ub(0, 0, 0, 8); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfLuminance4Alpha4ub2; fglFormat := GL_LUMINANCE_ALPHA; fglInternalFormat := GL_LUMINANCE4_ALPHA4; fglDataFormat := GL_UNSIGNED_BYTE; +{$ELSE} + fOpenGLFormat := tfLuminance8Alpha8ub2; +{$ENDIF} end; procedure TfdLuminance6Alpha2ub2.SetValues; @@ -3039,12 +3102,16 @@ begin fFormat := tfLuminance6Alpha2ub2; fWithAlpha := tfLuminance6Alpha2ub2; fWithoutAlpha := tfLuminance8ub1; - fOpenGLFormat := tfLuminance6Alpha2ub2; fPrecision := glBitmapRec4ub(8, 8, 8, 8); fShift := glBitmapRec4ub(0, 0, 0, 8); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfLuminance6Alpha2ub2; fglFormat := GL_LUMINANCE_ALPHA; fglInternalFormat := GL_LUMINANCE6_ALPHA2; fglDataFormat := GL_UNSIGNED_BYTE; +{$ELSE} + fOpenGLFormat := tfLuminance8Alpha8ub2; +{$ENDIF} end; procedure TfdLuminance8Alpha8ub2.SetValues; @@ -3058,7 +3125,7 @@ begin fPrecision := glBitmapRec4ub(8, 8, 8, 8); fShift := glBitmapRec4ub(0, 0, 0, 8); fglFormat := GL_LUMINANCE_ALPHA; - fglInternalFormat := GL_LUMINANCE8_ALPHA8; + fglInternalFormat := {$IFNDEF OPENGL_ES}GL_LUMINANCE8_ALPHA8{$ELSE}GL_LUMINANCE_ALPHA{$ENDIF}; fglDataFormat := GL_UNSIGNED_BYTE; end; @@ -3069,12 +3136,16 @@ begin fFormat := tfLuminance12Alpha4us2; fWithAlpha := tfLuminance12Alpha4us2; fWithoutAlpha := tfLuminance16us1; - fOpenGLFormat := tfLuminance12Alpha4us2; fPrecision := glBitmapRec4ub(16, 16, 16, 16); fShift := glBitmapRec4ub( 0, 0, 0, 16); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfLuminance12Alpha4us2; fglFormat := GL_LUMINANCE_ALPHA; fglInternalFormat := GL_LUMINANCE12_ALPHA4; fglDataFormat := GL_UNSIGNED_SHORT; +{$ELSE} + fOpenGLFormat := tfLuminance8Alpha8ub2; +{$ENDIF} end; procedure TfdLuminance16Alpha16us2.SetValues; @@ -3084,12 +3155,16 @@ begin fFormat := tfLuminance16Alpha16us2; fWithAlpha := tfLuminance16Alpha16us2; fWithoutAlpha := tfLuminance16us1; - fOpenGLFormat := tfLuminance16Alpha16us2; fPrecision := glBitmapRec4ub(16, 16, 16, 16); fShift := glBitmapRec4ub( 0, 0, 0, 16); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfLuminance16Alpha16us2; fglFormat := GL_LUMINANCE_ALPHA; fglInternalFormat := GL_LUMINANCE16_ALPHA16; fglDataFormat := GL_UNSIGNED_SHORT; +{$ELSE} + fOpenGLFormat := tfLuminance8Alpha8ub2; +{$ENDIF} end; procedure TfdR3G3B2ub1.SetValues; @@ -3099,13 +3174,17 @@ begin fFormat := tfR3G3B2ub1; fWithAlpha := tfRGBA4us1; fWithoutAlpha := tfR3G3B2ub1; - fOpenGLFormat := tfR3G3B2ub1; fRGBInverted := tfEmpty; fPrecision := glBitmapRec4ub(3, 3, 2, 0); fShift := glBitmapRec4ub(5, 2, 0, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfR3G3B2ub1; fglFormat := GL_RGB; fglInternalFormat := GL_R3_G3_B2; fglDataFormat := GL_UNSIGNED_BYTE_3_3_2; +{$ELSE} + fOpenGLFormat := tfR5G6B5us1; +{$ENDIF} end; procedure TfdRGBX4us1.SetValues; @@ -3115,13 +3194,17 @@ begin fFormat := tfRGBX4us1; fWithAlpha := tfRGBA4us1; fWithoutAlpha := tfRGBX4us1; - fOpenGLFormat := tfRGBX4us1; fRGBInverted := tfBGRX4us1; fPrecision := glBitmapRec4ub( 4, 4, 4, 0); fShift := glBitmapRec4ub(12, 8, 4, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfRGBX4us1; fglFormat := GL_RGBA; //GL_INVALID_OPERATION if not GL_BGRA or GL_RGBA fglInternalFormat := GL_RGB4; fglDataFormat := GL_UNSIGNED_SHORT_4_4_4_4; +{$ELSE} + fOpenGLFormat := tfR5G6B5us1; +{$ENDIF} end; procedure TfdXRGB4us1.SetValues; @@ -3131,13 +3214,17 @@ begin fFormat := tfXRGB4us1; fWithAlpha := tfARGB4us1; fWithoutAlpha := tfXRGB4us1; - fOpenGLFormat := tfXRGB4us1; fRGBInverted := tfXBGR4us1; fPrecision := glBitmapRec4ub(4, 4, 4, 0); fShift := glBitmapRec4ub(8, 4, 0, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfXRGB4us1; fglFormat := GL_BGRA; fglInternalFormat := GL_RGB4; fglDataFormat := GL_UNSIGNED_SHORT_4_4_4_4_REV; +{$ELSE} + fOpenGLFormat := tfR5G6B5us1; +{$ENDIF} end; procedure TfdR5G6B5us1.SetValues; @@ -3147,13 +3234,17 @@ begin fFormat := tfR5G6B5us1; fWithAlpha := tfRGB5A1us1; fWithoutAlpha := tfR5G6B5us1; - fOpenGLFormat := tfR5G6B5us1; fRGBInverted := tfB5G6R5us1; fPrecision := glBitmapRec4ub( 5, 6, 5, 0); fShift := glBitmapRec4ub(11, 5, 0, 0); +{$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_2_0)} + fOpenGLFormat := tfR5G6B5us1; fglFormat := GL_RGB; fglInternalFormat := GL_RGB565; fglDataFormat := GL_UNSIGNED_SHORT_5_6_5; +{$ELSE} + fOpenGLFormat := tfRGB8ub3; +{$IFEND} end; procedure TfdRGB5X1us1.SetValues; @@ -3163,13 +3254,17 @@ begin fFormat := tfRGB5X1us1; fWithAlpha := tfRGB5A1us1; fWithoutAlpha := tfRGB5X1us1; - fOpenGLFormat := tfRGB5X1us1; fRGBInverted := tfBGR5X1us1; fPrecision := glBitmapRec4ub( 5, 5, 5, 0); fShift := glBitmapRec4ub(11, 6, 1, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfRGB5X1us1; fglFormat := GL_RGBA; //GL_INVALID_OPERATION if not GL_BGRA or GL_RGBA fglInternalFormat := GL_RGB5; fglDataFormat := GL_UNSIGNED_SHORT_5_5_5_1; +{$ELSE} + fOpenGLFormat := tfR5G6B5us1; +{$ENDIF} end; procedure TfdX1RGB5us1.SetValues; @@ -3179,13 +3274,17 @@ begin fFormat := tfX1RGB5us1; fWithAlpha := tfA1RGB5us1; fWithoutAlpha := tfX1RGB5us1; - fOpenGLFormat := tfX1RGB5us1; fRGBInverted := tfX1BGR5us1; fPrecision := glBitmapRec4ub( 5, 5, 5, 0); fShift := glBitmapRec4ub(10, 5, 0, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfX1RGB5us1; fglFormat := GL_BGRA; //GL_INVALID_OPERATION if not GL_BGRA or GL_RGBA fglInternalFormat := GL_RGB5; fglDataFormat := GL_UNSIGNED_SHORT_1_5_5_5_REV; +{$ELSE} + fOpenGLFormat := tfR5G6B5us1; +{$ENDIF} end; procedure TfdRGB8ub3.SetValues; @@ -3195,12 +3294,12 @@ begin fFormat := tfRGB8ub3; fWithAlpha := tfRGBA8ub4; fWithoutAlpha := tfRGB8ub3; - fOpenGLFormat := tfRGB8ub3; fRGBInverted := tfBGR8ub3; fPrecision := glBitmapRec4ub(8, 8, 8, 0); fShift := glBitmapRec4ub(0, 8, 16, 0); + fOpenGLFormat := tfRGB8ub3; fglFormat := GL_RGB; - fglInternalFormat := GL_RGB8; + fglInternalFormat := {$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_3_0)}GL_RGB8{$ELSE}GL_RGB{$IFEND}; fglDataFormat := GL_UNSIGNED_BYTE; end; @@ -3211,13 +3310,17 @@ begin fFormat := tfRGBX8ui1; fWithAlpha := tfRGBA8ui1; fWithoutAlpha := tfRGBX8ui1; - fOpenGLFormat := tfRGB8ub3; fRGBInverted := tfBGRX8ui1; fPrecision := glBitmapRec4ub( 8, 8, 8, 0); fShift := glBitmapRec4ub(24, 16, 8, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfRGBX8ui1; fglFormat := GL_RGBA; //GL_INVALID_OPERATION if not GL_BGRA or GL_RGBA fglInternalFormat := GL_RGB8; fglDataFormat := GL_UNSIGNED_INT_8_8_8_8; +{$ELSE} + fOpenGLFormat := tfRGB8ub3; +{$ENDIF} end; procedure TfdXRGB8ui1.SetValues; @@ -3227,13 +3330,18 @@ begin fFormat := tfXRGB8ui1; fWithAlpha := tfXRGB8ui1; fWithoutAlpha := tfXRGB8ui1; - fOpenGLFormat := tfRGB8ub3; + fOpenGLFormat := tfXRGB8ui1; fRGBInverted := tfXBGR8ui1; fPrecision := glBitmapRec4ub( 8, 8, 8, 0); fShift := glBitmapRec4ub(16, 8, 0, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfXRGB8ui1; fglFormat := GL_BGRA; //GL_INVALID_OPERATION if not GL_BGRA or GL_RGBA fglInternalFormat := GL_RGB8; fglDataFormat := GL_UNSIGNED_INT_8_8_8_8_REV; +{$ELSE} + fOpenGLFormat := tfRGB8ub3; +{$ENDIF} end; procedure TfdRGB10X2ui1.SetValues; @@ -3243,13 +3351,17 @@ begin fFormat := tfRGB10X2ui1; fWithAlpha := tfRGB10A2ui1; fWithoutAlpha := tfRGB10X2ui1; - fOpenGLFormat := tfRGB10X2ui1; fRGBInverted := tfBGR10X2ui1; fPrecision := glBitmapRec4ub(10, 10, 10, 0); fShift := glBitmapRec4ub(22, 12, 2, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfRGB10X2ui1; fglFormat := GL_RGBA; //GL_INVALID_OPERATION if not GL_BGRA or GL_RGBA fglInternalFormat := GL_RGB10; fglDataFormat := GL_UNSIGNED_INT_10_10_10_2; +{$ELSE} + fOpenGLFormat := tfRGB16us3; +{$ENDIF} end; procedure TfdX2RGB10ui1.SetValues; @@ -3259,13 +3371,17 @@ begin fFormat := tfX2RGB10ui1; fWithAlpha := tfA2RGB10ui1; fWithoutAlpha := tfX2RGB10ui1; - fOpenGLFormat := tfX2RGB10ui1; fRGBInverted := tfX2BGR10ui1; fPrecision := glBitmapRec4ub(10, 10, 10, 0); fShift := glBitmapRec4ub(20, 10, 0, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfX2RGB10ui1; fglFormat := GL_BGRA; //GL_INVALID_OPERATION if not GL_BGRA or GL_RGBA fglInternalFormat := GL_RGB10; fglDataFormat := GL_UNSIGNED_INT_2_10_10_10_REV; +{$ELSE} + fOpenGLFormat := tfRGB16us3; +{$ENDIF} end; procedure TfdRGB16us3.SetValues; @@ -3275,13 +3391,17 @@ begin fFormat := tfRGB16us3; fWithAlpha := tfRGBA16us4; fWithoutAlpha := tfRGB16us3; - fOpenGLFormat := tfRGB16us3; fRGBInverted := tfBGR16us3; fPrecision := glBitmapRec4ub(16, 16, 16, 0); fShift := glBitmapRec4ub( 0, 16, 32, 0); +{$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_3_0)} + fOpenGLFormat := tfRGB16us3; fglFormat := GL_RGB; - fglInternalFormat := GL_RGB16; + fglInternalFormat := {$IFNDEF OPENGL_ES}GL_RGB16{$ELSE}GL_RGB16UI{$ENDIF}; fglDataFormat := GL_UNSIGNED_SHORT; +{$ELSE} + fOpenGLFormat := tfRGB8ub3; +{$IFEND} end; procedure TfdRGBA4us1.SetValues; @@ -3296,7 +3416,7 @@ begin fPrecision := glBitmapRec4ub( 4, 4, 4, 4); fShift := glBitmapRec4ub(12, 8, 4, 0); fglFormat := GL_RGBA; - fglInternalFormat := GL_RGBA4; + fglInternalFormat := {$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_3_0)}GL_RGBA8{$ELSE}GL_RGBA{$IFEND}; fglDataFormat := GL_UNSIGNED_SHORT_4_4_4_4; end; @@ -3307,13 +3427,17 @@ begin fFormat := tfARGB4us1; fWithAlpha := tfARGB4us1; fWithoutAlpha := tfXRGB4us1; - fOpenGLFormat := tfARGB4us1; fRGBInverted := tfABGR4us1; fPrecision := glBitmapRec4ub( 4, 4, 4, 4); fShift := glBitmapRec4ub( 8, 4, 0, 12); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfARGB4us1; fglFormat := GL_BGRA; fglInternalFormat := GL_RGBA4; fglDataFormat := GL_UNSIGNED_SHORT_4_4_4_4_REV; +{$ELSE} + fOpenGLFormat := tfRGBA4us1; +{$ENDIF} end; procedure TfdRGB5A1us1.SetValues; @@ -3328,7 +3452,7 @@ begin fPrecision := glBitmapRec4ub( 5, 5, 5, 1); fShift := glBitmapRec4ub(11, 6, 1, 0); fglFormat := GL_RGBA; - fglInternalFormat := GL_RGB5_A1; + fglInternalFormat := {$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_2_0)}GL_RGB5_A1{$ELSE}GL_RGBA{$IFEND}; fglDataFormat := GL_UNSIGNED_SHORT_5_5_5_1; end; @@ -3339,13 +3463,17 @@ begin fFormat := tfA1RGB5us1; fWithAlpha := tfA1RGB5us1; fWithoutAlpha := tfX1RGB5us1; - fOpenGLFormat := tfA1RGB5us1; fRGBInverted := tfA1BGR5us1; fPrecision := glBitmapRec4ub( 5, 5, 5, 1); fShift := glBitmapRec4ub(10, 5, 0, 15); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfA1RGB5us1; fglFormat := GL_BGRA; fglInternalFormat := GL_RGB5_A1; fglDataFormat := GL_UNSIGNED_SHORT_1_5_5_5_REV; +{$ELSE} + fOpenGLFormat := tfRGB5A1us1; +{$ENDIF} end; procedure TfdRGBA8ui1.SetValues; @@ -3355,13 +3483,17 @@ begin fFormat := tfRGBA8ui1; fWithAlpha := tfRGBA8ui1; fWithoutAlpha := tfRGBX8ui1; - fOpenGLFormat := tfRGBA8ui1; fRGBInverted := tfBGRA8ui1; fPrecision := glBitmapRec4ub( 8, 8, 8, 8); fShift := glBitmapRec4ub(24, 16, 8, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfRGBA8ui1; fglFormat := GL_RGBA; fglInternalFormat := GL_RGBA8; fglDataFormat := GL_UNSIGNED_INT_8_8_8_8; +{$ELSE} + fOpenGLFormat := tfRGBA8ub4; +{$ENDIF} end; procedure TfdARGB8ui1.SetValues; @@ -3371,13 +3503,17 @@ begin fFormat := tfARGB8ui1; fWithAlpha := tfARGB8ui1; fWithoutAlpha := tfXRGB8ui1; - fOpenGLFormat := tfARGB8ui1; fRGBInverted := tfABGR8ui1; fPrecision := glBitmapRec4ub( 8, 8, 8, 8); fShift := glBitmapRec4ub(16, 8, 0, 24); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfARGB8ui1; fglFormat := GL_BGRA; fglInternalFormat := GL_RGBA8; fglDataFormat := GL_UNSIGNED_INT_8_8_8_8_REV; +{$ELSE} + fOpenGLFormat := tfRGBA8ub4; +{$ENDIF} end; procedure TfdRGBA8ub4.SetValues; @@ -3392,7 +3528,7 @@ begin fPrecision := glBitmapRec4ub( 8, 8, 8, 8); fShift := glBitmapRec4ub( 0, 8, 16, 24); fglFormat := GL_RGBA; - fglInternalFormat := GL_RGBA8; + fglInternalFormat := {$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_3_0)}GL_RGBA8{$ELSE}GL_RGBA{$IFEND}; fglDataFormat := GL_UNSIGNED_BYTE; end; @@ -3403,13 +3539,17 @@ begin fFormat := tfRGB10A2ui1; fWithAlpha := tfRGB10A2ui1; fWithoutAlpha := tfRGB10X2ui1; - fOpenGLFormat := tfRGB10A2ui1; fRGBInverted := tfBGR10A2ui1; fPrecision := glBitmapRec4ub(10, 10, 10, 2); fShift := glBitmapRec4ub(22, 12, 2, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfRGB10A2ui1; fglFormat := GL_RGBA; fglInternalFormat := GL_RGB10_A2; fglDataFormat := GL_UNSIGNED_INT_10_10_10_2; +{$ELSE} + fOpenGLFormat := tfA2RGB10ui1; +{$ENDIF} end; procedure TfdA2RGB10ui1.SetValues; @@ -3419,13 +3559,22 @@ begin fFormat := tfA2RGB10ui1; fWithAlpha := tfA2RGB10ui1; fWithoutAlpha := tfX2RGB10ui1; - fOpenGLFormat := tfA2RGB10ui1; fRGBInverted := tfA2BGR10ui1; fPrecision := glBitmapRec4ub(10, 10, 10, 2); fShift := glBitmapRec4ub(20, 10, 0, 30); +{$IF NOT DEFINED(OPENGL_ES)} + fOpenGLFormat := tfA2RGB10ui1; fglFormat := GL_BGRA; fglInternalFormat := GL_RGB10_A2; fglDataFormat := GL_UNSIGNED_INT_2_10_10_10_REV; +{$ELSEIF DEFINED(OPENGL_ES_3_0)} + fOpenGLFormat := tfA2RGB10ui1; + fglFormat := GL_RGBA; + fglInternalFormat := GL_RGB10_A2; + fglDataFormat := GL_UNSIGNED_INT_2_10_10_10_REV; +{$ELSE} + fOpenGLFormat := tfRGBA8ui1; +{$IFEND} end; procedure TfdRGBA16us4.SetValues; @@ -3435,13 +3584,17 @@ begin fFormat := tfRGBA16us4; fWithAlpha := tfRGBA16us4; fWithoutAlpha := tfRGB16us3; - fOpenGLFormat := tfRGBA16us4; fRGBInverted := tfBGRA16us4; fPrecision := glBitmapRec4ub(16, 16, 16, 16); fShift := glBitmapRec4ub( 0, 16, 32, 48); +{$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_3_0)} + fOpenGLFormat := tfRGBA16us4; fglFormat := GL_RGBA; - fglInternalFormat := GL_RGBA16; + fglInternalFormat := {$IFNDEF OPENGL_ES}GL_RGBA16{$ELSE}GL_RGBA16UI{$ENDIF}; fglDataFormat := GL_UNSIGNED_SHORT; +{$ELSE} + fOpenGLFormat := tfRGBA8ub4; +{$IFEND} end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -3454,13 +3607,17 @@ begin fFormat := tfBGRX4us1; fWithAlpha := tfBGRA4us1; fWithoutAlpha := tfBGRX4us1; - fOpenGLFormat := tfBGRX4us1; fRGBInverted := tfRGBX4us1; fPrecision := glBitmapRec4ub( 4, 4, 4, 0); fShift := glBitmapRec4ub( 4, 8, 12, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfBGRX4us1; fglFormat := GL_BGRA; //GL_INVALID_OPERATION if not GL_BGRA or GL_RGBA fglInternalFormat := GL_RGB4; fglDataFormat := GL_UNSIGNED_SHORT_4_4_4_4; +{$ELSE} + fOpenGLFormat := tfR5G6B5us1; +{$ENDIF} end; procedure TfdXBGR4us1.SetValues; @@ -3470,13 +3627,17 @@ begin fFormat := tfXBGR4us1; fWithAlpha := tfABGR4us1; fWithoutAlpha := tfXBGR4us1; - fOpenGLFormat := tfXBGR4us1; fRGBInverted := tfXRGB4us1; fPrecision := glBitmapRec4ub( 4, 4, 4, 0); fShift := glBitmapRec4ub( 0, 4, 8, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfXBGR4us1; fglFormat := GL_RGBA; //GL_INVALID_OPERATION if not GL_BGRA or GL_RGBA fglInternalFormat := GL_RGB4; fglDataFormat := GL_UNSIGNED_SHORT_4_4_4_4_REV; +{$ELSE} + fOpenGLFormat := tfR5G6B5us1; +{$ENDIF} end; procedure TfdB5G6R5us1.SetValues; @@ -3486,13 +3647,17 @@ begin fFormat := tfB5G6R5us1; fWithAlpha := tfBGR5A1us1; fWithoutAlpha := tfB5G6R5us1; - fOpenGLFormat := tfB5G6R5us1; fRGBInverted := tfR5G6B5us1; fPrecision := glBitmapRec4ub( 5, 6, 5, 0); fShift := glBitmapRec4ub( 0, 5, 11, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfB5G6R5us1; fglFormat := GL_RGB; fglInternalFormat := GL_RGB565; fglDataFormat := GL_UNSIGNED_SHORT_5_6_5_REV; +{$ELSE} + fOpenGLFormat := tfR5G6B5us1; +{$ENDIF} end; procedure TfdBGR5X1us1.SetValues; @@ -3502,13 +3667,17 @@ begin fFormat := tfBGR5X1us1; fWithAlpha := tfBGR5A1us1; fWithoutAlpha := tfBGR5X1us1; - fOpenGLFormat := tfBGR5X1us1; fRGBInverted := tfRGB5X1us1; fPrecision := glBitmapRec4ub( 5, 5, 5, 0); fShift := glBitmapRec4ub( 1, 6, 11, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfBGR5X1us1; fglFormat := GL_BGRA; fglInternalFormat := GL_RGB5; fglDataFormat := GL_UNSIGNED_SHORT_5_5_5_1; +{$ELSE} + fOpenGLFormat := tfR5G6B5us1; +{$ENDIF} end; procedure TfdX1BGR5us1.SetValues; @@ -3518,13 +3687,17 @@ begin fFormat := tfX1BGR5us1; fWithAlpha := tfA1BGR5us1; fWithoutAlpha := tfX1BGR5us1; - fOpenGLFormat := tfX1BGR5us1; fRGBInverted := tfX1RGB5us1; fPrecision := glBitmapRec4ub( 5, 5, 5, 0); fShift := glBitmapRec4ub( 0, 5, 10, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfX1BGR5us1; fglFormat := GL_RGBA; //GL_INVALID_OPERATION if not GL_BGRA or GL_RGBA fglInternalFormat := GL_RGB5; fglDataFormat := GL_UNSIGNED_SHORT_1_5_5_5_REV; +{$ELSE} + fOpenGLFormat := tfR5G6B5us1; +{$ENDIF} end; procedure TfdBGR8ub3.SetValues; @@ -3534,13 +3707,17 @@ begin fFormat := tfBGR8ub3; fWithAlpha := tfBGRA8ub4; fWithoutAlpha := tfBGR8ub3; - fOpenGLFormat := tfBGR8ub3; fRGBInverted := tfRGB8ub3; fPrecision := glBitmapRec4ub( 8, 8, 8, 0); fShift := glBitmapRec4ub(16, 8, 0, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfBGR8ub3; fglFormat := GL_BGR; fglInternalFormat := GL_RGB8; fglDataFormat := GL_UNSIGNED_BYTE; +{$ELSE} + fOpenGLFormat := tfRGB8ub3; +{$ENDIF} end; procedure TfdBGRX8ui1.SetValues; @@ -3550,13 +3727,17 @@ begin fFormat := tfBGRX8ui1; fWithAlpha := tfBGRA8ui1; fWithoutAlpha := tfBGRX8ui1; - fOpenGLFormat := tfBGRX8ui1; fRGBInverted := tfRGBX8ui1; fPrecision := glBitmapRec4ub( 8, 8, 8, 0); fShift := glBitmapRec4ub( 8, 16, 24, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfBGRX8ui1; fglFormat := GL_BGRA; //GL_INVALID_OPERATION if not GL_BGRA or GL_RGBA fglInternalFormat := GL_RGB8; fglDataFormat := GL_UNSIGNED_INT_8_8_8_8; +{$ELSE} + fOpenGLFormat := tfRGB8ub3; +{$ENDIF} end; procedure TfdXBGR8ui1.SetValues; @@ -3566,13 +3747,17 @@ begin fFormat := tfXBGR8ui1; fWithAlpha := tfABGR8ui1; fWithoutAlpha := tfXBGR8ui1; - fOpenGLFormat := tfXBGR8ui1; fRGBInverted := tfXRGB8ui1; fPrecision := glBitmapRec4ub( 8, 8, 8, 0); fShift := glBitmapRec4ub( 0, 8, 16, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfXBGR8ui1; fglFormat := GL_RGBA; //GL_INVALID_OPERATION if not GL_BGRA or GL_RGBA fglInternalFormat := GL_RGB8; fglDataFormat := GL_UNSIGNED_INT_8_8_8_8_REV; +{$ELSE} + fOpenGLFormat := tfRGB8ub3; +{$ENDIF} end; procedure TfdBGR10X2ui1.SetValues; @@ -3582,13 +3767,17 @@ begin fFormat := tfBGR10X2ui1; fWithAlpha := tfBGR10A2ui1; fWithoutAlpha := tfBGR10X2ui1; - fOpenGLFormat := tfBGR10X2ui1; fRGBInverted := tfRGB10X2ui1; fPrecision := glBitmapRec4ub(10, 10, 10, 0); fShift := glBitmapRec4ub( 2, 12, 22, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfBGR10X2ui1; fglFormat := GL_BGRA; //GL_INVALID_OPERATION if not GL_BGRA or GL_RGBA fglInternalFormat := GL_RGB10; fglDataFormat := GL_UNSIGNED_INT_10_10_10_2; +{$ELSE} + fOpenGLFormat := tfRGB16us3; +{$ENDIF} end; procedure TfdX2BGR10ui1.SetValues; @@ -3598,13 +3787,17 @@ begin fFormat := tfX2BGR10ui1; fWithAlpha := tfA2BGR10ui1; fWithoutAlpha := tfX2BGR10ui1; - fOpenGLFormat := tfX2BGR10ui1; fRGBInverted := tfX2RGB10ui1; fPrecision := glBitmapRec4ub(10, 10, 10, 0); fShift := glBitmapRec4ub( 0, 10, 20, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfX2BGR10ui1; fglFormat := GL_RGBA; //GL_INVALID_OPERATION if not GL_BGRA or GL_RGBA fglInternalFormat := GL_RGB10; fglDataFormat := GL_UNSIGNED_INT_2_10_10_10_REV; +{$ELSE} + fOpenGLFormat := tfRGB16us3; +{$ENDIF} end; procedure TfdBGR16us3.SetValues; @@ -3614,13 +3807,17 @@ begin fFormat := tfBGR16us3; fWithAlpha := tfBGRA16us4; fWithoutAlpha := tfBGR16us3; - fOpenGLFormat := tfBGR16us3; fRGBInverted := tfRGB16us3; fPrecision := glBitmapRec4ub(16, 16, 16, 0); fShift := glBitmapRec4ub(32, 16, 0, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfBGR16us3; fglFormat := GL_BGR; fglInternalFormat := GL_RGB16; fglDataFormat := GL_UNSIGNED_SHORT; +{$ELSE} + fOpenGLFormat := tfRGB16us3; +{$ENDIF} end; procedure TfdBGRA4us1.SetValues; @@ -3630,13 +3827,17 @@ begin fFormat := tfBGRA4us1; fWithAlpha := tfBGRA4us1; fWithoutAlpha := tfBGRX4us1; - fOpenGLFormat := tfBGRA4us1; fRGBInverted := tfRGBA4us1; fPrecision := glBitmapRec4ub( 4, 4, 4, 4); fShift := glBitmapRec4ub( 4, 8, 12, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfBGRA4us1; fglFormat := GL_BGRA; fglInternalFormat := GL_RGBA4; fglDataFormat := GL_UNSIGNED_SHORT_4_4_4_4; +{$ELSE} + fOpenGLFormat := tfRGBA4us1; +{$ENDIF} end; procedure TfdABGR4us1.SetValues; @@ -3646,13 +3847,17 @@ begin fFormat := tfABGR4us1; fWithAlpha := tfABGR4us1; fWithoutAlpha := tfXBGR4us1; - fOpenGLFormat := tfABGR4us1; fRGBInverted := tfARGB4us1; fPrecision := glBitmapRec4ub( 4, 4, 4, 4); fShift := glBitmapRec4ub( 0, 4, 8, 12); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfABGR4us1; fglFormat := GL_RGBA; fglInternalFormat := GL_RGBA4; fglDataFormat := GL_UNSIGNED_SHORT_4_4_4_4_REV; +{$ELSE} + fOpenGLFormat := tfRGBA4us1; +{$ENDIF} end; procedure TfdBGR5A1us1.SetValues; @@ -3662,13 +3867,17 @@ begin fFormat := tfBGR5A1us1; fWithAlpha := tfBGR5A1us1; fWithoutAlpha := tfBGR5X1us1; - fOpenGLFormat := tfBGR5A1us1; fRGBInverted := tfRGB5A1us1; fPrecision := glBitmapRec4ub( 5, 5, 5, 1); fShift := glBitmapRec4ub( 1, 6, 11, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfBGR5A1us1; fglFormat := GL_BGRA; fglInternalFormat := GL_RGB5_A1; fglDataFormat := GL_UNSIGNED_SHORT_5_5_5_1; +{$ELSE} + fOpenGLFormat := tfRGB5A1us1; +{$ENDIF} end; procedure TfdA1BGR5us1.SetValues; @@ -3678,13 +3887,17 @@ begin fFormat := tfA1BGR5us1; fWithAlpha := tfA1BGR5us1; fWithoutAlpha := tfX1BGR5us1; - fOpenGLFormat := tfA1BGR5us1; fRGBInverted := tfA1RGB5us1; fPrecision := glBitmapRec4ub( 5, 5, 5, 1); fShift := glBitmapRec4ub( 0, 5, 10, 15); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfA1BGR5us1; fglFormat := GL_RGBA; fglInternalFormat := GL_RGB5_A1; fglDataFormat := GL_UNSIGNED_SHORT_1_5_5_5_REV; +{$ELSE} + fOpenGLFormat := tfRGB5A1us1; +{$ENDIF} end; procedure TfdBGRA8ui1.SetValues; @@ -3694,13 +3907,17 @@ begin fFormat := tfBGRA8ui1; fWithAlpha := tfBGRA8ui1; fWithoutAlpha := tfBGRX8ui1; - fOpenGLFormat := tfBGRA8ui1; fRGBInverted := tfRGBA8ui1; fPrecision := glBitmapRec4ub( 8, 8, 8, 8); fShift := glBitmapRec4ub( 8, 16, 24, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfBGRA8ui1; fglFormat := GL_BGRA; fglInternalFormat := GL_RGBA8; fglDataFormat := GL_UNSIGNED_INT_8_8_8_8; +{$ELSE} + fOpenGLFormat := tfRGBA8ub4; +{$ENDIF} end; procedure TfdABGR8ui1.SetValues; @@ -3710,13 +3927,17 @@ begin fFormat := tfABGR8ui1; fWithAlpha := tfABGR8ui1; fWithoutAlpha := tfXBGR8ui1; - fOpenGLFormat := tfABGR8ui1; fRGBInverted := tfARGB8ui1; fPrecision := glBitmapRec4ub( 8, 8, 8, 8); fShift := glBitmapRec4ub( 0, 8, 16, 24); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfABGR8ui1; fglFormat := GL_RGBA; fglInternalFormat := GL_RGBA8; fglDataFormat := GL_UNSIGNED_INT_8_8_8_8_REV; +{$ELSE} + fOpenGLFormat := tfRGBA8ub4 +{$ENDIF} end; procedure TfdBGRA8ub4.SetValues; @@ -3726,13 +3947,17 @@ begin fFormat := tfBGRA8ub4; fWithAlpha := tfBGRA8ub4; fWithoutAlpha := tfBGR8ub3; - fOpenGLFormat := tfBGRA8ub4; fRGBInverted := tfRGBA8ub4; fPrecision := glBitmapRec4ub( 8, 8, 8, 8); fShift := glBitmapRec4ub(16, 8, 0, 24); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfBGRA8ub4; fglFormat := GL_BGRA; fglInternalFormat := GL_RGBA8; fglDataFormat := GL_UNSIGNED_BYTE; +{$ELSE} + fOpenGLFormat := tfRGBA8ub4; +{$ENDIF} end; procedure TfdBGR10A2ui1.SetValues; @@ -3742,13 +3967,17 @@ begin fFormat := tfBGR10A2ui1; fWithAlpha := tfBGR10A2ui1; fWithoutAlpha := tfBGR10X2ui1; - fOpenGLFormat := tfBGR10A2ui1; fRGBInverted := tfRGB10A2ui1; fPrecision := glBitmapRec4ub(10, 10, 10, 2); fShift := glBitmapRec4ub( 2, 12, 22, 0); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfBGR10A2ui1; fglFormat := GL_BGRA; fglInternalFormat := GL_RGB10_A2; fglDataFormat := GL_UNSIGNED_INT_10_10_10_2; +{$ELSE} + fOpenGLFormat := tfA2RGB10ui1; +{$ENDIF} end; procedure TfdA2BGR10ui1.SetValues; @@ -3758,13 +3987,17 @@ begin fFormat := tfA2BGR10ui1; fWithAlpha := tfA2BGR10ui1; fWithoutAlpha := tfX2BGR10ui1; - fOpenGLFormat := tfA2BGR10ui1; fRGBInverted := tfA2RGB10ui1; fPrecision := glBitmapRec4ub(10, 10, 10, 2); fShift := glBitmapRec4ub( 0, 10, 20, 30); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfA2BGR10ui1; fglFormat := GL_RGBA; fglInternalFormat := GL_RGB10_A2; fglDataFormat := GL_UNSIGNED_INT_2_10_10_10_REV; +{$ELSE} + fOpenGLFormat := tfA2RGB10ui1; +{$ENDIF} end; procedure TfdBGRA16us4.SetValues; @@ -3774,13 +4007,17 @@ begin fFormat := tfBGRA16us4; fWithAlpha := tfBGRA16us4; fWithoutAlpha := tfBGR16us3; - fOpenGLFormat := tfBGRA16us4; fRGBInverted := tfRGBA16us4; fPrecision := glBitmapRec4ub(16, 16, 16, 16); fShift := glBitmapRec4ub(32, 16, 0, 48); +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfBGRA16us4; fglFormat := GL_BGRA; fglInternalFormat := GL_RGBA16; fglDataFormat := GL_UNSIGNED_SHORT; +{$ELSE} + fOpenGLFormat := tfRGBA16us4; +{$ENDIF} end; procedure TfdDepth16us1.SetValues; @@ -3789,12 +4026,14 @@ begin fBitsPerPixel := 16; fFormat := tfDepth16us1; fWithoutAlpha := tfDepth16us1; - fOpenGLFormat := tfDepth16us1; fPrecision := glBitmapRec4ub(16, 16, 16, 16); fShift := glBitmapRec4ub( 0, 0, 0, 0); +{$IF NOT DEFINED (OPENGL_ES) OR DEFINED(OPENGL_ES_2_0)} + fOpenGLFormat := tfDepth16us1; fglFormat := GL_DEPTH_COMPONENT; fglInternalFormat := GL_DEPTH_COMPONENT16; fglDataFormat := GL_UNSIGNED_SHORT; +{$IFEND} end; procedure TfdDepth24ui1.SetValues; @@ -3806,9 +4045,12 @@ begin fOpenGLFormat := tfDepth24ui1; fPrecision := glBitmapRec4ub(32, 32, 32, 32); fShift := glBitmapRec4ub( 0, 0, 0, 0); +{$IF NOT DEFINED (OPENGL_ES) OR DEFINED(OPENGL_ES_3_0)} + fOpenGLFormat := tfDepth24ui1; fglFormat := GL_DEPTH_COMPONENT; fglInternalFormat := GL_DEPTH_COMPONENT24; fglDataFormat := GL_UNSIGNED_INT; +{$IFEND} end; procedure TfdDepth32ui1.SetValues; @@ -3817,12 +4059,18 @@ begin fBitsPerPixel := 32; fFormat := tfDepth32ui1; fWithoutAlpha := tfDepth32ui1; - fOpenGLFormat := tfDepth32ui1; fPrecision := glBitmapRec4ub(32, 32, 32, 32); fShift := glBitmapRec4ub( 0, 0, 0, 0); +{$IF NOT DEFINED(OPENGL_ES)} + fOpenGLFormat := tfDepth32ui1; fglFormat := GL_DEPTH_COMPONENT; fglInternalFormat := GL_DEPTH_COMPONENT32; fglDataFormat := GL_UNSIGNED_INT; +{$ELSEIF DEFINED(OPENGL_ES_3_0)} + fOpenGLFormat := tfDepth24ui1; +{$ELSEIF DEFINED(OPENGL_ES_2_0)} + fOpenGLFormat := tfDepth16us1; +{$IFEND} end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -3843,13 +4091,17 @@ begin inherited SetValues; fFormat := tfS3tcDtx1RGBA; fWithAlpha := tfS3tcDtx1RGBA; - fOpenGLFormat := tfS3tcDtx1RGBA; fUncompressed := tfRGB5A1us1; fBitsPerPixel := 4; fIsCompressed := true; +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfS3tcDtx1RGBA; fglFormat := GL_COMPRESSED_RGBA; fglInternalFormat := GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; fglDataFormat := GL_UNSIGNED_BYTE; +{$ELSE} + fOpenGLFormat := fUncompressed; +{$ENDIF} end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -3870,13 +4122,17 @@ begin inherited SetValues; fFormat := tfS3tcDtx3RGBA; fWithAlpha := tfS3tcDtx3RGBA; - fOpenGLFormat := tfS3tcDtx3RGBA; fUncompressed := tfRGBA8ub4; fBitsPerPixel := 8; fIsCompressed := true; +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfS3tcDtx3RGBA; fglFormat := GL_COMPRESSED_RGBA; fglInternalFormat := GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; fglDataFormat := GL_UNSIGNED_BYTE; +{$ELSE} + fOpenGLFormat := fUncompressed; +{$ENDIF} end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -3897,13 +4153,17 @@ begin inherited SetValues; fFormat := tfS3tcDtx3RGBA; fWithAlpha := tfS3tcDtx3RGBA; - fOpenGLFormat := tfS3tcDtx3RGBA; fUncompressed := tfRGBA8ub4; fBitsPerPixel := 8; fIsCompressed := true; +{$IFNDEF OPENGL_ES} + fOpenGLFormat := tfS3tcDtx3RGBA; fglFormat := GL_COMPRESSED_RGBA; fglInternalFormat := GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; fglDataFormat := GL_UNSIGNED_BYTE; +{$ELSE} + fOpenGLFormat := fUncompressed; +{$ENDIF} end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -4535,11 +4795,14 @@ end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TglBitmap.SetAnisotropic(const aValue: Integer); +{$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_EXT)} var MaxAnisotropic: Integer; +{$IFEND} begin fAnisotropic := aValue; if (ID > 0) then begin +{$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_EXT)} if GL_EXT_texture_filter_anisotropic then begin if fAnisotropic > 0 then begin Bind(false); @@ -4551,6 +4814,9 @@ begin end else begin fAnisotropic := 0; end; +{$ELSE} + fAnisotropic := 0; +{$IFEND} end; end; @@ -4564,17 +4830,20 @@ begin end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TglBitmap.SetupParameters(out aBuildWithGlu: Boolean); +procedure TglBitmap.SetupParameters({$IFNDEF OPENGL_ES}out aBuildWithGlu: Boolean{$ENDIF}); begin // Set Up Parameters SetWrap(fWrapS, fWrapT, fWrapR); SetFilter(fFilterMin, fFilterMag); SetAnisotropic(fAnisotropic); - SetBorderColor(fBorderColor[0], fBorderColor[1], fBorderColor[2], fBorderColor[3]); +{$IFNDEF OPENGL_ES} + SetBorderColor(fBorderColor[0], fBorderColor[1], fBorderColor[2], fBorderColor[3]); if (GL_ARB_texture_swizzle or GL_EXT_texture_swizzle or GL_VERSION_3_3) then SetSwizzle(fSwizzle[0], fSwizzle[1], fSwizzle[2], fSwizzle[3]); +{$ENDIF} +{$IFNDEF OPENGL_ES} // Mip Maps Generation Mode aBuildWithGlu := false; if (MipMap = mmMipmap) then begin @@ -4584,6 +4853,10 @@ begin aBuildWithGlu := true; end else if (MipMap = mmMipmapGlu) then aBuildWithGlu := true; +{$ELSE} + if (MipMap = mmMipmap) then + glTexParameteri(Target, GL_GENERATE_MIPMAP, GL_TRUE); +{$ENDIF} end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -4641,7 +4914,9 @@ begin fID := 0; fTarget := 0; +{$IFNDEF OPENGL_ES} fIsResident := false; +{$ENDIF} fMipMap := glBitmapDefaultMipmap; fFreeDataAfterGenTexture := glBitmapGetDefaultFreeDataAfterGenTexture; @@ -4649,7 +4924,9 @@ begin glBitmapGetDefaultFilter (fFilterMin, fFilterMag); glBitmapGetDefaultTextureWrap(fWrapS, fWrapT, fWrapR); +{$IFNDEF OPENGL_ES} glBitmapGetDefaultSwizzle (fSwizzle[0], fSwizzle[1], fSwizzle[2], fSwizzle[3]); +{$ENDIF} end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -5788,6 +6065,7 @@ begin (Byte(aUseRGB) and 1) )); end; +{$IFNDEF OPENGL_ES} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TglBitmap.SetBorderColor(const aRed, aGreen, aBlue, aAlpha: Single); begin @@ -5800,6 +6078,7 @@ begin glTexParameterfv(Target, GL_TEXTURE_BORDER_COLOR, @fBorderColor[0]); end; end; +{$ENDIF} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TglBitmap.FreeData; @@ -5881,7 +6160,7 @@ begin Bind(false); glTexParameteri(Target, GL_TEXTURE_MAG_FILTER, fFilterMag); - if (MipMap = mmNone) or (Target = GL_TEXTURE_RECTANGLE) then begin + if (MipMap = mmNone) {$IFNDEF OPENGL_ES}or (Target = GL_TEXTURE_RECTANGLE){$ENDIF} then begin case fFilterMin of GL_NEAREST, GL_LINEAR: glTexParameteri(Target, GL_TEXTURE_MIN_FILTER, fFilterMin); @@ -5901,32 +6180,44 @@ procedure TglBitmap.SetWrap(const S: GLenum; const T: GLenum; const R: GLenum); procedure CheckAndSetWrap(const aValue: Cardinal; var aTarget: Cardinal); begin case aValue of +{$IFNDEF OPENGL_ES} GL_CLAMP: aTarget := GL_CLAMP; +{$ENDIF} GL_REPEAT: aTarget := GL_REPEAT; GL_CLAMP_TO_EDGE: begin - if GL_VERSION_1_2 or GL_EXT_texture_edge_clamp then - aTarget := GL_CLAMP_TO_EDGE +{$IFNDEF OPENGL_ES} + if not GL_VERSION_1_2 and not GL_EXT_texture_edge_clamp then + aTarget := GL_CLAMP else - aTarget := GL_CLAMP; +{$ENDIF} + aTarget := GL_CLAMP_TO_EDGE; end; +{$IFNDEF OPENGL_ES} GL_CLAMP_TO_BORDER: begin if GL_VERSION_1_3 or GL_ARB_texture_border_clamp then aTarget := GL_CLAMP_TO_BORDER else aTarget := GL_CLAMP; end; +{$ENDIF} +{$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_2_0)} GL_MIRRORED_REPEAT: begin + {$IFNDEF OPENGL_ES} if GL_VERSION_1_4 or GL_ARB_texture_mirrored_repeat or GL_IBM_texture_mirrored_repeat then + {$ELSE} + if GL_VERSION_2_0 then + {$ENDIF} aTarget := GL_MIRRORED_REPEAT else raise EglBitmap.Create('SetWrap - Unsupported Texturewrap GL_MIRRORED_REPEAT (S).'); end; +{$IFEND} else raise EglBitmap.Create('SetWrap - Unknow Texturewrap'); end; @@ -5941,10 +6232,14 @@ begin Bind(false); glTexParameteri(Target, GL_TEXTURE_WRAP_S, fWrapS); glTexParameteri(Target, GL_TEXTURE_WRAP_T, fWrapT); +{$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_3_0)} + {$IFDEF OPENGL_ES} if GL_VERSION_3_0 then{$ENDIF} glTexParameteri(Target, GL_TEXTURE_WRAP_R, fWrapR); +{$IFEND} end; end; +{$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_3_0)} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TglBitmap.SetSwizzle(const r, g, b, a: GLenum); @@ -5958,8 +6253,13 @@ procedure TglBitmap.SetSwizzle(const r, g, b, a: GLenum); end; begin +{$IFNDEF OPENGL_ES} if not (GL_ARB_texture_swizzle or GL_EXT_texture_swizzle or GL_VERSION_3_3) then raise EglBitmapNotSupported.Create('texture swizzle is not supported'); +{$ELSE} + if not GL_VERSION_3_0 then + raise EglBitmapNotSupported.Create('texture swizzle is not supported'); +{$ENDIF} CheckAndSetValue(r, 0); CheckAndSetValue(g, 1); CheckAndSetValue(b, 2); @@ -5967,9 +6267,17 @@ begin if (ID > 0) then begin Bind(false); +{$IFNDEF OPENGL_ES} glTexParameteriv(Target, GL_TEXTURE_SWIZZLE_RGBA, PGLint(@fSwizzle[0])); +{$ELSE} + glTexParameteriv(Target, GL_TEXTURE_SWIZZLE_R, PGLint(@fSwizzle[0])); + glTexParameteriv(Target, GL_TEXTURE_SWIZZLE_G, PGLint(@fSwizzle[1])); + glTexParameteriv(Target, GL_TEXTURE_SWIZZLE_B, PGLint(@fSwizzle[2])); + glTexParameteriv(Target, GL_TEXTURE_SWIZZLE_A, PGLint(@fSwizzle[3])); +{$ENDIF} end; end; +{$IFEND} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TglBitmap.Bind(const aEnableTextureUnit: Boolean); @@ -8117,6 +8425,7 @@ begin aStream.Write(Data^, FormatDesc.GetSize(Dimension)); end; +{$IFNDEF OPENGL_ES} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TglBitmap1D///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -8177,6 +8486,9 @@ var begin // Upload data FormatDesc := TFormatDescriptor.Get(Format); + if (FormatDesc.glInternalFormat = 0) or (FormatDesc.glDataFormat = 0) then + raise EglBitmap.Create('format is not supported by video adapter, please convert before uploading data'); + if FormatDesc.IsCompressed then begin if not Assigned(glCompressedTexImage1D) then raise EglBitmap.Create('compressed formats not supported by video adapter'); @@ -8224,6 +8536,7 @@ begin inherited; Target := GL_TEXTURE_1D; end; +{$ENDIF} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TglBitmap2D///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -8262,20 +8575,25 @@ begin end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TglBitmap2D.UploadData(const aTarget: GLenum; const aBuildWithGlu: Boolean); +procedure TglBitmap2D.UploadData(const aTarget: GLenum{$IFNDEF OPENGL_ES}; const aBuildWithGlu: Boolean{$ENDIF}); var FormatDesc: TFormatDescriptor; begin + FormatDesc := TFormatDescriptor.Get(Format); + if (FormatDesc.glInternalFormat = 0) or (FormatDesc.glDataFormat = 0) then + raise EglBitmap.Create('format is not supported by video adapter, please convert before uploading data'); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - FormatDesc := TFormatDescriptor.Get(Format); if FormatDesc.IsCompressed then begin if not Assigned(glCompressedTexImage2D) then raise EglBitmap.Create('compressed formats not supported by video adapter'); glCompressedTexImage2D(aTarget, 0, FormatDesc.glInternalFormat, Width, Height, 0, FormatDesc.GetSize(fDimension), Data) +{$IFNDEF OPENGL_ES} end else if aBuildWithGlu then begin gluBuild2DMipmaps(aTarget, FormatDesc.ChannelCount, Width, Height, FormatDesc.glFormat, FormatDesc.glDataFormat, Data) +{$ENDIF} end else begin glTexImage2D(aTarget, 0, FormatDesc.glInternalFormat, Width, Height, 0, FormatDesc.glFormat, FormatDesc.glDataFormat, Data); @@ -8320,6 +8638,7 @@ begin end; end; +{$IFNDEF OPENGL_ES} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TglBitmap2D.GetDataFromTexture; var @@ -8356,11 +8675,15 @@ begin raise; end; end; +{$ENDIF} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TglBitmap2D.GenTexture(const aTestTextureSize: Boolean); var - BuildWithGlu, PotTex, TexRec: Boolean; + {$IFNDEF OPENGL_ES} + BuildWithGlu, TexRec: Boolean; + {$ENDIF} + PotTex: Boolean; TexSize: Integer; begin if Assigned(Data) then begin @@ -8372,15 +8695,25 @@ begin raise EglBitmapSizeToLarge.Create('TglBitmap2D.GenTexture - The size for the texture is to large. It''s may be not conform with the Hardware.'); PotTex := IsPowerOfTwo(Height) and IsPowerOfTwo(Width); +{$IF NOT DEFINED(OPENGL_ES)} TexRec := (GL_ARB_texture_rectangle or GL_EXT_texture_rectangle or GL_NV_texture_rectangle) and (Target = GL_TEXTURE_RECTANGLE); if not (PotTex or GL_ARB_texture_non_power_of_two or GL_VERSION_2_0 or TexRec) then raise EglBitmapNonPowerOfTwo.Create('TglBitmap2D.GenTexture - Rendercontex dosn''t support non power of two texture.'); +{$ELSEIF DEFINED(OPENGL_ES_EXT)} + if not PotTex and not GL_OES_texture_npot then + raise EglBitmapNonPowerOfTwo.Create('TglBitmap2D.GenTexture - Rendercontex dosn''t support non power of two texture.'); +{$ELSE} + if not PotTex then + raise EglBitmapNonPowerOfTwo.Create('TglBitmap2D.GenTexture - Rendercontex dosn''t support non power of two texture.'); +{$IFEND} end; CreateId; - SetupParameters(BuildWithGlu); - UploadData(Target, BuildWithGlu); + SetupParameters({$IFNDEF OPENGL_ES}BuildWithGlu{$ENDIF}); + UploadData(Target{$IFNDEF OPENGL_ES}, BuildWithGlu{$ENDIF}); +{$IFNDEF OPENGL_ES} glAreTexturesResident(1, @fID, @fIsResident); +{$ENDIF} end; end; @@ -8668,6 +9001,7 @@ begin end; end; +{$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_2_0)} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TglBitmapCubeMap//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -8681,40 +9015,58 @@ procedure TglBitmapCubeMap.AfterConstruction; begin inherited; +{$IFNDEF OPENGL_ES} if not (GL_VERSION_1_3 or GL_ARB_texture_cube_map or GL_EXT_texture_cube_map) then raise EglBitmap.Create('TglBitmapCubeMap.AfterConstruction - CubeMaps are unsupported.'); +{$ELSE} + if not (GL_VERSION_2_0) then + raise EglBitmap.Create('TglBitmapCubeMap.AfterConstruction - CubeMaps are unsupported.'); +{$ENDIF} SetWrap; Target := GL_TEXTURE_CUBE_MAP; +{$IFNDEF OPENGL_ES} fGenMode := GL_REFLECTION_MAP; +{$ENDIF} end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure TglBitmapCubeMap.GenerateCubeMap(const aCubeTarget: Cardinal; const aTestTextureSize: Boolean); var + {$IFNDEF OPENGL_ES} BuildWithGlu: Boolean; + {$ENDIF} TexSize: Integer; begin if (aTestTextureSize) then begin glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, @TexSize); if (Height > TexSize) or (Width > TexSize) then - raise EglBitmapSizeToLarge.Create('TglBitmapCubeMap.GenTexture - The size for the Cubemap is to large. It''s may be not conform with the Hardware.'); + raise EglBitmapSizeToLarge.Create('TglBitmapCubeMap.GenerateCubeMap - The size for the Cubemap is to large. It''s may be not conform with the Hardware.'); +{$IF NOT DEFINED(OPENGL_ES)} if not ((IsPowerOfTwo(Height) and IsPowerOfTwo(Width)) or GL_VERSION_2_0 or GL_ARB_texture_non_power_of_two) then - raise EglBitmapNonPowerOfTwo.Create('TglBitmapCubeMap.GenTexture - Cubemaps dosn''t support non power of two texture.'); + raise EglBitmapNonPowerOfTwo.Create('TglBitmapCubeMap.GenerateCubeMap - Cubemaps dosn''t support non power of two texture.'); +{$ELSEIF DEFINED(OPENGL_ES_EXT)} + if not (IsPowerOfTwo(Height) and IsPowerOfTwo(Width)) and not GL_OES_texture_npot then + raise EglBitmapNonPowerOfTwo.Create('TglBitmapCubeMap.GenerateCubeMap - Cubemaps dosn''t support non power of two texture.'); +{$ELSE} + if not (IsPowerOfTwo(Height) and IsPowerOfTwo(Width)) then + raise EglBitmapNonPowerOfTwo.Create('TglBitmapCubeMap.GenerateCubeMap - Cubemaps dosn''t support non power of two texture.'); +{$IFEND} end; if (ID = 0) then CreateID; - SetupParameters(BuildWithGlu); - UploadData(aCubeTarget, BuildWithGlu); + SetupParameters({$IFNDEF OPENGL_ES}BuildWithGlu{$ENDIF}); + UploadData(aCubeTarget{$IFNDEF OPENGL_ES}, BuildWithGlu{$ENDIF}); end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TglBitmapCubeMap.Bind(const aEnableTexCoordsGen: Boolean; const aEnableTextureUnit: Boolean); +procedure TglBitmapCubeMap.Bind({$IFNDEF OPENGL_ES}const aEnableTexCoordsGen: Boolean;{$ENDIF} const aEnableTextureUnit: Boolean); begin inherited Bind (aEnableTextureUnit); +{$IFNDEF OPENGL_ES} if aEnableTexCoordsGen then begin glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, fGenMode); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, fGenMode); @@ -8723,19 +9075,24 @@ begin glEnable(GL_TEXTURE_GEN_T); glEnable(GL_TEXTURE_GEN_R); end; +{$ENDIF} end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -procedure TglBitmapCubeMap.Unbind(const aDisableTexCoordsGen: Boolean; const aDisableTextureUnit: Boolean); +procedure TglBitmapCubeMap.Unbind({$IFNDEF OPENGL_ES}const aDisableTexCoordsGen: Boolean;{$ENDIF} const aDisableTextureUnit: Boolean); begin inherited Unbind(aDisableTextureUnit); +{$IFNDEF OPENGL_ES} if aDisableTexCoordsGen then begin glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glDisable(GL_TEXTURE_GEN_R); end; +{$ENDIF} end; +{$IFEND} +{$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_2_0)} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TglBitmapNormalMap////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -8749,7 +9106,7 @@ type Func: TglBitmapNormalMapGetVectorFunc; end; - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// procedure glBitmapNormalMapPosX(out aVec: TVec; const aPosition: TglBitmapPixelPosition; const aHalfSize: Integer); begin aVec[0] := aHalfSize; @@ -8832,7 +9189,9 @@ end; procedure TglBitmapNormalMap.AfterConstruction; begin inherited; +{$IFNDEF OPENGL_ES} fGenMode := GL_NORMAL_MAP; +{$ENDIF} end; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -8878,14 +9237,16 @@ begin LoadFromFunc(SizeRec, glBitmapNormalMapFunc, tfBGR8ub3, @Rec); GenerateCubeMap(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, aTestTextureSize); end; - +{$IFEND} initialization glBitmapSetDefaultFormat (tfEmpty); glBitmapSetDefaultMipmap (mmMipmap); glBitmapSetDefaultFilter (GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR); glBitmapSetDefaultWrap (GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE); +{$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_3_0)} glBitmapSetDefaultSwizzle(GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA); +{$IFEND} glBitmapSetDefaultFreeDataAfterGenTexture(true); glBitmapSetDefaultDeleteTextureOnFree (true); @@ -8909,6 +9270,6 @@ finalization glbFreeLibrary(GLU_LibHandle); FreeAndNil(InitOpenGLCS); {$ENDIF} -{$ENDIF} +{$ENDIF} end. -- 2.1.4