From 6056f470e1f9e25aa03f7fe1d3692abc37d3ffd4 Mon Sep 17 00:00:00 2001 From: Bergmann89 Date: Tue, 17 Mar 2015 20:21:34 +0100 Subject: [PATCH 1/2] * added class function to get format descriptor from given format * fixed alignment bug in texture data download --- glBitmap.pas | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/glBitmap.pas b/glBitmap.pas index 165ee38..638bf0f 100644 --- a/glBitmap.pas +++ b/glBitmap.pas @@ -455,7 +455,12 @@ type { get the format descriptor by a given OpenGL internal format @param aInternalFormat OpenGL internal format to get format descriptor for @returns suitable format descriptor or tfEmpty-Descriptor } - class function GetByFormat(const aInternalFormat: GLenum): TglBitmapFormatDescriptor; + class function GetByFormat(const aInternalFormat: GLenum): TglBitmapFormatDescriptor; overload; + + { get the format descriptor by the given format + @param aFormat format to get descriptor for + @return suitable format descriptor or tfEmpty-Descriptor } + class function GetByFormat(const aFormat: TglBitmapFormat): TglBitmapFormatDescriptor; overload; end; //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -3920,6 +3925,14 @@ begin result := TFormatDescriptor.Get(tfEmpty); end; +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +class function TglBitmapFormatDescriptor.GetByFormat(const aFormat: TglBitmapFormat): TglBitmapFormatDescriptor; +begin + result := TFormatDescriptor.Get(aFormat); + if not Assigned(result) then + result := TFormatDescriptor.Get(tfEmpty); +end; + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TFormatDescriptor/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -8427,6 +8440,7 @@ begin FormatDesc := TFormatDescriptor.Get(IntFormat); GetMem(Temp, FormatDesc.GetSize(TempWidth, TempHeight)); try + glPixelStorei(GL_PACK_ALIGNMENT, 1); if FormatDesc.IsCompressed then begin if not Assigned(glGetCompressedTexImage) then raise EglBitmap.Create('compressed formats not supported by video adapter'); From a5e668965c3d2eeea57a5b6d51a162ae25f37180 Mon Sep 17 00:00:00 2001 From: Bergmann89 Date: Sun, 29 Mar 2015 17:38:51 +0200 Subject: [PATCH 2/2] * fixed some small bugs in format settings --- glBitmap.pas | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/glBitmap.pas b/glBitmap.pas index 638bf0f..4934c14 100644 --- a/glBitmap.pas +++ b/glBitmap.pas @@ -251,9 +251,9 @@ type tfARGB4us1, //< 1 x unsigned short (4bit alpha, 4bit red, 4bit green, 4bit blue) tfRGB5A1us1, //< 1 x unsigned short (5bit red, 5bit green, 5bit blue, 1bit alpha) tfA1RGB5us1, //< 1 x unsigned short (1bit alpha, 5bit red, 5bit green, 5bit blue) + tfRGBA8ub4, //< 1 x unsigned byte (red), 1 x unsigned byte (green), 1 x unsigned byte (blue), 1 x unsigned byte (alpha) tfRGBA8ui1, //< 1 x unsigned int (8bit red, 8bit green, 8bit blue, 8 bit alpha) tfARGB8ui1, //< 1 x unsigned int (8 bit alpha, 8bit red, 8bit green, 8bit blue) - tfRGBA8ub4, //< 1 x unsigned byte (red), 1 x unsigned byte (green), 1 x unsigned byte (blue), 1 x unsigned byte (alpha) tfRGB10A2ui1, //< 1 x unsigned int (10bit red, 10bit green, 10bit blue, 2bit alpha) tfA2RGB10ui1, //< 1 x unsigned int (2bit alpha, 10bit red, 10bit green, 10bit blue) tfRGBA16us4, //< 1 x unsigned short (red), 1 x unsigned short (green), 1 x unsigned short (blue), 1 x unsigned short (alpha) @@ -274,9 +274,9 @@ type tfABGR4us1, //< 1 x unsigned short (4bit alpha, 4bit blue, 4bit green, 4bit red) tfBGR5A1us1, //< 1 x unsigned short (5bit blue, 5bit green, 5bit red, 1bit alpha) tfA1BGR5us1, //< 1 x unsigned short (1bit alpha, 5bit blue, 5bit green, 5bit red) + tfBGRA8ub4, //< 1 x unsigned byte (blue), 1 x unsigned byte (green), 1 x unsigned byte (red), 1 x unsigned byte (alpha) tfBGRA8ui1, //< 1 x unsigned int (8bit blue, 8bit green, 8bit red, 8bit alpha) tfABGR8ui1, //< 1 x unsigned int (8bit alpha, 8bit blue, 8bit green, 8bit red) - tfBGRA8ub4, //< 1 x unsigned byte (blue), 1 x unsigned byte (green), 1 x unsigned byte (red), 1 x unsigned byte (alpha) tfBGR10A2ui1, //< 1 x unsigned int (10bit blue, 10bit green, 10bit red, 2bit alpha) tfA2BGR10ui1, //< 1 x unsigned int (2bit alpha, 10bit blue, 10bit green, 10bit red) tfBGRA16us4, //< 1 x unsigned short (blue), 1 x unsigned short (green), 1 x unsigned short (red), 1 x unsigned short (alpha) @@ -1735,9 +1735,9 @@ const TfdARGB4us1, TfdRGB5A1us1, TfdA1RGB5us1, + TfdRGBA8ub4, TfdRGBA8ui1, TfdARGB8ui1, - TfdRGBA8ub4, TfdRGB10A2ui1, TfdA2RGB10ui1, TfdRGBA16us4, @@ -1758,9 +1758,9 @@ const TfdABGR4us1, TfdBGR5A1us1, TfdA1BGR5us1, + TfdBGRA8ub4, TfdBGRA8ui1, TfdABGR8ui1, - TfdBGRA8ub4, TfdBGR10A2ui1, TfdA2BGR10ui1, TfdBGRA16us4, @@ -3063,7 +3063,7 @@ begin fPrecision := glBitmapRec4ub( 4, 4, 4, 4); fShift := glBitmapRec4ub(12, 8, 4, 0); fglFormat := GL_RGBA; - fglInternalFormat := {$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_3_0)}GL_RGBA8{$ELSE}GL_RGBA{$IFEND}; + fglInternalFormat := {$IF NOT DEFINED(OPENGL_ES) OR DEFINED(OPENGL_ES_3_0)}GL_RGBA4{$ELSE}GL_RGBA{$IFEND}; fglDataFormat := GL_UNSIGNED_SHORT_4_4_4_4; end;