triangles_drawable
Triangle soup stored on the GPU, without connectivity, ready to be drawn.
Fields and methods
Members of the struct triangles_drawable. Most of what you do with a CGP type goes through the free functions listed below.
Fields
opengl_shader_structure default_shader | Static shader shared by all triangles_drawable and used by default in initialize_data_on_gpu, loaded from shaders/mesh by the application. |
opengl_texture_image_structure default_texture | Static 1x1 white RGBA texture shared by all triangles_drawable and used by default in initialize_data_on_gpu. |
opengl_shader_structure shader | Shader program used to draw the triangles, which must be valid (non-zero id) at draw time. |
opengl_texture_image_structure texture | Main texture bound to texture unit 0 and sent to the uniform image_texture at draw time. |
opengl_vbo_structure vbo_position | VBO storing the vertex positions, three consecutive vertices per triangle, bound to shader location 0. |
opengl_vbo_structure vbo_normal | VBO storing the vertex normals, bound to shader location 1. |
opengl_vbo_structure vbo_color | VBO storing the vertex colors, bound to shader location 2. |
opengl_vbo_structure vbo_uv | VBO storing the vertex texture coordinates, bound to shader location 3. |
GLuint vao = 0 | OpenGL id of the Vertex Array Object describing the VBO layout, 0 when not initialized. |
affine model | Model transform of the drawable, reset to identity by initialize_data_on_gpu and clear. |
affine_rts hierarchy_transform_model | Additional transform applied before model in the model matrix sent to the shader. |
material_mesh_drawable_phong material | Phong material sent to the uniform struct material at draw time. |
int vertex_number = 0 | Number of vertices drawn with glDrawArrays (three per triangle). |
std::map<std::string,opengl_texture_image_structure> supplementary_texture | Additional textures keyed by uniform name and bound to texture units 1, 2, ... in the order of the map at draw time. |
Methods
| Uploads a non-indexed triangle soup (three consecutive positions per triangle) into VBOs and a VAO, filling missing normals with flat face normals, colors with white and uv with (0,0), and resets model and material. src | |
| Deletes the VBOs and the VAO, sets vertex_number to 0, and resets shader, texture, supplementary_texture, model and material without deleting the shader program or the textures. src | |
| Sends the uniform model = hierarchy_transform_model * model and the material uniforms to the current shader. src |
Functions taking a triangles_drawable
Draw 2
void draw(
triangles_drawable const& drawable,
environment_generic_structure const& environment = environment_generic_structure(),
uniform_generic_structure const& additional_uniforms = uniform_generic_structure(),
material_mesh_drawable_phong const* material_override = nullptr
)Draw a non-indexed triangles_drawable (triangle soup) with its shader, texture, model and material, plus the environment and optional additional uniforms.
void draw_wireframe(
triangles_drawable const& drawable,
environment_generic_structure const& environment = environment_generic_structure(),
vec3 const& color = {0,0,1},
uniform_generic_structure const& additional_uniforms = uniform_generic_structure()
)Draw the triangle edges of a triangles_drawable in a flat color, slightly offset toward the camera (no effect with Emscripten/WebGL).
Functions returning a triangles_drawable
None.
Operators
None.