|
|
|
@@ -907,6 +907,8 @@ type |
|
|
|
property glFormat: GLenum read GetglFormat; |
|
|
|
property glInternalFormat: GLenum read GetglInternalFormat; |
|
|
|
property glDataFormat: GLenum read GetglDataFormat; |
|
|
|
public |
|
|
|
class function GetByFormat(const aInternalFormat: GLenum): TglBitmapFormatDescriptor; |
|
|
|
end; |
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
|
@@ -3719,6 +3721,21 @@ begin |
|
|
|
fglDataFormat := GL_UNSIGNED_BYTE; |
|
|
|
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/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
|
@@ -5002,7 +5019,7 @@ var |
|
|
|
bfFormat: TbmpBitfieldFormat; |
|
|
|
pSourceLine, pDestLine: PByte; |
|
|
|
pSourceMD, pDestMD: Pointer; |
|
|
|
x, y: Cardinal; |
|
|
|
x, y: Integer; |
|
|
|
pixel: TglBitmapPixelData; |
|
|
|
begin |
|
|
|
bfFormat := TbmpBitfieldFormat.Create; |
|
|
|
@@ -5017,7 +5034,7 @@ var |
|
|
|
pDestMD := FormatDesc.CreateMappingData; |
|
|
|
try |
|
|
|
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); |
|
|
|
for x := 0 to aImage.Width-1 do begin |
|
|
|
bfFormat.Unmap(pSourceLine, pixel, pSourceMD); |
|
|
|
@@ -5386,6 +5403,7 @@ var |
|
|
|
TempPtr: PByte; |
|
|
|
Size: Integer; |
|
|
|
begin |
|
|
|
result := nil; |
|
|
|
Temp := (ClassType.Create as TglBitmap); |
|
|
|
try |
|
|
|
// copy texture data if assigned |
|
|
|
@@ -8051,9 +8069,9 @@ end; |
|
|
|
procedure TglBitmap2D.GetDataFromTexture; |
|
|
|
var |
|
|
|
Temp: PByte; |
|
|
|
TempWidth, TempHeight: GLint; |
|
|
|
TempIntFormat: GLenum; |
|
|
|
IntFormat, f: TglBitmapFormat; |
|
|
|
TempWidth, TempHeight: Integer; |
|
|
|
TempIntFormat: GLint; |
|
|
|
IntFormat: TglBitmapFormat; |
|
|
|
FormatDesc: TFormatDescriptor; |
|
|
|
begin |
|
|
|
Bind; |
|
|
|
@@ -8061,16 +8079,11 @@ begin |
|
|
|
// Request Data |
|
|
|
glGetTexLevelParameteriv(Target, 0, GL_TEXTURE_WIDTH, @TempWidth); |
|
|
|
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 |
|
|
|
FormatDesc := TFormatDescriptor.Get(IntFormat); |
|
|
|
|