-
Notifications
You must be signed in to change notification settings - Fork 95
/
vertexarray_draw.htm
16 lines (13 loc) · 1.31 KB
/
vertexarray_draw.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{%glEnableVertexAttribArray}(texcoord_attrib_index); // Attribute indexes were received from calls to {%glGetAttribLocation}, or passed into {%glBindAttribLocation}.
{%glEnableVertexAttribArray}(normal_attrib_index);
{%glEnableVertexAttribArray}(color_attrib_index);
{%glEnableVertexAttribArray}(position_attrib_index);
{%glVertexAttribPointer}(texcoord_attrib_index, 2, GL_FLOAT, false, 0, texcoords_data); // texcoords_data is a float*, 2 per vertex, representing UV coordinates.
{%glVertexAttribPointer}(normal_attrib_index, 3, GL_FLOAT, false, 0, normals_data); // normals_data is a float*, 3 per vertex, representing normal vectors.
{%glVertexAttribPointer}(color_attrib_index, 3, GL_UNSIGNED_BYTE, true, sizeof(unsigned char)*3, colors_data); // colors_data is a unsigned char*, 3 per vertex, representing the color of each vertex.
{%glVertexAttribPointer}(position_attrib_index, 3, GL_FLOAT, false, 0, vertex_data); // vertex_data is a float*, 3 per vertex, representing the position of each vertex
{%glDrawArrays}(GL_TRIANGLES, 0, vertex_count); // vertex_count is an integer containing the number of indices to be rendered
{%glDisableVertexAttribArray}(position_attrib_index);
{%glDisableVertexAttribArray}(texcoord_attrib_index);
{%glDisableVertexAttribArray}(normal_attrib_index);
{%glDisableVertexAttribArray}(color_attrib_index);