"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

glVertexAttribPointer issue

Hi, I have created object data and store them in vector array (in C++). Thus,  can I passed object data such as vertex, colors, or normals to  glVertexAttribPointer() using vector array in c++?

Before that, I have used pointer to point the address of my vector array

vector<float> v;

float* vertex =  &v[0];

and I passed the vertex pointer to  glVertexAttribPointer last arguments.

When I compiled the program, everthing works fine. But when I tested  the ImageTargets apps (I used this sample apps), and aimed to target, I got the following error 

fatal signal 11 (SIGSEGV) at 0x0040a00I searched this issue from google, and some said that the problem is caused by dereferencing a null pointer in native code.Does anybody know how to solve this issue?Thanks 

 

No, you cannot pass an std::vector<float> directly to glVertexAttribPointer()

another question: are you changing the content of the vector during execution ?

(actually, the question is why are you using an std::vector for vertex coordinates...)

 

Hi AlesandroB, 

oh, I see.

I used vector because I want to change the number of my vertices during runtime.

That's why I used vector because I can dynamically reserve the space for  vertices and manage each of vertices easily.  

Another thing; are you always passing the correct number of vertices to the glDrawArray function ?

maybe if you could share your OpenGL code where you set the vertex attrib pointer and you draw, it would help.

 

Hi,

you can obtain the size of your vector with:

int vertsSize = cubeVerts.size();
int normSize = cubeNormals.size();
int colSize = cubeColors.size();

Then, instead of using stack arrays, you can allocate them dynamically, for instance: