Gorilla.Context.Texturing
Unit Gorilla.Context.Texturing.pasClasses
- TGorillaTexture = class ( TTexture )
- TGorillaTextureBitmap = class ( TTextureBitmap )
- TGorillaCubeMapTextureBitmap = class ( TGorillaTextureBitmap )
Records
- record TPixelFormatExHelper
- record TGorillaTextureWrapHelper
- record TGorillaTextureDataTypeHelper
Enumerations
- enum TPixelFormatEx = ( None, RGB, RGBA, BGR, BGRA, RGBA16, BGR_565, BGRA4, BGR4, BGR5_A1, BGR5, BGR10_A2, RGB10_A2, L, LA, LA4, L16, A, R8, R16F, RG16F, RGBA16F, R32F, RG32F, RGBA32F, R, RG, RGB16F, RGB32F, StencilIndex, Depth, Depth16, Depth24, Depth32, DepthStencil ) ;
- enum TGorillaTextureKind = ( Texture2D, Texture3D, CubeMap ) ;
- enum TGorillaTextureWrap = ( Clamp, ClampToEdge, ClampToBorder, Repeated, MirroredRepeat ) ;
- enum TGorillaTextureDataType = ( dtByte, dtUnsignedByte, dtShort, dtUnsignedShort, dtInt, dtUnsignedInt, dtFloat, dtHalfFloat, dt2Bytes, dt3Bytes, dt4Bytes, dtDouble ) ;
- 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..34] of Integer = ;
Functions / Procedures
TGorillaTextureKind
GL_TEXTURE_2D GL_TEXTURE_3D GL_TEXTURE_CUBE_MAP
CubeMapPositiveX, CubeMapNegativeX, CubeMapPositiveY, CubeMapNegativeY, CubeMapPositiveZ, CubeMapNegativeZTGorillaTexture
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 FWrapS :
TGorillaTextureWrap
- protected FWrapT :
TGorillaTextureWrap
- protected FWrapR :
TGorillaTextureWrap
- protected FDataType :
TGorillaTextureDataType
- protected FBorderColor :
TAlphaColorF
- protected FDepth :
Integer
- protected FBuffer :
Pointer
- protected FBufferSize :
Int64
Methods
- public constructor Create ( ) ;
- 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 WrapS : TGorillaTextureWrap
- public WrapT : TGorillaTextureWrap
- public WrapR : TGorillaTextureWrap
- public DataType : TGorillaTextureDataType
- public BorderColor : TAlphaColorF
- public Depth : Integer
- public Buffer : Pointer
- public BufferSize : Int64
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 FSettingUp :
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 function GetGorillaTexture ( ) : TGorillaTexture ; 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 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 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
TGorillaCubeMapTextureBitmap
Ancestors
Members
Fields
Methods
- public constructor Create ( ) ;
- public constructor Create ( const AWidth : Integer; const AHeight : Integer ) ;
- public destructor Destroy ( ) ;
- protected function GetCubeMapFace ( AIndex : TGorillaCubeMapFace ) : TTextureBitmap ;
- protected procedure SetCubeMapFace ( AIndex : TGorillaCubeMapFace; AValue : TTextureBitmap ) ;
- protected procedure DoCreateCubeMapFaces ( ) ;
- protected procedure DoFreeCubeMapFaces ( ) ;
- protected procedure UpdateCubeMapFaces ( ) ;