X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Ftexture1d.cpp;h=feff9f9883f3f1b39921193fd75eb4c4e5effde4;hb=33b6ca811172d402fc891eeed9cd2a5edc28d61d;hp=71c736f04da4ecb7971d22461434169445614f6b;hpb=2b7f8e45e75bec30c1ea27fc0efd8286f67adc3f;p=libs%2Fgl.git diff --git a/source/core/texture1d.cpp b/source/core/texture1d.cpp index 71c736f0..feff9f98 100644 --- a/source/core/texture1d.cpp +++ b/source/core/texture1d.cpp @@ -2,7 +2,6 @@ #include #include #include -#include "bindable.h" #include "error.h" #include "texture1d.h" @@ -43,21 +42,37 @@ void Texture1D::allocate(unsigned level) throw invalid_operation("Texture1D::allocate"); if(level>=levels) throw invalid_argument("Texture1D::allocate"); + + bool direct = ARB_texture_storage && ARB_direct_state_access; + if(!direct) + { + glActiveTexture(GL_TEXTURE0); + glBindTexture(target, id); + } + + allocate_(level); + + if(!direct) + glBindTexture(target, 0); +} + +void Texture1D::allocate_(unsigned level) +{ if(allocated&(1< _bind(!ARB_direct_state_access, this); + GLenum fmt = get_gl_pixelformat(storage_fmt); if(ARB_direct_state_access) - glTextureStorage1D(id, levels, storage_fmt, width); + glTextureStorage1D(id, levels, fmt, width); else - glTexStorage1D(target, levels, storage_fmt, width); + glTexStorage1D(target, levels, fmt, width); apply_swizzle(); allocated |= (1<=levels) throw out_of_range("Texture1D::image"); - unsigned w = get_level_size(level); - if(ARB_texture_storage) - return sub_image(level, 0, w, data); + return sub_image(level, 0, get_level_size(level), data); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(target, id); + + image_(level, data); + + if(auto_gen_mipmap && level==0) + { + generate_mipmap_(); + allocated |= (1<=levels) throw out_of_range("Texture1D::sub_image"); - Conditional _bind(!ARB_direct_state_access, this); - allocate(level); + bool direct = (ARB_direct_state_access && (ARB_texture_storage || (allocated&(1<