Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualPromit

Posted 22 February 2013 - 04:55 PM

For me, a Mesh is essentially a VAO, plus some parameters for topology (triangle lists, strips etc) and offsets. It's composed from vertex buffers, an index buffer, and a "vertex declaration" (D3D9 terminology) slash "input layout" (D3D10+ terminology). It's essentially an array of the data that you wind up passing as VertexAttribPointer. Tends to look like this:

 

struct VertexElement{
    unsigned int Index;
    int Size;
    int Type;
    unsigned int Stride;
    unsigned int Offset;
    class GraphicsBuffer* Buffer;
    unsigned int Divisor;
};
   
 VertexElement ve[] = {
        { VE_Position, 3, GL_FLOAT, sizeof(SimpleVertex), offsetof(SimpleVertex, position), rawVb },
        { VE_TexCoord, 2, GL_FLOAT, sizeof(SimpleVertex), offsetof(SimpleVertex, texcoord), rawVb },
        { VE_Diffuse, 4, GL_FLOAT, sizeof(SimpleVertex), offsetof(SimpleVertex, color), rawVb },
    };
 
 

That plus an index buffer is enough information to recompose the relevant GL calls to create a VAO. Each of these things gets paired with a material and a few other things (bounding volumes for example) and away we go.


#2Promit

Posted 22 February 2013 - 04:55 PM

For me, a Mesh is essentially a VAO, plus some parameters for topology (triangle lists, strips etc) and offsets. It's composed from vertex buffers, an index buffer, and a "vertex declaration" (D3D9 terminology) slash "input layout" (D3D10+ terminology). It's essentially an array of the data that you wind up passing as VertexAttribPointer. Tends to look like this:


 

struct VertexElement{
    unsigned int Index;
    int Size;
    int Type;
    unsigned int Stride;
    unsigned int Offset;
    class GraphicsBuffer* Buffer;
    unsigned int Divisor;
};
    VertexElement ve[] = {
        { VE_Position, 3, GL_FLOAT, sizeof(SimpleVertex), offsetof(SimpleVertex, position), rawVb },
        { VE_TexCoord, 2, GL_FLOAT, sizeof(SimpleVertex), offsetof(SimpleVertex, texcoord), rawVb },
        { VE_Diffuse, 4, GL_FLOAT, sizeof(SimpleVertex), offsetof(SimpleVertex, color), rawVb },
    };
 

 

 

That plus an index buffer is enough information to recompose the relevant GL calls to create a VAO. Each of these things gets paired with a material and a few other things (bounding volumes for example) and away we go.


#1Promit

Posted 22 February 2013 - 04:54 PM

For me, a Mesh is essentially a VAO, plus some parameters for topology (triangle lists, strips etc) and offsets. It's composed from vertex buffers, an index buffer, and a "vertex declaration" (D3D9 terminology) slash "input layout" (D3D10+ terminology). It's essentially an array of the data that you wind up passing as VertexAttribPointer. Tends to look like this:

struct VertexElement
{
    unsigned int Index;
    int Size;
    int Type;
    unsigned int Stride;
    unsigned int Offset;
    class GraphicsBuffer* Buffer;
    unsigned int Divisor;
};
 
VertexElement ve[] = {

{ VE_Position, 3, GL_FLOAT, sizeof(SimpleVertex), offsetof(SimpleVertex, position), vbo }, { VE_TexCoord, 2, GL_FLOAT, sizeof(SimpleVertex), offsetof(SimpleVertex, texcoord), vbo }, { VE_Diffuse, 4, GL_FLOAT, sizeof(SimpleVertex), offsetof(SimpleVertex, color), vbo }, };

 

That plus an index buffer is enough information to recompose the relevant GL calls to create a VAO. Each of these things gets paired with a material and a few other things (bounding volumes for example) and away we go.


PARTNERS