Overview
In SingleColoredCube we saw that VBOs were used to draw the single colored cube using Position data. In this post we will discuss how to draw a Multi Colored cube using VBOs with Position and Color data having unique color on each face. It looks as shown at the bottom. It looks elongated because aspect ratio is not applied.
Details
System class diagram
Every 3D object such as MutiColoredCube derives from BaseGeometry class. It overrides mesh with an instance of CubeMesh to generate geometry.MultiColoredCube
| Name | Description |
|---|---|
| Init | This method overrides the base class Init method. It creates the mesh object. Generates the vertices data consisting of Position and color in non indexed mode. and later sets them up in VBO buffers. |
| vertexShaderSource | This method overrides the base class vertexShaderSource method. It returns the vertex shader code to render the cube object. |
| fragmentShaderSource | This method overrides the base class fragmentShaderSource method. It returns the fragment shader code to render the cube object. |
Output
No comments:
Post a Comment