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 The 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, see <https://www.gnu.org/licenses/>.
21 */
22
28
29#ifndef OPENGL_COMPOSITOR_H_
30#define OPENGL_COMPOSITOR_H_
31
32#include <kicad_gl/kiglad.h> // Must be included first
33
34#include <gal/compositor.h>
37#include <deque>
38
39namespace KIGFX
40{
41
43{
44public:
46 virtual ~OPENGL_COMPOSITOR();
47
49 virtual void Initialize() override;
50
52 virtual void Resize( unsigned int aWidth, unsigned int aHeight ) override;
53
55 virtual unsigned int CreateBuffer() override;
56
58 virtual void SetBuffer( unsigned int aBufferHandle ) override;
59
61 inline virtual unsigned int GetBuffer() const override
62 {
64 return DIRECT_RENDERING;
65
66 return m_curBuffer + 1;
67 }
68
70 virtual void ClearBuffer( const COLOR4D& aColor ) override;
71
73 virtual void DrawBuffer( unsigned int aBufferHandle ) override;
74
76 virtual void Begin() override;
77
78 // @copydoc COMPOSITOR::Present()
79 virtual void Present() override;
80
81 // Constant used by glBindFramebuffer to turn off rendering to framebuffers
82 static const unsigned int DIRECT_RENDERING = 0;
83
84 VECTOR2I GetScreenSize() const;
85 GLenum GetBufferTexture( unsigned int aBufferHandle );
86 void DrawBuffer( unsigned int aSourceHandle, unsigned int aDestHandle );
87
96 void DrawBufferDifference( unsigned int aSourceHandle, unsigned int aDestHandle );
97
98 unsigned int CreateBuffer( VECTOR2I aDimensions );
99
100 void SetAntialiasingMode( GAL_ANTIALIASING_MODE aMode ); // clears all buffers
102
105
106protected:
108 void bindFb( unsigned int aFb );
109
113 void clean();
114
116 inline unsigned int usedBuffers()
117 {
118 return m_buffers.size();
119 }
120
121 // Buffers are simply textures storing a result of certain target rendering.
128
130 unsigned int m_curBuffer;
131 GLuint m_mainFbo;
133 typedef std::deque<OPENGL_BUFFER> OPENGL_BUFFERS;
134
137
139 GLuint m_curFbo;
140
142 std::unique_ptr<OPENGL_PRESENTOR> m_antialiasing;
143
144 // Difference shader for XOR-style compositing
149
155
159 void drawFullScreenQuad();
160};
161} // namespace KIGFX
162
163#endif /* COMPOSITOR_H_ */
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
GAL_ANTIALIASING_MODE m_currentAntialiasingMode
VECTOR2D GetAntialiasRenderingOffset() const
virtual void Begin() override
Call this at the beginning of each frame.
unsigned int usedBuffers()
Returns number of used buffers.
void SetAntialiasingMode(GAL_ANTIALIASING_MODE aMode)
static const unsigned int DIRECT_RENDERING
virtual unsigned int GetBuffer() const override
Return currently used buffer handle.
void clean()
Perform freeing of resources.
GLint m_diffDstTexUniform
Destination texture uniform location.
bool initDifferenceShader()
Initialize the difference shader program.
virtual void Present() override
Call this to present the output buffer to the screen.
bool m_initialized
Initialization status flag.
GLint m_diffSrcTexUniform
Source texture uniform location.
std::deque< OPENGL_BUFFER > OPENGL_BUFFERS
void bindFb(unsigned int aFb)
Binds a specific Framebuffer Object.
GAL_ANTIALIASING_MODE GetAntialiasingMode() const
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.
void drawFullScreenQuad()
Draw a fullscreen quad for compositing.
void DrawBufferDifference(unsigned int aSourceHandle, unsigned int aDestHandle)
Draw buffer with difference blending (XOR-style for gerbview).
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
GLuint m_differenceShader
Difference shader program.
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)
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 eda_group.h:29
GLuint attachmentPoint
Point to which an image from texture is attached.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683
VECTOR2< double > VECTOR2D
Definition vector2d.h:682