KiCad PCB EDA Suite
KIGFX::ANTIALIASING_SMAA Class Reference

#include <antialiasing.h>

Inheritance diagram for KIGFX::ANTIALIASING_SMAA:
KIGFX::OPENGL_PRESENTOR

Public Member Functions

 ANTIALIASING_SMAA (OPENGL_COMPOSITOR *aCompositor)
 
bool Init () override
 
unsigned int CreateBuffer () override
 
VECTOR2U GetInternalBufferSize () override
 
void OnLostBuffers () override
 
void Begin () override
 
void DrawBuffer (GLuint buffer) override
 
void Present () override
 

Private Member Functions

void loadShaders ()
 
void updateUniforms ()
 

Private Attributes

bool areBuffersInitialized
 
unsigned int smaaBaseBuffer
 
unsigned int smaaEdgesBuffer
 
unsigned int smaaBlendBuffer
 
unsigned int smaaAreaTex
 
unsigned int smaaSearchTex
 
bool shadersLoaded
 
std::unique_ptr< SHADERpass_1_shader
 
GLint pass_1_metrics
 
std::unique_ptr< SHADERpass_2_shader
 
GLint pass_2_metrics
 
std::unique_ptr< SHADERpass_3_shader
 
GLint pass_3_metrics
 
OPENGL_COMPOSITORcompositor
 

Detailed Description

Definition at line 98 of file antialiasing.h.

Constructor & Destructor Documentation

◆ ANTIALIASING_SMAA()

ANTIALIASING_SMAA::ANTIALIASING_SMAA ( OPENGL_COMPOSITOR aCompositor)

Definition at line 200 of file antialiasing.cpp.

200  :
201  areBuffersInitialized( false ),
202  shadersLoaded( false ),
203  compositor( aCompositor )
204 {
205  smaaBaseBuffer = 0;
206  smaaEdgesBuffer = 0;
207  smaaBlendBuffer = 0;
208  smaaAreaTex = 0;
209  smaaSearchTex = 0;
210 
211  pass_1_metrics = 0;
212  pass_2_metrics = 0;
213  pass_3_metrics = 0;
214 }
unsigned int smaaEdgesBuffer
Definition: antialiasing.h:120
unsigned int smaaSearchTex
Definition: antialiasing.h:125
unsigned int smaaBlendBuffer
Definition: antialiasing.h:121
OPENGL_COMPOSITOR * compositor
Definition: antialiasing.h:138
unsigned int smaaBaseBuffer
Definition: antialiasing.h:119

References pass_1_metrics, pass_2_metrics, pass_3_metrics, smaaAreaTex, smaaBaseBuffer, smaaBlendBuffer, smaaEdgesBuffer, and smaaSearchTex.

Member Function Documentation

◆ Begin()

void ANTIALIASING_SMAA::Begin ( )
overridevirtual

Implements KIGFX::OPENGL_PRESENTOR.

Definition at line 458 of file antialiasing.cpp.

459 {
462 }
static const COLOR4D BLACK
Definition: color4d.h:381
virtual void ClearBuffer(const COLOR4D &aColor) override
Clear the selected buffer (set by the SetBuffer() function).
virtual void SetBuffer(unsigned int aBufferHandle) override
Set the selected buffer as the rendering target.
OPENGL_COMPOSITOR * compositor
Definition: antialiasing.h:138
unsigned int smaaBaseBuffer
Definition: antialiasing.h:119

References KIGFX::COLOR4D::BLACK, KIGFX::OPENGL_COMPOSITOR::ClearBuffer(), compositor, KIGFX::OPENGL_COMPOSITOR::SetBuffer(), and smaaBaseBuffer.

◆ CreateBuffer()

unsigned int ANTIALIASING_SMAA::CreateBuffer ( )
overridevirtual

Implements KIGFX::OPENGL_PRESENTOR.

Definition at line 445 of file antialiasing.cpp.

446 {
448 }
virtual unsigned int CreateBuffer() override
Prepare a new buffer that may be used as a rendering target.
OPENGL_COMPOSITOR * compositor
Definition: antialiasing.h:138

References compositor, KIGFX::OPENGL_COMPOSITOR::CreateBuffer(), and KIGFX::OPENGL_COMPOSITOR::GetScreenSize().

◆ DrawBuffer()

void ANTIALIASING_SMAA::DrawBuffer ( GLuint  buffer)
overridevirtual

Implements KIGFX::OPENGL_PRESENTOR.

Definition at line 451 of file antialiasing.cpp.

452 {
453  // draw to internal buffer
455 }
virtual void DrawBuffer(unsigned int aBufferHandle) override
Draw the selected buffer to the output buffer.
OPENGL_COMPOSITOR * compositor
Definition: antialiasing.h:138
unsigned int smaaBaseBuffer
Definition: antialiasing.h:119

References compositor, KIGFX::OPENGL_COMPOSITOR::DrawBuffer(), and smaaBaseBuffer.

◆ GetInternalBufferSize()

VECTOR2U ANTIALIASING_SMAA::GetInternalBufferSize ( )
overridevirtual

Implements KIGFX::OPENGL_PRESENTOR.

Definition at line 217 of file antialiasing.cpp.

218 {
219  return compositor->GetScreenSize();
220 }
OPENGL_COMPOSITOR * compositor
Definition: antialiasing.h:138

References compositor, and KIGFX::OPENGL_COMPOSITOR::GetScreenSize().

◆ Init()

bool ANTIALIASING_SMAA::Init ( )
overridevirtual

Implements KIGFX::OPENGL_PRESENTOR.

Definition at line 411 of file antialiasing.cpp.

412 {
413  if( !shadersLoaded )
414  loadShaders();
415 
416  if( !areBuffersInitialized )
417  {
419  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
420  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
421 
423  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
424  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
425 
427  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
428  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
429 
430  updateUniforms();
431  areBuffersInitialized = true;
432  }
433 
434  // Nothing to initialize
435  return true;
436 }
unsigned int smaaEdgesBuffer
Definition: antialiasing.h:120
unsigned int smaaBlendBuffer
Definition: antialiasing.h:121
virtual unsigned int CreateBuffer() override
Prepare a new buffer that may be used as a rendering target.
OPENGL_COMPOSITOR * compositor
Definition: antialiasing.h:138
unsigned int smaaBaseBuffer
Definition: antialiasing.h:119

References areBuffersInitialized, compositor, KIGFX::OPENGL_COMPOSITOR::CreateBuffer(), loadShaders(), shadersLoaded, smaaBaseBuffer, smaaBlendBuffer, smaaEdgesBuffer, and updateUniforms().

◆ loadShaders()

void ANTIALIASING_SMAA::loadShaders ( )
private

Definition at line 223 of file antialiasing.cpp.

224 {
225  // Load constant textures
226  glEnable( GL_TEXTURE_2D );
227  glActiveTexture( GL_TEXTURE0 );
228 
229  glGenTextures( 1, &smaaAreaTex );
230  glBindTexture( GL_TEXTURE_2D, smaaAreaTex );
231  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
232  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
233  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
234  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
235  glTexImage2D( GL_TEXTURE_2D, 0, GL_RG8, AREATEX_WIDTH, AREATEX_HEIGHT, 0, GL_RG,
236  GL_UNSIGNED_BYTE, areaTexBytes );
237  checkGlError( "loading smaa area tex", __FILE__, __LINE__ );
238 
239  glGenTextures( 1, &smaaSearchTex );
240  glBindTexture( GL_TEXTURE_2D, smaaSearchTex );
241  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
242  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
243  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
244  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
245  glTexImage2D( GL_TEXTURE_2D, 0, GL_R8, SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT, 0, GL_RED,
246  GL_UNSIGNED_BYTE, searchTexBytes );
247  checkGlError( "loading smaa search tex", __FILE__, __LINE__ );
248 
249  // Quality settings:
250  // THRESHOLD: intended to exclude spurious edges in photorealistic game graphics
251  // but in a high-contrast CAD application, all edges are intentional
252  // should be set fairly low, so user color choices do not affect antialiasing
253  // MAX_SEARCH_STEPS: steps of 2px, searched in H/V direction to discover true angle of edges
254  // improves AA for lines close H/V but creates fuzzyness at junctions
255  // MAX_SEARCH_STEPS_DIAG: steps of 1px, searched in diagonal direction
256  // improves lines close to 45deg but turns small circles into octagons
257  // CORNER_ROUNDING: SMAA can distinguish actual corners from aliasing jaggies,
258  // we want to preserve those as much as possible
259  // Edge Detection: In Eeschema, when a single pixel line changes color, edge detection using
260  // color is too aggressive and leads to a white spot at the transition point
261  std::string quality_string;
262  const char* edge_detect_shader;
263 
264  // trades imperfect AA of shallow angles for a near artifact-free reproduction of fine features
265  // jaggies are smoothed over max 5px (original step + 2px in both directions)
266  quality_string = "#define SMAA_THRESHOLD 0.005\n"
267  "#define SMAA_MAX_SEARCH_STEPS 1\n"
268  "#define SMAA_MAX_SEARCH_STEPS_DIAG 2\n"
269  "#define SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR 1.5\n"
270  "#define SMAA_CORNER_ROUNDING 0\n";
272 
273  // set up shaders
274  std::string vert_preamble( R"SHADER(
275 #version 120
276 #define SMAA_GLSL_2_1
277 #define SMAA_INCLUDE_VS 1
278 #define SMAA_INCLUDE_PS 0
279 uniform vec4 SMAA_RT_METRICS;
280 )SHADER" );
281 
282  std::string frag_preamble( R"SHADER(
283 #version 120
284 #define SMAA_GLSL_2_1
285 #define SMAA_INCLUDE_VS 0
286 #define SMAA_INCLUDE_PS 1
287 uniform vec4 SMAA_RT_METRICS;
288 )SHADER" );
289 
290  std::string smaa_source = std::string( BUILTIN_SHADERS::smaa_base_shader_p1 )
291  + std::string( BUILTIN_SHADERS::smaa_base_shader_p2 )
292  + std::string( BUILTIN_SHADERS::smaa_base_shader_p3 )
293  + std::string( BUILTIN_SHADERS::smaa_base_shader_p4 );
294 
295  //
296  // Set up pass 1 Shader
297  //
298  pass_1_shader = std::make_unique<SHADER>();
299  pass_1_shader->LoadShaderFromStrings( KIGFX::SHADER_TYPE_VERTEX, vert_preamble, quality_string,
301  pass_1_shader->LoadShaderFromStrings( KIGFX::SHADER_TYPE_FRAGMENT, frag_preamble,
302  quality_string, smaa_source, edge_detect_shader );
303  pass_1_shader->Link();
304  checkGlError( "linking pass 1 shader", __FILE__, __LINE__ );
305 
306  GLint smaaColorTexParameter = pass_1_shader->AddParameter( "colorTex" );
307  checkGlError( "pass1: getting colorTex uniform", __FILE__, __LINE__ );
308  pass_1_metrics = pass_1_shader->AddParameter( "SMAA_RT_METRICS" );
309  checkGlError( "pass1: getting metrics uniform", __FILE__, __LINE__ );
310 
311  pass_1_shader->Use();
312  checkGlError( "pass1: using shader", __FILE__, __LINE__ );
313  pass_1_shader->SetParameter( smaaColorTexParameter, 0 );
314  checkGlError( "pass1: setting colorTex uniform", __FILE__, __LINE__ );
315  pass_1_shader->Deactivate();
316  checkGlError( "pass1: deactivating shader", __FILE__, __LINE__ );
317 
318  //
319  // set up pass 2 shader
320  //
321  pass_2_shader = std::make_unique<SHADER>();
322  pass_2_shader->LoadShaderFromStrings( KIGFX::SHADER_TYPE_VERTEX, vert_preamble, quality_string,
324  pass_2_shader->LoadShaderFromStrings( KIGFX::SHADER_TYPE_FRAGMENT, frag_preamble,
325  quality_string, smaa_source,
327  pass_2_shader->Link();
328  checkGlError( "linking pass 2 shader", __FILE__, __LINE__ );
329 
330  GLint smaaEdgesTexParameter = pass_2_shader->AddParameter( "edgesTex" );
331  checkGlError( "pass2: getting colorTex uniform", __FILE__, __LINE__ );
332  GLint smaaAreaTexParameter = pass_2_shader->AddParameter( "areaTex" );
333  checkGlError( "pass2: getting areaTex uniform", __FILE__, __LINE__ );
334  GLint smaaSearchTexParameter = pass_2_shader->AddParameter( "searchTex" );
335  checkGlError( "pass2: getting searchTex uniform", __FILE__, __LINE__ );
336  pass_2_metrics = pass_2_shader->AddParameter( "SMAA_RT_METRICS" );
337  checkGlError( "pass2: getting metrics uniform", __FILE__, __LINE__ );
338 
339  pass_2_shader->Use();
340  checkGlError( "pass2: using shader", __FILE__, __LINE__ );
341  pass_2_shader->SetParameter( smaaEdgesTexParameter, 0 );
342  checkGlError( "pass2: setting colorTex uniform", __FILE__, __LINE__ );
343  pass_2_shader->SetParameter( smaaAreaTexParameter, 1 );
344  checkGlError( "pass2: setting areaTex uniform", __FILE__, __LINE__ );
345  pass_2_shader->SetParameter( smaaSearchTexParameter, 3 );
346  checkGlError( "pass2: setting searchTex uniform", __FILE__, __LINE__ );
347  pass_2_shader->Deactivate();
348  checkGlError( "pass2: deactivating shader", __FILE__, __LINE__ );
349 
350  //
351  // set up pass 3 shader
352  //
353  pass_3_shader = std::make_unique<SHADER>();
354  pass_3_shader->LoadShaderFromStrings( KIGFX::SHADER_TYPE_VERTEX, vert_preamble, quality_string,
356  pass_3_shader->LoadShaderFromStrings( KIGFX::SHADER_TYPE_FRAGMENT, frag_preamble,
357  quality_string, smaa_source,
359  pass_3_shader->Link();
360 
361  GLint smaaP3ColorTexParameter = pass_3_shader->AddParameter( "colorTex" );
362  checkGlError( "pass3: getting colorTex uniform", __FILE__, __LINE__ );
363  GLint smaaBlendTexParameter = pass_3_shader->AddParameter( "blendTex" );
364  checkGlError( "pass3: getting blendTex uniform", __FILE__, __LINE__ );
365  pass_3_metrics = pass_3_shader->AddParameter( "SMAA_RT_METRICS" );
366  checkGlError( "pass3: getting metrics uniform", __FILE__, __LINE__ );
367 
368  pass_3_shader->Use();
369  checkGlError( "pass3: using shader", __FILE__, __LINE__ );
370  pass_3_shader->SetParameter( smaaP3ColorTexParameter, 0 );
371  checkGlError( "pass3: setting colorTex uniform", __FILE__, __LINE__ );
372  pass_3_shader->SetParameter( smaaBlendTexParameter, 1 );
373  checkGlError( "pass3: setting blendTex uniform", __FILE__, __LINE__ );
374  pass_3_shader->Deactivate();
375  checkGlError( "pass3: deactivating shader", __FILE__, __LINE__ );
376 
377  shadersLoaded = true;
378 }
#define SEARCHTEX_WIDTH
Copyright (C) 2013 Jorge Jimenez (jorge@iryoku.com) Copyright (C) 2013 Jose I.
Definition: SmaaSearchTex.h:33
#define AREATEX_HEIGHT
Definition: SmaaAreaTex.h:34
const char smaa_pass_3_fragment_shader[]
Fragment shader.
Definition: shader.h:47
int checkGlError(const std::string &aInfo, const char *aFile, int aLine, bool aThrow)
Check if a recent OpenGL operation has failed.
Definition: utils.cpp:45
unsigned int smaaSearchTex
Definition: antialiasing.h:125
#define AREATEX_WIDTH
Copyright (C) 2013 Jorge Jimenez (jorge@iryoku.com) Copyright (C) 2013 Jose I.
Definition: SmaaAreaTex.h:33
static const unsigned char searchTexBytes[]
Stored in R8 format.
Definition: SmaaSearchTex.h:43
const char smaa_base_shader_p4[]
#define SEARCHTEX_HEIGHT
Definition: SmaaSearchTex.h:34
const unsigned char areaTexBytes[]
Stored in R8G8 format.
Definition: SmaaAreaTex.h:43
const char smaa_pass_2_fragment_shader[]
Vertex shader.
Definition: shader.h:46
std::unique_ptr< SHADER > pass_2_shader
Definition: antialiasing.h:132
std::unique_ptr< SHADER > pass_3_shader
Definition: antialiasing.h:135
const char smaa_base_shader_p3[]
std::unique_ptr< SHADER > pass_1_shader
Definition: antialiasing.h:129
const char smaa_pass_1_fragment_shader_luma[]

References AREATEX_HEIGHT, AREATEX_WIDTH, areaTexBytes, checkGlError(), pass_1_metrics, pass_1_shader, pass_2_metrics, pass_2_shader, pass_3_metrics, pass_3_shader, SEARCHTEX_HEIGHT, SEARCHTEX_WIDTH, searchTexBytes, KIGFX::SHADER_TYPE_FRAGMENT, KIGFX::SHADER_TYPE_VERTEX, shadersLoaded, KIGFX::BUILTIN_SHADERS::smaa_base_shader_p1, KIGFX::BUILTIN_SHADERS::smaa_base_shader_p2, KIGFX::BUILTIN_SHADERS::smaa_base_shader_p3, KIGFX::BUILTIN_SHADERS::smaa_base_shader_p4, KIGFX::BUILTIN_SHADERS::smaa_pass_1_fragment_shader_luma, KIGFX::BUILTIN_SHADERS::smaa_pass_1_vertex_shader, KIGFX::BUILTIN_SHADERS::smaa_pass_2_fragment_shader, KIGFX::BUILTIN_SHADERS::smaa_pass_2_vertex_shader, KIGFX::BUILTIN_SHADERS::smaa_pass_3_fragment_shader, KIGFX::BUILTIN_SHADERS::smaa_pass_3_vertex_shader, smaaAreaTex, and smaaSearchTex.

Referenced by Init().

◆ OnLostBuffers()

void ANTIALIASING_SMAA::OnLostBuffers ( )
overridevirtual

Implements KIGFX::OPENGL_PRESENTOR.

Definition at line 439 of file antialiasing.cpp.

440 {
441  areBuffersInitialized = false;
442 }

References areBuffersInitialized.

◆ Present()

void ANTIALIASING_SMAA::Present ( )
overridevirtual

Implements KIGFX::OPENGL_PRESENTOR.

Definition at line 492 of file antialiasing.cpp.

493 {
494  auto sourceTexture = compositor->GetBufferTexture( smaaBaseBuffer );
495 
496  glDisable( GL_BLEND );
497  glDisable( GL_DEPTH_TEST );
498  glEnable( GL_TEXTURE_2D );
499 
500  //
501  // pass 1: main-buffer -> smaaEdgesBuffer
502  //
505 
506  glActiveTexture( GL_TEXTURE0 );
507  glBindTexture( GL_TEXTURE_2D, sourceTexture );
508  checkGlError( "binding colorTex", __FILE__, __LINE__ );
509  pass_1_shader->Use();
510  checkGlError( "using smaa pass 1 shader", __FILE__, __LINE__ );
511  draw_fullscreen_triangle();
512  pass_1_shader->Deactivate();
513 
514  //
515  // pass 2: smaaEdgesBuffer -> smaaBlendBuffer
516  //
519 
520  auto edgesTex = compositor->GetBufferTexture( smaaEdgesBuffer );
521 
522  glActiveTexture( GL_TEXTURE0 );
523  glBindTexture( GL_TEXTURE_2D, edgesTex );
524  glActiveTexture( GL_TEXTURE1 );
525  glBindTexture( GL_TEXTURE_2D, smaaAreaTex );
526  glActiveTexture( GL_TEXTURE3 );
527  glBindTexture( GL_TEXTURE_2D, smaaSearchTex );
528 
529  pass_2_shader->Use();
530  draw_fullscreen_triangle();
531  pass_2_shader->Deactivate();
532 
533  //
534  // pass 3: colorTex + BlendBuffer -> output
535  //
538  auto blendTex = compositor->GetBufferTexture( smaaBlendBuffer );
539 
540  glActiveTexture( GL_TEXTURE0 );
541  glBindTexture( GL_TEXTURE_2D, sourceTexture );
542  glActiveTexture( GL_TEXTURE1 );
543  glBindTexture( GL_TEXTURE_2D, blendTex );
544 
545  pass_3_shader->Use();
546  draw_fullscreen_triangle();
547  pass_3_shader->Deactivate();
548 }
static const COLOR4D BLACK
Definition: color4d.h:381
unsigned int smaaEdgesBuffer
Definition: antialiasing.h:120
int checkGlError(const std::string &aInfo, const char *aFile, int aLine, bool aThrow)
Check if a recent OpenGL operation has failed.
Definition: utils.cpp:45
unsigned int smaaSearchTex
Definition: antialiasing.h:125
static const unsigned int DIRECT_RENDERING
virtual void ClearBuffer(const COLOR4D &aColor) override
Clear the selected buffer (set by the SetBuffer() function).
unsigned int smaaBlendBuffer
Definition: antialiasing.h:121
virtual void SetBuffer(unsigned int aBufferHandle) override
Set the selected buffer as the rendering target.
std::unique_ptr< SHADER > pass_2_shader
Definition: antialiasing.h:132
std::unique_ptr< SHADER > pass_3_shader
Definition: antialiasing.h:135
GLenum GetBufferTexture(unsigned int aBufferHandle)
std::unique_ptr< SHADER > pass_1_shader
Definition: antialiasing.h:129
OPENGL_COMPOSITOR * compositor
Definition: antialiasing.h:138
unsigned int smaaBaseBuffer
Definition: antialiasing.h:119

References KIGFX::COLOR4D::BLACK, checkGlError(), KIGFX::OPENGL_COMPOSITOR::ClearBuffer(), compositor, KIGFX::OPENGL_COMPOSITOR::DIRECT_RENDERING, KIGFX::OPENGL_COMPOSITOR::GetBufferTexture(), pass_1_shader, pass_2_shader, pass_3_shader, KIGFX::OPENGL_COMPOSITOR::SetBuffer(), smaaAreaTex, smaaBaseBuffer, smaaBlendBuffer, smaaEdgesBuffer, and smaaSearchTex.

◆ updateUniforms()

void ANTIALIASING_SMAA::updateUniforms ( )
private

Definition at line 381 of file antialiasing.cpp.

382 {
383  auto dims = compositor->GetScreenSize();
384 
385  pass_1_shader->Use();
386  checkGlError( "pass1: using shader", __FILE__, __LINE__ );
387  pass_1_shader->SetParameter( pass_1_metrics, 1.f / float( dims.x ), 1.f / float( dims.y ),
388  float( dims.x ), float( dims.y ) );
389  checkGlError( "pass1: setting metrics uniform", __FILE__, __LINE__ );
390  pass_1_shader->Deactivate();
391  checkGlError( "pass1: deactivating shader", __FILE__, __LINE__ );
392 
393  pass_2_shader->Use();
394  checkGlError( "pass2: using shader", __FILE__, __LINE__ );
395  pass_2_shader->SetParameter( pass_2_metrics, 1.f / float( dims.x ), 1.f / float( dims.y ),
396  float( dims.x ), float( dims.y ) );
397  checkGlError( "pass2: setting metrics uniform", __FILE__, __LINE__ );
398  pass_2_shader->Deactivate();
399  checkGlError( "pass2: deactivating shader", __FILE__, __LINE__ );
400 
401  pass_3_shader->Use();
402  checkGlError( "pass3: using shader", __FILE__, __LINE__ );
403  pass_3_shader->SetParameter( pass_3_metrics, 1.f / float( dims.x ), 1.f / float( dims.y ),
404  float( dims.x ), float( dims.y ) );
405  checkGlError( "pass3: setting metrics uniform", __FILE__, __LINE__ );
406  pass_3_shader->Deactivate();
407  checkGlError( "pass3: deactivating shader", __FILE__, __LINE__ );
408 }
int checkGlError(const std::string &aInfo, const char *aFile, int aLine, bool aThrow)
Check if a recent OpenGL operation has failed.
Definition: utils.cpp:45
std::unique_ptr< SHADER > pass_2_shader
Definition: antialiasing.h:132
std::unique_ptr< SHADER > pass_3_shader
Definition: antialiasing.h:135
std::unique_ptr< SHADER > pass_1_shader
Definition: antialiasing.h:129
OPENGL_COMPOSITOR * compositor
Definition: antialiasing.h:138

References checkGlError(), compositor, KIGFX::OPENGL_COMPOSITOR::GetScreenSize(), pass_1_metrics, pass_1_shader, pass_2_metrics, pass_2_shader, pass_3_metrics, and pass_3_shader.

Referenced by Init().

Member Data Documentation

◆ areBuffersInitialized

bool KIGFX::ANTIALIASING_SMAA::areBuffersInitialized
private

Definition at line 117 of file antialiasing.h.

Referenced by Init(), and OnLostBuffers().

◆ compositor

OPENGL_COMPOSITOR* KIGFX::ANTIALIASING_SMAA::compositor
private

◆ pass_1_metrics

GLint KIGFX::ANTIALIASING_SMAA::pass_1_metrics
private

Definition at line 130 of file antialiasing.h.

Referenced by ANTIALIASING_SMAA(), loadShaders(), and updateUniforms().

◆ pass_1_shader

std::unique_ptr<SHADER> KIGFX::ANTIALIASING_SMAA::pass_1_shader
private

Definition at line 129 of file antialiasing.h.

Referenced by loadShaders(), Present(), and updateUniforms().

◆ pass_2_metrics

GLint KIGFX::ANTIALIASING_SMAA::pass_2_metrics
private

Definition at line 133 of file antialiasing.h.

Referenced by ANTIALIASING_SMAA(), loadShaders(), and updateUniforms().

◆ pass_2_shader

std::unique_ptr<SHADER> KIGFX::ANTIALIASING_SMAA::pass_2_shader
private

Definition at line 132 of file antialiasing.h.

Referenced by loadShaders(), Present(), and updateUniforms().

◆ pass_3_metrics

GLint KIGFX::ANTIALIASING_SMAA::pass_3_metrics
private

Definition at line 136 of file antialiasing.h.

Referenced by ANTIALIASING_SMAA(), loadShaders(), and updateUniforms().

◆ pass_3_shader

std::unique_ptr<SHADER> KIGFX::ANTIALIASING_SMAA::pass_3_shader
private

Definition at line 135 of file antialiasing.h.

Referenced by loadShaders(), Present(), and updateUniforms().

◆ shadersLoaded

bool KIGFX::ANTIALIASING_SMAA::shadersLoaded
private

Definition at line 127 of file antialiasing.h.

Referenced by Init(), and loadShaders().

◆ smaaAreaTex

unsigned int KIGFX::ANTIALIASING_SMAA::smaaAreaTex
private

Definition at line 124 of file antialiasing.h.

Referenced by ANTIALIASING_SMAA(), loadShaders(), and Present().

◆ smaaBaseBuffer

unsigned int KIGFX::ANTIALIASING_SMAA::smaaBaseBuffer
private

Definition at line 119 of file antialiasing.h.

Referenced by ANTIALIASING_SMAA(), Begin(), DrawBuffer(), Init(), and Present().

◆ smaaBlendBuffer

unsigned int KIGFX::ANTIALIASING_SMAA::smaaBlendBuffer
private

Definition at line 121 of file antialiasing.h.

Referenced by ANTIALIASING_SMAA(), Init(), and Present().

◆ smaaEdgesBuffer

unsigned int KIGFX::ANTIALIASING_SMAA::smaaEdgesBuffer
private

Definition at line 120 of file antialiasing.h.

Referenced by ANTIALIASING_SMAA(), Init(), and Present().

◆ smaaSearchTex

unsigned int KIGFX::ANTIALIASING_SMAA::smaaSearchTex
private

Definition at line 125 of file antialiasing.h.

Referenced by ANTIALIASING_SMAA(), loadShaders(), and Present().


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