Reputation: 1100
I am developing a real world application that is to render solid white polygons on the screen, and change their alpha values as time passes. I am trying to learn how to use GLTriangleBatch to perform this (I know C++ well, but not so much about OpenGL), and have not been able to find any good examples online. So far, I have found a few resources that led me to put together the following bit of code, but I am still confused on some portions:
GLTriangleBatch myTriangles;
myTriangles.BeginMesh(1000000); // Include how many vertices you have: 1???
myTriangles.AddTriangle(...); // Add a triangle: 2???
// Repeat for all triangles for this batch
myTriangles.End(); // Done adding triangles
myTriangles.Draw(); // Draw the triangles
I have marked the portions I am confused on with ???, and the questions appear below:
Question 1: Does this number of vertices have to be exact, or is it okay to over-estimate and / or underestimate? Furthermore, does this number of vertices represent the "batched" vertices, or the individual vertices of each triangle (e.g. would 2 connected triangles with 2 shared vertices require 6 vertices or 4?)
Question 2: The paramaters are:
Upvotes: 0
Views: 153
Reputation: 4421
This GLTriangleBatch
class apparently is part of a framework provided with the OpenGL Super Bible book. It is not part of the OpenGL standard (OpenGL is a plain C API).
As for the first question, I assume the nMaxVerts
parameter of BeginMesh()
is the upper limit of vertexes you want to draw (each triangle = 3 verts). So you can set this to either an exact value or an over-estimate. But you'd have to find some documentation or look at the source to know for sure.
For the second question, yes verts[3]
are the three positions that make the triangle.
vNorms
is the Face Normal of the triangle. It is used for lighting calculation. And the last member, vTexCoords[3]
are the Texture Coordinates of the triangle. These are used for texture mapping. You can set them to zero if you are not applying texture to your mesh.
Upvotes: 3