Files
portersky b6adb7c23a style: move public members first in class declarations
- Reorder all class headers to put public interface before private members
- Document convention in AGENTS.md
2026-05-05 22:30:56 +02:00

59 lines
1.3 KiB
C++

#pragma once
#include <cstddef>
#include <vector>
#include "glad/glad.h"
namespace cbt::opengl {
enum class texture_target {
_1d = GL_TEXTURE_1D,
_2d = GL_TEXTURE_2D,
_3d = GL_TEXTURE_3D,
cube = GL_TEXTURE_CUBE_MAP,
};
enum class texture_format {
rgb = GL_RGB,
rgba = GL_RGBA,
rg = GL_RG,
red = GL_RED,
depth = GL_DEPTH_COMPONENT,
};
enum class texture_type {
ubyte = GL_UNSIGNED_BYTE,
ushort = GL_UNSIGNED_SHORT,
uint = GL_UNSIGNED_INT,
float_ = GL_FLOAT,
};
class texture {
public:
texture();
explicit texture(texture_target target);
~texture();
texture(texture const&) = delete;
texture& operator=(texture const&) = delete;
texture(texture&& other) noexcept;
texture& operator=(texture&& other) noexcept;
auto bind(GLuint unit = 0) -> void;
auto unbind() -> void;
auto upload(void const* data, int width, int height, texture_format format, texture_type type) -> void;
auto set_filter(GLenum min_filter, GLenum mag_filter) -> void;
auto set_wrap(GLenum wrap_s, GLenum wrap_t) -> void;
auto generate_mipmaps() -> void;
auto id() const -> GLuint;
auto valid() const -> bool;
private:
GLuint m_id = 0;
texture_target m_target = texture_target::_2d;
};
}