Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Vertex
- {
- Vertex() : position( 0.0f ), texcoord( 0.0f ), color( 1.0f )
- {
- }
- glm::vec3 position;
- glm::vec2 texcoord;
- glm::vec4 color;
- static unsigned int Size();
- };
- inline unsigned int Vertex::Size()
- {
- return sizeof( Vertex );
- }
- namespace VertexAttribute
- {
- const unsigned int P_LOC = 0;
- const unsigned int T_LOC = 1;
- const unsigned int C_LOC = 2;
- const unsigned int P_OFFSET = offsetof( Vertex, position );
- const unsigned int T_OFFSET = offsetof( Vertex, texcoord );
- const unsigned int C_OFFSET = offsetof( Vertex, color );
- }
- glEnableVertexAttribArray( 0 ) // в шейдере это будет layout(location = 0) in vec3 inVertex;
- glVertexAttribPointer( VertexAttribute::P_LOC, sizeof( vec3 ), GL_FLOAT, GL_FALSE, Vertex::Size(), VertexAttribute:P_OFFSET );
- glEnableVertexAttribArray( 1 ) // в шейдере это будет layout(location = 1) in vec2 inTexCoord;
- glVertexAttribPointer( VertexAttribute::T_LOC, sizeof( vec2 ), GL_FLOAT, GL_FALSE, Vertex::Size(), VertexAttribute::T_OFFSET );
- glEnableVertexAttribArray( 2 ) // в шейдере это будет layout(location = 2) in vec4 inColor;
- glVertexAttribPointer( VertexAttribute::C_LOC, sizeof( vec4 ), GL_FLOAT, GL_FALSE, Vertex::Size(), VertexAttribute::C_OFFSET );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement