]> git.lizzy.rs Git - dragonfireclient.git/blob - src/tile.cpp
minecraft-like crafting
[dragonfireclient.git] / src / tile.cpp
1 /*
2 Minetest-c55
3 Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "tile.h"
21 #include "main.h"
22
23 // A mapping from tiles to paths of textures
24 const char * g_tile_texture_paths[TILES_COUNT] =
25 {
26         NULL,
27         "../data/stone.png",
28         "../data/water.png",
29         "../data/grass.png",
30         "../data/tree.png",
31         "../data/leaves.png",
32         "../data/grass_footsteps.png",
33         "../data/mese.png",
34         "../data/mud.png",
35         "../data/tree_top.png",
36         "../data/mud_with_grass.png",
37         "../data/cloud.png",
38         "../data/coalstone.png",
39         "../data/wood.png",
40 };
41
42 const char * tile_texture_path_get(u32 i)
43 {
44         assert(i < TILES_COUNT);
45
46         return g_tile_texture_paths[i];
47 }
48
49 // A mapping from tiles to materials
50 // Initialized at run-time.
51 video::SMaterial g_tile_materials[TILES_COUNT];
52
53 void tile_materials_preload(IrrlichtWrapper *irrlicht)
54 {
55         for(s32 i=0; i<TILES_COUNT; i++)
56         {
57                 const char *path = g_tile_texture_paths[i];
58
59                 video::ITexture *t = NULL;
60
61                 if(path != NULL)
62                 {
63                         t = irrlicht->getTexture(path);
64                         assert(t != NULL);
65                 }
66
67                 g_tile_materials[i].Lighting = false;
68                 g_tile_materials[i].BackfaceCulling = false;
69                 g_tile_materials[i].setFlag(video::EMF_BILINEAR_FILTER, false);
70                 g_tile_materials[i].setFlag(video::EMF_ANTI_ALIASING, video::EAAM_OFF);
71                 //if(i != TILE_WATER)
72                 g_tile_materials[i].setFlag(video::EMF_FOG_ENABLE, true);
73                 
74                 //g_tile_materials[i].setFlag(video::EMF_TEXTURE_WRAP, video::ETC_REPEAT);
75                 //g_tile_materials[i].setFlag(video::EMF_ANISOTROPIC_FILTER, false);
76
77                 g_tile_materials[i].setTexture(0, t);
78         }
79         
80         g_tile_materials[TILE_WATER].MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
81         //g_tile_materials[TILE_WATER].MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
82 }
83
84 video::SMaterial & tile_material_get(u32 i)
85 {
86         assert(i < TILES_COUNT);
87
88         return g_tile_materials[i];
89 }
90