sajis997

01-29-2015, 03:27 AM

Hello forum,

I am confused about the specification of one of the parameter in the above mentioned function - stride. According to the documentation it says that -

"Specifies the byte offset between consecutive generic vertex attributes. If stride is 0, the generic vertex attributes are understood to be tightly packed in the array. The initial value is 0."

Is there any graphical explanation so that I can get some insights from the above statement. I have vertex attributes arranged in a struct as follows:

struct Vertex

{

glm::vec3 position;

glm::vec3 color;

};

Vertex mVertices[3];

GLushort mIndices[3];

What should be the value of the parameter - "stride". I have the vertex attributes defined as follows for a simple triangle , but the color output is strange.

//setup the triangle geometry

mVertices[0].color = glm::vec3(1.0,0.0,0.0);

mVertices[1].color = glm::vec3(0.0,1.0,0.0);

mVertices[2].color = glm::vec3(0.0,0.0,1.0);

mVertices[0].position = glm::vec3(-1,-1,0);

mVertices[1].position = glm::vec3(0,1,0);

mVertices[2].position = glm::vec3(1,-1,0);

//setup the triangle indices

mIndices[0] = 0;

mIndices[1] = 1;

mIndices[2] = 2;

Check the following screen-shot

http://imgur.com/WMgR9PB

I wonder how the black color is appearing from. I defined the color at one end of the triangle to be blue.

Any idea ?

I am confused about the specification of one of the parameter in the above mentioned function - stride. According to the documentation it says that -

"Specifies the byte offset between consecutive generic vertex attributes. If stride is 0, the generic vertex attributes are understood to be tightly packed in the array. The initial value is 0."

Is there any graphical explanation so that I can get some insights from the above statement. I have vertex attributes arranged in a struct as follows:

struct Vertex

{

glm::vec3 position;

glm::vec3 color;

};

Vertex mVertices[3];

GLushort mIndices[3];

What should be the value of the parameter - "stride". I have the vertex attributes defined as follows for a simple triangle , but the color output is strange.

//setup the triangle geometry

mVertices[0].color = glm::vec3(1.0,0.0,0.0);

mVertices[1].color = glm::vec3(0.0,1.0,0.0);

mVertices[2].color = glm::vec3(0.0,0.0,1.0);

mVertices[0].position = glm::vec3(-1,-1,0);

mVertices[1].position = glm::vec3(0,1,0);

mVertices[2].position = glm::vec3(1,-1,0);

//setup the triangle indices

mIndices[0] = 0;

mIndices[1] = 1;

mIndices[2] = 2;

Check the following screen-shot

http://imgur.com/WMgR9PB

I wonder how the black color is appearing from. I defined the color at one end of the triangle to be blue.

Any idea ?