]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texture1d.cpp
Throw an exception if Texture*::allocate is called before storage
[libs/gl.git] / source / texture1d.cpp
index 6affe8999a2414ae61b950c8f3c232a9269e4af1..c5e57df22843d0e0dc84675c24d08bebcaaf1c74 100644 (file)
@@ -32,6 +32,8 @@ void Texture1D::storage(PixelFormat fmt, unsigned wd)
 
 void Texture1D::allocate(unsigned level)
 {
+       if(width==0)
+               throw invalid_operation("Texture1D::allocate");
        if(allocated&(1<<level))
                return;
 
@@ -65,7 +67,7 @@ void Texture1D::image(unsigned level, PixelFormat fmt, DataType type, const void
                return sub_image(level, 0, w, fmt, type, data);
 
        BindRestore _bind(this);
-       glTexImage1D(target, level, ifmt, w, 0, fmt, type, data);
+       glTexImage1D(target, level, ifmt, w, 0, get_upload_format(fmt), type, data);
 
        allocated |= 1<<level;
        if(gen_mipmap && level==0)
@@ -83,6 +85,7 @@ void Texture1D::sub_image(unsigned level, int x, unsigned wd, PixelFormat fmt, D
        Conditional<BindRestore> _bind(!ARB_direct_state_access, this);
        allocate(level);
 
+       fmt = get_upload_format(fmt);
        if(ARB_direct_state_access)
                glTextureSubImage1D(id, level, x, wd, fmt, type, data);
        else