61 lines
1.2 KiB
C++
61 lines
1.2 KiB
C++
#pragma once
|
|
#ifndef _NB_TEXTURES
|
|
#define _NB_TEXTURES
|
|
|
|
#include "Buffers.hpp"
|
|
#include "OGLObjects.hpp"
|
|
|
|
namespace nb {
|
|
|
|
template<bool Immutable=false>
|
|
class TextureBuffer : public virtual Buffer<TextureBuffer<false>> {
|
|
using Base = Buffer<TextureBuffer<false>>;
|
|
using BufferType = Base;
|
|
|
|
public:
|
|
using Base::Base;
|
|
static const GLenum Target = GL_TEXTURE_BUFFER;
|
|
|
|
protected:
|
|
|
|
};
|
|
|
|
template <>
|
|
class TextureBuffer<true>
|
|
: public virtual TextureBuffer<false>, public virtual ImmutableBuffer<TextureBuffer<true>> {
|
|
using Base = TextureBuffer<false>;
|
|
using BufferType = ImmutableBuffer<TextureBuffer<true>>;
|
|
|
|
public:
|
|
using BufferType::BufferType;
|
|
using Base::Target;
|
|
};
|
|
|
|
class Texture : public OpenGLObject {
|
|
using Base = OpenGLObject;
|
|
public:
|
|
using Base::Base;
|
|
using Base::id;
|
|
|
|
Texture(GLenum);
|
|
|
|
virtual void bind() const override { glBindTexture(target, _id); }
|
|
virtual void unbind() const override { glBindTexture(target, 0); }
|
|
|
|
const GLenum target;
|
|
|
|
friend Base;
|
|
|
|
protected:
|
|
using Base::_id;
|
|
|
|
virtual void remove() override {
|
|
if (_id) {
|
|
glDeleteTextures(0, &_id);
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
} // namespace nb
|
|
#endif // _NB_TEXTURES
|