|
|
@@ -4,6 +4,8 @@
|
|
|
#include "FileStream.h"
|
|
|
#include <cassert>
|
|
|
#include "Allocator.h"
|
|
|
+#include "Device.h"
|
|
|
+#include "Renderer.h"
|
|
|
|
|
|
namespace crown
|
|
|
{
|
|
|
@@ -19,19 +21,15 @@ TextureResource* TextureResource::load(Allocator& allocator, ResourceArchive* ar
|
|
|
{
|
|
|
TextureResource* resource = (TextureResource*)allocator.allocate(sizeof(TextureResource));
|
|
|
|
|
|
- stream->read(&resource->format, sizeof(PixelFormat));
|
|
|
- stream->read(&resource->width, sizeof(uint16_t));
|
|
|
- stream->read(&resource->height, sizeof(uint16_t));
|
|
|
-
|
|
|
- stream->read(&resource->mode, sizeof(TextureMode));
|
|
|
- stream->read(&resource->filter, sizeof(TextureFilter));
|
|
|
- stream->read(&resource->wrap, sizeof(TextureWrap));
|
|
|
+ stream->read(&resource->m_format, sizeof(PixelFormat));
|
|
|
+ stream->read(&resource->m_width, sizeof(uint16_t));
|
|
|
+ stream->read(&resource->m_height, sizeof(uint16_t));
|
|
|
|
|
|
- size_t size = resource->width * resource->height * Pixel::GetBytesPerPixel(resource->format);
|
|
|
+ size_t size = resource->m_width * resource->m_height * Pixel::GetBytesPerPixel(resource->m_format);
|
|
|
|
|
|
- resource->data = (uint8_t*)allocator.allocate(sizeof(uint8_t) * size);
|
|
|
+ resource->m_data = (uint8_t*)allocator.allocate(sizeof(uint8_t) * size);
|
|
|
|
|
|
- stream->read(resource->data, size);
|
|
|
+ stream->read(resource->m_data, size);
|
|
|
|
|
|
return resource;
|
|
|
}
|
|
|
@@ -39,13 +37,27 @@ TextureResource* TextureResource::load(Allocator& allocator, ResourceArchive* ar
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+void TextureResource::online(TextureResource* texture)
|
|
|
+{
|
|
|
+ assert(texture != NULL);
|
|
|
+
|
|
|
+ texture->m_render_texture = GetDevice()->GetRenderer()->load_texture(texture);
|
|
|
+}
|
|
|
+
|
|
|
//-----------------------------------------------------------------------------
|
|
|
void TextureResource::unload(Allocator& allocator, TextureResource* resource)
|
|
|
{
|
|
|
assert(resource != NULL);
|
|
|
|
|
|
- allocator.deallocate(resource->data);
|
|
|
+ allocator.deallocate(resource->m_data);
|
|
|
allocator.deallocate(resource);
|
|
|
}
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+void TextureResource::offline()
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
} // namespace crown
|