Just™ Game Engine
texture.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021-2022 Konstanty Misiak
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7#pragma once
8#include "jng/core/base.hpp"
9
10namespace jng {
11
12 enum class TextureFormat {
13 None,
14
15 RGBA8, // normalized integer
16 R32, // unsigned integer
17
19 };
20
21 enum class TextureFilter {
22 Linear,
24 };
25
26 enum class TextureWrapMode {
27 Clamp,
28 Wrap
29 };
30
36
37 TextureSpecification(TextureFormat inFormat) : format{ inFormat } {}
38 };
39
40 class Texture final
41 {
42 public:
43 struct Properties {
47 };
48
49 explicit Texture(const char* path);
50 explicit Texture(const Properties& properties);
51 ~Texture();
52
53 void bind(u32 slot) const;
54 void unbind(u32 slot) const;
55 void setData(void* data, size_t size) const;
56
57 u32 getID() const { return m_id; }
58 const Properties& getProperties() const { return m_properties; }
59 void* getRendererID() { return reinterpret_cast<void*>(static_cast<u64>(m_id)); }
60 private:
61 void createTexture();
62
63 Properties m_properties;
64 u32 m_id;
65 };
66
67} // namespace jng
Definition: texture.hpp:41
~Texture()
Definition: texture_ogl.cpp:51
void unbind(u32 slot) const
Definition: texture_ogl.cpp:61
void setData(void *data, size_t size) const
Definition: texture_ogl.cpp:66
u32 getID() const
Definition: texture.hpp:57
void bind(u32 slot) const
Definition: texture_ogl.cpp:56
Texture(const char *path)
Definition: texture_ogl.cpp:29
void * getRendererID()
Definition: texture.hpp:59
const Properties & getProperties() const
Definition: texture.hpp:58
Definition: base.hpp:11
TextureWrapMode
Definition: texture.hpp:26
uint64_t u64
Definition: base.hpp:42
TextureFilter
Definition: texture.hpp:21
uint32_t u32
Definition: base.hpp:41
TextureFormat
Definition: texture.hpp:12
Definition: texture.hpp:43
u32 width
Definition: texture.hpp:45
TextureSpecification specification
Definition: texture.hpp:44
u32 height
Definition: texture.hpp:46
Definition: texture.hpp:31
TextureFilter magnificationFilter
Definition: texture.hpp:34
TextureWrapMode wrapMode
Definition: texture.hpp:35
TextureFilter minificationFilter
Definition: texture.hpp:33
TextureSpecification(TextureFormat inFormat)
Definition: texture.hpp:37
TextureFormat format
Definition: texture.hpp:32