Catos Engine (Source) 0.0.1
Lightweight Game engine
Loading...
Searching...
No Matches
renderPass.h
Go to the documentation of this file.
1//
2// Created by allos on 10/16/2024.
3//
4#pragma once
5
6#include <math/vecs.h>
7#include <renderer/shader.h>
8
9using namespace catos::math;
10
11namespace catos {
12
13 typedef unsigned int ColorBuffer;
14 typedef unsigned int FrameBuffer;
15 typedef unsigned int RenderBuffer;
16
18 enum PassType: unsigned int {
20 COLOR = 0x8CE0,
22 COLOR_SINGLE = 0x8CE1,
23 DEPTH = 0x8D00,
24 STENCIL = 0x8D20,
25 };
26
30 bool willBeVisible = false;
31
33 Vector2 size{512, 512};
34
36 bool resizeToRenderSize = false;
37
39
40 };
41
42 /* a RenderPass is a object that renders everything with a given shader
43 * This then generates a texture which can be used for displaying or info for a different pass / shader.
44 */
45 class RenderPass {
46
47 public:
48
49 RenderPass(const RenderPassCreationInfo& info, Shader& shaderToUse);
51
53 void bindPass();
55 void unbindPass();
56
57 FrameBuffer getFrameBuffer() { return frameBuffer; };
58 ColorBuffer getPassTexture() { return colorBuffer; };
59 RenderBuffer getRenderBuffer() { return renderBuffer; };
60
62 bool isFinal() { return _isFinal; };
63
64 private:
65
66 void generateFrameBuffer(const Vector2& size);
67 void generateColorBuffer(const Vector2& size, PassType type);
68 void generateRenderBuffer(const Vector2& size);
69
70
71 unsigned int frameBuffer;
72 unsigned int colorBuffer;
73 unsigned int renderBuffer;
74
75 bool _isFinal = false;
76 bool _shouldResize = false;
77
78 Shader& shader;
79
80 };
81
82
83}
Definition application.h:13
unsigned int ColorBuffer
Definition renderPass.h:13
unsigned int FrameBuffer
Definition renderPass.h:14
unsigned int RenderBuffer
Definition renderPass.h:15
PassType
What kind of type the Pass Should be.
Definition renderPass.h:18
@ COLOR
All colors.
Definition renderPass.h:20
@ COLOR_SINGLE
1 single color support
Definition renderPass.h:22
@ DEPTH
Definition renderPass.h:23
@ STENCIL
Definition renderPass.h:24
Definition vecs.h:10
Definition vecs.h:13
Info about how the RenderPass should be created.
Definition renderPass.h:28
bool resizeToRenderSize
If the pass should resize to the global Render size.
Definition renderPass.h:36
bool willBeVisible
If the Pass will be presented to the Window.
Definition renderPass.h:30
Vector2 size
The size of the Pass's image.
Definition renderPass.h:33
PassType passType
Definition renderPass.h:38
Definition renderPass.h:45
~RenderPass()
Definition renderPass.cpp:27
RenderPass(const RenderPassCreationInfo &info, Shader &shaderToUse)
Definition renderPass.cpp:9
FrameBuffer getFrameBuffer()
Definition renderPass.h:57
void unbindPass()
UnBinds and cleans the pass.
Definition renderPass.cpp:72
void bindPass()
Binds and cleans the pass.
Definition renderPass.cpp:59
bool isFinal()
isFinal is wether or not the User will see this texture.
Definition renderPass.h:62
ColorBuffer getPassTexture()
Definition renderPass.h:58
RenderBuffer getRenderBuffer()
Definition renderPass.h:59
Definition shader.h:35