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
glVertexAttribPointer issue
Hi,
this sounds like a genuine C++ issue (not really about Vuforia);
glVertexAttribPointer issue
Hi,
glVertexAttribPointer issue
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...)
glVertexAttribPointer issue
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.
glVertexAttribPointer issue
Ok, so, if you change the vector (number of vertices during runtime, as you say) dynamically, that probably explains the issue;
glVertexAttribPointer issue
Hi
glVertexAttribPointer issue
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.
glVertexAttribPointer issue
Hi,
Yes, the number of vertices is correct.
Actually the I declare constructor in global scope, and genCubeData in initRendering.
in renderFrame()
glVertexAttribPointer issue
Hi, the code seems to be correct, however I would check (by using some Logs) that:
glVertexAttribPointer issue
Hi AlesandroB,
glVertexAttribPointer issue
Hi,
you can obtain the size of your vector with:
Then, instead of using stack arrays, you can allocate them dynamically, for instance:
glVertexAttribPointer issue
Hi AlessandroB,
I've tried using dynamic arrays, but I got the error similar like the first error "Fatal Signal 11 (SIGSEGV)"
glVertexAttribPointer issue
Hi,
the fact that you use for instance only 200 elements out of the total 10,000, is not a problem, because you are using this line at the end:
glVertexAttribPointer issue
Hi,
Ah I see.. thank you for discussion. I will try to find another approach..