X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Ftexture2darray.cpp;h=1a085ed8e73bbe6c89c5361b7839a5fe32180c32;hp=34b9532d3e80965dbc6777a2ff4d0e60a191d8ab;hb=HEAD;hpb=9087cc0a372b9c739f15398c7a22c0a6eb5041bb diff --git a/source/texture2darray.cpp b/source/texture2darray.cpp deleted file mode 100644 index 34b9532d..00000000 --- a/source/texture2darray.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include -#include -#include "error.h" -#include "pixelstore.h" -#include "texture2darray.h" - -using namespace std; - -namespace Msp { -namespace GL { - -Texture2DArray::Texture2DArray(): - Texture3D(GL_TEXTURE_2D_ARRAY) -{ - static Require _req(EXT_texture_array); -} - -void Texture2DArray::layer_image(unsigned level, unsigned z, PixelComponents comp, DataType type, 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, comp, type, data); -} - -void Texture2DArray::layer_image(unsigned level, unsigned z, const Graphics::Image &img) -{ - if(!get_width()) - throw invalid_operation("Texture2DArray::layer_image"); - - unsigned w = img.get_width(); - unsigned h = img.get_height(); - PixelFormat fmt = pixelformat_from_image(img); - if(w!=get_width() || h!=get_height()) - throw incompatible_data("Texture2DArray::layer_image"); - - PixelStore pstore = PixelStore::from_image(img); - BindRestore _bind_ps(pstore); - - layer_image(level, z, get_components(fmt), get_component_type(fmt), img.get_data()); -} - - -Texture2DArray::Loader::Loader(Texture2DArray &t): - DataFile::DerivedObjectLoader(t) -{ - init(); -} - -Texture2DArray::Loader::Loader(Texture2DArray &t, Collection &c): - DataFile::DerivedObjectLoader(t, c) -{ - init(); -} - -void Texture2DArray::Loader::init() -{ - add("external_image", &Loader::external_image); -} - -void Texture2DArray::Loader::external_image(unsigned z, const string &fn) -{ - Graphics::Image img; - RefPtr io = get_collection().open_raw(fn); - if(!io) - throw IO::file_not_found(fn); - img.load_io(*io); - - obj.layer_image(0, z, img); -} - -} // namespace GL -} // namespace Msp