Просмотр исходного кода

Better compiler interface and updated TGACompiler

Daniele Bartolini 12 лет назад
Родитель
Сommit
c9736b448f

+ 41 - 55
tools/cli/resource-compiler.cpp

@@ -1,8 +1,36 @@
-#include "Crown.h"
-#include "tga/TGACompiler.h"
-#include "txt/TXTCompiler.h"
-#include "vs/VSCompiler.h"
-#include "ps/PSCompiler.h"
+/*
+Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <cstdio>
+
+#include "Args.h"
+#include "Path.h"
+#include "String.h"
+#include "Hash.h"
+#include "TGACompiler.h"
 
 using namespace crown;
 
@@ -30,58 +58,16 @@ int main(int argc, char** argv)
 	// If there are no resources
 	if (first_resource >= argc)
 	{
-		Log::e("you have to specify at least one resource.");
+		printf("you have to specify at least one resource.");
 		exit(EXIT_FAILURE);
 	}
 
-	TGACompiler tga(root_path, dest_path);
-	TXTCompiler txt(root_path, dest_path);
-	VSCompiler vs(root_path, dest_path);
-	PSCompiler ps(root_path, dest_path);
+	TGACompiler tga;
+	// TXTCompiler txt(root_path, dest_path);
+	// VSCompiler vs(root_path, dest_path);
+	// PSCompiler ps(root_path, dest_path);
 
-	char resource_name[MAX_RESOURCE_NAME_LENGTH];
-	char resource_type[MAX_RESOURCE_TYPE_LENGTH];
-
-	// Dispatch requests to the appropriate compiler
-	for (int32_t res = first_resource; res < argc; res++)
-	{
-		char* resource = argv[res];
-
-		path::filename_without_extension(resource, resource_name, MAX_RESOURCE_NAME_LENGTH);
-		path::extension(resource, resource_type, MAX_RESOURCE_TYPE_LENGTH);
-
-		uint32_t resource_name_hash = hash::murmur2_32(resource_name, string::strlen(resource_name), hash_seed);
-		uint32_t resource_type_hash = hash::murmur2_32(resource_type, string::strlen(resource_type), 0);
-
-		switch (resource_type_hash)
-		{
-			case TEXTURE_TYPE:
-			{
-				tga.compile(resource, resource_name_hash, resource_type_hash);
-				break;
-			}
-			case TEXT_TYPE:
-			{
-				txt.compile(resource, resource_name_hash, resource_type_hash);
-				break;
-			}
-			case VERTEX_SHADER_TYPE:
-			{
-				vs.compile(resource, resource_name_hash, resource_type_hash);
-				break;
-			}
-			case PIXEL_SHADER_TYPE:
-			{
-				ps.compile(resource, resource_name_hash, resource_type_hash);
-				break;	
-			}
-			default:
-			{
-				Log::e("Resource type not supported.");
-				break;
-			}
-		}
-	}
+	tga.compile(root_path, dest_path, argv[first_resource]);
 
 	return 0;
 }
@@ -157,13 +143,13 @@ void check_arguments(const char* root_path, const char* dest_path)
 {
 	if (root_path == NULL)
 	{
-		Log::e("you have to specify the root path with `--root-path`\n");
+		printf("you have to specify the root path with `--root-path`\n");
 		exit(EXIT_FAILURE);
 	}
 
 	if (dest_path == NULL)
 	{
-		Log::e("you have to specify the destination path with `--dest-path`\n");
+		printf("you have to specify the destination path with `--dest-path`\n");
 		exit(EXIT_FAILURE);
 	}
 }

+ 24 - 114
tools/compilers/Compiler.cpp

@@ -26,147 +26,57 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include <cstring>
 #include <cstdlib>
+#include <iostream>
+
 #include "Compiler.h"
-#include "Hash.h"
-#include "Path.h"
-#include "DiskFile.h"
-#include "Log.h"
+#include "ResourceFormat.h"
 
 namespace crown
 {
 
 //-----------------------------------------------------------------------------
-Compiler::Compiler(const char* root_path, const char* dest_path, uint32_t type_expected) :
-	m_root_fs(root_path),
-	m_dest_fs(dest_path),
-	m_type_expected(type_expected)
-{
-	memset(m_resource_name, 0, MAX_RESOURCE_NAME_LENGTH);
-}
-
-//-----------------------------------------------------------------------------
-Compiler::~Compiler()
-{
-}
-
-//-----------------------------------------------------------------------------
-size_t Compiler::compile(const char* resource, uint32_t name, uint32_t type)
+size_t Compiler::compile(const char* root_path, const char* dest_path, const char* resource)
 {
-	string::strncpy(m_resource_name, resource, MAX_RESOURCE_NAME_LENGTH);
-	string::strncpy(m_resource_path, m_root_fs.os_path(resource), MAX_RESOURCE_PATH_LENGTH);
-
-	char resource_name[MAX_RESOURCE_NAME_LENGTH];
-	char resource_type[MAX_RESOURCE_TYPE_LENGTH];
-
-	path::filename_without_extension(resource, resource_name, MAX_RESOURCE_NAME_LENGTH);
-	path::extension(resource, resource_type, MAX_RESOURCE_TYPE_LENGTH);
+	std::string resource_path = std::string(root_path) + "/" + std::string(resource);
 
-	char output_name[17];
-	snprintf(output_name, 17, "%.8X%.8X", name, type);
-
-	Log::i("%s <= %s", output_name, resource);
-
-	if (type != m_type_expected)
+	// The compilation fails when returned size is zero
+	size_t resource_size = 0;
+	if ((resource_size = compile_impl(resource_path.c_str())) == 0)
 	{
-		Log::e("'%s': resource type does not match expected type.", resource);
+		std::cout << "Compilation failed." << std::endl;
 		return 0;
 	}
 
-	if (!m_root_fs.exists(resource))
-	{
-		Log::e("'%s': resource does not exist.");
-		return 0;
-	}
-
-	// Read source file
-	DiskFile* input_file = m_root_fs.open(resource, FOM_READ);
-
-	size_t header_size = read_header(input_file);
-	size_t resource_size = read_resource(input_file);
+	// Setup resource header
+	ResourceHeader resource_header;
+	resource_header.magic = RESOURCE_MAGIC_NUMBER;
+	resource_header.version = RESOURCE_VERSION;
+	resource_header.size = resource_size;
 
-	// Write compiled file
-	DiskFile* output_file;
+	// Open destination file and write the header
+	std::fstream out_file;
+	out_file.open("out.raw", std::fstream::out | std::fstream::binary);
 
-	if (m_dest_fs.exists(output_name))
+	if (!out_file.is_open())
 	{
-		m_dest_fs.delete_file(output_name);
+		std::cout << "Unable to write compiled file." << std::endl;
+		return 0;
 	}
 
-	m_dest_fs.create_file(output_name);
-	output_file = m_dest_fs.open(output_name, FOM_WRITE);
+	out_file.write((char*)&resource_header, sizeof(ResourceHeader));
 
-	write_header(output_file, name, type, resource_size);
-	write_resource(output_file);
+	// Write resource-specific data
+	write_impl(out_file);
 
-	m_root_fs.close(input_file);
-	m_dest_fs.close(output_file);
+	out_file.close();
 
 	// Cleanup
 	cleanup();
 }
 
-//-----------------------------------------------------------------------------
-size_t Compiler::read_header(DiskFile* in_file)
-{
-	return read_header_impl(in_file);
-}
-
-//-----------------------------------------------------------------------------
-size_t Compiler::read_resource(DiskFile* in_file)
-{
-	return read_resource_impl(in_file);
-}
-
-//-----------------------------------------------------------------------------
-void Compiler::write_header(DiskFile* out_file, uint32_t name, uint32_t type, uint32_t resource_size)
-{
-	CompiledHeader header;
-	header.magic = COMPILED_HEADER_MAGIC_NUMBER;
-	header.version = COMPILER_VERSION;
-	header.name = name;
-	header.type = type;
-	header.size = resource_size;
-
-	out_file->write(&header, sizeof(CompiledHeader));
-
-	write_header_impl(out_file);
-}
-
-//-----------------------------------------------------------------------------
-void Compiler::write_resource(DiskFile* out_file)
-{
-	write_resource_impl(out_file);
-}
-
 //-----------------------------------------------------------------------------
 void Compiler::cleanup()
 {
-	cleanup_impl();
-
-	string::strncpy(m_resource_name, "", MAX_RESOURCE_NAME_LENGTH);
-}
-
-//-----------------------------------------------------------------------------
-const char* Compiler::root_path() const
-{
-	return m_root_fs.root_path();
-}
-
-//-----------------------------------------------------------------------------
-const char* Compiler::dest_path() const
-{
-	return m_dest_fs.root_path();
-}
-
-//-----------------------------------------------------------------------------
-const char* Compiler::resource_name() const
-{
-	return m_resource_name;
-}
-
-const char* Compiler::resource_path() const
-{
-	return m_resource_path;
 }
 
 } // namespace crown

+ 7 - 56
tools/compilers/Compiler.h

@@ -26,33 +26,13 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include "Types.h"
-#include "Filesystem.h"
+#include <string>
+#include <fstream>
+#include <cstdint>
 
 namespace crown
 {
 
-const size_t	MAX_RESOURCE_NAME_LENGTH			= 1024;
-const size_t	MAX_RESOURCE_TYPE_LENGTH			= 64;
-const size_t	MAX_RESOURCE_PATH_LENGTH			= 2048;
-
-const uint32_t	COMPILED_HEADER_MAGIC_NUMBER		= 0xCE010101;
-const uint32_t	COMPILER_VERSION					= 1;
-
-/// Contains the header data common to all
-/// types of resources passing through the
-/// standard Compiler mechanics.
-struct CompiledHeader
-{
-	uint32_t	magic;		// Magic number used to identify the file
-	uint32_t	version;	// Version of the compiler used to compile the resource
-	uint32_t	name;		// Name of the resource (murmur2_32 hash)
-	uint32_t	type;		// Type of the resource (murmur2_32 hash)
-	uint32_t	size;		// Size of the resource data _not_ including header (in bytes)
-};
-
-class DiskFile;
-
 /// Resource compiler interface.
 /// Every specific resource compiler must inherith from this
 /// interface and implement its methods accordingly.
@@ -60,44 +40,15 @@ class Compiler
 {
 public:
 
-							Compiler(const char* root_path, const char* dest_path, uint32_t type_expected);
-	virtual					~Compiler();
-
-	size_t					compile(const char* resource, uint32_t name, uint32_t type);
-
-	size_t					read_header(DiskFile* in_file);
-	size_t					read_resource(DiskFile* in_file);
-
-	void					write_header(DiskFile* out_file, uint32_t name, uint32_t type, uint32_t resource_size);
-	void					write_resource(DiskFile* out_file);
+	virtual					~Compiler() {}
 
+	size_t					compile(const char* root_path, const char* dest_path, const char* resource);
 	void					cleanup();
 
-	const char*				root_path() const;
-	const char*				dest_path() const;
-	const char*				resource_name() const;
-	const char*				resource_path() const;
-
 protected:
 
-	virtual size_t			read_header_impl(DiskFile* in_file) = 0;
-	virtual size_t			read_resource_impl(DiskFile* in_file) = 0;
-
-	virtual void			write_header_impl(DiskFile* out_file) = 0;
-	virtual void			write_resource_impl(DiskFile* out_file) = 0;
-
-	virtual void			cleanup_impl() = 0;
-
-private:
-
-	// Filesystems
-	Filesystem			m_root_fs;
-	Filesystem			m_dest_fs;
-
-	uint32_t			m_type_expected;
-
-	char				m_resource_name[MAX_RESOURCE_NAME_LENGTH];
-	char 				m_resource_path[MAX_RESOURCE_PATH_LENGTH];
+	virtual size_t			compile_impl(const char* resource_path) = 0;
+	virtual void			write_impl(std::fstream& out_file) = 0;
 };
 
 } // namespace crown

+ 77 - 84
tools/compilers/tga/TGACompiler.cpp

@@ -24,75 +24,88 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
+#include <fstream>
+#include <iostream>
+
 #include "TGACompiler.h"
-#include "DiskFile.h"
 #include "PixelFormat.h"
-#include "Resource.h"
-#include "Log.h"
+#include "TextureFormat.h"
 
 namespace crown
 {
 
 //-----------------------------------------------------------------------------
-TGACompiler::TGACompiler(const char* root_path, const char* dest_path) :
-	Compiler(root_path, dest_path, TEXTURE_TYPE),
-	m_image_format(PF_UNKNOWN),
-	m_image_channels(0),
-	m_image_size(0),
-	m_image_data(NULL)
+TGACompiler::TGACompiler() :
+	m_texture_data_size(0),
+	m_texture_data(NULL)
 {
-	memset(&m_tga_header, 0, sizeof(TGAHeader));
 }
 
 //-----------------------------------------------------------------------------
 TGACompiler::~TGACompiler()
 {
-	cleanup_impl();
+	if (m_texture_data)
+	{
+		delete[] m_texture_data;
+	}
 }
 
 //-----------------------------------------------------------------------------
-size_t TGACompiler::read_header_impl(DiskFile* in_file)
+size_t TGACompiler::compile_impl(const char* resource_path)
 {
+	std::fstream in_file;
+	in_file.open(resource_path, std::fstream::in | std::fstream::binary);
+
+	if (!in_file.is_open())
+	{
+		std::cout << "Unable to open file: " << resource_path << std::endl;
+		return 0;
+	}
+
 	// Read the header
-	in_file->read(&m_tga_header, sizeof(TGAHeader));
+	if (!in_file.read((char*)(char*)&m_tga_header, sizeof(TGAHeader)))
+	{
+		std::cout << "Unable to read the TGA header." << std::endl;
+		return 0;
+	}
 
 	// Skip TGA ID
-	in_file->skip(m_tga_header.id_length);
+	in_file.seekg(m_tga_header.id_length);
 
-	return sizeof(TGAHeader) + m_tga_header.id_length;
-}
+	// Compute color channels
+	m_tga_channels = m_tga_header.pixel_depth / 8;
+	m_tga_size = m_tga_header.width * m_tga_header.height;
 
-//-----------------------------------------------------------------------------
-size_t TGACompiler::read_resource_impl(DiskFile* in_file)
-{
-	// Compute color channels	
-	m_image_channels = m_tga_header.pixel_depth / 8;
-	
-	// Compute image size
-	m_image_size = m_tga_header.width * m_tga_header.height;
+	m_texture_header.version = TEXTURE_VERSION;
+	m_texture_header.width = m_tga_header.width;
+	m_texture_header.height = m_tga_header.height;
 
 	// Select the appropriate pixel format and allocate
 	// resource data based on tga size and channels
-	switch (m_image_channels)
+	switch (m_tga_channels)
 	{
 		case 2:
 		case 3:
 		{
-			m_image_format = PF_RGB_8;
-			m_image_data = (uint8_t*)default_allocator().allocate(m_image_size * 3 * sizeof(uint8_t));
+			m_texture_header.format = PF_RGB_8;
+
+			m_texture_data_size = m_tga_size * 3;
+			m_texture_data = new uint8_t[m_texture_data_size];
 
 			break;
 		}
 		case 4:
 		{
-			m_image_format = PF_RGBA_8;
-			m_image_data = (uint8_t*)default_allocator().allocate(m_image_size * m_image_channels * sizeof(uint8_t));
+			m_texture_header.format = PF_RGBA_8;
+
+			m_texture_data_size = m_tga_size * m_tga_channels;
+			m_texture_data = new uint8_t[m_texture_data_size];
 			
 			break;
 		}
 		default:
 		{
-			Log::e("Unable to determine TGA channels.");
+			std::cout << "Unable to determine TGA channels." << std::endl;
 			return 0;
 		}
 	}
@@ -102,7 +115,7 @@ size_t TGACompiler::read_resource_impl(DiskFile* in_file)
 	{
 		case 0:
 		{
-			Log::e("Fatal: The resource does not contain image data.");
+			std::cout << "The file does not contain image data: " << resource_path << std::endl;
 			return 0;
 		}
 		case 2:
@@ -119,73 +132,54 @@ size_t TGACompiler::read_resource_impl(DiskFile* in_file)
 
 		default:
 		{
-			Log::e("Fatal: Image type not supported.");
+			std::cout << "Image type not supported." << std::endl;
 			return 0;
 		}
 	}
 
 	// Return the total resource size
-	return m_image_size * m_image_channels + sizeof(PixelFormat) + sizeof(uint16_t) + sizeof(uint16_t);
-}
-
-//-----------------------------------------------------------------------------
-void TGACompiler::write_header_impl(DiskFile* out_file)
-{
-	// Write the texture header
-	out_file->write(&m_image_format, sizeof(PixelFormat));
-	out_file->write(&m_tga_header.width, sizeof(uint16_t));
-	out_file->write(&m_tga_header.height, sizeof(uint16_t));
-}
-
-//-----------------------------------------------------------------------------
-void TGACompiler::write_resource_impl(DiskFile* out_file)
-{
-	// Write out the data
-	out_file->write(m_image_data, m_image_size * m_image_channels);
+	return sizeof(TextureHeader) + m_texture_data_size;
 }
 
 //-----------------------------------------------------------------------------
-void TGACompiler::cleanup_impl()
+void TGACompiler::write_impl(std::fstream& out_file)
 {
-	if (m_image_data)
-	{
-		default_allocator().deallocate(m_image_data);
-		m_image_data = NULL;
-	}
+	out_file.write((char*)&m_texture_header, sizeof(TextureHeader));
+	out_file.write((char*)m_texture_data, m_texture_data_size);
 }
 
 //-----------------------------------------------------------------------------
-void TGACompiler::load_uncompressed(DiskFile* in_file)
+void TGACompiler::load_uncompressed(std::fstream& in_file)
 {
 	uint64_t size = m_tga_header.width * m_tga_header.height;
 
-	if (m_image_channels == 2)
+	if (m_tga_channels == 2)
 	{
 		int32_t j = 0;
 
-		for (uint64_t i = 0; i < size * m_image_channels; i++)
+		for (uint64_t i = 0; i < size * m_tga_channels; i++)
 		{
 			uint16_t pixel_data;
 			
-			in_file->read(&pixel_data, sizeof(pixel_data));
+			in_file.read((char*)&pixel_data, sizeof(pixel_data));
 			
-			m_image_data[j + 0] = (pixel_data & 0x7c) >> 10;
-			m_image_data[j + 1] = (pixel_data & 0x3e) >> 5;
-			m_image_data[j + 2] = (pixel_data & 0x1f);
+			m_texture_data[j + 0] = (pixel_data & 0x7c) >> 10;
+			m_texture_data[j + 1] = (pixel_data & 0x3e) >> 5;
+			m_texture_data[j + 2] = (pixel_data & 0x1f);
 			
 			j += 3;
 		}
 	}
 	else
 	{
-		in_file->read(m_image_data, (size_t)(size * m_image_channels));
+		in_file.read((char*)m_texture_data, (size_t)(size * m_tga_channels));
 
 		swap_red_blue();
 	}
 }
 
 //-----------------------------------------------------------------------------
-void TGACompiler::load_compressed(DiskFile* in_file)
+void TGACompiler::load_compressed(std::fstream& in_file)
 {
 	uint8_t rle_id = 0;
 	uint32_t i = 0;
@@ -197,28 +191,28 @@ void TGACompiler::load_compressed(DiskFile* in_file)
 
 	while (i < size)
 	{
-		in_file->read(&rle_id, sizeof(uint8_t));
+		in_file.read((char*)&rle_id, sizeof(uint8_t));
 
 		// If MSB == 1
 		if (rle_id & 0x80)
 		{
 			rle_id -= 127;
 			
-			in_file->read(&colors, m_image_channels);
+			in_file.read((char*)&colors, m_tga_channels);
 
 			while (rle_id)
 			{
-				m_image_data[colors_read + 0] = colors[2];
-				m_image_data[colors_read + 1] = colors[1];
-				m_image_data[colors_read + 2] = colors[0];
+				m_texture_data[colors_read + 0] = colors[2];
+				m_texture_data[colors_read + 1] = colors[1];
+				m_texture_data[colors_read + 2] = colors[0];
 
-				if (m_image_channels == 4)
+				if (m_tga_channels == 4)
 				{
-					m_image_data[colors_read + 3] = colors[3];
+					m_texture_data[colors_read + 3] = colors[3];
 				}
 
 				rle_id--;
-				colors_read += m_image_channels;
+				colors_read += m_tga_channels;
 				i++;
 			}
 		}
@@ -228,19 +222,19 @@ void TGACompiler::load_compressed(DiskFile* in_file)
 
 			while (rle_id)
 			{
-				in_file->read(colors, m_image_channels);
+				in_file.read((char*)colors, m_tga_channels);
 				
-				m_image_data[colors_read + 0] = colors[2];
-				m_image_data[colors_read + 1] = colors[1];
-				m_image_data[colors_read + 2] = colors[0];
+				m_texture_data[colors_read + 0] = colors[2];
+				m_texture_data[colors_read + 1] = colors[1];
+				m_texture_data[colors_read + 2] = colors[0];
 
-				if (m_image_channels == 4)
+				if (m_tga_channels == 4)
 				{
-					m_image_data[colors_read + 3] = colors[3];
+					m_texture_data[colors_read + 3] = colors[3];
 				}
 
 				rle_id--;
-				colors_read += m_image_channels;
+				colors_read += m_tga_channels;
 				i++;
 			}
 		}
@@ -250,13 +244,12 @@ void TGACompiler::load_compressed(DiskFile* in_file)
 //-----------------------------------------------------------------------------
 void TGACompiler::swap_red_blue()
 {
-	for (uint64_t i = 0; i < m_image_size * m_image_channels; i += m_image_channels)
+	for (uint64_t i = 0; i < m_tga_size * m_tga_channels; i += m_tga_channels)
 	{
-		m_image_data[i + 0] ^= m_image_data[i + 2];
-		m_image_data[i + 2] ^= m_image_data[i + 0];
-		m_image_data[i + 0] ^= m_image_data[i + 2];
+		m_texture_data[i + 0] ^= m_texture_data[i + 2];
+		m_texture_data[i + 2] ^= m_texture_data[i + 0];
+		m_texture_data[i + 0] ^= m_texture_data[i + 2];
 	}
 }
 
 } // namespace crown
-

+ 11 - 16
tools/compilers/tga/TGACompiler.h

@@ -27,8 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Compiler.h"
-#include "DiskFile.h"
-#include "PixelFormat.h"
+#include "TextureFormat.h"
 
 namespace crown
 {
@@ -52,31 +51,27 @@ class TGACompiler : public Compiler
 {
 public:
 
-					TGACompiler(const char* root_path, const char* dest_path);
+					TGACompiler();
 					~TGACompiler();
 
-	size_t			read_header_impl(DiskFile* in_file);
-	size_t			read_resource_impl(DiskFile* in_file);
-
-	void			write_header_impl(DiskFile* out_file);
-	void			write_resource_impl(DiskFile* out_file);
-
-	void			cleanup_impl();
+	size_t			compile_impl(const char* resource_path);
+	void			write_impl(std::fstream& out_file);
 
 private:
 
-	void			load_uncompressed(DiskFile* in_file);
-	void			load_compressed(DiskFile* in_file);
+	void			load_uncompressed(std::fstream& in_file);
+	void			load_compressed(std::fstream& in_file);
 	void			swap_red_blue();
 
 private:
 
 	TGAHeader		m_tga_header;
+	uint32_t		m_tga_channels;
+	uint32_t		m_tga_size;
 
-	PixelFormat		m_image_format;
-	uint32_t		m_image_channels;
-	uint64_t		m_image_size;
-	uint8_t*		m_image_data;
+	TextureHeader	m_texture_header;
+	size_t			m_texture_data_size;
+	uint8_t*		m_texture_data;
 };
 
 } // namespace crown