18 #ifndef HEADER_SP_TEXTURE_HPP
19 #define HEADER_SP_TEXTURE_HPP
21 #include "graphics/gl_headers.hpp"
22 #include "utils/log.hpp"
23 #include "utils/no_copy.hpp"
30 #include <dimension2d.h>
34 namespace video {
class IImageLoader;
class IImage; }
42 extern "C" void squishCompressImage(uint8_t* rgba,
int width,
int height,
43 int pitch,
void* blocks,
unsigned flags);
53 std::string m_container_id;
55 GLuint m_texture_name = 0;
57 std::atomic_uint m_width;
59 std::atomic_uint m_height;
63 const bool m_undo_srgb;
66 void generateHQMipmap(
void* in,
67 const std::vector<std::pair<core::dimension2du,
68 unsigned> >&, uint8_t* out);
70 void generateQuickMipmap(std::shared_ptr<video::IImage> first_image,
71 const std::vector<std::pair<core::dimension2du,
72 unsigned> >&, uint8_t* out);
74 std::shared_ptr<video::IImage>
75 getImageFromPath(
const std::string& path)
const;
77 std::shared_ptr<video::IImage> getMask(
const core::dimension2du& s)
const;
79 void applyMask(video::IImage* texture, video::IImage* mask);
81 void createTransparent()
84 glBindTexture(GL_TEXTURE_2D, m_texture_name);
85 static uint32_t data[4] = { 0, 0, 0, 0 };
86 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0,
92 GL_UNSIGNED_BYTE, data);
93 glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0,
99 GL_UNSIGNED_BYTE, data);
100 glBindTexture(GL_TEXTURE_2D, 0);
106 void createWhite(
bool private_init =
true)
109 glBindTexture(GL_TEXTURE_2D, m_texture_name);
110 static int32_t data[4] = { -1, -1, -1, -1 };
111 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0,
117 GL_UNSIGNED_BYTE, data);
118 glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0,
124 GL_UNSIGNED_BYTE, data);
125 glBindTexture(GL_TEXTURE_2D, 0);
141 bool texImage2d(std::shared_ptr<video::IImage> texture,
142 std::shared_ptr<video::IImage> mipmaps);
144 bool compressedTexImage2d(std::shared_ptr<video::IImage> texture,
145 const std::vector<std::pair<core::dimension2du,
146 unsigned> >& mipmap_sizes);
148 bool saveCompressedTexture(std::shared_ptr<video::IImage> texture,
149 const std::vector<std::pair<core::dimension2du,
151 const std::string& cache_location);
153 std::vector<std::pair<core::dimension2du, unsigned> >
154 compressTexture(std::shared_ptr<video::IImage>& texture);
156 bool useTextureCache(
const std::string& full_path,
157 const std::string& cache_directory,
158 std::string* cache_loc);
160 std::shared_ptr<video::IImage> getTextureCache(
const std::string& path,
161 std::vector<std::pair<core::dimension2du, unsigned> >* sizes);
165 static std::shared_ptr<SPTexture> getWhiteTexture()
168 tex->m_path =
"unicolor_white";
169 return std::shared_ptr<SPTexture>(tex);
172 static std::shared_ptr<SPTexture> getTransparentTexture()
175 return std::shared_ptr<SPTexture>(tex);
179 const std::string& container_id);
183 const std::string& getPath()
const {
return m_path; }
185 std::shared_ptr<video::IImage> getTextureImage()
const;
187 GLuint getTextureHandler()
const {
return m_texture_name; }
189 bool initialized()
const
190 {
return m_width.load() != 0 && m_height.load() != 0; }
192 unsigned getWidth()
const {
return m_width.load(); }
194 unsigned getHeight()
const {
return m_height.load(); }
196 bool threadedLoad(
const std::string& cache_directory);
198 std::string getCacheDirectory();
Definition: material.hpp:48
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
Definition: sp_texture.hpp:49