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)
 
void DrawBufferDifference (unsigned int aSourceHandle, unsigned int aDestHandle)
 Draw buffer with difference blending (XOR-style for gerbview).
 
unsigned int CreateBuffer (VECTOR2I aDimensions)
 
void SetAntialiasingMode (GAL_ANTIALIASING_MODE aMode)
 
GAL_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.
 
bool initDifferenceShader ()
 Initialize the difference shader program.
 
void drawFullScreenQuad ()
 Draw a fullscreen quad for compositing.
 

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.
 
GAL_ANTIALIASING_MODE m_currentAntialiasingMode
 
std::unique_ptr< OPENGL_PRESENTORm_antialiasing
 
GLuint m_differenceShader
 Difference shader program.
 
GLint m_diffSrcTexUniform
 Source texture uniform location.
 
GLint m_diffDstTexUniform
 Destination texture uniform location.
 
bool m_differenceShaderInitialized
 
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 137 of file opengl_compositor.h.

Constructor & Destructor Documentation

◆ OPENGL_COMPOSITOR()

◆ ~OPENGL_COMPOSITOR()

OPENGL_COMPOSITOR::~OPENGL_COMPOSITOR ( )
virtual

Definition at line 68 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 316 of file opengl_compositor.cpp.

References m_antialiasing.

◆ 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(), DrawBufferDifference(), Initialize(), and SetBuffer().

◆ clean()

void OPENGL_COMPOSITOR::clean ( )
protected

◆ ClearBuffer()

void OPENGL_COMPOSITOR::ClearBuffer ( const COLOR4D & aColor)
overridevirtual

Clear the selected buffer (set by the SetBuffer() function).

Implements KIGFX::COMPOSITOR.

Definition at line 297 of file opengl_compositor.cpp.

References KIGFX::COLOR4D::b, DIRECT_RENDERING, KIGFX::COLOR4D::g, m_curFbo, m_initialized, and KIGFX::COLOR4D::r.

Referenced by CreateBuffer().

◆ 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 167 of file opengl_compositor.cpp.

References m_antialiasing.

◆ 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 322 of file opengl_compositor.cpp.

References m_antialiasing.

Referenced by DrawBufferDifference().

◆ DrawBuffer() [2/2]

void OPENGL_COMPOSITOR::DrawBuffer ( unsigned int aSourceHandle,
unsigned int aDestHandle )

Definition at line 328 of file opengl_compositor.cpp.

References m_buffers, m_initialized, SetBuffer(), and usedBuffers().

◆ DrawBufferDifference()

void OPENGL_COMPOSITOR::DrawBufferDifference ( unsigned int aSourceHandle,
unsigned int aDestHandle )

Draw buffer with difference blending (XOR-style for gerbview).

Computes |src - dst| for each color channel, showing differences and canceling out identical overlapping content.

Parameters
aSourceHandleSource buffer (new layer)
aDestHandleDestination buffer (existing content)

Definition at line 599 of file opengl_compositor.cpp.

References bindFb(), checkGlError(), DrawBuffer(), drawFullScreenQuad(), initDifferenceShader(), m_buffers, m_diffDstTexUniform, m_differenceShader, m_diffSrcTexUniform, m_initialized, m_mainFbo, SetBuffer(), traceGalXorMode, usedBuffers(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ drawFullScreenQuad()

void OPENGL_COMPOSITOR::drawFullScreenQuad ( )
protected

Draw a fullscreen quad for compositing.

Definition at line 568 of file opengl_compositor.cpp.

Referenced by DrawBufferDifference().

◆ GetAntialiasingMode()

GAL_ANTIALIASING_MODE OPENGL_COMPOSITOR::GetAntialiasingMode ( ) const

Definition at line 94 of file opengl_compositor.cpp.

References m_currentAntialiasingMode.

◆ GetAntialiasRenderingOffset()

VECTOR2D OPENGL_COMPOSITOR::GetAntialiasRenderingOffset ( ) const

Definition at line 433 of file opengl_compositor.cpp.

References KIGFX::AA_HIGHQUALITY, and m_currentAntialiasingMode.

◆ GetAntialiasSupersamplingFactor()

int OPENGL_COMPOSITOR::GetAntialiasSupersamplingFactor ( ) const

Definition at line 423 of file opengl_compositor.cpp.

References KIGFX::AA_HIGHQUALITY, and m_currentAntialiasingMode.

◆ 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.

◆ GetBufferTexture()

GLenum OPENGL_COMPOSITOR::GetBufferTexture ( unsigned int aBufferHandle)

Definition at line 267 of file opengl_compositor.cpp.

References m_buffers, and usedBuffers().

◆ GetScreenSize()

VECTOR2I OPENGL_COMPOSITOR::GetScreenSize ( ) const

Definition at line 306 of file opengl_compositor.cpp.

References KIGFX::COMPOSITOR::m_height, and KIGFX::COMPOSITOR::m_width.

Referenced by SetBuffer().

◆ initDifferenceShader()

bool OPENGL_COMPOSITOR::initDifferenceShader ( )
protected

Initialize the difference shader program.

Returns
true if shader compiled and linked successfully

Definition at line 443 of file opengl_compositor.cpp.

References m_diffDstTexUniform, m_differenceShader, m_differenceShaderInitialized, m_diffSrcTexUniform, and traceGalXorMode.

Referenced by DrawBufferDifference().

◆ 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.

◆ 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 155 of file opengl_compositor.cpp.

References clean(), m_antialiasing, KIGFX::COMPOSITOR::m_height, m_initialized, and KIGFX::COMPOSITOR::m_width.

◆ SetAntialiasingMode()

void OPENGL_COMPOSITOR::SetAntialiasingMode ( GAL_ANTIALIASING_MODE aMode)

Definition at line 85 of file opengl_compositor.cpp.

References clean(), m_currentAntialiasingMode, and m_initialized.

◆ 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 274 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 DrawBuffer(), and DrawBufferDifference().

◆ usedBuffers()

unsigned int KIGFX::OPENGL_COMPOSITOR::usedBuffers ( )
inlineprotected

Returns number of used buffers.

Definition at line 120 of file opengl_compositor.h.

References m_buffers.

Referenced by CreateBuffer(), DrawBuffer(), DrawBufferDifference(), 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 140 of file opengl_compositor.h.

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

◆ m_curBuffer

unsigned int KIGFX::OPENGL_COMPOSITOR::m_curBuffer
protected

Currently used buffer handle.

Definition at line 134 of file opengl_compositor.h.

Referenced by GetBuffer(), OPENGL_COMPOSITOR(), 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 143 of file opengl_compositor.h.

Referenced by bindFb(), ClearBuffer(), GetBuffer(), OPENGL_COMPOSITOR(), and SetBuffer().

◆ m_currentAntialiasingMode

GAL_ANTIALIASING_MODE KIGFX::OPENGL_COMPOSITOR::m_currentAntialiasingMode
protected

◆ m_depthBuffer

GLuint KIGFX::OPENGL_COMPOSITOR::m_depthBuffer
protected

Depth buffer handle.

Definition at line 136 of file opengl_compositor.h.

Referenced by clean(), Initialize(), and OPENGL_COMPOSITOR().

◆ m_diffDstTexUniform

GLint KIGFX::OPENGL_COMPOSITOR::m_diffDstTexUniform
protected

Destination texture uniform location.

Definition at line 151 of file opengl_compositor.h.

Referenced by DrawBufferDifference(), initDifferenceShader(), and OPENGL_COMPOSITOR().

◆ m_differenceShader

GLuint KIGFX::OPENGL_COMPOSITOR::m_differenceShader
protected

Difference shader program.

Definition at line 149 of file opengl_compositor.h.

Referenced by clean(), DrawBufferDifference(), initDifferenceShader(), and OPENGL_COMPOSITOR().

◆ m_differenceShaderInitialized

bool KIGFX::OPENGL_COMPOSITOR::m_differenceShaderInitialized
protected

Definition at line 152 of file opengl_compositor.h.

Referenced by clean(), initDifferenceShader(), and OPENGL_COMPOSITOR().

◆ m_diffSrcTexUniform

GLint KIGFX::OPENGL_COMPOSITOR::m_diffSrcTexUniform
protected

Source texture uniform location.

Definition at line 150 of file opengl_compositor.h.

Referenced by DrawBufferDifference(), initDifferenceShader(), and OPENGL_COMPOSITOR().

◆ m_height

unsigned int KIGFX::COMPOSITOR::m_height
protectedinherited

◆ m_initialized

bool KIGFX::OPENGL_COMPOSITOR::m_initialized
protected

◆ m_mainFbo

GLuint KIGFX::OPENGL_COMPOSITOR::m_mainFbo
protected

Main FBO handle (storing all target textures)

Definition at line 135 of file opengl_compositor.h.

Referenced by bindFb(), clean(), CreateBuffer(), DrawBufferDifference(), Initialize(), OPENGL_COMPOSITOR(), and SetBuffer().

◆ m_width

unsigned int KIGFX::COMPOSITOR::m_width
protectedinherited

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