Colobot
framebuffer.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2015, 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 
25 #pragma once
26 
27 namespace Gfx
28 {
29 
35 {
37  int width = 1024;
39  int height = 1024;
41  int depth = 16;
43  int samples = 1;
45  bool colorTexture = false;
47  bool depthTexture = false;
48 
50  void LoadDefault()
51  {
52  *this = FramebufferParams();
53  }
54 };
55 
68 {
69 public:
70  virtual ~CFramebuffer() {}
71 
73  virtual void Create() = 0;
74 
76  virtual void Destroy() = 0;
77 
79  virtual bool IsDefault() = 0;
80 
82  virtual int GetWidth() = 0;
83 
85  virtual int GetHeight() = 0;
86 
88  virtual int GetDepth() = 0;
89 
91  virtual int GetSamples() = 0;
92 
94  virtual int GetColorTexture() = 0;
95 
97  virtual int GetDepthTexture() = 0;
98 
100  virtual void Bind() = 0;
101 
103  virtual void Unbind() = 0;
104 
106  virtual void CopyToScreen(int fromX, int fromY, int fromWidth, int fromHeight, int toX, int toY, int toWidth, int toHeight) = 0;
107 };
108 
109 
117 {
118 private:
119  int m_width, m_height, m_depth;
120 
121 public:
122  explicit CDefaultFramebuffer(const FramebufferParams &params);
123 
125  void Create() override;
126 
128  void Destroy() override;
129 
131  bool IsDefault() override;
132 
134  int GetWidth() override;
135 
137  int GetHeight() override;
138 
140  int GetDepth() override;
141 
143  int GetSamples() override;
144 
146  int GetColorTexture() override;
147 
149  int GetDepthTexture() override;
150 
152  void Bind() override;
153 
155  void Unbind() override;
156 
158  void CopyToScreen(int fromX, int fromY, int fromWidth, int fromHeight, int toX, int toY, int toWidth, int toHeight) override;
159 };
160 
161 } // end of Gfx
void Unbind() override
Unbinds this framebuffer from context.
Definition: framebuffer.cpp:90
virtual void CopyToScreen(int fromX, int fromY, int fromWidth, int fromHeight, int toX, int toY, int toWidth, int toHeight)=0
Copies content of color buffer to screen.
virtual void Destroy()=0
Destroys this framebuffer.
int samples
Requested number of samples for multisampling.
Definition: framebuffer.h:43
bool IsDefault() override
Returns true.
Definition: framebuffer.cpp:43
int GetHeight() override
Returns height of buffers in this framebuffer.
Definition: framebuffer.cpp:55
int GetDepthTexture() override
Returns texture that contains depth buffer or 0 if not available.
Definition: framebuffer.cpp:79
int GetSamples() override
Returns number of samples or 1 if multisampling is not supported.
Definition: framebuffer.cpp:67
void Bind() override
Binds this framebuffer to context.
Definition: framebuffer.cpp:85
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: framebuffer.cpp:94
virtual int GetSamples()=0
Returns number of samples or 1 if multisampling is not supported.
virtual void Unbind()=0
Unbinds this framebuffer from context.
int depth
Requested depth buffer.
Definition: framebuffer.h:41
int width
Requested width of buffers.
Definition: framebuffer.h:37
virtual int GetWidth()=0
Returns width of buffers in this framebuffer.
Contains parameters for new framebuffer.
Definition: framebuffer.h:34
virtual int GetHeight()=0
Returns height of buffers in this framebuffer.
Namespace for (new) graphics code.
Definition: app.h:49
int GetDepth() override
Returns depth size in bits.
Definition: framebuffer.cpp:61
virtual int GetDepth()=0
Returns depth size in bits.
virtual void Bind()=0
Binds this framebuffer to context.
int GetColorTexture() override
Returns texture that contains color buffer or 0 if not available.
Definition: framebuffer.cpp:73
int height
Requested height of buffers.
Definition: framebuffer.h:39
bool colorTexture
true requests color texture
Definition: framebuffer.h:45
void LoadDefault()
Loads default values.
Definition: framebuffer.h:50
void Destroy() override
Destroys default framebuffer.
Definition: framebuffer.cpp:39
int GetWidth() override
Returns width of buffers in this framebuffer.
Definition: framebuffer.cpp:49
virtual void Create()=0
Creates this framebuffer.
bool depthTexture
true requests depth texture
Definition: framebuffer.h:47
Concrete implementation of default framebuffer.
Definition: framebuffer.h:116
virtual int GetColorTexture()=0
Returns texture that contains color buffer or 0 if not available.
void Create() override
Creates default framebuffer.
Definition: framebuffer.cpp:35
Abstract interface of default framebuffer and offscreen framebuffers.
Definition: framebuffer.h:67
virtual int GetDepthTexture()=0
Returns texture that contains depth buffer or 0 if not available.
virtual bool IsDefault()=0
Returns true if this is default framebuffer.