KiCad PCB EDA Suite
Loading...
Searching...
No Matches
opengl_compositor.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2013-2016 CERN
5 * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Maciej Suminski <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
33#ifndef OPENGL_COMPOSITOR_H_
34#define OPENGL_COMPOSITOR_H_
35
36#include <gal/opengl/kiglew.h> // Must be included first
37
38#include <gal/compositor.h>
41#include <deque>
42
43namespace KIGFX
44{
45
47{
48public:
50 virtual ~OPENGL_COMPOSITOR();
51
53 virtual void Initialize() override;
54
56 virtual void Resize( unsigned int aWidth, unsigned int aHeight ) override;
57
59 virtual unsigned int CreateBuffer() override;
60
62 virtual void SetBuffer( unsigned int aBufferHandle ) override;
63
65 inline virtual unsigned int GetBuffer() const override
66 {
68 return DIRECT_RENDERING;
69
70 return m_curBuffer + 1;
71 }
72
74 virtual void ClearBuffer( const COLOR4D& aColor ) override;
75
77 virtual void DrawBuffer( unsigned int aBufferHandle ) override;
78
80 virtual void Begin() override;
81
82 // @copydoc COMPOSITOR::Present()
83 virtual void Present() override;
84
85 // Constant used by glBindFramebuffer to turn off rendering to framebuffers
86 static const unsigned int DIRECT_RENDERING = 0;
87
88 VECTOR2I GetScreenSize() const;
89 GLenum GetBufferTexture( unsigned int aBufferHandle );
90 void DrawBuffer( unsigned int aSourceHandle, unsigned int aDestHandle );
91 unsigned int CreateBuffer( VECTOR2I aDimensions );
92
93 void SetAntialiasingMode( OPENGL_ANTIALIASING_MODE aMode ); // clears all buffers
95
98
99protected:
101 void bindFb( unsigned int aFb );
102
106 void clean();
107
109 inline unsigned int usedBuffers()
110 {
111 return m_buffers.size();
112 }
113
114 // Buffers are simply textures storing a result of certain target rendering.
116 {
120 };
121
123 unsigned int m_curBuffer;
124 GLuint m_mainFbo;
126 typedef std::deque<OPENGL_BUFFER> OPENGL_BUFFERS;
127
130
132 GLuint m_curFbo;
133
135 std::unique_ptr<OPENGL_PRESENTOR> m_antialiasing;
136};
137} // namespace KIGFX
138
139#endif /* COMPOSITOR_H_ */
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
VECTOR2D GetAntialiasRenderingOffset() const
OPENGL_ANTIALIASING_MODE m_currentAntialiasingMode
virtual void Begin() override
Call this at the beginning of each frame.
unsigned int usedBuffers()
Returns number of used buffers.
static const unsigned int DIRECT_RENDERING
virtual unsigned int GetBuffer() const override
Return currently used buffer handle.
OPENGL_ANTIALIASING_MODE GetAntialiasingMode() const
void SetAntialiasingMode(OPENGL_ANTIALIASING_MODE aMode)
void clean()
Perform freeing of resources.
virtual void Present() override
Call this to present the output buffer to the screen.
bool m_initialized
Initialization status flag.
std::deque< OPENGL_BUFFER > OPENGL_BUFFERS
void bindFb(unsigned int aFb)
Binds a specific Framebuffer Object.
GLuint m_curFbo
Store the used FBO name in case there was more than one compositor used.
virtual void Initialize() override
Perform primary initialization, necessary to use the object.
GLuint m_depthBuffer
Depth buffer handle.
virtual void ClearBuffer(const COLOR4D &aColor) override
Clear the selected buffer (set by the SetBuffer() function).
std::unique_ptr< OPENGL_PRESENTOR > m_antialiasing
virtual void Resize(unsigned int aWidth, unsigned int aHeight) override
Clear the state of COMPOSITOR, so it has to be reinitialized again with the new dimensions.
OPENGL_BUFFERS m_buffers
Stores information about initialized buffers.
virtual void DrawBuffer(unsigned int aBufferHandle) override
Draw the selected buffer to the output buffer.
GLuint m_mainFbo
Main FBO handle (storing all target textures)
int GetAntialiasSupersamplingFactor() const
unsigned int m_curBuffer
Currently used buffer handle.
GLenum GetBufferTexture(unsigned int aBufferHandle)
virtual void SetBuffer(unsigned int aBufferHandle) override
Set the selected buffer as the rendering target.
virtual unsigned int CreateBuffer() override
Prepare a new buffer that may be used as a rendering target.
Class that handles multitarget rendering (ie.
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
GLuint textureTarget
Main texture handle.
GLuint attachmentPoint
Point to which an image from texture is attached.