X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FTextureBase.hpp;fp=src%2Fgraphics%2FTextureBase.hpp;h=4c3e8a850b49efcf5bcaca28147a0dd6c7f11ad9;hb=be3a81656b8493010d2329fa00da617e24293438;hp=0000000000000000000000000000000000000000;hpb=1709d12eb27ecf7626d724a3fc14096a93f3cb4c;p=blank.git diff --git a/src/graphics/TextureBase.hpp b/src/graphics/TextureBase.hpp new file mode 100644 index 0000000..4c3e8a8 --- /dev/null +++ b/src/graphics/TextureBase.hpp @@ -0,0 +1,69 @@ +#ifndef BLANK_GRAPHICS_TEXTUREBASE_HPP_ +#define BLANK_GRAPHICS_TEXTUREBASE_HPP_ + +#include + + +namespace blank { + +template +class TextureBase { + +public: + TextureBase(); + ~TextureBase(); + + TextureBase(TextureBase &&other) noexcept; + TextureBase &operator =(TextureBase &&) noexcept; + + TextureBase(const TextureBase &) = delete; + TextureBase &operator =(const TextureBase &) = delete; + +public: + void Bind(GLsizei which = 0) noexcept { + glBindTexture(TARGET, handle[which]); + } + + void FilterNearest() noexcept { + glTexParameteri(TARGET, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(TARGET, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + } + void FilterLinear() noexcept { + glTexParameteri(TARGET, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(TARGET, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + } + void FilterTrilinear() noexcept { + glTexParameteri(TARGET, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(TARGET, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glGenerateMipmap(TARGET); + } + + void WrapEdge() noexcept { + glTexParameteri(TARGET, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + glTexParameteri(TARGET, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(TARGET, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } + void WrapBorder() noexcept { + glTexParameteri(TARGET, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_BORDER); + glTexParameteri(TARGET, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + glTexParameteri(TARGET, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + } + void WrapRepeat() noexcept { + glTexParameteri(TARGET, GL_TEXTURE_WRAP_R, GL_REPEAT); + glTexParameteri(TARGET, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(TARGET, GL_TEXTURE_WRAP_T, GL_REPEAT); + } + void WrapMirror() noexcept { + glTexParameteri(TARGET, GL_TEXTURE_WRAP_R, GL_MIRRORED_REPEAT); + glTexParameteri(TARGET, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); + glTexParameteri(TARGET, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); + } + +private: + GLuint handle[COUNT]; + +}; + +} + +#endif