]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texture2darray.cpp
Remove the deprecated ProgramBuilder class
[libs/gl.git] / source / texture2darray.cpp
index 4123f0e2906e261b64fe0227c27894a00f8c7a09..1ecb4cf2be69e1b34a28f1f8b8cea643b84e2325 100644 (file)
@@ -15,14 +15,21 @@ Texture2DArray::Texture2DArray():
        static Require _req(EXT_texture_array);
 }
 
-void Texture2DArray::layer_image(unsigned level, unsigned z, PixelFormat fmt, DataType type, const void *data)
+void Texture2DArray::layer_image(unsigned level, unsigned z, const void *data)
 {
        unsigned w = get_width();
        unsigned h = get_height();
        unsigned d = get_depth();
        get_level_size(level, w, h, d);
 
-       sub_image(level, 0, 0, z, w, h, 1, fmt, type, data);
+       sub_image(level, 0, 0, z, w, h, 1, data);
+}
+
+void Texture2DArray::layer_image(unsigned level, unsigned z, PixelComponents comp, DataType type, const void *data)
+{
+       if(comp!=get_components(format) || type!=get_component_type(format))
+               throw incompatible_data("Texture2DArray::layer_image");
+       layer_image(level, z, data);
 }
 
 void Texture2DArray::layer_image(unsigned level, unsigned z, const Graphics::Image &img)
@@ -32,14 +39,16 @@ void Texture2DArray::layer_image(unsigned level, unsigned z, const Graphics::Ima
 
        unsigned w = img.get_width();
        unsigned h = img.get_height();
-       PixelFormat fmt = pixelformat_from_graphics(img.get_format());
        if(w!=get_width() || h!=get_height())
                throw incompatible_data("Texture2DArray::layer_image");
+       PixelFormat fmt = pixelformat_from_image(img);
+       if(get_components(fmt)!=get_components(format) || get_component_type(fmt)!=get_component_type(format))
+               throw incompatible_data("Texture2DArray::layer_image");
 
        PixelStore pstore = PixelStore::from_image(img);
        BindRestore _bind_ps(pstore);
 
-       layer_image(level, z, fmt, UNSIGNED_BYTE, img.get_data());
+       layer_image(level, z, img.get_pixels());
 }
 
 
@@ -63,9 +72,7 @@ void Texture2DArray::Loader::init()
 void Texture2DArray::Loader::external_image(unsigned z, const string &fn)
 {
        Graphics::Image img;
-       RefPtr<IO::Seekable> io = get_collection().open_raw(fn);
-       img.load_io(*io);
-
+       load_external_image(img, fn);
        obj.layer_image(0, z, img);
 }