2018-09-16 00:43:29 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-10-10 14:54:13 +00:00
|
|
|
#include <list>
|
2018-09-16 00:43:29 +00:00
|
|
|
|
2018-10-09 15:42:17 +00:00
|
|
|
#include "ImageLoader.h"
|
|
|
|
|
2018-09-16 00:43:29 +00:00
|
|
|
#include "Texture.h"
|
|
|
|
#include "Sampler.h"
|
|
|
|
|
|
|
|
namespace charcoal
|
|
|
|
{
|
|
|
|
class TextureFactory
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
TextureFactory() {}
|
2018-09-17 00:50:51 +00:00
|
|
|
virtual ~TextureFactory() {}
|
2018-09-16 00:43:29 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
template <typename T>
|
|
|
|
static Texture* gen_texture(
|
|
|
|
Texture::Format data_format,
|
|
|
|
Texture::Type data_type,
|
|
|
|
unsigned long width,
|
|
|
|
unsigned long height,
|
|
|
|
const std::vector<T>& data,
|
|
|
|
Texture::InternalFormat internal_format,
|
|
|
|
unsigned short mipmap_level = 0,
|
|
|
|
Texture::Target texture_target = Texture::Target::TEXTURE_2D
|
|
|
|
)
|
|
|
|
{
|
|
|
|
m_textures.emplace_back(data_format, data_type, width, height, data, internal_format, mipmap_level, texture_target);
|
|
|
|
return &m_textures.back();
|
|
|
|
}
|
|
|
|
|
2018-10-09 15:42:17 +00:00
|
|
|
static Texture* gen_image_texture(const image_loader::ImageRGBA& image)
|
|
|
|
{
|
|
|
|
return gen_texture(Texture::Format::RGBA, Texture::Type::UNSIGNED_BYTE, image.width, image.height, image.data, Texture::InternalFormat::RGBA);
|
|
|
|
}
|
|
|
|
|
2018-09-16 00:43:29 +00:00
|
|
|
static Sampler* gen_sampler(
|
|
|
|
Sampler::Wrap wrap_s,
|
|
|
|
Sampler::Wrap wrap_t,
|
|
|
|
Sampler::MagFilter magnification_filter,
|
|
|
|
Sampler::MinFilter minification_filter
|
|
|
|
)
|
|
|
|
{
|
|
|
|
m_samplers.emplace_back(wrap_s, wrap_t, magnification_filter, minification_filter);
|
|
|
|
return &m_samplers.back();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-10-10 14:54:13 +00:00
|
|
|
static std::list<Texture> m_textures;
|
|
|
|
static std::list<Sampler> m_samplers;
|
2018-09-16 00:43:29 +00:00
|
|
|
};
|
|
|
|
}
|