summaryrefslogtreecommitdiff
path: root/src/tile.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2010-12-20 22:03:49 +0200
committerPerttu Ahola <celeron55@gmail.com>2010-12-20 22:03:49 +0200
commit123e8fdf53ffb40c7464d0559a49e048fed79d7d (patch)
tree98df766999e684e46629bfa886195427adda2967 /src/tile.cpp
parent6350c5d7a606924a12ba41468d126ff94d9e6d36 (diff)
downloadminetest-123e8fdf53ffb40c7464d0559a49e048fed79d7d.tar.gz
minetest-123e8fdf53ffb40c7464d0559a49e048fed79d7d.tar.bz2
minetest-123e8fdf53ffb40c7464d0559a49e048fed79d7d.zip
framework for modifying textures
Diffstat (limited to 'src/tile.cpp')
-rw-r--r--src/tile.cpp43
1 files changed, 27 insertions, 16 deletions
diff --git a/src/tile.cpp b/src/tile.cpp
index 5161b2284..174c72fdf 100644
--- a/src/tile.cpp
+++ b/src/tile.cpp
@@ -18,36 +18,40 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include "tile.h"
+#include "irrlichtwrapper.h"
-const char * g_tile_texture_names[TILES_COUNT] =
+// A mapping from tiles to paths of textures
+const char * g_tile_texture_paths[TILES_COUNT] =
{
NULL,
- "stone",
- "water",
- "grass",
- "tree",
- "leaves",
- "grass_footsteps",
- "mese",
- "mud",
- "tree_top",
- "mud_with_grass",
- "cloud",
+ "../data/stone.png",
+ "../data/water.png",
+ "../data/grass.png",
+ "../data/tree.png",
+ "../data/leaves.png",
+ "../data/grass_footsteps.png",
+ "../data/mese.png",
+ "../data/mud.png",
+ "../data/tree_top.png",
+ "../data/mud_with_grass.png",
+ "../data/cloud.png",
};
+// A mapping from tiles to materials
+// Initialized at run-time.
video::SMaterial g_tile_materials[TILES_COUNT];
-void tile_materials_preload(TextureCache &cache)
+void tile_materials_preload(IrrlichtWrapper *irrlicht)
{
for(s32 i=0; i<TILES_COUNT; i++)
{
- const char *name = g_tile_texture_names[i];
+ const char *path = g_tile_texture_paths[i];
video::ITexture *t = NULL;
- if(name != NULL)
+ if(path != NULL)
{
- t = cache.get(name);
+ t = irrlicht->getTexture(path);
assert(t != NULL);
}
@@ -68,3 +72,10 @@ void tile_materials_preload(TextureCache &cache)
//g_tile_materials[TILE_WATER].MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
}
+video::SMaterial & tile_material_get(u32 i)
+{
+ assert(i < TILES_COUNT);
+
+ return g_tile_materials[i];
+}
+