PDA

View Full Version : Different buffers for different objects



Wasabi
08-08-2011, 04:57 PM
I have an object which contains classes which contain the data of the vertexes:
[class]class NFault
{
NVertexColors* Colors; //array of fill and wireframe colors
NVertexGeometry* Geometry; //array of vertex coordinates and normals
unsigned int* Index;
//...
};[/CODE]
The colors have a much higher chance of being altered, so I've separated them into a different object from the geometry of the vertexes in order to have two buffers, one for the geometry and one for the colors, so that I can alter one set of data without having to re-copy all the other things which remain constant.

Now, if I want to have an array of such objects (NFault*), how will I do it? Can I have different buffers for different objects?

However, if I do that, I will have a problem when I define the shader, won't I?

//Fault 1
glBindAttribLocation(Environment.ShaderProgram,0,"in_Position");
glBindAttribLocation(Environment.ShaderProgram,1,"in_Normal");
glBindAttribLocation(Environment.ShaderProgram,2,"FillColor");
glBindAttribLocation(Environment.ShaderProgram,3,"WireframeColor");
//Fault 2
glBindAttribLocation(Environment.ShaderProgram,4,"in_Position");
glBindAttribLocation(Environment.ShaderProgram,5,"in_Normal");
glBindAttribLocation(Environment.ShaderProgram,6,"FillColor");
glBindAttribLocation(Environment.ShaderProgram,7,"WireframeColor");

Won't these conflicting binds clash?

How else can I do this (not necessarily using buffers, that was just an idea)? How can I create an array of such objects?

Will I have to redefine NFault, absorbing the values of NVertexGeometry and NVertexColors, transforming it instead into

class NFault
{
float** pos;
float** normal;
float** fillColor;
float** wireColor;
unsigned int* Index;
//...
}
and then declaring each as an array of float[3] pointers?

Wasabi
08-09-2011, 12:59 PM
Any ideas?

How can I have more than one object drawn with the class I have now? Will I have to alter it to the float** version of the class instead?