]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/client/tile.h
Clean up font caching, fix bitmap fonts
[dragonfireclient.git] / src / client / tile.h
index 8a8c5bd4788c05f381d7300b8f8ecfb76eea4d7f..533df676e2f2f5523f1cdd2c823d959088840e4a 100644 (file)
@@ -27,6 +27,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include <SMaterial.h>
 #include <memory>
 #include "util/numeric.h"
+#include "config.h"
+
+#if ENABLE_GLES
+#include <IVideoDriver.h>
+#endif
 
 class IGameDef;
 struct TileSpec;
@@ -59,29 +64,10 @@ std::string getImagePath(std::string path);
 
        Utilizes a thread-safe cache.
 */
-std::string getTexturePath(const std::string &filename);
+std::string getTexturePath(const std::string &filename, bool *is_base_pack = nullptr);
 
 void clearTextureNameCache();
 
-/*
-       ITextureSource::generateTextureFromMesh parameters
-*/
-namespace irr {namespace scene {class IMesh;}}
-struct TextureFromMeshParams
-{
-       scene::IMesh *mesh = nullptr;
-       core::dimension2d<u32> dim;
-       std::string rtt_texture_name;
-       bool delete_texture_on_shutdown;
-       v3f camera_position;
-       v3f camera_lookat;
-       core::CMatrix4<f32> camera_projection_matrix;
-       video::SColorf ambient_light;
-       v3f light_position;
-       video::SColorf light_color;
-       f32 light_radius;
-};
-
 /*
        TextureSource creates and caches textures.
 */
@@ -119,8 +105,6 @@ class ITextureSource : public ISimpleTextureSource
         */
        virtual Palette* getPalette(const std::string &name) = 0;
        virtual bool isKnownSourceImage(const std::string &name)=0;
-       virtual video::ITexture* generateTextureFromMesh(
-                       const TextureFromMeshParams &params)=0;
        virtual video::ITexture* getNormalTexture(const std::string &name)=0;
        virtual video::SColor getTextureAverageColor(const std::string &name)=0;
        virtual video::ITexture *getShaderFlagsTexture(bool normalmap_present)=0;
@@ -139,8 +123,6 @@ class IWritableTextureSource : public ITextureSource
        virtual video::ITexture* getTexture(
                        const std::string &name, u32 *id = nullptr)=0;
        virtual bool isKnownSourceImage(const std::string &name)=0;
-       virtual video::ITexture* generateTextureFromMesh(
-                       const TextureFromMeshParams &params)=0;
 
        virtual void processQueue()=0;
        virtual void insertSourceImage(const std::string &name, video::IImage *img)=0;
@@ -152,8 +134,9 @@ class IWritableTextureSource : public ITextureSource
 
 IWritableTextureSource *createTextureSource();
 
-#ifdef __ANDROID__
-video::IImage * Align2Npot2(video::IImage * image, video::IVideoDriver* driver);
+#if ENABLE_GLES
+bool hasNPotSupport();
+video::IImage * Align2Npot2(video::IImage * image, irr::video::IVideoDriver* driver);
 #endif
 
 enum MaterialType{
@@ -163,7 +146,10 @@ enum MaterialType{
        TILE_MATERIAL_LIQUID_OPAQUE,
        TILE_MATERIAL_WAVING_LEAVES,
        TILE_MATERIAL_WAVING_PLANTS,
-       TILE_MATERIAL_OPAQUE
+       TILE_MATERIAL_OPAQUE,
+       TILE_MATERIAL_WAVING_LIQUID_BASIC,
+       TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT,
+       TILE_MATERIAL_WAVING_LIQUID_OPAQUE,
 };
 
 // Material flags
@@ -209,7 +195,8 @@ struct TileLayer
                        texture_id == other.texture_id &&
                        material_type == other.material_type &&
                        material_flags == other.material_flags &&
-                       color == other.color;
+                       color == other.color &&
+                       scale == other.scale;
        }
 
        /*!
@@ -226,17 +213,23 @@ struct TileLayer
                switch (material_type) {
                case TILE_MATERIAL_OPAQUE:
                case TILE_MATERIAL_LIQUID_OPAQUE:
+               case TILE_MATERIAL_WAVING_LIQUID_OPAQUE:
                        material.MaterialType = video::EMT_SOLID;
                        break;
                case TILE_MATERIAL_BASIC:
                case TILE_MATERIAL_WAVING_LEAVES:
                case TILE_MATERIAL_WAVING_PLANTS:
+               case TILE_MATERIAL_WAVING_LIQUID_BASIC:
+                       material.MaterialTypeParam = 0.5;
                        material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
                        break;
                case TILE_MATERIAL_ALPHA:
                case TILE_MATERIAL_LIQUID_TRANSPARENT:
+               case TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT:
                        material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
                        break;
+               default:
+                       break;
                }
                material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) != 0;
                if (!(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL)) {
@@ -296,6 +289,8 @@ struct TileLayer
         * a color then the color of the node owning this tile.
         */
        video::SColor color;
+
+       u8 scale;
 };
 
 /*!
@@ -303,10 +298,7 @@ struct TileLayer
  */
 struct TileSpec
 {
-       TileSpec() {
-               for (int layer = 0; layer < MAX_TILE_LAYERS; layer++)
-                       layers[layer] = TileLayer();
-       }
+       TileSpec() = default;
 
        /*!
         * Returns true if this tile can be merged with the other tile.
@@ -323,9 +315,14 @@ struct TileSpec
                        && emissive_light == other.emissive_light;
        }
 
+       //! If true, the tile rotation is ignored.
+       bool world_aligned = false;
+       //! Tile rotation.
        u8 rotation = 0;
        //! This much light does the tile emit.
        u8 emissive_light = 0;
        //! The first is base texture, the second is overlay.
        TileLayer layers[MAX_TILE_LAYERS];
 };
+
+std::vector<std::string> getTextureDirs();