add("generate_mipmap", &Loader::generate_mipmap);
add("image_data", &Loader::image_data);
add("mipmap_levels", &Loader::mipmap_levels);
+ add("raw_data", &Loader::raw_data);
}
void Texture::Loader::finish()
levels = l;
}
+void Texture::Loader::raw_data(const string &data)
+{
+ if(obj.manager)
+ obj.set_manager(0);
+
+ obj.image(0, data.data());
+}
+
} // namespace GL
} // namespace Msp
void generate_mipmap(bool);
void image_data(const std::string &);
void mipmap_levels(unsigned);
+ void raw_data(const std::string &);
};
public:
using TextureBackend::generate_mipmap;
+ /** Replaces contents of an entire mipmap level. Allocated storage must
+ exist. The image data is interpreted according to the storage format and
+ must have size matching the selected mipmap level. */
+ virtual void image(unsigned level, const void *) = 0;
+
/** Loads an image into the texture from a file. */
virtual void load_image(const std::string &, unsigned = 0);
void Texture1D::Loader::init()
{
- add("raw_data", &Loader::raw_data);
add("storage", &Loader::storage);
add("storage", &Loader::storage_levels);
}
-void Texture1D::Loader::raw_data(const string &data)
-{
- obj.image(0, data.data());
-}
-
void Texture1D::Loader::storage(PixelFormat fmt, unsigned w)
{
obj.storage(fmt, w);
private:
void init();
- void raw_data(const std::string &);
void storage(PixelFormat, unsigned);
void storage_levels(PixelFormat, unsigned, unsigned);
};
cannot be changed once set. */
void storage(PixelFormat, unsigned wd, unsigned lv = 0);
- /** Replaces contents of an entire mipmap level. Allocated storage must
- exist. The image data is interpreted according to the storage format and
- must have size matching the selected mipmap level. */
- void image(unsigned level, const void *);
+ virtual void image(unsigned level, const void *);
/** Replaces a range of texels in the texture. Allocated storage must
exist. The image data is interpreted according to the storage format and
void Texture2D::Loader::init()
{
- add("raw_data", &Loader::raw_data);
add("storage", &Loader::storage);
add("storage", &Loader::storage_levels);
}
-void Texture2D::Loader::raw_data(const string &data)
-{
- if(obj.manager)
- obj.set_manager(0);
- obj.image(0, data.data());
-}
-
void Texture2D::Loader::storage(PixelFormat fmt, unsigned w, unsigned h)
{
obj.storage(fmt, w, h);
private:
void init();
- void raw_data(const std::string &);
void storage(PixelFormat, unsigned, unsigned);
void storage_levels(PixelFormat, unsigned, unsigned, unsigned);
};
cannot be changed once set. */
void storage(PixelFormat, unsigned wd, unsigned ht, unsigned lv = 0);
- /** Replaces contents of an entire mipmap level. Allocated storage must
- exist. The image data is interpreted according to the storage format and
- must have size matching the selected mipmap level. */
- virtual void image(unsigned level, const void *);
+ void image(unsigned level, const void *) override;
/** Replaces a rectangular region of the texture. Allocated storage must
exist. The image data is interpreted according to the storage format and
allocate();
}
+void Texture2DMultisample::image(unsigned, const void *)
+{
+ throw invalid_operation("Texture2DMultisample::image");
+}
+
void Texture2DMultisample::image(const Graphics::Image &, unsigned)
{
throw invalid_operation("Texture2DMultisample::image");
for the texture. */
void storage(PixelFormat, unsigned wd, unsigned ht, unsigned sm);
+ virtual void image(unsigned, const void *);
virtual void image(const Graphics::Image &, unsigned = 0);
unsigned get_width() const { return width; }
void Texture3D::Loader::init()
{
- add("raw_data", &Loader::raw_data);
add("storage", &Loader::storage);
add("storage", &Loader::storage_levels);
}
-void Texture3D::Loader::raw_data(const string &data)
-{
- obj.image(0, data.data());
-}
-
void Texture3D::Loader::storage(PixelFormat fmt, unsigned w, unsigned h, unsigned d)
{
obj.storage(fmt, w, h, d);
private:
void init();
- void raw_data(const std::string &);
void storage(PixelFormat, unsigned, unsigned, unsigned);
void storage_levels(PixelFormat, unsigned, unsigned, unsigned, unsigned);
};
allocate();
}
+void TextureCube::image(unsigned level, const void *data)
+{
+ const char *pixels = static_cast<const char *>(data);
+ unsigned face_size = size*size*get_pixel_size(storage_fmt);
+ for(unsigned i=0; i<6; ++i)
+ image(static_cast<TextureCubeFace>(i), level, pixels+i*face_size);
+}
+
void TextureCube::image(TextureCubeFace face, unsigned level, const void *data)
{
unsigned lsz = get_level_size(level);
else if(w!=size || h!=size)
throw incompatible_data("TextureCube::image");
- const char *pixels = reinterpret_cast<const char *>(img.get_pixels());
- unsigned face_size = img.get_stride()*size;
- for(unsigned i=0; i<6; ++i)
- image(static_cast<TextureCubeFace>(i), 0, pixels+i*face_size);
+ image(0, img.get_pixels());
}
unsigned TextureCube::get_n_levels() const
cannot be changed once set. */
void storage(PixelFormat, unsigned size, unsigned lv = 0);
+ virtual void image(unsigned, const void *);
+
/** Replaces contents of a single face. Allocated storage must exist. The
image data is interpreted according to the storage format and must have size
matching the selected mipmap level. */