#ifndef MSP_GL_TEXTURE1D_H_
#define MSP_GL_TEXTURE1D_H_
-#include "texture.h"
+#include <string>
+#include "texture1d_backend.h"
namespace Msp {
namespace GL {
-class Texture1D: public Texture
+/**
+One-dimensional texture, consisting of a single row of texels.
+*/
+class Texture1D: public Texture1DBackend
{
+ friend Texture1DBackend;
+
public:
class Loader: public DataFile::DerivedObjectLoader<Texture1D, Texture::Loader>
{
private:
void init();
- void raw_data(const std::string &);
void storage(PixelFormat, unsigned);
void storage_levels(PixelFormat, unsigned, unsigned);
};
private:
- unsigned width;
- unsigned levels;
- unsigned allocated;
+ unsigned width = 0;
+ unsigned levels = 0;
public:
- Texture1D();
+ /** Sets storage format and size and allocates memory for the texture. If
+ lv is zero, a complete mipmap pyramid is automatically created. Storage
+ cannot be changed once set. */
+ void storage(PixelFormat, unsigned wd, unsigned lv = 0);
+
+ virtual void image(unsigned level, const void *);
- void storage(PixelFormat, unsigned, unsigned = 0);
+ /** Replaces a range of texels in the texture. Allocated storage must
+ exist. The image data is interpreted according to the storage format and
+ the range must be fully inside the selected mipmap level. */
+ void sub_image(unsigned level, unsigned x, unsigned wd, const void *);
- void allocate(unsigned);
- void image(unsigned, const void *);
- void sub_image(unsigned, int, unsigned, const void *);
virtual void image(const Graphics::Image &, unsigned = 0);
- using Texture::image;
+
unsigned get_width() const { return width; }
private:
public:
virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; }
- virtual std::uint64_t get_data_size() const;
+ virtual std::size_t get_data_size() const;
virtual void unload() { }
};