瀏覽代碼

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

legacy
Sam Hocevar sam 11 年之前
父節點
當前提交
bd2abf9a78
共有 5 個檔案被更改,包括 20 行新增2 行删除
  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 查看文件

@@ -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]


+ 2
- 0
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);


+ 14
- 0
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);


+ 1
- 0
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:


+ 2
- 1
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;
};


Loading…
取消
儲存