Photon Editor Library 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
OpenglTexture.h
Go to the documentation of this file.
1#pragma once
2
5
6#include "ThirdParty/glad2.h"
7
8#include <Common/primitive_type.h>
9#include <Math/math_fwd.h>
10#include <Utility/TSpan.h>
11
12#include <cstddef>
13
14namespace ph::editor::ghi
15{
16
17class OpenglTexture final
18{
19public:
20 GLuint textureID = 0;
21 GLsizei widthPx = 0;
22 GLsizei heightPx = 0;
23 GLenum internalFormat = GL_NONE;
24 GLenum filterType = GL_LINEAR;
25 GLenum wrapType = GL_REPEAT;
26 GLsizei numSamples = 1;
27 uint32 numPixelComponents : 3 = 0;
28 uint32 isImmutableStorage : 1 = false;
29
30 void create(const TextureDesc& desc);
31 void createImmutableStorage(const TextureDesc& desc);
32 void createMultiSampled(const TextureDesc& desc);
33
36 void uploadPixelData(
37 TSpanView<std::byte> pixelData,
38 EPixelFormat pixelFormat,
39 EPixelComponent pixelComponent);
40
43 void uploadPixelData(
44 const math::Vector2UI& regionOriginPx,
45 const math::Vector2UI& regionSizePx,
46 TSpanView<std::byte> pixelData,
47 EPixelFormat pixelFormat,
48 EPixelComponent pixelComponent);
49
54 void uploadPixelData(
55 const math::Vector3UI& newTextureSizePx,
56 TSpanView<std::byte> pixelData,
57 EPixelFormat pixelFormat,
58 EPixelComponent pixelComponent);
59
60 void bindNonDSATexture() const;
61 void bindSlot(uint32 slotIndex) const;
62 void destroy();
63 bool isColor() const;
64
65 std::size_t numPixels() const
66 {
67 return static_cast<std::size_t>(widthPx) * heightPx;
68 }
69
70 bool isMultiSampled() const
71 {
72 return numSamples > 1;
73 }
74
75 bool hasResource() const
76 {
77 return textureID != 0;
78 }
79};
80
81}// end namespace ph::editor::ghi
Definition OpenglTexture.h:18
GLenum wrapType
Definition OpenglTexture.h:25
bool isMultiSampled() const
Definition OpenglTexture.h:70
GLenum filterType
Definition OpenglTexture.h:24
uint32 isImmutableStorage
Definition OpenglTexture.h:28
uint32 numPixelComponents
Definition OpenglTexture.h:27
void create(const TextureDesc &desc)
Definition OpenglTexture.cpp:21
void bindNonDSATexture() const
Definition OpenglTexture.cpp:183
void bindSlot(uint32 slotIndex) const
Definition OpenglTexture.cpp:195
GLsizei widthPx
Definition OpenglTexture.h:21
void createMultiSampled(const TextureDesc &desc)
Definition OpenglTexture.cpp:61
void createImmutableStorage(const TextureDesc &desc)
Definition OpenglTexture.cpp:33
void destroy()
Definition OpenglTexture.cpp:200
GLuint textureID
Definition OpenglTexture.h:20
std::size_t numPixels() const
Definition OpenglTexture.h:65
bool hasResource() const
Definition OpenglTexture.h:75
GLsizei numSamples
Definition OpenglTexture.h:26
GLsizei heightPx
Definition OpenglTexture.h:22
void uploadPixelData(TSpanView< std::byte > pixelData, EPixelFormat pixelFormat, EPixelComponent pixelComponent)
Upload pixel data for the full texture.
Definition OpenglTexture.cpp:87
bool isColor() const
Definition OpenglTexture.cpp:206
GLenum internalFormat
Definition OpenglTexture.h:23
Definition ghi_infos.h:101
Definition PlatformDisplay.h:13
EPixelFormat
Definition ghi_enums.h:31
EPixelComponent
Definition ghi_enums.h:42