Browse Source

mrpigeon: try the new tile definition system… which doesn’t work.

legacy
Sam Hocevar sam 11 years ago
parent
commit
bd2abf9a78
5 changed files with 20 additions and 2 deletions
  1. +1
    -1
      src/gpu/tile.lolfx
  2. +2
    -0
      src/scene.cpp
  3. +14
    -0
      src/tiler.cpp
  4. +1
    -0
      src/tiler.h
  5. +2
    -1
      src/tileset.h

+ 1
- 1
src/gpu/tile.lolfx View File

@@ -32,7 +32,7 @@ varying vec2 pass_TexCoord;
void main() void main()
{ {
vec4 col = texture2D(in_Texture, pass_TexCoord); 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] [vert.hlsl]


+ 2
- 0
src/scene.cpp View File

@@ -160,6 +160,8 @@ void Scene::Reset()


void Scene::AddTile(TileSet *tileset, int id, vec3 pos, int o, vec2 scale) void Scene::AddTile(TileSet *tileset, int id, vec3 pos, int o, vec2 scale)
{ {
ASSERT(id < tileset->GetTileCount());

Tile t; Tile t;
/* FIXME: this sorting only works for a 45-degree camera */ /* FIXME: this sorting only works for a 45-degree camera */
t.prio = -pos.y - 2 * 32 * pos.z + (o ? 0 : 32); t.prio = -pos.y - 2 * 32 * pos.z + (o ? 0 : 32);


+ 14
- 0
src/tiler.cpp View File

@@ -54,6 +54,20 @@ TileSet *Tiler::Register(char const *path, ivec2 size, ivec2 count)
return tileset; 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) void Tiler::Deregister(TileSet *tileset)
{ {
data->tilesets.RemoveSlot(tileset); data->tilesets.RemoveSlot(tileset);


+ 1
- 0
src/tiler.h View File

@@ -28,6 +28,7 @@ class Tiler
{ {
public: public:
static TileSet *Register(char const *path, ivec2 size, ivec2 count); static TileSet *Register(char const *path, ivec2 size, ivec2 count);
static TileSet *Register(char const *path);
static void Deregister(TileSet *); static void Deregister(TileSet *);


private: private:


+ 2
- 1
src/tileset.h View File

@@ -44,8 +44,10 @@ protected:


public: public:
/* New methods */ /* New methods */
int AddTile(ibox2 rect);
int GetTileCount() const; int GetTileCount() const;
ivec2 GetTileSize(int tileid) const; ivec2 GetTileSize(int tileid) const;

ivec2 GetTextureSize() const; ivec2 GetTextureSize() const;
ShaderTexture GetTexture() const; ShaderTexture GetTexture() const;
void Bind(); void Bind();
@@ -55,7 +57,6 @@ public:


private: private:
void Init(char const *path); void Init(char const *path);
int AddTile(ibox2 rect);


TileSetData *m_data; TileSetData *m_data;
}; };


Loading…
Cancel
Save