#include "texture2d.h"
#include <dxgi1_6.h>
#include <iostream>

void texture2d::create(const texture_data& in_data) {
	sg_image_desc desc{};
	desc.type = SG_IMAGETYPE_2D;
	desc.render_target = false;
	desc.width = in_data.size.x();
	desc.height = in_data.size.y();
	desc.num_slices = 1;
	desc.num_mipmaps = 1;
	desc.usage = SG_USAGE_IMMUTABLE;
	desc.pixel_format = in_data.pixel_format;
	desc.sample_count = 1;
	desc.data = in_data.get_image_data();

	create_from_desc(desc);
}

void texture2d::update(const sg_image_data& in_data) {
	auto desc = get_image_desc();
	desc.data = in_data;
	clear();
	create_from_desc(desc);
}

void texture2d::resize(const Eigen::Vector2i& in_size) {
	std::cerr << "texture2d can't resize!" << std::endl;
}
