Aegis2D
Modular C++26 2D game engine for networked games
Loading...
Searching...
No Matches
texture.hpp
Go to the documentation of this file.
1
3#pragma once
4
5#include <aegis2d/render/export.hpp>
8
9#include <cstdint>
10#include <filesystem>
11
13
26class AEGIS2D_RENDER_EXPORT Texture {
27public:
32 explicit Texture(const Image& image);
33
38 [[nodiscard]] static Texture load(const std::filesystem::path& path);
39
40 Texture(const Texture&) = delete;
41 Texture& operator=(const Texture&) = delete;
44 Texture(Texture&& other) noexcept;
48 Texture& operator=(Texture&& other) noexcept;
51
54 [[nodiscard]] TextureSize size() const noexcept;
55
58 [[nodiscard]] std::uint32_t id() const noexcept;
59
62 void bind(std::uint32_t unit = 0) const noexcept;
63
67 [[nodiscard]] Image pixels() const;
68
69private:
70 std::uint32_t id_ = 0;
71 TextureSize size_;
72};
73
74} // namespace aegis2d::render::opengl
An image on the GPU, ready to be drawn.
Definition texture.hpp:26
static Texture load(const std::filesystem::path &path)
Reads an image file and sends it to the GPU.
Texture & operator=(const Texture &)=delete
Texture(const Image &image)
Sends an image to the GPU.
Texture(Texture &&other) noexcept
Takes over the texture of other, which becomes empty.
Texture(const Texture &)=delete
TextureSize size() const noexcept
Size of the image.
Texture & operator=(Texture &&other) noexcept
Deletes this texture and takes over the texture of other.
~Texture()
Deletes the texture.
Images in memory: loaded from files, generated by the engine, saved as PNG.
OpenGL backend of the renderer.
Definition context.hpp:18
Definition endpoint.hpp:85
Backend-independent renderer interface and the sprite it draws.
RGBA image with 8 bits per channel, ready to become a texture.
Definition image.hpp:25
Width and height of a texture, in pixels.
Definition renderer.hpp:38