• Advertisement

Archived

This topic is now archived and is closed to further replies.

Data types and vertex arrays

This topic is 4988 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

right now i am trying to optimize my program by adding vertex arrays. i am having a little problem right now with it. whenever i define the vertex array and put GL_FLOAT as the datatype it gives an error. the vertex array is defined as vector vertex; whenever i define vertex as GL_FLOAT the vector class doesnt know what to do with it. any ideas of what i can do to fix it? heres my code:
glEnable(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, vertex);
glDrawElements(GL_TRIANGLES, face.capacity(), GL_UNSIGNED_INT, face);
glDisable(GL_VERTEX_ARRAY);

...face is another vector which is the index for the vertices [edited by - adam17 on May 26, 2004 2:36:49 PM]

Share this post

Share on other sites
Advertisement
Define your vertex array of type GLfloat . GL_FLOAT is just a define to tell the function that the array is of type (GL)float so that it knows how to handle the bits and bytes of the array.

[edited by - baumep on May 26, 2004 2:39:41 PM]

Share this post

Share on other sites
I don''t know if you can directly use stl vector as input. Try something like &vertex[0]

And don''t use capacity(). Use size(). (capacity >= size)

You should never let your fears become the boundaries of your dreams.

Share this post

Share on other sites
i tried the GLfloat thing and i still get the same error...
--------------------Configuration: Box Physics - Win32 Debug--------------------
Compiling...
main.cpp
h:\adam\software\visual c++\box physics\object.h(396) : error C2664: ''glVertexPointer'' : cannot convert parameter 4 from ''class std::vector >'' to ''const void *''
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
h:\adam\software\visual c++\box physics\object.h(397) : error C2664: ''glDrawElements'' : cannot convert parameter 4 from ''class std::vector >'' to ''const void *''
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.
Creating browse info file...

Box Physics.exe - 2 error(s), 0 warning(s)

Share this post

Share on other sites
I think vertex array fucntion take only arrays of data as input. You can''t use a vector. Its an abstract data type. While an array is just a package of data of a certain type thats all in the same place in memory

Share this post

Share on other sites

• Advertisement
• Advertisement
• Popular Tags

• Advertisement
• Popular Now

• 10
• 11
• 9
• 16
• 19
• Advertisement