Compare commits

...

4 Комити

1 измењених фајлова са 29 додато и 14 уклоњено
  1. +29
    -14
      glBitmap.pas

+ 29
- 14
glBitmap.pas Прегледај датотеку

@@ -29,6 +29,7 @@ unit glBitmap;
// Delphi Versions
{$IFDEF fpc}
{$MODE Delphi}
{$MINENUMSIZE DEFAULT}

{$IFDEF CPUI386}
{$DEFINE CPU386}
@@ -251,9 +252,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 +275,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)
@@ -429,7 +430,7 @@ type

property RGBInverted: TglBitmapFormat read fRGBInverted; //< suitable format with inverted RGB channels
property WithAlpha: TglBitmapFormat read fWithAlpha; //< suitable format with alpha channel
property WithoutAlpha: TglBitmapFormat read fWithAlpha; //< suitable format without alpha channel
property WithoutAlpha: TglBitmapFormat read fWithoutAlpha; //< suitable format without alpha channel
property OpenGLFormat: TglBitmapFormat read fOpenGLFormat; //< suitable format that is supported by OpenGL
property Uncompressed: TglBitmapFormat read fUncompressed; //< suitable format with uncompressed data

@@ -455,7 +456,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;

////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1730,9 +1736,9 @@ const
TfdARGB4us1,
TfdRGB5A1us1,
TfdA1RGB5us1,
TfdRGBA8ub4,
TfdRGBA8ui1,
TfdARGB8ui1,
TfdRGBA8ub4,
TfdRGB10A2ui1,
TfdA2RGB10ui1,
TfdRGBA16us4,
@@ -1753,9 +1759,9 @@ const
TfdABGR4us1,
TfdBGR5A1us1,
TfdA1BGR5us1,
TfdBGRA8ub4,
TfdBGRA8ui1,
TfdABGR8ui1,
TfdBGRA8ub4,
TfdBGR10A2ui1,
TfdA2BGR10ui1,
TfdBGRA16us4,
@@ -3058,7 +3064,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;

@@ -3920,6 +3926,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///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -7079,7 +7093,7 @@ begin
pf24bit:
IntFormat := tfBGR8ub3;
pf32bit:
IntFormat := tfBGRA8ub4;
IntFormat := tfXRGB8ui1;
else
raise EglBitmap.Create('AssignFromBitmap - Invalid Pixelformat.');
end;
@@ -8427,6 +8441,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');
@@ -8510,13 +8525,13 @@ begin
raise EglBitmapNonPowerOfTwo.Create('TglBitmap1D.GenTexture - Rendercontex dosn''t support non power of two texture.');
end;

inherited UploadData(aDataObj, aCheckSize);

if (fID = 0) then
CreateID;
SetupParameters(BuildWithGlu);
UploadDataIntern(aDataObj, BuildWithGlu);
glAreTexturesResident(1, @fID, @fIsResident);

inherited UploadData(aDataObj, aCheckSize);
end;
{$ENDIF}

@@ -8586,6 +8601,8 @@ begin
{$IFEND}
end;

inherited UploadData(aDataObj, aCheckSize);

if (fID = 0) then
CreateID;
SetupParameters({$IFNDEF OPENGL_ES}BuildWithGlu{$ENDIF});
@@ -8593,8 +8610,6 @@ begin
{$IFNDEF OPENGL_ES}
glAreTexturesResident(1, @fID, @fIsResident);
{$ENDIF}

inherited UploadData(aDataObj, aCheckSize);
end;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -8679,12 +8694,12 @@ begin
{$IFEND}
end;

inherited UploadData(aDataObj, aCheckSize);

if (fID = 0) then
CreateID;
SetupParameters({$IFNDEF OPENGL_ES}BuildWithGlu{$ENDIF});
UploadDataIntern(aDataObj, aCubeTarget{$IFNDEF OPENGL_ES}, BuildWithGlu{$ENDIF});

inherited UploadData(aDataObj, aCheckSize);
end;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Loading…
Откажи
Сачувај