Colobot
glframebuffer.h
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
20 #pragma once
21 
23 
24 #include "graphics/opengl/glutil.h"
25 
26 namespace Gfx
27 {
28 
37 {
38 protected:
39  FramebufferParams m_params;
40 
41  int m_width, m_height, m_depth, m_samples;
42 
43  GLuint m_fbo;
44  GLuint m_colorRenderbuffer;
45  GLuint m_colorTexture;
46  GLuint m_depthRenderbuffer;
47  GLuint m_depthTexture;
48 
49  static GLuint m_currentFBO;
50 
51 public:
52  CGLFramebuffer(const FramebufferParams& params);
53 
54  bool Create() override;
55 
56  void Destroy() override;
57 
58  bool IsDefault() override;
59 
60  int GetWidth() override;
61 
62  int GetHeight() override;
63 
64  int GetDepth() override;
65 
66  int GetSamples() override;
67 
68  int GetColorTexture() override;
69 
70  int GetDepthTexture() override;
71 
72  void Bind() override;
73 
74  void Unbind() override;
75 
76  void CopyToScreen(int fromX, int fromY, int fromWidth, int fromHeight, int toX, int toY, int toWidth, int toHeight) override;
77 };
78 
87 {
88 protected:
89  FramebufferParams m_params;
90 
91  int m_width, m_height, m_depth, m_samples;
92 
93  GLuint m_fbo;
94  GLuint m_colorRenderbuffer;
95  GLuint m_colorTexture;
96  GLuint m_depthRenderbuffer;
97  GLuint m_depthTexture;
98 
99  static GLuint m_currentFBO;
100 
101 public:
102  CGLFramebufferEXT(const FramebufferParams& params);
103 
104  bool Create() override;
105 
106  void Destroy() override;
107 
108  bool IsDefault() override;
109 
110  int GetWidth() override;
111 
112  int GetHeight() override;
113 
114  int GetDepth() override;
115 
116  int GetSamples() override;
117 
118  int GetColorTexture() override;
119 
120  int GetDepthTexture() override;
121 
122  void Bind() override;
123 
124  void Unbind() override;
125 
126  void CopyToScreen(int fromX, int fromY, int fromWidth, int fromHeight, int toX, int toY, int toWidth, int toHeight) override;
127 };
128 
129 } // end of Gfx
Abstract representation of framebuffer and offscreen buffers.
int GetHeight() override
Returns height of buffers in this framebuffer.
Definition: glframebuffer.cpp:241
void Destroy() override
Destroys this framebuffer.
Definition: glframebuffer.cpp:189
int GetSamples() override
Returns number of samples or 1 if multisampling is not supported.
Definition: glframebuffer.cpp:253
Definition: glframebuffer.h:86
void CopyToScreen(int fromX, int fromY, int fromWidth, int fromHeight, int toX, int toY, int toWidth, int toHeight) override
Copies content of color buffer to screen.
Definition: glframebuffer.cpp:284
void Bind() override
Binds this framebuffer to context.
Definition: glframebuffer.cpp:271
bool Create() override
Creates this framebuffer.
Definition: glframebuffer.cpp:45
int GetDepth() override
Returns depth size in bits.
Definition: glframebuffer.cpp:247
Contains parameters for new framebuffer.
Definition: framebuffer.h:34
Namespace for (new) graphics code.
Definition: app.h:49
Implementation of CFramebuffer interface in OpenGL 3.0+.
Definition: glframebuffer.h:36
int GetColorTexture() override
Returns texture that contains color buffer or 0 if not available.
Definition: glframebuffer.cpp:259
int GetWidth() override
Returns width of buffers in this framebuffer.
Definition: glframebuffer.cpp:235
bool IsDefault() override
Returns true if this is default framebuffer.
Definition: glframebuffer.cpp:229
void Unbind() override
Unbinds this framebuffer from context.
Definition: glframebuffer.cpp:278
Abstract interface of default framebuffer and offscreen framebuffers.
Definition: framebuffer.h:67
int GetDepthTexture() override
Returns texture that contains depth buffer or 0 if not available.
Definition: glframebuffer.cpp:265