forked from mortennobel/SimpleRenderEngine
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFramebuffer.hpp
More file actions
73 lines (62 loc) · 2.24 KB
/
Copy pathFramebuffer.hpp
File metadata and controls
73 lines (62 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* SimpleRenderEngine (https://github.com/mortennobel/SimpleRenderEngine)
*
* Created by Morten Nobel-Jørgensen ( http://www.nobel-joergensen.com/ )
* License: MIT
*/
#pragma once
#include <memory>
#include <vector>
#include <string>
#include "glm/glm.hpp"
#include "Texture.hpp"
#include "impl/CPPShim.hpp"
namespace sre {
class RenderPass;
class Texture;
/**
* A framebuffer object allows rendering into textures instead of the screen.
*
* A framebuffer is created with a destination texture. It is important that this texture is not used in
* materials when rendering to the framebuffer (reading and writing to a texture at the same time is not supported).
*
* To use a framebuffer, pass it to RenderPassBuilder when a renderpass is being created.
*/
class Framebuffer {
public:
class FrameBufferBuilder {
public:
FrameBufferBuilder& withColorTexture(std::shared_ptr<Texture> texture);
FrameBufferBuilder& withDepthTexture(std::shared_ptr<Texture> texture);
FrameBufferBuilder& withName(std::string name);
std::shared_ptr<Framebuffer> build();
private:
std::vector<std::shared_ptr<Texture>> textures;
std::shared_ptr<Texture> depthTexture;
glm::uvec2 size;
std::string name;
FrameBufferBuilder() = default;
FrameBufferBuilder(const FrameBufferBuilder&) = default;
friend class Framebuffer;
};
~Framebuffer();
static FrameBufferBuilder create();
static int getMaximumDepthAttachments();
static int getMaximumColorAttachments();
void setColorTexture(std::shared_ptr<Texture> tex, int index = 0);
void setDepthTexture(std::shared_ptr<Texture> tex);
const std::string& getName();
private:
void bind();
bool dirty = true;
explicit Framebuffer(std::string name);
std::vector<std::shared_ptr<Texture>> textures;
std::shared_ptr<Texture> depthTexture;
unsigned int frameBufferObjectId;
uint32_t renderbuffer = 0;
std::string name;
glm::uvec2 size;
friend class RenderPass;
friend class Inspector;
};
}