Procházet zdrojové kódy

* added function to get FormatDescriptor from internal OpenGL Format

* fixed some hints / warnings
master
Bergmann89 před 11 roky
rodič
revize
401bba6efa
1 změnil soubory, kde provedl 27 přidání a 14 odebrání
  1. +27
    -14
      glBitmap.pas

+ 27
- 14
glBitmap.pas Zobrazit soubor

@@ -907,6 +907,8 @@ type
property glFormat: GLenum read GetglFormat; property glFormat: GLenum read GetglFormat;
property glInternalFormat: GLenum read GetglInternalFormat; property glInternalFormat: GLenum read GetglInternalFormat;
property glDataFormat: GLenum read GetglDataFormat; property glDataFormat: GLenum read GetglDataFormat;
public
class function GetByFormat(const aInternalFormat: GLenum): TglBitmapFormatDescriptor;
end; end;


//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -3719,6 +3721,21 @@ begin
fglDataFormat := GL_UNSIGNED_BYTE; fglDataFormat := GL_UNSIGNED_BYTE;
end; end;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TglBitmapFormatDescriptor///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class function TglBitmapFormatDescriptor.GetByFormat(const aInternalFormat: GLenum): TglBitmapFormatDescriptor;
var
f: TglBitmapFormat;
begin
for f := Low(TglBitmapFormat) to High(TglBitmapFormat) do begin
result := TFormatDescriptor.Get(f);
if (result.glInternalFormat = aInternalFormat) then
exit;
end;
result := TFormatDescriptor.Get(tfEmpty);
end;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TFormatDescriptor/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //TFormatDescriptor///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -5002,7 +5019,7 @@ var
bfFormat: TbmpBitfieldFormat; bfFormat: TbmpBitfieldFormat;
pSourceLine, pDestLine: PByte; pSourceLine, pDestLine: PByte;
pSourceMD, pDestMD: Pointer; pSourceMD, pDestMD: Pointer;
x, y: Cardinal;
x, y: Integer;
pixel: TglBitmapPixelData; pixel: TglBitmapPixelData;
begin begin
bfFormat := TbmpBitfieldFormat.Create; bfFormat := TbmpBitfieldFormat.Create;
@@ -5017,7 +5034,7 @@ var
pDestMD := FormatDesc.CreateMappingData; pDestMD := FormatDesc.CreateMappingData;
try try
for y := 0 to aImage.Height-1 do begin for y := 0 to aImage.Height-1 do begin
pSourceLine := aImage.PixelData + y * aImage.DataDescription.BytesPerLine;
pSourceLine := aImage.PixelData + y {%H-}* aImage.DataDescription.BytesPerLine;
pDestLine := ImageData + y * Round(FormatDesc.PixelSize * aImage.Width); pDestLine := ImageData + y * Round(FormatDesc.PixelSize * aImage.Width);
for x := 0 to aImage.Width-1 do begin for x := 0 to aImage.Width-1 do begin
bfFormat.Unmap(pSourceLine, pixel, pSourceMD); bfFormat.Unmap(pSourceLine, pixel, pSourceMD);
@@ -5386,6 +5403,7 @@ var
TempPtr: PByte; TempPtr: PByte;
Size: Integer; Size: Integer;
begin begin
result := nil;
Temp := (ClassType.Create as TglBitmap); Temp := (ClassType.Create as TglBitmap);
try try
// copy texture data if assigned // copy texture data if assigned
@@ -8051,9 +8069,9 @@ end;
procedure TglBitmap2D.GetDataFromTexture; procedure TglBitmap2D.GetDataFromTexture;
var var
Temp: PByte; Temp: PByte;
TempWidth, TempHeight: GLint;
TempIntFormat: GLenum;
IntFormat, f: TglBitmapFormat;
TempWidth, TempHeight: Integer;
TempIntFormat: GLint;
IntFormat: TglBitmapFormat;
FormatDesc: TFormatDescriptor; FormatDesc: TFormatDescriptor;
begin begin
Bind; Bind;
@@ -8061,16 +8079,11 @@ begin
// Request Data // Request Data
glGetTexLevelParameteriv(Target, 0, GL_TEXTURE_WIDTH, @TempWidth); glGetTexLevelParameteriv(Target, 0, GL_TEXTURE_WIDTH, @TempWidth);
glGetTexLevelParameteriv(Target, 0, GL_TEXTURE_HEIGHT, @TempHeight); glGetTexLevelParameteriv(Target, 0, GL_TEXTURE_HEIGHT, @TempHeight);
glGetTexLevelParameteriv(Target, 0, GL_TEXTURE_INTERNAL_FORMAT, PGLint(@TempIntFormat));
glGetTexLevelParameteriv(Target, 0, GL_TEXTURE_INTERNAL_FORMAT, @TempIntFormat);


IntFormat := tfEmpty;
for f := Low(TglBitmapFormat) to High(TglBitmapFormat) do begin
FormatDesc := TFormatDescriptor.Get(f);
if (FormatDesc.glInternalFormat = TempIntFormat) then begin
IntFormat := FormatDesc.Format;
break;
end;
end;
IntFormat := tfEmpty;
FormatDesc := (TglBitmapFormatDescriptor.GetByFormat(TempIntFormat) as TFormatDescriptor);
IntFormat := FormatDesc.Format;


// Getting data from OpenGL // Getting data from OpenGL
FormatDesc := TFormatDescriptor.Get(IntFormat); FormatDesc := TFormatDescriptor.Get(IntFormat);


Načítá se…
Zrušit
Uložit