charcoal/OpenGLEngine/TextureFactory.h
elipzer 0e3982591e Textures Work!
MyBuiltinTexturedScene (number 7) displays a cube that loads its
faces from a hard-coded texture. Mipmaping is supported. Just use
the XXX_MIPMAP_XXX Min/Mag filters to use it. TODO next is
combining lighting and textures and then up after that is shadows.
I may just do lighting and shadows before lighting, shadows, and
textures.
2018-09-16 20:50:51 -04:00

52 lines
1.2 KiB
C++

#pragma once
#include <vector>
#include "Texture.h"
#include "Sampler.h"
namespace charcoal
{
class TextureFactory
{
private:
TextureFactory() {}
virtual ~TextureFactory() {}
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();
}
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:
static std::vector<Texture> m_textures;
static std::vector<Sampler> m_samplers;
};
std::vector<Texture> TextureFactory::m_textures;
std::vector<Sampler> TextureFactory::m_samplers;
}