1 #include <msp/gl/extensions/msp_texture1d.h>
11 Texture1D::Texture1D():
12 Texture(GL_TEXTURE_1D),
17 static Require _req(MSP_texture1D);
20 void Texture1D::storage(PixelFormat fmt, unsigned wd)
23 throw invalid_operation("Texture1D::storage");
25 throw invalid_argument("Texture1D::storage");
26 require_pixelformat(fmt);
32 void Texture1D::allocate(unsigned level)
34 if(allocated&(1<<level))
37 image(level, get_base_pixelformat(ifmt), UNSIGNED_BYTE, 0);
40 void Texture1D::image(unsigned level, PixelFormat fmt, DataType type, const void *data)
43 throw invalid_operation("Texture1D::image");
45 unsigned w = get_level_size(level);
47 BindRestore _bind(this);
48 glTexImage1D(target, level, ifmt, w, 0, fmt, type, data);
50 allocated |= 1<<level;
51 if(gen_mipmap && level==0)
53 for(; w; w>>=1, ++level) ;
54 allocated |= (1<<level)-1;
58 unsigned Texture1D::get_level_size(unsigned level)
63 UInt64 Texture1D::get_data_size() const
65 return id ? width*get_pixel_size(ifmt) : 0;