]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texture1d.cpp
Use UNSIGNED_SHORT for allocating DEPTH_COMPONENT textures
[libs/gl.git] / source / texture1d.cpp
index f700d013b5dc6a55f88196695b8a8ec83b2242b9..046fca6fa4eccbe49a5a5174ba498adefc1b892c 100644 (file)
@@ -1,3 +1,4 @@
+#include <msp/gl/extensions/msp_texture1d.h>
 #include "bindable.h"
 #include "error.h"
 #include "texture1d.h"
@@ -12,7 +13,9 @@ Texture1D::Texture1D():
        ifmt(RGB),
        width(0),
        allocated(0)
-{ }
+{
+       static Require _req(MSP_texture1D);
+}
 
 void Texture1D::storage(PixelFormat fmt, unsigned wd)
 {
@@ -31,7 +34,8 @@ void Texture1D::allocate(unsigned level)
        if(allocated&(1<<level))
                return;
 
-       image(level, get_base_pixelformat(ifmt), UNSIGNED_BYTE, 0);
+       PixelFormat base_fmt = get_base_pixelformat(ifmt);
+       image(level, base_fmt, get_alloc_type(base_fmt), 0);
 }
 
 void Texture1D::image(unsigned level, PixelFormat fmt, DataType type, const void *data)
@@ -47,6 +51,7 @@ void Texture1D::image(unsigned level, PixelFormat fmt, DataType type, const void
        allocated |= 1<<level;
        if(gen_mipmap && level==0)
        {
+               auto_generate_mipmap();
                for(; w; w>>=1, ++level) ;
                allocated |= (1<<level)-1;
        }