AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
Texture.h
1/*
2 * AUI Framework - Declarative UI toolkit for modern C++20
3 * Copyright (C) 2020-2024 Alex2772 and Contributors
4 *
5 * SPDX-License-Identifier: MPL-2.0
6 *
7 * This Source Code Form is subject to the terms of the Mozilla Public
8 * License, v. 2.0. If a copy of the MPL was not distributed with this
9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 */
11
12#pragma once
13
14#include <cstdint>
15
16namespace gl {
17 constexpr uint32_t TEXTURE_1D = 0x0DE1;
18 constexpr uint32_t TEXTURE_2D = 0x0DE1;
19 constexpr uint32_t TEXTURE_3D = 0x806F;
20 constexpr uint32_t TEXTURE_2D_ARRAY = 0x8C1A;
21
22
23 template<unsigned TEXTURE_TARGET>
24 class API_AUI_VIEWS Texture {
25 public:
26 Texture();
27 virtual ~Texture();
28 void setupNearest();
29 void setupLinear();
30 void setupClampToEdge();
31 void setupRepeat();
32 void setupMirroredRepeat();
33 Texture(const Texture&) = delete;
34
35 void bind(uint8_t index = 0);
36 static void unbind(uint8_t index = 0);
37
38 operator bool() const {
39 return mTexture;
40 }
41 uint32_t getHandle() const {
42 return mTexture;
43 }
44
45 private:
46 uint32_t mTexture = 0;
47 enum class Filtering {
48 UNDEFINED,
49 NEAREST,
50 LINEAR,
51 } mFiltering = Filtering::UNDEFINED;
52
53 enum class Wrapping {
54 UNDEFINED,
55 CLAMP_TO_EDGE,
56 REPEAT,
57 MIRRORED_REPEAT,
58 } mWrapping = Wrapping::UNDEFINED;
59 };
60}