Euphoria
texture.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
5#include "eu/base/size.h"
6
8
9#include "eu/core/color.h"
10
11namespace eu::render
12{
13
17
18enum class TextureEdge
19{
22};
23
24
31
32
33enum class Transparency
34{
37};
38
39enum class ColorData
40{
43
44 // todo(Gustav): should this be more specific so we could define better default colors if the load fails?
47
50};
51
52
53// todo(Gustav): this doesn't do anything except allow code reuse, remove?
56{
57 unsigned int id;
58
61
62 BaseTexture(const BaseTexture&) = delete;
63 void operator=(const BaseTexture&) = delete;
64
66 BaseTexture& operator=(BaseTexture&&) noexcept;
67
69 void unload();
70};
71
74{
75 Texture2d() = delete;
76
78 Texture2d(DEBUG_LABEL_ARG_MANY const void* pixel_data, unsigned int pixel_format, int w, int h, TextureEdge te, TextureRenderStyle trs, Transparency t, ColorData cd);
79};
80
82
83// todo(Gustav): turn into an enum?
85constexpr std::size_t cubemap_size = 6;
86
90{
91 TextureCubemap() = delete;
92
93 TextureCubemap(DEBUG_LABEL_ARG_MANY const std::array<void*, cubemap_size>& pixel_data, int width, int height, ColorData cd);
94};
95
97
98
99
103{
106 FrameBuffer(unsigned int f, const Size& s);
108
109 FrameBuffer(const FrameBuffer&) = delete;
111 void operator=(const FrameBuffer&) = delete;
112 void operator=(FrameBuffer&&) = delete;
113
115
116 unsigned int fbo = 0;
117 unsigned int rbo = 0;
118
119 bool debug_is_msaa = false;
120};
121
128
135
136
146std::shared_ptr<FrameBuffer> build_simple_framebuffer(DEBUG_LABEL_ARG_MANY const Size& size);
147
148
160std::shared_ptr<FrameBuffer> build_msaa_framebuffer(DEBUG_LABEL_ARG_MANY const Size& size, int msaa_samples, ColorBitsPerPixel bits_per_pixel);
161
162
171std::shared_ptr<FrameBuffer> build_hdr_floating_framebuffer(DEBUG_LABEL_ARG_MANY const Size& size, ColorBitsPerPixel bits_per_pixel);
172
173
181std::shared_ptr<FrameBuffer> build_shadow_framebuffer(DEBUG_LABEL_ARG_MANY const Size& size);
182
183
186{
187 std::shared_ptr<FrameBuffer> fbo;
188
189 BoundFbo(const BoundFbo&) = delete;
190 BoundFbo(BoundFbo&&) = delete;
191 void operator=(const BoundFbo&) = delete;
192 void operator=(BoundFbo&&) = delete;
193
194 explicit BoundFbo(std::shared_ptr<FrameBuffer> f);
196};
197
199
203
204}
#define DEBUG_LABEL_ARG_MANY
first debug label argument of many
std::shared_ptr< FrameBuffer > build_msaa_framebuffer(DEBUG_LABEL_ARG_MANY const Size &size, int msaa_samples, ColorBitsPerPixel bits_per_pixel)
Builds a multisample anti-aliasing (MSAA) framebuffer for high-quality rendering.
std::shared_ptr< FrameBuffer > build_simple_framebuffer(DEBUG_LABEL_ARG_MANY const Size &size)
Build a simple LDR frame buffer.
TextureCubemap load_cubemap_from_color(DEBUG_LABEL_ARG_MANY core::SingleColor pixel, ColorData cd)
void resolve_multisampled_buffer(const FrameBuffer &src, FrameBuffer *dst)
std::shared_ptr< FrameBuffer > build_hdr_floating_framebuffer(DEBUG_LABEL_ARG_MANY const Size &size, ColorBitsPerPixel bits_per_pixel)
Build a HDR frame buffer.
ColorBitsPerPixel
The number of bits/pixel to use for the color buffer.
Definition texture.h:131
std::shared_ptr< FrameBuffer > build_shadow_framebuffer(DEBUG_LABEL_ARG_MANY const Size &size)
Create a depth-only framebuffer for shadow rendering.
DepthBits
The number of bits to use for the depth buffer.
Definition texture.h:124
constexpr std::size_t cubemap_size
0=right(x+), 1=left(x-), 2=top(y+), 3=bottom(y-), 4=front(z+), 5=back(z-)
Definition texture.h:85
TextureRenderStyle
Definition texture.h:26
Texture2d load_image_from_color(DEBUG_LABEL_ARG_MANY core::SingleColor pixel, TextureEdge te, TextureRenderStyle trs, Transparency t, ColorData cd)
@ non_color_data
Don't apply transformations to the color data. Texture is a normal/roughness/ao/specular map or simil...
Definition texture.h:46
@ color_data
Apply transformations to the color data. Texture is a diffuse/albedo map, created with human eyes on ...
Definition texture.h:42
@ dont_care
Explicitly don't care about the color data but same as non_color_data.
Definition texture.h:49
SingleColor
A single color in a format to load directly into open gl texture(ABGR on little endian).
Definition color.h:9
Definition ui.h:4
a size
Definition size.h:11
BaseTexture(const BaseTexture &)=delete
unsigned int id
Definition texture.h:57
BaseTexture(BaseTexture &&) noexcept
void operator=(const BaseTexture &)=delete
void unload()
clears the loaded texture to a invalid texture
BoundFbo(const BoundFbo &)=delete
BoundFbo(BoundFbo &&)=delete
void operator=(BoundFbo &&)=delete
std::shared_ptr< FrameBuffer > fbo
Definition texture.h:187
void operator=(const BoundFbo &)=delete
BoundFbo(std::shared_ptr< FrameBuffer > f)
"render to texture" feature
Definition texture.h:103
FrameBuffer(const FrameBuffer &)=delete
FrameBuffer(unsigned int f, const Size &s)
FrameBuffer(FrameBuffer &&)=delete
void operator=(FrameBuffer &&)=delete
void operator=(const FrameBuffer &)=delete
A 2d image texture.
Definition texture.h:74
Texture2d(DEBUG_LABEL_ARG_MANY const void *pixel_data, unsigned int pixel_format, int w, int h, TextureEdge te, TextureRenderStyle trs, Transparency t, ColorData cd)
"internal"
A cubemap texture.
Definition texture.h:90
TextureCubemap(DEBUG_LABEL_ARG_MANY const std::array< void *, cubemap_size > &pixel_data, int width, int height, ColorData cd)