Archived

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

adam17

Data types and vertex arrays

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


Link to post
Share on other sites
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


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


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


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


Link to post
Share on other sites