Restructure project sources.

This commit is contained in:
2018-03-26 12:17:52 +02:00
parent a206f81eb2
commit 8015b84311
41 changed files with 2 additions and 37 deletions

51
src/fmri/Texture.cpp Normal file
View File

@@ -0,0 +1,51 @@
#include <algorithm>
#include "Texture.hpp"
using namespace fmri;
Texture::Texture() noexcept
{
glGenTextures(1, &id);
}
Texture::Texture(GLuint id) noexcept : id(id)
{
}
Texture::~Texture()
{
if (id != 0) {
glDeleteTextures(1, &id);
}
}
Texture &Texture::operator=(Texture && other) noexcept
{
std::swap(id, other.id);
return *this;
}
Texture::Texture(Texture && other) noexcept
{
std::swap(id, other.id);
}
void Texture::bind(GLenum target) const
{
glBindTexture(target, id);
}
void Texture::configure(GLenum target) const
{
bind(target);
const float color[] = {1, 0, 1}; // Background color for textures.
// Set up (lack of) repetition
glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_BORDER);
glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, color);
// Set up texture scaling
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); // Use mipmapping for scaling down
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // Use nearest pixel when scaling up.
}