Skip to content

Commit

Permalink
libgui|GLBuffer: Added a 3D vertex format
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Apr 28, 2013
1 parent 08502ef commit f41fa27
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
16 changes: 16 additions & 0 deletions doomsday/libgui/include/de/gui/glbuffer.h
Expand Up @@ -75,6 +75,22 @@ struct LIBGUI_PUBLIC Vertex2TexRgba
static internal::AttribSpec const _spec[3];
};

/**
* Vertex format with 3D coordinates, one set of texture coordinates, and an
* RGBA color.
*/
struct LIBGUI_PUBLIC Vertex3TexRgba
{
Vector3f pos;
Vector2f texCoord;
Vector4f rgba;

static internal::AttribSpecs formatSpec();

private:
static internal::AttribSpec const _spec[3];
};

namespace gl
{
enum Usage {
Expand Down
18 changes: 16 additions & 2 deletions doomsday/libgui/src/glbuffer.cpp
Expand Up @@ -23,18 +23,32 @@ namespace de {
using namespace internal;
using namespace gl;

// Vertex Formats ------------------------------------------------------------

AttribSpec const Vertex2TexRgba::_spec[3] = {
{ AttribSpec::Position, 2, GL_FLOAT, false, sizeof(Vertex2TexRgba), 0 },
{ AttribSpec::TexCoord0, 2, GL_FLOAT, false, sizeof(Vertex2TexRgba), 2 * sizeof(float) },
{ AttribSpec::Color, 4, GL_FLOAT, false, sizeof(Vertex2TexRgba), 4 * sizeof(float) }
};

AttribSpecs Vertex2TexRgba::formatSpec()
{
AttribSpecs Vertex2TexRgba::formatSpec() {
DENG2_ASSERT(sizeof(Vertex2TexRgba) == 8 * sizeof(float)); // sanity check
return AttribSpecs(_spec, sizeof(_spec)/sizeof(_spec[0]));
}

AttribSpec const Vertex3TexRgba::_spec[3] = {
{ AttribSpec::Position, 3, GL_FLOAT, false, sizeof(Vertex3TexRgba), 0 },
{ AttribSpec::TexCoord0, 2, GL_FLOAT, false, sizeof(Vertex3TexRgba), 3 * sizeof(float) },
{ AttribSpec::Color, 4, GL_FLOAT, false, sizeof(Vertex3TexRgba), 5 * sizeof(float) }
};

AttribSpecs Vertex3TexRgba::formatSpec() {
DENG2_ASSERT(sizeof(Vertex3TexRgba) == 9 * sizeof(float)); // sanity check
return AttribSpecs(_spec, sizeof(_spec)/sizeof(_spec[0]));
}

// ---------------------------------------------------------------------------

DENG2_PIMPL(GLBuffer)
{
GLuint name;
Expand Down

0 comments on commit f41fa27

Please sign in to comment.