Otclient  14/8/2020
framebuffer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #ifndef FRAMEBUFFER_H
24 #define FRAMEBUFFER_H
25 
26 #include "declarations.h"
27 #include "texture.h"
28 
30 {
31 protected:
32  FrameBuffer();
33 
34  friend class FrameBufferManager;
35 
36 public:
37  virtual ~FrameBuffer();
38 
39  void resize(const Size& size);
40  void bind();
41  void release();
42  void draw();
43  void draw(const Rect& dest);
44  void draw(const Rect& dest, const Rect& src);
45 
46  void setBackuping(bool enabled) { m_backuping = enabled; }
47  void setSmooth(bool enabled) { m_smooth = enabled; }
48 
49  TexturePtr getTexture() { return m_texture; }
50  Size getSize();
51  bool isBackuping() { return m_backuping; }
52  bool isSmooth() { return m_smooth; }
53 
54 private:
55  void internalCreate();
56  void internalBind();
57  void internalRelease();
58 
59  TexturePtr m_texture;
60  TexturePtr m_screenBackup;
61  Size m_oldViewportSize;
62  uint m_fbo;
63  uint m_prevBoundFbo;
64  stdext::boolean<true> m_backuping;
65  stdext::boolean<true> m_smooth;
66 
67  static uint boundFbo;
68 };
69 
70 #endif
FrameBuffer::setSmooth
void setSmooth(bool enabled)
Definition: framebuffer.h:47
TRect< int >
FrameBuffer::FrameBuffer
FrameBuffer()
Definition: framebuffer.cpp:32
stdext::boolean< true >
FrameBuffer::draw
void draw()
Definition: framebuffer.cpp:97
uint
unsigned int uint
Definition: types.h:31
FrameBuffer::release
void release()
Definition: framebuffer.cpp:91
FrameBuffer::setBackuping
void setBackuping(bool enabled)
Definition: framebuffer.h:46
FrameBuffer
Definition: framebuffer.h:29
FrameBuffer::bind
void bind()
Definition: framebuffer.cpp:84
declarations.h
texture.h
stdext::shared_object_ptr< Texture >
FrameBuffer::~FrameBuffer
virtual ~FrameBuffer()
Definition: framebuffer.cpp:48
FrameBuffer::resize
void resize(const Size &size)
Definition: framebuffer.cpp:57
FrameBufferManager
Definition: framebuffermanager.h:29
FrameBuffer::isBackuping
bool isBackuping()
Definition: framebuffer.h:51
FrameBuffer::getSize
Size getSize()
Definition: framebuffer.cpp:148
FrameBuffer::getTexture
TexturePtr getTexture()
Definition: framebuffer.h:49
TSize< int >
FrameBuffer::isSmooth
bool isSmooth()
Definition: framebuffer.h:52
stdext::shared_object
Definition: shared_object.h:41