From bd2abf9a786717821efb1549f1285b9980685cae Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 28 Mar 2013 17:01:12 +0000 Subject: [PATCH] =?UTF-8?q?mrpigeon:=20try=20the=20new=20tile=20definition?= =?UTF-8?q?=20system=E2=80=A6=20which=20doesn=E2=80=99t=20work.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gpu/tile.lolfx | 2 +- src/scene.cpp | 2 ++ src/tiler.cpp | 14 ++++++++++++++ src/tiler.h | 1 + src/tileset.h | 3 ++- 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/gpu/tile.lolfx b/src/gpu/tile.lolfx index 8e373b83..52d7d2e3 100644 --- a/src/gpu/tile.lolfx +++ b/src/gpu/tile.lolfx @@ -32,7 +32,7 @@ varying vec2 pass_TexCoord; void main() { vec4 col = texture2D(in_Texture, pass_TexCoord); - gl_FragColor = col; + gl_FragColor = mix(col, vec4(1.0, 1.0, 0.0, 1.0), 0.5); } [vert.hlsl] diff --git a/src/scene.cpp b/src/scene.cpp index 413e2621..31a4adc1 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -160,6 +160,8 @@ void Scene::Reset() void Scene::AddTile(TileSet *tileset, int id, vec3 pos, int o, vec2 scale) { + ASSERT(id < tileset->GetTileCount()); + Tile t; /* FIXME: this sorting only works for a 45-degree camera */ t.prio = -pos.y - 2 * 32 * pos.z + (o ? 0 : 32); diff --git a/src/tiler.cpp b/src/tiler.cpp index 80de480a..509422e2 100644 --- a/src/tiler.cpp +++ b/src/tiler.cpp @@ -54,6 +54,20 @@ TileSet *Tiler::Register(char const *path, ivec2 size, ivec2 count) return tileset; } +TileSet *Tiler::Register(char const *path) +{ + int id = data->tilesets.MakeSlot(path); + TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id); + + if (!tileset) + { + tileset = new TileSet(path); + data->tilesets.SetEntity(id, tileset); + } + + return tileset; +} + void Tiler::Deregister(TileSet *tileset) { data->tilesets.RemoveSlot(tileset); diff --git a/src/tiler.h b/src/tiler.h index 675db1de..76cc2f5a 100644 --- a/src/tiler.h +++ b/src/tiler.h @@ -28,6 +28,7 @@ class Tiler { public: static TileSet *Register(char const *path, ivec2 size, ivec2 count); + static TileSet *Register(char const *path); static void Deregister(TileSet *); private: diff --git a/src/tileset.h b/src/tileset.h index 44dd5ff2..0d3cef1b 100644 --- a/src/tileset.h +++ b/src/tileset.h @@ -44,8 +44,10 @@ protected: public: /* New methods */ + int AddTile(ibox2 rect); int GetTileCount() const; ivec2 GetTileSize(int tileid) const; + ivec2 GetTextureSize() const; ShaderTexture GetTexture() const; void Bind(); @@ -55,7 +57,6 @@ public: private: void Init(char const *path); - int AddTile(ibox2 rect); TileSetData *m_data; };