Castle Game Engine: CastleRenderer: Class TGLTextureNode

# Class TGLTextureNode
Description | Hierarchy | Fields | Methods | Properties
## Unit CastleRenderer ## Declaration `type TGLTextureNode = class(TResourceRenderer)` ## Description OpenGL handling for VRML/X3D texture node. ## Hierarchy TObject TResourceRenderer TGLTextureNode ## Overview ### Methods
| `procedure HandleTexturePropertiesCore( TextureProperties: TTexturePropertiesNode; out Filter: TTextureFilter; out Anisotropy: TGLfloat; out GUITexture: boolean);`
| `procedure HandleTextureProperties( TextureProperties: TX3DNode; out Filter: TTextureFilter; out Anisotropy: TGLfloat; out GUITexture: boolean);`
| `class function IsClassForTextureNode( ANode: TAbstractTextureNode): boolean; virtual; abstract;`
| `procedure PrepareCore(State: TX3DGraphTraverseState); virtual; abstract;`
| `constructor Create(ARenderer: TGLRenderer; ANode: TX3DNode); override;`
| `function TextureNode: TAbstractTextureNode;`
| `class function ClassForTextureNode( ANode: TAbstractTextureNode): TGLTextureNodeClass;`
| `procedure Prepare(State: TX3DGraphTraverseState);`
| `function Bind(const TextureUnit: Cardinal): boolean; virtual; abstract;`
| `function Enable(const TextureUnit: Cardinal; Shader: TShader; const Env: TTextureEnv): boolean; virtual; abstract;`
| `procedure EnableAll( const TextureUnitsCount: Cardinal; var TextureSlotsUsed: Cardinal; Shader: TShader); virtual; abstract;`
## Description ### Methods
| `procedure HandleTexturePropertiesCore( TextureProperties: TTexturePropertiesNode; out Filter: TTextureFilter; out Anisotropy: TGLfloat; out GUITexture: boolean);`
Calculate things from TextureProperties node. If TextureProperties = `Nil`, they are taken from defaults (possibly in Attributes).
| `procedure HandleTextureProperties( TextureProperties: TX3DNode; out Filter: TTextureFilter; out Anisotropy: TGLfloat; out GUITexture: boolean);`
Calculate things from TextureProperties node. If TextureProperties = `Nil` or not of TTexturePropertiesNode class, they are taken from defaults (possibly in Attributes). This is useful when interpreting VRML/X3D files, as you have no guarantee user didn't place there some disallowed node in "textureProperties" field.
| `class function IsClassForTextureNode( ANode: TAbstractTextureNode): boolean; virtual; abstract;`
Decide if this class can handle given texture Node.
| `procedure PrepareCore(State: TX3DGraphTraverseState); virtual; abstract;`
Do the time-consuming preparations before rendering this texture. Called from TGLRenderer.Prepare, always through our Prepare method. Our Prepare method takes care to catch common exceptions from this (EFramebufferError, ETextureLoadError), convert them to OnWarning and make Unprepare to undo the preparations. So Prepare-Unprepare work like constructor-destructor, with Unprepare having to be prepared to finilizing incomplete instance.
| `constructor Create(ARenderer: TGLRenderer; ANode: TX3DNode); override;`
ANode must be TAbstractTextureNode
| `function TextureNode: TAbstractTextureNode;`
Reference to handled texture node. Never `Nil`. It's guaranteed to satisfy IsClassForTextureNode method of this class.
| `class function ClassForTextureNode( ANode: TAbstractTextureNode): TGLTextureNodeClass;`
Find suitable TGLTextureNode class that can best handle given Node. Returns `Nil` if not found. Descedants implementors: override IsClassForTextureNode to be correctly recognized by this.
| `procedure Prepare(State: TX3DGraphTraverseState);`
Do the time-consuming preparations before rendering this texture. Calls PrepareCore.
| `function Bind(const TextureUnit: Cardinal): boolean; virtual; abstract;`
Bind texture for OpenGL (without enabling it). Just like Enable, returns `False` when texture node was not successfully prepared for OpenGL. Returns `True` when it was successfully bound (caller can be sure then that given texture unit is currently active).
| `function Enable(const TextureUnit: Cardinal; Shader: TShader; const Env: TTextureEnv): boolean; virtual; abstract;`
Enables texture for OpenGL. This has to bind texture identifier and enable proper texture state (for example: 2D, and not 3D, and not cube). When returns `False`, it means that texture node was not successfully prepared for OpenGL, which means (we assume that you called Prepare before Enable) that texture failed to load, required not available OpenGL version / extension etc. Caller will then disable the texture unit, and you don't have to generate tex coords for it. When returns `True` (success) caller can be sure that the specified TextureUnit is currently bound (if OpenGL multitexturing extensions are available at all). This is useful, if you want to later adjust texture unit parameters, like glTexEnvi(GL_TEXTURE_ENV, ...). It's also already enabled (by glEnable(GL_TEXTURE_2D / GL_TEXTURE_CUBE_MAP / GL_TEXTURE_3D) ).
| `procedure EnableAll( const TextureUnitsCount: Cardinal; var TextureSlotsUsed: Cardinal; Shader: TShader); virtual; abstract;`
Sets texture state for many texture units, based on this node. On every texture unit where something is enabled, proper texture identifier must be bound. Also, has to set complete glTexEnv on every enabled texture unit. TextureUnitsCount says how many texture units can be enabled/disabled. TextureUnitsCount does *not* take into account whether multitexturing OpenGL extensions are available at all. Look at GLFeatures.UseMultiTexturing for this. Think of GLFeatures.UseMultiTexturing as capping TextureUnitsCount to 1 (still, remember to honour TextureUnitsCount = 0 case in your implementation, even when GLFeatures.UseMultiTexturing = `True`). You have to update TextureSlotsUsed, this is the count of texture units where some texture coordinates should be generated. It's initial value may be > 0, in case some texture slots are already taken. This means that all texture units above TextureSlotsUsed (to TextureUnitsCount - 1) should be disabled by the caller (no need to do this in `EnableAll`), and there's no need to generated texture coords for them. ( Yes, there is some small optimization missed in the definition of TextureSlotsUsed: if some textures in the middle of multitexture children list failed to load, but some following children succeded, we'll generate tex coords even for the useless texture units in the middle. We could avoid generating texture coords for them, by changing TextureSlotsUsed into bool array. This optimization is not considered worthy implementing for now. ) You have to set texture state of all texture units < TextureSlotsUsed, and only on them.
Generated by PasDoc 0.13.0 on 2015-06-15 04:43:11