KiCad PCB EDA Suite
|
#include <opengl_compositor.h>
Classes | |
struct | OPENGL_BUFFER |
Public Member Functions | |
OPENGL_COMPOSITOR () | |
virtual | ~OPENGL_COMPOSITOR () |
virtual void | Initialize () override |
Perform primary initialization, necessary to use the object. | |
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. | |
virtual unsigned int | CreateBuffer () override |
Prepare a new buffer that may be used as a rendering target. | |
virtual void | SetBuffer (unsigned int aBufferHandle) override |
Set the selected buffer as the rendering target. | |
virtual unsigned int | GetBuffer () const override |
Return currently used buffer handle. | |
virtual void | ClearBuffer (const COLOR4D &aColor) override |
Clear the selected buffer (set by the SetBuffer() function). | |
virtual void | DrawBuffer (unsigned int aBufferHandle) override |
Draw the selected buffer to the output buffer. | |
virtual void | Begin () override |
Call this at the beginning of each frame. | |
virtual void | Present () override |
Call this to present the output buffer to the screen. | |
VECTOR2I | GetScreenSize () const |
GLenum | GetBufferTexture (unsigned int aBufferHandle) |
void | DrawBuffer (unsigned int aSourceHandle, unsigned int aDestHandle) |
unsigned int | CreateBuffer (VECTOR2I aDimensions) |
void | SetAntialiasingMode (OPENGL_ANTIALIASING_MODE aMode) |
OPENGL_ANTIALIASING_MODE | GetAntialiasingMode () const |
int | GetAntialiasSupersamplingFactor () const |
VECTOR2D | GetAntialiasRenderingOffset () const |
Static Public Attributes | |
static const unsigned int | DIRECT_RENDERING = 0 |
Protected Types | |
typedef std::deque< OPENGL_BUFFER > | OPENGL_BUFFERS |
Protected Member Functions | |
void | bindFb (unsigned int aFb) |
Binds a specific Framebuffer Object. | |
void | clean () |
Perform freeing of resources. | |
unsigned int | usedBuffers () |
Returns number of used buffers. | |
Protected Attributes | |
bool | m_initialized |
Initialization status flag. | |
unsigned int | m_curBuffer |
Currently used buffer handle. | |
GLuint | m_mainFbo |
Main FBO handle (storing all target textures) | |
GLuint | m_depthBuffer |
Depth buffer handle. | |
OPENGL_BUFFERS | m_buffers |
Stores information about initialized buffers. | |
GLuint | m_curFbo |
Store the used FBO name in case there was more than one compositor used. | |
OPENGL_ANTIALIASING_MODE | m_currentAntialiasingMode |
std::unique_ptr< OPENGL_PRESENTOR > | m_antialiasing |
unsigned int | m_width |
Width of the buffer (in pixels) | |
unsigned int | m_height |
Height of the buffer (in pixels) | |
Definition at line 46 of file opengl_compositor.h.
|
protected |
Definition at line 126 of file opengl_compositor.h.
OPENGL_COMPOSITOR::OPENGL_COMPOSITOR | ( | ) |
Definition at line 46 of file opengl_compositor.cpp.
References m_antialiasing.
|
virtual |
Definition at line 58 of file opengl_compositor.cpp.
References clean(), and m_initialized.
|
overridevirtual |
Call this at the beginning of each frame.
Implements KIGFX::COMPOSITOR.
Definition at line 315 of file opengl_compositor.cpp.
References m_antialiasing.
Referenced by KIGFX::OPENGL_GAL::BeginDrawing().
|
protected |
Binds a specific Framebuffer Object.
Definition at line 380 of file opengl_compositor.cpp.
References checkGlError(), DIRECT_RENDERING, m_curFbo, and m_mainFbo.
Referenced by clean(), CreateBuffer(), Initialize(), and SetBuffer().
|
protected |
Perform freeing of resources.
Definition at line 394 of file opengl_compositor.cpp.
References bindFb(), DIRECT_RENDERING, m_buffers, m_depthBuffer, m_initialized, and m_mainFbo.
Referenced by Resize(), SetAntialiasingMode(), and ~OPENGL_COMPOSITOR().
|
overridevirtual |
Clear the selected buffer (set by the SetBuffer() function).
Implements KIGFX::COMPOSITOR.
Definition at line 296 of file opengl_compositor.cpp.
References KIGFX::COLOR4D::b, DIRECT_RENDERING, KIGFX::COLOR4D::g, m_curFbo, m_initialized, and KIGFX::COLOR4D::r.
Referenced by KIGFX::ANTIALIASING_SUPERSAMPLING::Begin(), KIGFX::ANTIALIASING_SMAA::Begin(), KIGFX::OPENGL_GAL::ClearTarget(), CreateBuffer(), and KIGFX::ANTIALIASING_SMAA::Present().
|
overridevirtual |
Prepare a new buffer that may be used as a rendering target.
Implements KIGFX::COMPOSITOR.
Definition at line 157 of file opengl_compositor.cpp.
References m_antialiasing.
Referenced by KIGFX::OPENGL_GAL::BeginDrawing(), KIGFX::ANTIALIASING_NONE::CreateBuffer(), KIGFX::ANTIALIASING_SUPERSAMPLING::CreateBuffer(), KIGFX::ANTIALIASING_SMAA::CreateBuffer(), KIGFX::ANTIALIASING_SUPERSAMPLING::Init(), and KIGFX::ANTIALIASING_SMAA::Init().
unsigned int OPENGL_COMPOSITOR::CreateBuffer | ( | VECTOR2I | aDimensions | ) |
Definition at line 163 of file opengl_compositor.cpp.
References bindFb(), KIGFX::COLOR4D::BLACK, checkGlError(), ClearBuffer(), DIRECT_RENDERING, m_buffers, m_initialized, m_mainFbo, usedBuffers(), VECTOR2< T >::x, and VECTOR2< T >::y.
|
overridevirtual |
Draw the selected buffer to the output buffer.
aBufferHandle | is the handle of the buffer to be drawn. |
Implements KIGFX::COMPOSITOR.
Definition at line 321 of file opengl_compositor.cpp.
References m_antialiasing.
Referenced by KIGFX::ANTIALIASING_NONE::DrawBuffer(), KIGFX::ANTIALIASING_SMAA::DrawBuffer(), KIGFX::ANTIALIASING_SUPERSAMPLING::DrawBuffer(), KIGFX::OPENGL_GAL::EndDiffLayer(), and KIGFX::OPENGL_GAL::EndDrawing().
void OPENGL_COMPOSITOR::DrawBuffer | ( | unsigned int | aSourceHandle, |
unsigned int | aDestHandle | ||
) |
Definition at line 327 of file opengl_compositor.cpp.
References m_buffers, m_initialized, SetBuffer(), and usedBuffers().
OPENGL_ANTIALIASING_MODE OPENGL_COMPOSITOR::GetAntialiasingMode | ( | ) | const |
Definition at line 84 of file opengl_compositor.cpp.
References m_currentAntialiasingMode.
Referenced by KIGFX::OPENGL_GAL::updatedGalDisplayOptions().
VECTOR2D OPENGL_COMPOSITOR::GetAntialiasRenderingOffset | ( | ) | const |
Definition at line 424 of file opengl_compositor.cpp.
References m_currentAntialiasingMode, and KIGFX::SUPERSAMPLING.
Referenced by KIGFX::OPENGL_GAL::BeginDrawing().
int OPENGL_COMPOSITOR::GetAntialiasSupersamplingFactor | ( | ) | const |
Definition at line 415 of file opengl_compositor.cpp.
References m_currentAntialiasingMode, and KIGFX::SUPERSAMPLING.
Referenced by KIGFX::OPENGL_GAL::BeginDrawing().
|
inlineoverridevirtual |
Return currently used buffer handle.
Implements KIGFX::COMPOSITOR.
Definition at line 65 of file opengl_compositor.h.
References DIRECT_RENDERING, m_curBuffer, and m_curFbo.
Referenced by KIGFX::OPENGL_GAL::ClearTarget().
GLenum OPENGL_COMPOSITOR::GetBufferTexture | ( | unsigned int | aBufferHandle | ) |
Definition at line 264 of file opengl_compositor.cpp.
References m_buffers, and usedBuffers().
Referenced by KIGFX::ANTIALIASING_SUPERSAMPLING::Present(), and KIGFX::ANTIALIASING_SMAA::Present().
VECTOR2I OPENGL_COMPOSITOR::GetScreenSize | ( | ) | const |
Definition at line 305 of file opengl_compositor.cpp.
References KIGFX::COMPOSITOR::m_height, and KIGFX::COMPOSITOR::m_width.
Referenced by KIGFX::ANTIALIASING_NONE::CreateBuffer(), KIGFX::ANTIALIASING_SMAA::CreateBuffer(), KIGFX::ANTIALIASING_NONE::GetInternalBufferSize(), KIGFX::ANTIALIASING_SUPERSAMPLING::GetInternalBufferSize(), KIGFX::ANTIALIASING_SMAA::GetInternalBufferSize(), SetBuffer(), and KIGFX::ANTIALIASING_SMAA::updateUniforms().
|
overridevirtual |
Perform primary initialization, necessary to use the object.
Implements KIGFX::COMPOSITOR.
Definition at line 90 of file opengl_compositor.cpp.
References bindFb(), checkGlError(), DIRECT_RENDERING, m_antialiasing, m_currentAntialiasingMode, m_depthBuffer, m_initialized, m_mainFbo, KIGFX::SMAA, KIGFX::SUPERSAMPLING, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by KIGFX::OPENGL_GAL::BeginDrawing().
|
overridevirtual |
Call this to present the output buffer to the screen.
Implements KIGFX::COMPOSITOR.
Definition at line 374 of file opengl_compositor.cpp.
References m_antialiasing.
Referenced by KIGFX::OPENGL_GAL::EndDrawing().
|
overridevirtual |
Clear the state of COMPOSITOR, so it has to be reinitialized again with the new dimensions.
aWidth | is the framebuffer width (in pixels). |
aHeight | is the framebuffer height (in pixels). |
Implements KIGFX::COMPOSITOR.
Definition at line 145 of file opengl_compositor.cpp.
References clean(), m_antialiasing, KIGFX::COMPOSITOR::m_height, m_initialized, and KIGFX::COMPOSITOR::m_width.
Referenced by KIGFX::OPENGL_GAL::ResizeScreen().
void OPENGL_COMPOSITOR::SetAntialiasingMode | ( | OPENGL_ANTIALIASING_MODE | aMode | ) |
Definition at line 75 of file opengl_compositor.cpp.
References clean(), m_currentAntialiasingMode, and m_initialized.
Referenced by KIGFX::OPENGL_GAL::OPENGL_GAL(), and KIGFX::OPENGL_GAL::updatedGalDisplayOptions().
|
overridevirtual |
Set the selected buffer as the rendering target.
All the following drawing functions are going to be rendered in the selected buffer.
aBufferHandle | is the handle of the buffer or 0 in case of rendering directly to the display. |
Implements KIGFX::COMPOSITOR.
Definition at line 271 of file opengl_compositor.cpp.
References bindFb(), checkGlError(), DIRECT_RENDERING, GetScreenSize(), m_buffers, m_curBuffer, m_curFbo, m_initialized, m_mainFbo, and usedBuffers().
Referenced by KIGFX::ANTIALIASING_SUPERSAMPLING::Begin(), KIGFX::ANTIALIASING_SMAA::Begin(), KIGFX::OPENGL_GAL::BeginDrawing(), KIGFX::OPENGL_GAL::blitCursor(), KIGFX::OPENGL_GAL::ClearScreen(), KIGFX::OPENGL_GAL::ClearTarget(), DrawBuffer(), KIGFX::OPENGL_GAL::DrawGrid(), KIGFX::OPENGL_GAL::EndDrawing(), KIGFX::ANTIALIASING_SUPERSAMPLING::Present(), and KIGFX::ANTIALIASING_SMAA::Present().
|
inlineprotected |
Returns number of used buffers.
Definition at line 109 of file opengl_compositor.h.
References m_buffers.
Referenced by CreateBuffer(), DrawBuffer(), GetBufferTexture(), and SetBuffer().
|
static |
Definition at line 86 of file opengl_compositor.h.
Referenced by KIGFX::OPENGL_GAL::BeginDrawing(), bindFb(), KIGFX::OPENGL_GAL::blitCursor(), clean(), ClearBuffer(), KIGFX::OPENGL_GAL::ClearScreen(), CreateBuffer(), KIGFX::ANTIALIASING_NONE::DrawBuffer(), GetBuffer(), Initialize(), KIGFX::ANTIALIASING_SUPERSAMPLING::Present(), KIGFX::ANTIALIASING_SMAA::Present(), and SetBuffer().
|
protected |
Definition at line 135 of file opengl_compositor.h.
Referenced by Begin(), CreateBuffer(), DrawBuffer(), Initialize(), OPENGL_COMPOSITOR(), Present(), and Resize().
|
protected |
Stores information about initialized buffers.
Definition at line 129 of file opengl_compositor.h.
Referenced by clean(), CreateBuffer(), DrawBuffer(), GetBufferTexture(), SetBuffer(), and usedBuffers().
|
protected |
Currently used buffer handle.
Definition at line 123 of file opengl_compositor.h.
Referenced by GetBuffer(), and SetBuffer().
|
protected |
Store the used FBO name in case there was more than one compositor used.
Definition at line 132 of file opengl_compositor.h.
Referenced by bindFb(), ClearBuffer(), GetBuffer(), and SetBuffer().
|
protected |
Definition at line 134 of file opengl_compositor.h.
Referenced by GetAntialiasingMode(), GetAntialiasRenderingOffset(), GetAntialiasSupersamplingFactor(), Initialize(), and SetAntialiasingMode().
|
protected |
Depth buffer handle.
Definition at line 125 of file opengl_compositor.h.
Referenced by clean(), and Initialize().
|
protectedinherited |
Height of the buffer (in pixels)
Definition at line 113 of file compositor.h.
Referenced by KIGFX::CAIRO_COMPOSITOR::CreateBuffer(), GetScreenSize(), KIGFX::CAIRO_COMPOSITOR::Resize(), and Resize().
|
protected |
Initialization status flag.
Definition at line 122 of file opengl_compositor.h.
Referenced by clean(), ClearBuffer(), CreateBuffer(), DrawBuffer(), Initialize(), Resize(), SetAntialiasingMode(), SetBuffer(), and ~OPENGL_COMPOSITOR().
|
protected |
Main FBO handle (storing all target textures)
Definition at line 124 of file opengl_compositor.h.
Referenced by bindFb(), clean(), CreateBuffer(), Initialize(), and SetBuffer().
|
protectedinherited |
Width of the buffer (in pixels)
Definition at line 112 of file compositor.h.
Referenced by KIGFX::CAIRO_COMPOSITOR::CreateBuffer(), GetScreenSize(), KIGFX::CAIRO_COMPOSITOR::Resize(), and Resize().