forked from bwrrp/glblaat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGLFramebuffer.h
71 lines (57 loc) · 1.92 KB
/
GLFramebuffer.h
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
// Copyright (c) 2009 Stef Busking
// Distributed under the terms of the MIT License.
#pragma once
#include "GLResource.h"
#include "GL.h"
#include "GLRendertarget.h"
#include "GLTexture.h"
#include <map>
class GLFramebuffer : public GLResource
{
public:
static GLFramebuffer *New(int width, int height);
~GLFramebuffer();
GLRendertarget *AttachRendertarget(int attachment, GLRendertarget *rt);
GLRendertarget *AttachRendertarget(int attachment, GLRendertarget &rt);
GLRendertarget *DetachRendertarget(int attachment);
bool CreateDepthBuffer(int format = GL_DEPTH_COMPONENT);
bool CreateDepthTexture(int format = GL_DEPTH_COMPONENT);
bool CreateDepthTextureRectangle(int format = GL_DEPTH_COMPONENT);
bool CreatePackedDepthStencilBuffer();
bool CreatePackedDepthStencilTexture();
bool CreatePackedDepthStencilTextureRectangle();
bool CreateColorBuffer(
int attachment = GL_COLOR_ATTACHMENT0_EXT,
int format = GL_RGBA);
bool CreateColorTexture(
int attachment = GL_COLOR_ATTACHMENT0_EXT,
int internalformat = GL_RGBA8,
int format = GL_RGBA,
int type = GL_UNSIGNED_BYTE);
bool CreateColorTextureRectangle(
int attachment = GL_COLOR_ATTACHMENT0_EXT,
int internalformat = GL_RGBA8,
int format = GL_RGBA,
int type = GL_UNSIGNED_BYTE);
void Bind();
void Unbind();
bool IsBound() const { return bound; }
int GetStatus();
bool IsOk();
inline int GetWidth() const { return width; }
inline int GetHeight() const { return height; }
GLTexture *GetTexture2D(int attachment = GL_COLOR_ATTACHMENT0_EXT);
const GLTexture *GetTexture2D(int attachment) const;
bool Resize(int width, int height);
protected:
GLFramebuffer(int width, int height);
GLuint id;
std::map<int, GLRendertarget*> attachments;
int width;
int height;
bool bound;
private:
// Not implemented
GLFramebuffer(const GLFramebuffer&);
void operator=(const GLFramebuffer&);
};