TilemapVX: Use SimpleShader for unanimated ground layers
Also remove some useless member variables.
This commit is contained in:
parent
6bc3460294
commit
ac9b98157e
|
@ -69,8 +69,6 @@ struct TilemapVXPrivate : public ViewportElement, TileAtlasVX::Reader
|
||||||
size_t aboveQuads;
|
size_t aboveQuads;
|
||||||
|
|
||||||
uint16_t frameIdx;
|
uint16_t frameIdx;
|
||||||
uint8_t aniIdxA;
|
|
||||||
uint8_t aniIdxC;
|
|
||||||
Vec2 aniOffset;
|
Vec2 aniOffset;
|
||||||
|
|
||||||
bool atlasDirty;
|
bool atlasDirty;
|
||||||
|
@ -110,8 +108,6 @@ struct TilemapVXPrivate : public ViewportElement, TileAtlasVX::Reader
|
||||||
groundQuads(0),
|
groundQuads(0),
|
||||||
aboveQuads(0),
|
aboveQuads(0),
|
||||||
frameIdx(0),
|
frameIdx(0),
|
||||||
aniIdxA(0),
|
|
||||||
aniIdxC(0),
|
|
||||||
atlasDirty(true),
|
atlasDirty(true),
|
||||||
buffersDirty(false),
|
buffersDirty(false),
|
||||||
mapViewportDirty(false),
|
mapViewportDirty(false),
|
||||||
|
@ -292,12 +288,27 @@ struct TilemapVXPrivate : public ViewportElement, TileAtlasVX::Reader
|
||||||
/* SceneElement */
|
/* SceneElement */
|
||||||
void draw()
|
void draw()
|
||||||
{
|
{
|
||||||
TilemapVXShader &shader = shState->shaders().tilemapVX;
|
ShaderBase *shader;
|
||||||
shader.bind();
|
|
||||||
shader.setTexSize(Vec2i(atlas.width, atlas.height));
|
if (bitmaps[BM_A1] != 0)
|
||||||
shader.applyViewportProj();
|
{
|
||||||
shader.setTranslation(dispPos);
|
/* Animated tileset */
|
||||||
shader.setAniOffset(aniOffset);
|
TilemapVXShader &tmShader = shState->shaders().tilemapVX;
|
||||||
|
tmShader.bind();
|
||||||
|
tmShader.setAniOffset(aniOffset);
|
||||||
|
|
||||||
|
shader = &tmShader;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Static tileset */
|
||||||
|
shader = &shState->shaders().simple;
|
||||||
|
shader->bind();
|
||||||
|
}
|
||||||
|
|
||||||
|
shader->setTexSize(Vec2i(atlas.width, atlas.height));
|
||||||
|
shader->applyViewportProj();
|
||||||
|
shader->setTranslation(dispPos);
|
||||||
|
|
||||||
TEX::bind(atlas.tex);
|
TEX::bind(atlas.tex);
|
||||||
GLMeta::vaoBind(vao);
|
GLMeta::vaoBind(vao);
|
||||||
|
@ -400,10 +411,10 @@ void TilemapVX::update()
|
||||||
const uint8_t aniIndicesC[3*4] =
|
const uint8_t aniIndicesC[3*4] =
|
||||||
{ 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2 };
|
{ 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2 };
|
||||||
|
|
||||||
p->aniIdxA = aniIndicesA[p->frameIdx / 30];
|
uint8_t aniIdxA = aniIndicesA[p->frameIdx / 30];
|
||||||
p->aniIdxC = aniIndicesC[p->frameIdx / 30];
|
uint8_t aniIdxC = aniIndicesC[p->frameIdx / 30];
|
||||||
|
|
||||||
p->aniOffset = Vec2(p->aniIdxA * 2 * 32, p->aniIdxC * 32);
|
p->aniOffset = Vec2(aniIdxA * 2 * 32, aniIdxC * 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
TilemapVX::BitmapArray &TilemapVX::getBitmapArray() const
|
TilemapVX::BitmapArray &TilemapVX::getBitmapArray() const
|
||||||
|
|
Loading…
Reference in New Issue