# Help on Vertex Array in glVertexPointer

This topic is 4833 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi... I would like to know if I can use a vector of a struct/class and connect it with glVertexPointer, like a struct/class class vec3 { GLdouble x,y,z; }; becuase I tried it and it doesn'work.... Is really necessary to make a vector with just the vertex information and without a class/struct to help in my development??.. this.. GLdouble * vertex = malloc ( (sizeof(GLdouble)*3)*n_vertex); or this GLdouble vertex[]= { (0,0,1) , (0,1,0), (1,0,0) ... etc...) is bad compare with vec3 *vertexarray = malloc ( sizeof(GLdouble)*n_vertex); or vector <vec3> vertexarray;

##### Share on other sites
how did you try to use it?

##### Share on other sites
You can use classes. How are you setting up the arrays and how are you calling gl*Pointer functions?

##### Share on other sites
Quote:
 Original post by KalidorYou can use classes. How are you setting up the arrays and how are you calling gl*Pointer functions?

i tried one time this...

in c++

class vec3
{
GLdouble x,y,z;
};

vector <vec3> vectorarry;
..
..

glVertexPointer (3, GL_DOUBLE, 0, vectorarry);

and another doubt...

if I use glDrawElements, it will use the NORMAL_ARRAY, but its needs to have the normal of vector, doesn´t it??? So, it will be shaded as phong model... Is there a way to use the normal of faces, and make Gourand??/

##### Share on other sites
ah, you cant use the std::vector like that, as you are trying to pass a pointer to the array class not the data it holds, the correct method is;
glVertexPointer (3, GL_DOUBLE, 0, &vectorarry[0]);

and, yes, if you use vertex arrays everything is specified per-vertex.

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 13
• 18
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633360
• Total Posts
3011514
• ### Who's Online (See full list)

There are no registered users currently online

×