]> git.lizzy.rs Git - minetest.git/blobdiff - src/tile.h
Merge pull request #29 from cisoun/master
[minetest.git] / src / tile.h
index 2a342313d4ea13110e40a92f8ca8aaaa3c0e905d..216d76508ec0347f97a769eb83e5941dc03e6852 100644 (file)
@@ -1,6 +1,6 @@
 /*
 Minetest-c55
-Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
+Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -25,6 +25,22 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "utility.h"
 #include <string>
 
+/*
+       tile.{h,cpp}: Texture handling stuff.
+*/
+
+/*
+       Gets the path to a texture by first checking if the texture exists
+       in texture_path and if not, using the data path.
+
+       Checks all supported extensions by replacing the original extension.
+
+       If not found, returns "".
+
+       Utilizes a thread-safe cache.
+*/
+std::string getTexturePath(const std::string &filename);
+
 /*
        Specifies a texture in an atlas.
 
@@ -103,10 +119,28 @@ struct SourceAtlasPointer
        }
 };
 
+/*
+       Implementation (to be used as a no-op on the server)
+*/
+class ITextureSource
+{
+public:
+       ITextureSource(){}
+       virtual ~ITextureSource(){}
+       virtual u32 getTextureId(const std::string &name){return 0;}
+       virtual u32 getTextureIdDirect(const std::string &name){return 0;}
+       virtual std::string getTextureName(u32 id){return "";}
+       virtual AtlasPointer getTexture(u32 id){return AtlasPointer(0);}
+       virtual AtlasPointer getTexture(const std::string &name)
+               {return AtlasPointer(0);}
+       virtual video::ITexture* getTextureRaw(const std::string &name)
+               {return NULL;}
+};
+
 /*
        Creates and caches textures.
 */
-class TextureSource
+class TextureSource : public ITextureSource
 {
 public:
        TextureSource(IrrlichtDevice *device);
@@ -243,8 +277,6 @@ enum MaterialType{
 /*
        This fully defines the looks of a tile.
        The SMaterial of a tile is constructed according to this.
-
-       TODO: Change this to use an AtlasPointer
 */
 struct TileSpec
 {
@@ -255,6 +287,7 @@ struct TileSpec
                // Use this so that leaves don't need a separate material
                //material_type(MATERIAL_ALPHA_SIMPLE),
                material_flags(
+                       //0 // <- DEBUG, Use the one below
                        MATERIAL_FLAG_BACKFACE_CULLING
                )
        {