From what I’ve found on the web, I’m thinking the answer to this is a negatory, but can one “draw a C++ class”?
i.e.
struct AAA
{
float x,y,z,r,g,b;
void setPos(float _x, float _y, float _z);
void setColor(float _r, float _g, float _b);
}
...
void Display()
{
unsigned short indexes[3] = {0,1,2};
AAA vertexes = new AAA[3]
vertexes[0].setPos(0,0,0);
vertexes[0].setColor(0,0,1);
//... initializing vertexes[1] and [2]
glGenBuffers(1,&VBO);
glBindBuffer(GL_ARRAY_BUFFER,VBO);
glBufferData(GL_ARRAY_BUFFER,sizeof(vertexes)*sizeof(AAA),&vertexes[0],GL_STATIC_DRAW);
glVertexAttribPointer(0,3,GL_FLOAT,GL_FALSE,sizeof(AAA),BUFFER_OFFSET(0));
glVertexAttribPointer(1,3,GL_FLOAT,GL_FALSE,sizeof(AAA),BUFFER_OFFSET(3*sizeof(float)));
glGenBuffers(1,&VIO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,VIO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER,sizeof(unsigned short)*3,vertexes,GL_STATIC_DRAW);
glDrawArrayElements(GL_TRIANGLES,3,GL_UNSIGNED_SHORT,BUFFER_OFFSET(0));
I forgot to define some variables there, but you get the jist of it. My question is: won’t the SetColor() function mess up the object’s size? Do vertex-objects (defining position, color, texture, etc) need to be pure data?