Tarum
Tarum

Reputation: 161

About usage of glVertexAttribPointer

GLfloat m_tex[3][4][2] = {
{ {{1.0, 2.0}, {2.0, 3.0}}, {{0.0, -3.0}, {9.0, 11.0}}, {{23.0, 12.0}, {43.0, 22.0}}, {{15.0, 4.0}, {3.0, 12.0}} },
{ {{13.0, 4.0}, {56.0, 3.0}}, {{5.0, 9.0}, {3.0, 5.0}}, {{3.0, 1.0}, {4.0, 9.0}}, {{5.0, 4.0}, {7.0, 12.0}} },
{ {{3.0, 9.0}, {6.0, 13.0}}, {{8.0, 19.0}, {13.0, 6.0}}, {{3.0, 3.0}, {9.0, 6.0}}, {{35.0, 7.0}, {13.0, 12.0}} }
};

glVertexAttribPointer(Yloc, 2, GL_FLOAT, 0, 0, m_tex[0]); 
glVertexAttribPointer(Uloc, 2, GL_FLOAT, 0, 0, m_tex[1]);
glVertexAttribPointer(Vloc, 2, GL_FLOAT, 0, 0, m_tex[2]);

I know the meaning of glVertexAttribPointer. It sets the value of m_tex[0] in 2 floats to vertex Yloc but m_tex[0] includes:

{{1.0, 2.0}, {2.0, 3.0}}, {{0.0, -3.0}, {9.0, 11.0}}, {{23.0, 12.0}, {43.0, 22.0}}, {{15.0, 4.0}, {3.0, 12.0}}

So does it take first two ones ? {1.0,2.0}

I am not sure.

Upvotes: 0

Views: 100

Answers (1)

Mandar
Mandar

Reputation: 1044

Yes, it will take two numbers on each iteration

  +-----------------------------------------------------------+
  | glVertexAttribPointer(Yloc, 2, GL_FLOAT, 0, 0, m_tex[0]); |
  +-----------------------------------------------------------+
                                |                     |
   take 2 floats each time     <+   from this set   <-+
   [1.0,2.0]

If you change 2 parameter to 3 it will iterate for components[x,y,z]

  +-----------------------------------------------------------+
  | glVertexAttribPointer(Yloc, 3, GL_FLOAT, 0, 0, m_tex[0]); |
  +-----------------------------------------------------------+
                                |                     |
   take 3 floats each time     <+   from this set   <-+
   [1.0,2.0,2.0]

Upvotes: 1

Related Questions