sjoerd222's picture

VertexAttribPointer - OpenGL ES 2.0

Hi

I have some Texture Vertices I want to use:

float[] quadGridTexture_Vertices = {0.0f,
                                               2.0f,
                                               0.0f,
                                               2.0f,
                                               0.0f,
                                               2.0f,
                                               0.0f,
                                               2.0f
                                               };

What works is:
GL.VertexAttribPointer(s_quad_grid__a_texCoord, 1, VertexAttribPointerType.Float, false, sizeof(float), ref quadGridTexture_Vertices[0]);

What does not:
GL.VertexAttribPointer(s_quad_grid__a_texCoord, 1, VertexAttribPointerType.Float, false, sizeof(float), quadGridTexture_Vertices);

Could somebody explain how to get the second one working? I'm looking for the equivalent of
glVertexAttribPointer (s_quad_grid__a_texCoord, 1, GL_FLOAT,  GL_FALSE, 1 * sizeof(GLfloat), & quadGridTexture_Vertices[0] );

What I want to do with this knowledge is to put the Vertex data together with texture coordinates into one vertex array:

float[] test_Vertices = {-0.5f,0.5f,-0.5f,
                                               0.0f,
                                               0.5f,0.5f,-0.5f,
                                               2.0f
                                             };

And then use something like this:

GL.VertexAttribPointer(s_quad_grid__a_position, 3, VertexAttribPointerType.Float, false, 4*sizeof(float), test_Vertices );
GL.VertexAttribPointer(s_quad_grid__a_texCoord, 1, VertexAttribPointerType.Float, false, sizeof(float), ref test_Vertices [0]);

The working C-Code:

glVertexAttribPointer(s_quad_grid__a_position, 3, GL_FLOAT, GL_FALSE, 4*sizeof(GLfloat), test_Vertices );
glVertexAttribPointer(s_quad_grid__a_texCoord, 1, GL_FLOAT, GL_FALSE, sizeof(GLfloat), &test_Vertices [0]);

(In this case 1D texture coordinates)

Thank you very much for helping out.