X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Ftexture2darray.cpp;h=07f04c691b7dad0f9387ecd5362ece69196a6264;hb=3efe3bab1c8290bd49a957ebec0ad97e58a35fcf;hp=1ecb4cf2be69e1b34a28f1f8b8cea643b84e2325;hpb=7aaec9a70b8d7733429bec043f8e33e02956f266;p=libs%2Fgl.git diff --git a/source/core/texture2darray.cpp b/source/core/texture2darray.cpp index 1ecb4cf2..07f04c69 100644 --- a/source/core/texture2darray.cpp +++ b/source/core/texture2darray.cpp @@ -1,7 +1,4 @@ -#include -#include #include "error.h" -#include "pixelstore.h" #include "texture2darray.h" using namespace std; @@ -9,27 +6,13 @@ 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, 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, data); -} + if(level>=n_levels || z>=depth) + throw out_of_range("Texture2DArray::layer_image"); -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); + LinAl::Vector size = get_level_size(level); + sub_image(level, 0, 0, z, size.x, size.y, 1, data); } void Texture2DArray::layer_image(unsigned level, unsigned z, const Graphics::Image &img) @@ -45,9 +28,6 @@ void Texture2DArray::layer_image(unsigned level, unsigned z, const Graphics::Ima 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, img.get_pixels()); }