forked from organicmaps/organicmaps-tmp
setting Vertex structure through VertexDecl mechanism.
This commit is contained in:
parent
fe9b9bfc13
commit
e0663bab7e
2 changed files with 14 additions and 9 deletions
|
@ -1,7 +1,8 @@
|
|||
#include "vertex.hpp"
|
||||
|
||||
#include "opengl.hpp"
|
||||
|
||||
#include "../base/macros.hpp"
|
||||
|
||||
namespace graphics
|
||||
{
|
||||
namespace gl
|
||||
|
@ -38,16 +39,17 @@ namespace graphics
|
|||
return *this;
|
||||
}
|
||||
|
||||
void Vertex::setupLayout(void * glPtr)
|
||||
VertexDecl const * Vertex::getVertexDecl()
|
||||
{
|
||||
OGLCHECK(glEnableClientStateFn(GL_VERTEX_ARRAY_MWM));
|
||||
OGLCHECK(glVertexPointerFn(3, GL_FLOAT, sizeof(Vertex), (void*)((char*)glPtr + Vertex::vertexOffset)));
|
||||
static VertexAttrib attrs [] =
|
||||
{
|
||||
VertexAttrib("Position", vertexOffset, EFloat, 3, sizeof(Vertex)),
|
||||
VertexAttrib("Normal", normalOffset, EFloat, 2, sizeof(Vertex)),
|
||||
VertexAttrib("TexCoordIn", texCoordOffset, EFloat, 2, sizeof(Vertex))
|
||||
};
|
||||
|
||||
OGLCHECK(glEnableClientStateFn(GL_NORMAL_ARRAY_MWM));
|
||||
OGLCHECK(glNormalPointerFn(2, GL_FLOAT, sizeof(Vertex), (void*)((char*)glPtr + Vertex::normalOffset)));
|
||||
|
||||
OGLCHECK(glEnableClientStateFn(GL_TEXTURE_COORD_ARRAY_MWM));
|
||||
OGLCHECK(glTexCoordPointerFn(2, GL_FLOAT, sizeof(Vertex), (void*)((char*)glPtr + Vertex::texCoordOffset)));
|
||||
static VertexDecl vd(attrs, ARRAY_SIZE(attrs));
|
||||
return &vd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "../color.hpp"
|
||||
#include "../vertex_decl.hpp"
|
||||
|
||||
#include "../../geometry/point2d.hpp"
|
||||
|
||||
|
@ -28,6 +29,8 @@ namespace graphics
|
|||
Vertex(Vertex const & v);
|
||||
Vertex const & operator=(Vertex const & v);
|
||||
|
||||
static VertexDecl const * getVertexDecl();
|
||||
|
||||
static void setupLayout(void * glPtr);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue