Yope3D, 3D rendering (Part 3)
<p>In this article about the Yope3D project, the expansion of the basic rendering system discussed in Part 2 is discussed, with features like 3D rendering, index-based rendering, and window resizing.</p>
<p>The GitHub repository with the code is here: <a href="https://github.com/yugumishra/Yope3D/tree/main" rel="noopener ugc nofollow" target="_blank">https://github.com/yugumishra/Yope3D/tree/main</a></p>
<p>As mentioned in the last article, the Yope3D rendering system as of now is not the most efficient; it is required that we rewrite 50% of the vertices due to the geometry program requiring a mesh of triangles to render the object. Right now, this problem is not very apparent since the vertices only consist of position data. However, as more and more data is added to the vertices and as mesh size becomes larger, this becomes a very apparent problem. This problem is solved by using index-based rendering. This method of rendering requires another piece of data: the indices that show how the vertices link to become triangles. In exchange, the vertices in the vertex array do not have to repeat. The GPU uses the indices passed in to reference the vertices, requiring no overwrite of vertices.</p>
<p>To implement this in Yope3D’s current system, all that was necessary was to introduce an indices array that held the indices, create an index buffer object (OpenGL object that held the indices), buffer the data to it, and in the render method of the renderer, simply reference the index buffer instead of the vertex buffer, and use glDrawElements as opposed to glDrawArrays.</p>
<p><a href="https://medium.com/@yugumish/yope3d-3d-rendering-part-3-17890e48fda5"><strong>Learn More</strong></a></p>