Browse Source

EasyMesh : vdecl/vbo flag test fixup.

Tileset : added GetTileSize().
legacy
Benjamin ‘Touky’ Huet touky 11 years ago
parent
commit
77dcb3c146
3 changed files with 19 additions and 10 deletions
  1. +13
    -10
      src/easymesh/easymesh.cpp
  2. +5
    -0
      src/tileset.cpp
  3. +1
    -0
      src/tileset.h

+ 13
- 10
src/easymesh/easymesh.cpp View File

@@ -241,8 +241,10 @@ void GpuEasyMeshData::SetupVertexData(uint16_t vdecl_flags, EasyMesh* src_mesh)
memcpy(mesh, vbo_data, vbo_bytes); \ memcpy(mesh, vbo_data, vbo_bytes); \
new_vbo->Unlock(); new_vbo->Unlock();


if (vdecl_flags == ((1 << VertexUsage::Position) | (1 << VertexUsage::Normal) |
(1 << VertexUsage::Color) | (1 << VertexUsage::TexCoordExt)))
uint16_t baseflag = (1 << VertexUsage::Position) | (1 << VertexUsage::Normal) | (1 << VertexUsage::Color);
if (vdecl_flags == (baseflag | (1 << VertexUsage::TexCoordExt)) ||
vdecl_flags == (baseflag | (1 << VertexUsage::TexCoord) |
(1 << VertexUsage::TexCoordExt)))
{ {
new_vdecl = new VertexDeclaration( new_vdecl = new VertexDeclaration(
VertexStream<vec3,vec3,u8vec4,vec4>( VertexStream<vec3,vec3,u8vec4,vec4>(
@@ -264,8 +266,7 @@ void GpuEasyMeshData::SetupVertexData(uint16_t vdecl_flags, EasyMesh* src_mesh)


COPY_VBO; COPY_VBO;
} }
else if (vdecl_flags == ((1 << VertexUsage::Position) | (1 << VertexUsage::Normal) |
(1 << VertexUsage::Color) | (1 << VertexUsage::TexCoord)))
else if (vdecl_flags == (baseflag | (1 << VertexUsage::TexCoord)))
{ {
new_vdecl = new VertexDeclaration( new_vdecl = new VertexDeclaration(
VertexStream<vec3,vec3,u8vec4,vec2>( VertexStream<vec3,vec3,u8vec4,vec2>(
@@ -287,8 +288,7 @@ void GpuEasyMeshData::SetupVertexData(uint16_t vdecl_flags, EasyMesh* src_mesh)


COPY_VBO; COPY_VBO;
} }
else if (vdecl_flags == ((1 << VertexUsage::Position) | (1 << VertexUsage::Normal) |
(1 << VertexUsage::Color)))
else if (vdecl_flags == baseflag)
{ {
new_vdecl = new VertexDeclaration( new_vdecl = new VertexDeclaration(
VertexStream<vec3,vec3,u8vec4>( VertexStream<vec3,vec3,u8vec4>(
@@ -335,16 +335,19 @@ void GpuEasyMeshData::RenderMeshData(mat4 const &model)


vdecl->Bind(); vdecl->Bind();


if (vflags == ((1 << VertexUsage::Position) | (1 << VertexUsage::Normal) |
(1 << VertexUsage::Color) | (1 << VertexUsage::TexCoord)))
uint16_t baseflag = (1 << VertexUsage::Position) | (1 << VertexUsage::Normal) | (1 << VertexUsage::Color);
if (vflags == (baseflag | (1 << VertexUsage::TexCoord)) ||
vflags == (baseflag | (1 << VertexUsage::TexCoordExt)) ||
vflags == (baseflag | (1 << VertexUsage::TexCoord) |
(1 << VertexUsage::TexCoordExt)))
{ {
vdecl->SetStream(vbo, *gpu_sd.GetAttribute(lol::String("in_Vertex")), vdecl->SetStream(vbo, *gpu_sd.GetAttribute(lol::String("in_Vertex")),
*gpu_sd.GetAttribute(lol::String("in_Normal")), *gpu_sd.GetAttribute(lol::String("in_Normal")),
*gpu_sd.GetAttribute(lol::String("in_Color")), *gpu_sd.GetAttribute(lol::String("in_Color")),
*gpu_sd.GetAttribute(lol::String("in_TexCoord"))); *gpu_sd.GetAttribute(lol::String("in_TexCoord")));
} }
else if (vflags == ((1 << VertexUsage::Position) | (1 << VertexUsage::Normal) |
(1 << VertexUsage::Color)))
else if (vflags == baseflag)
{ {
vdecl->SetStream(vbo, *gpu_sd.GetAttribute(lol::String("in_Vertex")), vdecl->SetStream(vbo, *gpu_sd.GetAttribute(lol::String("in_Vertex")),
*gpu_sd.GetAttribute(lol::String("in_Normal")), *gpu_sd.GetAttribute(lol::String("in_Normal")),


+ 5
- 0
src/tileset.cpp View File

@@ -174,6 +174,11 @@ ivec2 TileSet::GetSize(int tileid) const
return data->size; return data->size;
} }


vec2 TileSet::GetTileSize() const
{
return vec2(data->tx, data->ty);
}

ShaderTexture TileSet::GetTexture() const ShaderTexture TileSet::GetTexture() const
{ {
return data->m_texture->GetTexture(); return data->m_texture->GetTexture();


+ 1
- 0
src/tileset.h View File

@@ -43,6 +43,7 @@ public:
/* New methods */ /* New methods */
ivec2 GetCount() const; ivec2 GetCount() const;
ivec2 GetSize(int tileid) const; ivec2 GetSize(int tileid) const;
vec2 GetTileSize() const;
ShaderTexture GetTexture() const; ShaderTexture GetTexture() const;
void Bind(); void Bind();
void Unbind(); void Unbind();


Loading…
Cancel
Save