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-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 
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 bool 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  bool 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
int samples
Requested number of samples for multisampling.
Definition: framebuffer.h:43
int depth
Requested depth buffer.
Definition: framebuffer.h:41
int width
Requested width of buffers.
Definition: framebuffer.h:37
Contains parameters for new framebuffer.
Definition: framebuffer.h:34
Namespace for (new) graphics code.
Definition: app.h:49
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
bool depthTexture
true requests depth texture
Definition: framebuffer.h:47
Concrete implementation of default framebuffer.
Definition: framebuffer.h:116
Abstract interface of default framebuffer and offscreen framebuffers.
Definition: framebuffer.h:67