Gorilla.Context.Texturing
Unit Gorilla.Context.Texturing.pasClasses
- TGorillaTexture = class ( TTexture )
- TTextureBitmapPrivateAccess = class ( TBitmap )
- TGorillaTextureBitmap = class ( TTextureBitmap )
- TGorillaCubeMapTextureBitmap = class ( TGorillaTextureBitmap )
Records
- record TPixelFormatExHelper
- record TGorillaTextureWrapHelper
- record TGorillaTextureDataTypeHelper
- record TTextureFilterHelper
Enumerations
- enum TGorillaTextureDataType = ( dtByte, dtUnsignedByte, dtShort, dtUnsignedShort, dtInt, dtUnsignedInt, dtFloat, dtHalfFloat, dt2Bytes, dt3Bytes, dt4Bytes, dtDouble ) ;
- enum TPixelFormatEx = ( None, RGB, RGBA, BGR, BGRA, RGBA16, BGR_565, BGRA4, BGR4, BGR5_A1, BGR5, BGR10_A2, RGB10_A2, L, LA, LA4, L16, Alpha, R16F, RG16F, RGBA16F, R32F, RG32F, RGBA32F, R, R8, R8_SNORM, RedInteger, R8UI, R8I, R16UI, R16I, R32UI, R32I, RG, RG8, RG8_SNORM, RGInteger, RG8UI, RG8I, RG16UI, RG16I, RG32UI, RG32I, RGB8, SRGB8, RGB565, RGB8_SNORM, R11F_G11F_B10F, RGB9_E5, RGB16F, RGB32F, RGBInteger, RGB8UI, RGB8I, RGB16UI, RGB16I, RGB32UI, RGB32I, RGBA8, SRGB8_ALPHA8, RGBA8_SNORM, RGB5_A1, RGBA4, RGBAInteger, RGBA8UI, RGBA8I, RGB10_A2UI, RGBA16UI, RGBA16I, RGBA32I, RGBA32UI, StencilIndex, Depth, Depth16, Depth24, Depth32, Depth24Stencil8, Depth32Stencil8, DepthStencil ) ;
- enum TGorillaTextureKind = ( Texture2D, Texture3D, CubeMap ) ;
- enum TGorillaTextureWrap = ( Clamp, ClampToEdge, ClampToBorder, Repeated, MirroredRepeat ) ;
- enum TGorillaGeometryCubeSide = ( gcsFront, gcsBack, gcsLeft, gcsRight, gcsTop, gcsBottom, gcsOriginal ) ;
- enum TGorillaCubeMapFace = ( PositiveX, NegativeX, PositiveY, NegativeY, PositiveZ, NegativeZ ) ;
Constants
- const GORILLA_TEXTURES_MIN : Integer = $1;
- const GORILLA_TEXTURES_MAX : Integer = $1F;
- const PixelFormatExBytes : array[0..79] of Integer = ;
- const GORILLA_DEFAULT_TEXTURE_COMPS : TPixelFormatEx = RGBA;
- const GORILLA_DEFAULT_TEXTURE_COMPS_2 : TPixelFormatEx = RGB;
- const GORILLA_DEFAULT_TEXTURE_COMPS_16F : TPixelFormatEx = RGBA16F;
- const GORILLA_DEFAULT_TEXTURE_COMPS_2_16F : TPixelFormatEx = RGB16F;
- const GORILLA_DEFAULT_TEXTURE_FORMAT : TPixelFormatEx = RGBA;
- const GORILLA_DEFAULT_TEXTURE_FORMAT_2 : TPixelFormatEx = RGB;
- const GORILLA_DEFAULT_TEXTURE_COMPS_NONE : TPixelFormatEx = None;
- const GORILLA_DEFAULT_TEXTURE_FORMAT_NONE : TPixelFormatEx = None;
- const GORILLA_DEFAULT_TEXTURE_DATATYPE : TGorillaTextureDataType = dtUnsignedByte;
Functions / Procedures
TGorillaTextureKind
GL_TEXTURE_2D GL_TEXTURE_3D GL_TEXTURE_CUBE_MAP
CubeMapPositiveX, CubeMapNegativeX, CubeMapPositiveY, CubeMapNegativeY, CubeMapPositiveZ, CubeMapNegativeZTPixelFormatExHelper
Methods
- public function ToValue ( const AFormat : TPixelFormatEx ) : Cardinal ; static overload;
- public function ToValue ( const AFormat : TPixelFormat ) : Cardinal ; static overload;
- public function ToPixelFormat ( const AFormat : TPixelFormatEx ) : TPixelFormat ; static;
- public function GetCorrespondingFormat ( const AComp : TPixelFormatEx ) : TPixelFormatEx ; static;
- public function GetCorrespondingDataType ( const AComp : TPixelFormatEx ) : TGorillaTextureDataType ; static;
- public function CompatibleFormat ( const AComp : TPixelFormatEx; const AFormat : TPixelFormatEx ) : TPixelFormatEx ; static;
- public function ToString ( const AFormat : TPixelFormatEx ) : string ; static;
TGorillaTexture
Extends the internal FMX texture class with more configuration opportunities to initialize a texture.
Remarks
The parent bitmap should be a TGorillaTextureBitmap instance, otherwise default values will be used for extended fields like WrapS, WrapT, ...Ancestors
Members
Fields
- protected FKind :
TGorillaTextureKind
- protected FTextureUnit :
Integer
- protected FComponents :
TPixelFormatEx
- protected FFormat :
TPixelFormatEx
- protected FDataType :
TGorillaTextureDataType
- protected FWrapS :
TGorillaTextureWrap
- protected FWrapT :
TGorillaTextureWrap
- protected FWrapR :
TGorillaTextureWrap
- protected FBorderColor :
TAlphaColorF
- protected FDepth :
Integer
- protected FAttachedCubeMapFace :
TGorillaCubeMapFace
- protected FIsCompressed :
Boolean
- protected FBuffer :
Pointer
- protected FBufferSize :
Int64
Methods
- public constructor Create ( ) ;
- public destructor Destroy ( ) ;
- protected procedure SetFormat ( const AValue : TPixelFormatEx ) ;
- protected procedure InternalAssignError ( Source : TPersistent ) ;
- protected procedure InheritedAssign ( Source : TPersistent ) ;
- public procedure Assign
(
Source :
TPersistent
)
;
override;
Overrides the internal assignment routine to apply gorilla specific extended fields to the texture.
- public procedure GetBindingAndKind
(
out
ABinding :
Cardinal; out
AKind :
Cardinal
)
;
Returns the graphics api value (f.e. OpenGL) for texture binding type (GL_TEXTURE_BINDING_2D, GL_TEXTURE_BINDING_3D, GL_TEXTURE_BINDING_CUBE_MAP) and texture kind (GL_TEXTURE_2D, GL_TEXTURE_3D, GL_TEXTURE_CUBE_MAP)
- public procedure GetFormatAndType
(
out
AComps :
Cardinal; out
AFormat :
Cardinal; out
ADataType :
Cardinal
)
;
Request the graphics api value (f.e. OpenGL) for components (internal-format), format and datatype.
Properties
- public Kind : TGorillaTextureKind
- public TextureUnit : Integer
Stores the texture unit id which was used at latest activation, f.e. "GL_TEXTURE0", "GL_TEXTURE1", ...
read FTextureUnit
write FTextureUnit - public Components : TPixelFormatEx
Initializing a texture allows a format value and a component value.
read FComponents
write FComponents - public Format : TPixelFormatEx
- public DataType : TGorillaTextureDataType
- public WrapS : TGorillaTextureWrap
- public WrapT : TGorillaTextureWrap
- public WrapR : TGorillaTextureWrap
- public BorderColor : TAlphaColorF
- public Depth : Integer
- public AttachedCubeMapFace : TGorillaCubeMapFace
Before attaching a cubemap texture for FBO rendering you have to define which side will be rendered. Set this property before calling FBO.AttachTexture(...)
read FAttachedCubeMapFace
write FAttachedCubeMapFace - public IsCompressed : Boolean
Defines if a texture is compressed in GPU memory or not. Set this property by the owning TGorillaTextureBitmap component and not directly in this texture object, because compressed image data is stored in the owning bitmap.
read FIsCompressed
write FIsCompressed - public Buffer : Pointer
- public BufferSize : Int64
TTextureBitmapPrivateAccess
Helper class for implicit type conversion to access the private FTexture field.
Ancestors
Members
TGorillaTextureBitmap
Overrides the FMX texture bitmap component to allow more opportunities to configure texture (format, min-, magfilter, wrapping, datatype, ...) The basic problem with the FMX implementation is, that it uses fixed values for textures. This is not usable for usage in render passes, where a specific type of texture is expected, f.e. for shadow mapping.
Remarks
Because in render passes we create a TTextureBitmap / TGorillaTextureBitmap we need to store texture settings here, to apply them to the automatically created texture instance.Ancestors
Members
Fields
- protected FKind :
TGorillaTextureKind
- protected FComponents :
TPixelFormatEx
- protected FFormat :
TPixelFormatEx
- protected FMinFilter :
TTextureFilter
- protected FMagFilter :
TTextureFilter
- protected FWrapS :
TGorillaTextureWrap
- protected FWrapT :
TGorillaTextureWrap
- protected FWrapR :
TGorillaTextureWrap
- protected FDataType :
TGorillaTextureDataType
- protected FStyle :
TTextureStyles
- protected FBorderColor :
TAlphaColorF
- protected FDepth :
Integer
- protected FAttachedCubeMapFace :
TGorillaCubeMapFace
- protected FProtectFormatSettings :
Boolean
- protected FSettingUp :
Integer
- protected FIsCompressed :
Boolean
- protected FCompressedData :
TMemoryStream
- protected FIsDecompressing :
Integer
- protected FBuffer :
PByte
- protected FBufferSize :
Int64
Methods
- public constructor Create ( ) ;
- public constructor Create ( const AWidth : Integer; const AHeight : Integer ) ;
- public destructor Destroy ( ) ;
- protected procedure SetKind ( const AValue : TGorillaTextureKind ) ; virtual;
- protected procedure SetFormat ( const AValue : TPixelFormatEx ) ; virtual;
- protected procedure SetComponents ( const AValue : TPixelFormatEx ) ; virtual;
- protected procedure SetDataType ( const AValue : TGorillaTextureDataType ) ; virtual;
- protected procedure SetAttachedCubeMapFace ( const AValue : TGorillaCubeMapFace ) ; virtual;
- protected function GetGorillaTexture ( ) : TGorillaTexture ; virtual;
- protected function GetTextureReference ( ) : TTexture ;
- protected procedure SetTextureReference ( const AValue : TTexture ) ;
- protected procedure SetIsCompressed ( const AValue : Boolean ) ;
- protected procedure BitmapChanged ( ) ; override;
- protected procedure InheritedDestroyResources ( ) ; virtual;
- protected procedure DoInitBuffer
(
)
;
virtual;
Initializes the workaround buffer for other bitmap data formats.
- protected procedure DoFreeBuffer
(
)
;
virtual;
Destroys the workaround buffer for other bitmap data formats.
- protected procedure DoCreateHandle ( const AValue : TPixelFormat ) ; virtual;
- protected procedure DoFreeHandle ( ) ; virtual;
- protected function GLHasAnyErrors ( ) : Boolean ; class;
- public procedure ClearAfterCompression ( ) ;
- public procedure Recompress ( ) ;
- public procedure Decompress ( ) ;
- public procedure ValidateBuffer ( ) ;
- public procedure Assign
(
Source :
TPersistent
)
;
override;
Overrides the internal assignment routine to apply gorilla specific extended fields to the texture.
- public procedure GetFormatAndType
(
ATexture :
TTexture; out
AComps :
Cardinal; out
AFormat :
Cardinal; out
ADataType :
Cardinal
)
;
Request texture format components (internalformat), general format and datatype.
- public procedure SetPixelFormat
(
const
AValue :
TPixelFormat
)
;
DirtyHack method to change pixel format of bitmap image.
- public procedure BeginSetup
(
)
;
Use this method when setting up texture properties. We need to initialize the texture with all properties.
- public procedure EndSetup
(
)
;
Call this method after setting up texture properties. A previous call to BeginSetup() is needed.
- public procedure Set3DSize ( AWidth : Integer; AHeight : Integer; ADepth : Integer ) ;
- public procedure UpdateCubeMapFace
(
const
ASide :
TGorillaCubeMapFace; ATexture :
TTexture; const
ABits :
Pointer; const
APitch :
Integer
)
;
overload;
Call this method to upload image data for a specific face of a cube map texture.
- public procedure UpdateCubeMapFace
(
const
ASide :
TGorillaCubeMapFace; ATexture :
TBitmap
)
;
overload;
Call this method to upload image data for a specific face of a cube map texture.
- public procedure UpdateBuffer
(
ABuffer :
Pointer; ASize :
Int64
)
;
Upload complete image data for textures instead of cube map textures.
- public procedure Update3DSlice
(
ASlice :
Integer; ABuffer :
Pointer; ASize :
Int64
)
;
Upload image data for a specific slice (by depth) to a 3D texture.
Properties
- public Kind : TGorillaTextureKind
- public Format : TPixelFormatEx
- public Components : TPixelFormatEx
Specifies the number of color components in the texture. In OpenGL this is called InternalFormat.
read FComponents
write SetComponents - public MinFilter : TTextureFilter
- public MagFilter : TTextureFilter
- public WrapS : TGorillaTextureWrap
- public WrapT : TGorillaTextureWrap
- public WrapR : TGorillaTextureWrap
- public DataType : TGorillaTextureDataType
Allows to read / write the datatype of bytes in a texture: dtByte, dtUnsignedByte, dtShort, dtUnsignedShort, dtInt, dtUnsignedInt, dtFloat, dt2Bytes, dt3Bytes, dt4Bytes, dtDouble
read FDataType
write SetDataType - public BorderColor : TAlphaColorF
- public Depth : Integer
- public Style : TTextureStyles
- public GorillaTexture : TGorillaTexture
Returns a new or existing texture instance. Instead of FMX default property "Texture" the routine checks if a texture already exists, instead of always creating a new one.
read GetGorillaTexture - public AttachedCubeMapFace : TGorillaCubeMapFace
Before attaching a cubemap texture for FBO rendering you have to define which side will be rendered. Set this property before calling FBO.AttachTexture(...)
read FAttachedCubeMapFace
write SetAttachedCubeMapFace - public ProtectFormatSettings : Boolean
Because bitmaps created by FMX are always of BGRA format, we need the opportunity to protect Gorilla3D-bitmaps from modifying the format, when assigning from FMX-bitmap. Otherwise different format settings will appear.
read FProtectFormatSettings
write FProtectFormatSettings - public IsCompressed : Boolean
- public CompressedData : TMemoryStream
- public Buffer : PByte
The main problem with texturing in FMX is, that it uses only BGRA / RGBA as bitmap data. This leads to problems in OpenGL rendering when another bitmap format is needed. If a format, different from default, is detected we build our own buffer. This leads to more memory usage, but helps to solve the problem until the problem is fixed in FMX.
read FBuffer - public BufferSize : Int64
- public TextureReference : TTexture
Returns only the reference to the texture. Instead of the "Texture" property, this will not instanciate a new texture.
read GetTextureReference
write SetTextureReference
TGorillaCubeMapTextureBitmap
Ancestors
Members
Fields
Methods
- public constructor Create ( ) ;
- public constructor Create ( const AWidth : Integer; const AHeight : Integer ) ;
- public destructor Destroy ( ) ;
- protected procedure DoChange ( ) ; override;
- protected function GetCubeMapFace ( AIndex : TGorillaCubeMapFace ) : TTextureBitmap ;
- protected procedure SetCubeMapFace ( AIndex : TGorillaCubeMapFace; AValue : TTextureBitmap ) ;
- protected procedure DoCreateCubeMapFaces ( ) ;
- protected procedure DoFreeCubeMapFaces ( ) ;
- protected procedure UpdateCubeMapFaces ( ) ;