KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KIGFX::OPENGL_COMPOSITOR Class Reference

#include <opengl_compositor.h>

Inheritance diagram for KIGFX::OPENGL_COMPOSITOR:
KIGFX::COMPOSITOR

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_BUFFEROPENGL_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_PRESENTORm_antialiasing
 
unsigned int m_width
 Width of the buffer (in pixels)
 
unsigned int m_height
 Height of the buffer (in pixels)
 

Detailed Description

Definition at line 46 of file opengl_compositor.h.

Member Typedef Documentation

◆ OPENGL_BUFFERS

Definition at line 126 of file opengl_compositor.h.

Constructor & Destructor Documentation

◆ OPENGL_COMPOSITOR()

OPENGL_COMPOSITOR::OPENGL_COMPOSITOR ( )

Definition at line 46 of file opengl_compositor.cpp.

References m_antialiasing.

◆ ~OPENGL_COMPOSITOR()

OPENGL_COMPOSITOR::~OPENGL_COMPOSITOR ( )
virtual

Definition at line 58 of file opengl_compositor.cpp.

References clean(), and m_initialized.

Member Function Documentation

◆ Begin()

void OPENGL_COMPOSITOR::Begin ( )
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().

◆ bindFb()

void OPENGL_COMPOSITOR::bindFb ( unsigned int  aFb)
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().

◆ clean()

void OPENGL_COMPOSITOR::clean ( )
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().

◆ ClearBuffer()

void OPENGL_COMPOSITOR::ClearBuffer ( const COLOR4D aColor)
overridevirtual

◆ CreateBuffer() [1/2]

unsigned int OPENGL_COMPOSITOR::CreateBuffer ( )
overridevirtual

Prepare a new buffer that may be used as a rendering target.

Returns
is the handle of the buffer. In case of failure 0 (zero) is returned as the handle.

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().

◆ CreateBuffer() [2/2]

unsigned int OPENGL_COMPOSITOR::CreateBuffer ( VECTOR2I  aDimensions)

◆ DrawBuffer() [1/2]

void OPENGL_COMPOSITOR::DrawBuffer ( unsigned int  aBufferHandle)
overridevirtual

Draw the selected buffer to the output buffer.

Parameters
aBufferHandleis 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().

◆ DrawBuffer() [2/2]

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().

◆ GetAntialiasingMode()

OPENGL_ANTIALIASING_MODE OPENGL_COMPOSITOR::GetAntialiasingMode ( ) const

◆ GetAntialiasRenderingOffset()

VECTOR2D OPENGL_COMPOSITOR::GetAntialiasRenderingOffset ( ) const

◆ GetAntialiasSupersamplingFactor()

int OPENGL_COMPOSITOR::GetAntialiasSupersamplingFactor ( ) const

◆ GetBuffer()

virtual unsigned int KIGFX::OPENGL_COMPOSITOR::GetBuffer ( ) const
inlineoverridevirtual

Return currently used buffer handle.

Returns
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().

◆ GetBufferTexture()

GLenum OPENGL_COMPOSITOR::GetBufferTexture ( unsigned int  aBufferHandle)

◆ GetScreenSize()

◆ Initialize()

void OPENGL_COMPOSITOR::Initialize ( )
overridevirtual

◆ Present()

void OPENGL_COMPOSITOR::Present ( )
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().

◆ Resize()

void OPENGL_COMPOSITOR::Resize ( unsigned int  aWidth,
unsigned int  aHeight 
)
overridevirtual

Clear the state of COMPOSITOR, so it has to be reinitialized again with the new dimensions.

Parameters
aWidthis the framebuffer width (in pixels).
aHeightis 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().

◆ SetAntialiasingMode()

void OPENGL_COMPOSITOR::SetAntialiasingMode ( OPENGL_ANTIALIASING_MODE  aMode)

◆ SetBuffer()

void OPENGL_COMPOSITOR::SetBuffer ( unsigned int  aBufferHandle)
overridevirtual

Set the selected buffer as the rendering target.

All the following drawing functions are going to be rendered in the selected buffer.

Parameters
aBufferHandleis 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().

◆ usedBuffers()

unsigned int KIGFX::OPENGL_COMPOSITOR::usedBuffers ( )
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().

Member Data Documentation

◆ DIRECT_RENDERING

◆ m_antialiasing

std::unique_ptr<OPENGL_PRESENTOR> KIGFX::OPENGL_COMPOSITOR::m_antialiasing
protected

◆ m_buffers

OPENGL_BUFFERS KIGFX::OPENGL_COMPOSITOR::m_buffers
protected

Stores information about initialized buffers.

Definition at line 129 of file opengl_compositor.h.

Referenced by clean(), CreateBuffer(), DrawBuffer(), GetBufferTexture(), SetBuffer(), and usedBuffers().

◆ m_curBuffer

unsigned int KIGFX::OPENGL_COMPOSITOR::m_curBuffer
protected

Currently used buffer handle.

Definition at line 123 of file opengl_compositor.h.

Referenced by GetBuffer(), and SetBuffer().

◆ m_curFbo

GLuint KIGFX::OPENGL_COMPOSITOR::m_curFbo
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().

◆ m_currentAntialiasingMode

OPENGL_ANTIALIASING_MODE KIGFX::OPENGL_COMPOSITOR::m_currentAntialiasingMode
protected

◆ m_depthBuffer

GLuint KIGFX::OPENGL_COMPOSITOR::m_depthBuffer
protected

Depth buffer handle.

Definition at line 125 of file opengl_compositor.h.

Referenced by clean(), and Initialize().

◆ m_height

unsigned int KIGFX::COMPOSITOR::m_height
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().

◆ m_initialized

bool KIGFX::OPENGL_COMPOSITOR::m_initialized
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().

◆ m_mainFbo

GLuint KIGFX::OPENGL_COMPOSITOR::m_mainFbo
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().

◆ m_width

unsigned int KIGFX::COMPOSITOR::m_width
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().


The documentation for this class was generated from the following files: