Changes between Version 3 and Version 4 of documentation/C++Manual/Interfaces
- Timestamp:
- 04/08/08 13:20:15 (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
documentation/C++Manual/Interfaces
v3 v4 91 91 {{{ 92 92 // Called by Rocket when it wants to render geometry that the application does not wish to optimise. 93 virtual void RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rocket::Core::Texture*texture, const EMP::Core::Vector2f& translation) = 0;93 virtual void RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture, const EMP::Core::Vector2f& translation) = 0; 94 94 }}} 95 95 96 All geometry from Rocket is given in this format of indexed triangles. ''vertices'' is an array of vertices making up the geometry. Each vertex is a ''Rocket::Core::Vertex'' type, defined in <Rocket/Core/Vertex.h>. ''num_vertices'' is number of vertices in the array; no index will be equal to or higher than this number. ''indices'' is an array of integer indices, each indexing a single vertex from the vertex array. ''num_indices'' is the total number of indices in the array; as all geometry is given in triangles, this will always be a multiple of three. ''texture'' is a pointerto the texture to be applied to the geometry; this will be NULL for untextured geometry. Lastly, ''translation'' is the 2D translation to be applied to the geometry.96 All geometry from Rocket is given in this format of indexed triangles. ''vertices'' is an array of vertices making up the geometry. Each vertex is a ''Rocket::Core::Vertex'' type, defined in <Rocket/Core/Vertex.h>. ''num_vertices'' is number of vertices in the array; no index will be equal to or higher than this number. ''indices'' is an array of integer indices, each indexing a single vertex from the vertex array. ''num_indices'' is the total number of indices in the array; as all geometry is given in triangles, this will always be a multiple of three. ''texture'' is the application-defined handle to the texture to be applied to the geometry; this will be NULL for untextured geometry. Lastly, ''translation'' is the 2D translation to be applied to the geometry. 97 97 98 98 All physical coordinates (the vertex positions and the geometry translation) are given in pixel offsets from the top-left of the current context being rendered. 106 106 {{{ 107 107 // Called by Rocket when it wants to compile geometry it believes will be static for the forseeable future. 108 virtual Rocket::Core::CompiledGeometryHandle CompileGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rocket::Core::Texture*texture);108 virtual Rocket::Core::CompiledGeometryHandle CompileGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture); 109 109 110 110 // Called by Rocket when it wants to render application-compiled geometry. 147 147 {{{ 148 148 // Called by Rocket when a texture is required by the library. 149 virtual bool LoadTexture(Rocket::Core::Texture* texture, const EMP::Core::String& source, const EMP::Core::String& source_path) = 0; 149 virtual bool LoadTexture(Rocket::Core::TextureHandle& texture_handle, 150 EMP::Core::Vector2i& texture_dimensions, 151 const EMP::Core::String& source, 152 const EMP::Core::String& source_path) = 0; 150 153 151 154 // Called by Rocket when a texture is required to be built from an internally-generated sequence of pixels. 152 virtual bool GenerateTexture(Rocket::Core::Texture* texture, const EMP::Core::byte* source) = 0; 155 virtual bool GenerateTexture(Rocket::Core::TextureHandle& texture_handle, 156 const EMP::Core::byte* source, 157 const EMP::Core::Vector2i& source_dimensions) = 0; 153 158 154 159 // Called by Rocket when a loaded texture is no longer required. 155 virtual void ReleaseTexture(Rocket::Core::Texture * texture) = 0;160 virtual void ReleaseTexture(Rocket::Core::TextureHandle texture_handle) = 0; 156 161 }}} 157 162 158 LoadTexture() is called when Rocket wants to load a texture from an external source (usually a file, but this is up to the application). ''source'' is the source name specified in the RML (for an image tag) or RCSS (for a decorator image reference). ''source_path'' is the path of the referencing document. The ''texture'' parameter is a pointer to a ''Rocket::Core::Texture'' structure to be filled if the texture load succeeded. The ''Rocket::Core::Texture'' structure is defined in <Rocket/Core/Texture.h>, and given below: 159 160 {{{ 161 struct Rocket::Core::Texture 162 { 163 EMP::Core::Vector2i dimensions; 164 Rocket::Core::TextureHandle handle; 165 }; 166 }}} 167 168 ''dimensions'' should be set to the x- and y-dimensions of the loaded texture, and ''handle'' to a non-NULL unique handle the application can use to identify the texture. Like the other handles, it is a void pointer, and NULL is reserved for invalid handles. 163 LoadTexture() is called when Rocket wants to load a texture from an external source (usually a file, but this is up to the application). ''source'' is the source name specified in the RML (for an image tag) or RCSS (for a decorator image reference). ''source_path'' is the path of the referencing document. The ''texture_handle'' parameter is a reference to a ''Rocket::Core::TextureHandle'' type. This is a void*, and can be set to whatever you need to uniquely identify the loaded texture (except 0, which is reserved for an invalid texture). ''texture_dimensions'' should be set to the x- and y-dimensions of the loaded texture. 169 164 170 165 If the LoadTexture() function succeeds in loading the texture, it should return true. Otherwise it should return false. 171 166 172 GenerateTexture() is used by the font system to convert raw pixel data to a texture. The ''texture '' parameter is a pointer to a ''Rocket::Core::Texture'' object, as in LoadTexture(), but the ''dimensions'' variable has been populated with the dimensions of the raw texture data. ''handle'' still needs to be set to the application-specific texture handle. The raw pixel data is given in ''source''; this is an array of unsigned, 8-bit values in RGBA order. It is laid out in tightly-packed rows, so is exactly (dimensions.x * dimensions.y * 4) bytes in size.167 GenerateTexture() is used by the font system to convert raw pixel data to a texture. The ''texture_handle'' parameter is a reference to a ''Rocket::Core::TextureHandle'' type to be set, as in LoadTexture(). The raw pixel data is given in ''source''; this is an array of unsigned, 8-bit values in RGBA order. It is laid out in tightly-packed rows, so is exactly (source_dimensions.x * source_dimensions.y * 4) bytes in size. The ''source_dimensions'' variable is set to the dimensions of the raw texture data. 173 168 174 169 ReleaseTexture() is called with a texture handle once it is no longer required by Rocket.