Euphoria
texture.h
Go to the documentation of this file.
1#pragma once
2
3#include "eu/base/size.h"
4
6
7#include "eu/core/color.h"
8
9namespace eu::render
10{
11
16enum class TextureEdge
17{
18 clamp,
19 repeat
20};
21
22
24{
25 pixel,
26 mipmap,
27 linear
28};
29
30
31enum class Transparency
32{
33 include,
35};
36
37enum class ColorData
38{
41
42 // todo(Gustav): should this be more specific so we could define better default colors if the load fails?
45
48};
49
50
51// todo(Gustav): this doesn't do anything except allow code reuse, remove?
54{
55 unsigned int id;
56
59
60 BaseTexture(const BaseTexture&) = delete;
61 void operator=(const BaseTexture&) = delete;
62
65
67 void unload();
68};
69
78
80
81// todo(Gustav): turn into an enum?
83constexpr std::size_t cubemap_size = 6;
84
88{
89 TextureCubemap() = delete;
90
91 TextureCubemap(DEBUG_LABEL_ARG_MANY const std::array<void*, cubemap_size>& pixel_data, int width, int height, ColorData cd);
92};
93
95
96
97
101{
104 FrameBuffer(unsigned int f, const Size& s);
106
107 FrameBuffer(const FrameBuffer&) = delete;
109 void operator=(const FrameBuffer&) = delete;
110 void operator=(FrameBuffer&&) = delete;
111
113
114 unsigned int fbo = 0;
115 unsigned int rbo = 0;
116
117 bool debug_is_msaa = false;
118};
119
121enum class DepthBits
122{
123 use_none,
125};
126
129{
130 use_depth,
132};
133
134
144std::shared_ptr<FrameBuffer> build_simple_framebuffer(DEBUG_LABEL_ARG_MANY const Size& size);
145
146
159
160
170
171
179std::shared_ptr<FrameBuffer> build_shadow_framebuffer(DEBUG_LABEL_ARG_MANY const Size& size);
180
181
184{
185 std::shared_ptr<FrameBuffer> fbo;
186
187 BoundFbo(const BoundFbo&) = delete;
188 BoundFbo(BoundFbo&&) = delete;
189 void operator=(const BoundFbo&) = delete;
190 void operator=(BoundFbo&&) = delete;
191
192 explicit BoundFbo(std::shared_ptr<FrameBuffer> f);
194};
195
197
202}
#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:129
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:122
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:83
TextureRenderStyle
Definition texture.h:24
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...
@ color_data
Apply transformations to the color data. Texture is a diffuse/albedo map, created with human eyes on ...
@ dont_care
Explicitly don't care about the color data but same as non_color_data.
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 (inclusive) range between two values.
Definition range.h:19
a size
Definition size.h:11
Base class for all textures, but only exist due to code reuse and can easily be inlined.
Definition texture.h:54
BaseTexture(const BaseTexture &)=delete
unsigned int id
Definition texture.h:55
BaseTexture(BaseTexture &&) noexcept
void operator=(const BaseTexture &)=delete
void unload()
clears the loaded texture to a invalid texture
raii class to render to a FrameBuffer
Definition texture.h:184
BoundFbo(const BoundFbo &)=delete
BoundFbo(BoundFbo &&)=delete
void operator=(BoundFbo &&)=delete
std::shared_ptr< FrameBuffer > fbo
Definition texture.h:185
void operator=(const BoundFbo &)=delete
BoundFbo(std::shared_ptr< FrameBuffer > f)
"render to texture" feature
Definition texture.h:101
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:72
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:88
TextureCubemap(DEBUG_LABEL_ARG_MANY const std::array< void *, cubemap_size > &pixel_data, int width, int height, ColorData cd)