Jump to content
  • Advertisement
Sign in to follow this  
Fabio de T P

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.

If you intended to correct an error in the post then please contact us.

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 this post


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

Share this post


Link to post
Share on other sites
Quote:
Original post by Kalidor
You 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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!