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
| `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; out TexCoordsNeeded: Cardinal; Shader: TShader); virtual; abstract;`
## Description ### Methods
| `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_ARB / GL_TEXTURE_3D) ).
| `procedure EnableAll( const TextureUnitsCount: Cardinal; out TexCoordsNeeded: 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 set TexCoordsNeeded, this is the count of texture units where some texture coordinates should be generated. This means that all texture units above TexCoordsNeeded (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 TexCoordsNeeded: 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 TexCoordsNeeded into bool array. This optimization is not considered worthy implementing for now. ) You have to set texture state of all texture units < TexCoordsNeeded, and only on them.
Generated by PasDoc 0.13.0 on 2013-08-17 21:27:13