In the helloTriangle example can you explain the VertexData and its values and why bytes?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

In the helloTriangle example can you explain the VertexData and its values and why bytes?

ElvJOGL
Hi elect,

could you go over why you chose to write the vertexData that variable the way you did.

for instance, what's the relation between your vertexData variable and values to an NON-JOGL program getting the vertices from an array of vectors like:

vertexData[3][4] = {{-1, -1, 0, 1}, {1, -1, 0, 1}, {-1, 1, 0, 1}}

I chose vec4 in inquiry because I assume that your vertexData in jogl are homogeneous as well.

Can you elaborate?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: In the helloTriangle example can you explain the VertexData and its values and why bytes?

elect
Heya,

actually your questions are really good because they point out which are the doubt of beginners, then I am gonna update the HelloTriangle and this is what I add

Each line represents an interleaved vertex attribute array and they are
     * counted starting from zero. This means the first line is vertex 0, the
     * second vertex 1 and the last one vertex 2. Usually floats are used, but
     * in this sample I went with bytes. They are interleaved because for each
     * line, the first two bytes indicates the position while the last four the
     * color of the i-th vertex. Take in account the positions are going to be
     * used as they are but the colors are going to be, instead, normalized.
     * Since I am going to load them as signed bytes they will be resolved in
     * the range [-1, 1]. That is, in the shaders, a Byte.MAX_VALUE will
     * correspond to a value equal to 1.