Log in or register to post comments

How can I use glDrawArrays() instead of glDrawElements() on FrameMarkers?

February 24, 2012 - 10:34am #1

I am trying to use the same image that I successfully shows using the ImageTargets Sample, the thing is my .h doesn't have "indices" or a constant of the type NUM_C_OBJECT_INDEX.

Now, that wouldn't be a problem normally as I would just change this like of code:

glDrawElements(GL_TRIANGLES, numIndices, GL_UNSIGNED_SHORT, indices);

for this one:

glDrawArrays(GL_TRIANGLES, 0, vertex);

where vertex = myObjectVertices. The thing is when I try to do this I get this error:


No matching function for call to 'glDrawArrays'

unless I use:

glDrawArrays(GL_TRIANGLES, 0, myObjectVertices); //so not the variable but the object itself.

the problem here is that since on FrameMarkers I am able to use several renders I need to be able to assign the variable so it delimits to the corresponding image but I can't figure how to get that error fixed aside from using the object itself which isn't useful. Any ideas?

My variables:

const GLvoid* vertices = 0;
            const GLvoid* vertex = 0;
            const GLvoid* normals = 0;
            const GLvoid* indices = 0;
            const GLvoid* texCoords = 0;
            int numIndices = 0;


case 1:
                    vertices = &CobjectVertices[0];
                    normals = &CobjectNormals[0];
                    indices = &CobjectIndices[0];
                    texCoords = &CobjectTexCoords[0];
                    numIndices = NUM_C_OBJECT_INDEX;
                case 2:
                    vertices = &myObjectVerts[0];
                    vertex = &myObjectVerts;
                    normals = &myObjectNormals[0];
                    texCoords = &myObjectTexCoords[0];

Re: How can I use glDrawArrays() instead of glDrawElements() on

February 26, 2012 - 2:29pm #2

The third parameter of glDrawArrays is the count (number of vertices), not a pointer to the array. You set the vertex array with the call to glVertexAttribPointer.


- Kim

Log in or register to post comments