#include <msp/core/raii.h>
#include <msp/gl/extensions/arb_direct_state_access.h>
#include <msp/gl/extensions/arb_texture_storage.h>
+#include <msp/graphics/imageloader.h>
#include "bindable.h"
#include "buffer.h"
#include "error.h"
Buffer pixel_buffer;
char *mapped_address;
Graphics::Image image;
+ Graphics::ImageLoader *img_loader;
unsigned n_bytes;
int phase;
io(i),
pixel_buffer(PIXEL_UNPACK_BUFFER),
mapped_address(0),
+ img_loader(Graphics::ImageLoader::open_io(io)),
phase(0)
{ }
{
if(mapped_address)
pixel_buffer.unmap();
+ delete img_loader;
}
bool Texture2D::AsyncLoader::needs_sync() const
{
if(phase==0)
{
- /* TODO Enhance the ImageLoader system so that the image can be loaded
- directly to the buffer */
- image.load_io(io);
+ image.load_headers(*img_loader);
n_bytes = image.get_stride()*image.get_height();
}
else if(phase==1)
mapped_address = reinterpret_cast<char *>(pixel_buffer.map());
}
else if(phase==2)
- {
- const char *data = reinterpret_cast<const char *>(image.get_pixels());
- copy(data, data+n_bytes, mapped_address);
- }
+ image.load_into(*img_loader, mapped_address);
else if(phase==3)
{
Bind _bind_buf(pixel_buffer, PIXEL_UNPACK_BUFFER);