Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
imagesource.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
7#include <IImage.h>
8#include <map>
9#include <set>
10#include <string>
11
12using namespace irr;
13
14// This file is only used for internal generation of images.
15// Use texturesource.h to handle textures.
16
17// A cache used for storing source images.
18// (A "source image" is an unmodified image directly taken from the filesystem.)
19// Does not contain modified images.
21public:
23
24 void insert(const std::string &name, video::IImage *img, bool prefer_local);
25
26 video::IImage* get(const std::string &name);
27
28 // Primarily fetches from cache, secondarily tries to read from filesystem.
29 video::IImage *getOrLoad(const std::string &name);
30private:
31 std::map<std::string, video::IImage*> m_images;
32};
33
34// Generates images using texture modifiers, and caches source images.
37
43 video::IImage* generateImage(std::string_view name, std::set<std::string> &source_image_names);
44
45 // Insert a source image into the cache without touching the filesystem.
46 void insertSourceImage(const std::string &name, video::IImage *img, bool prefer_local);
47
48 // TODO should probably be moved elsewhere
49 static video::SColor getImageAverageColor(const video::IImage &image);
50
51private:
52
53 // Generate image based on a string like "stone.png" or "[crack:1:0".
54 // If baseimg is NULL, it is created. Otherwise stuff is made on it.
55 // source_image_names is important to determine when to flush the image from a cache (dynamic media).
56 bool generateImagePart(std::string_view part_of_name, video::IImage *& baseimg,
57 std::set<std::string> &source_image_names);
58
59 // Cached settings needed for making textures from meshes
64
65 // Cache of source images
67};
Definition imagesource.h:20
video::IImage * get(const std::string &name)
Definition imagesource.cpp:64
void insert(const std::string &name, video::IImage *img, bool prefer_local)
Definition imagesource.cpp:30
video::IImage * getOrLoad(const std::string &name)
Definition imagesource.cpp:74
~SourceImageCache()
Definition imagesource.cpp:23
std::map< std::string, video::IImage * > m_images
Definition imagesource.h:31
Definition clientmap.h:30
Definition imagesource.h:35
static video::SColor getImageAverageColor(const video::IImage &image)
Definition imagesource.cpp:1940
bool m_setting_mipmap
Definition imagesource.h:60
bool m_setting_anisotropic_filter
Definition imagesource.h:63
bool generateImagePart(std::string_view part_of_name, video::IImage *&baseimg, std::set< std::string > &source_image_names)
Definition imagesource.cpp:1000
video::IImage * generateImage(std::string_view name, std::set< std::string > &source_image_names)
Definition imagesource.cpp:1827
ImageSource()
Definition imagesource.cpp:1820
SourceImageCache m_sourcecache
Definition imagesource.h:66
bool m_setting_bilinear_filter
Definition imagesource.h:62
void insertSourceImage(const std::string &name, video::IImage *img, bool prefer_local)
Definition imagesource.cpp:1966
bool m_setting_trilinear_filter
Definition imagesource.h:61