1 #include <msp/gl/extensions/arb_direct_state_access.h>
2 #include <msp/gl/extensions/arb_texture_storage.h>
3 #include <msp/gl/extensions/msp_texture1d.h>
6 #include "texture1d_backend.h"
11 OpenGLTexture1D::OpenGLTexture1D():
12 Texture(GL_TEXTURE_1D)
14 static Require _req(MSP_texture1D);
17 void OpenGLTexture1D::allocate()
19 unsigned width = static_cast<const Texture1D *>(this)->width;
20 unsigned levels = static_cast<const Texture1D *>(this)->levels;
25 GLenum gl_fmt = get_gl_pixelformat(storage_fmt);
26 if(ARB_texture_storage)
28 if(ARB_direct_state_access)
29 glTextureStorage1D(id, levels, gl_fmt, width);
33 glTexStorage1D(target, levels, gl_fmt, width);
39 glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, levels-1);
40 GLenum comp = get_gl_components(get_components(storage_fmt));
41 GLenum type = get_gl_type(get_component_type(storage_fmt));
42 for(unsigned i=0; i<levels; ++i)
44 unsigned lv_size = static_cast<const Texture1D *>(this)->get_level_size(i);
45 glTexImage1D(target, i, gl_fmt, lv_size, 0, comp, type, 0);
52 void OpenGLTexture1D::sub_image(unsigned level, int x, unsigned wd, const void *data)
54 GLenum comp = get_gl_components(get_components(storage_fmt));
55 GLenum type = get_gl_type(get_component_type(storage_fmt));
56 if(ARB_direct_state_access)
57 glTextureSubImage1D(id, level, x, wd, comp, type, data);
61 glTexSubImage1D(target, level, x, wd, comp, type, data);