KiCad PCB EDA Suite
COGL_ATT_LIST Class Reference

Class COGL_ATT_LIST Helper class to create an attribute list. More...

#include <cogl_att_list.h>

Static Public Member Functions

static const int * GetAttributesList (ANTIALIASING_MODE aAntiAliasingMode)
 Get a list of attributes to pass to wxGLCanvas. More...
 

Static Private Attributes

static const int m_openGL_attributes_list []
 Attributes list to be passed to a wxGLCanvas creation. More...
 
static int m_openGL_attributes_list_to_use [] = { 0 }
 Attributes list that was (eventualy) changed and are passed to creation. More...
 

Detailed Description

Class COGL_ATT_LIST Helper class to create an attribute list.

Definition at line 46 of file cogl_att_list.h.

Member Function Documentation

◆ GetAttributesList()

const int * COGL_ATT_LIST::GetAttributesList ( ANTIALIASING_MODE  aAntiAliasingMode)
static

Get a list of attributes to pass to wxGLCanvas.

Parameters
aAntiAliasingMode= 0 - disabled; try to initialize (if is supported) the list with anti aliasing capabilities
Returns
a list of options to be passed in the creation of a EDA_3D_CANVAS class

Definition at line 84 of file cogl_att_list.cpp.

85 {
86  wxASSERT( aAntiAliasingMode <= ANTIALIASING_MODE::AA_8X );
87 
91 
92  if( aAntiAliasingMode > ANTIALIASING_MODE::AA_NONE )
93  {
94  // There is a bug on wxGLCanvas that makes IsDisplaySupported fail
95  // while testing for antialiasing.
96  // http://trac.wxwidgets.org/ticket/16909
97  // this next code will only work after this bug is fixed
98  //
99  // On my experience (Mario) it was only working on Linux but failing on
100  // Windows, so there was no AA.
101 
102 
103  // Check if the canvas supports multisampling.
104  if( wxGLCanvas::IsDisplaySupported( m_openGL_attributes_list_to_use ) )
105  {
106  static const int aaSamples[4] = {0, 2, 4, 8};
107 
108  // Check for possible sample sizes, start form the requested.
109  int maxSamples = aaSamples[static_cast<int>( aAntiAliasingMode )];
110 
112 
113  for( ; (maxSamples > 0) &&
114  ( !wxGLCanvas::IsDisplaySupported( m_openGL_attributes_list_to_use ) );
115  maxSamples = maxSamples >> 1 )
116  {
118  }
119  }
120  else
121  {
122  DBG( printf("GetAttributesList: AntiAliasing is not supported.\n") );
123  aAntiAliasingMode = ANTIALIASING_MODE::AA_NONE;
124  }
125  }
126 
127  // Disable antialising if it failed or was not requested
128  if( aAntiAliasingMode == ANTIALIASING_MODE::AA_NONE )
129  {
130  // Remove multisampling information
131  // (hoping that the GPU driver will decide what is best)
136  }
137 
139 }
#define ATT_WX_GL_SAMPLE_BUFFERS_DATA
static const int m_openGL_attributes_list[]
Attributes list to be passed to a wxGLCanvas creation.
Definition: cogl_att_list.h:70
#define ATT_WX_GL_SAMPLES_OFFSET
#define ATT_WX_GL_SAMPLES_OFFSET_DATA
static int m_openGL_attributes_list_to_use[]
Attributes list that was (eventualy) changed and are passed to creation.
Definition: cogl_att_list.h:75
#define DBG(x)
Definition: fctsys.h:33
#define ATT_WX_GL_SAMPLE_BUFFERS_OFFSET

References AA_8X, AA_NONE, ATT_WX_GL_SAMPLE_BUFFERS_DATA, ATT_WX_GL_SAMPLE_BUFFERS_OFFSET, ATT_WX_GL_SAMPLES_OFFSET, ATT_WX_GL_SAMPLES_OFFSET_DATA, DBG, m_openGL_attributes_list, and m_openGL_attributes_list_to_use.

Referenced by DLG_SELECT_3DMODEL::DLG_SELECT_3DMODEL(), EDA_3D_VIEWER::EDA_3D_VIEWER(), and PANEL_PREV_3D::PANEL_PREV_3D().

Member Data Documentation

◆ m_openGL_attributes_list

const int COGL_ATT_LIST::m_openGL_attributes_list
staticprivate
Initial value:
= {
WX_GL_RGBA, WX_GL_RGBA,
WX_GL_DOUBLEBUFFER, WX_GL_DOUBLEBUFFER,
WX_GL_DEPTH_SIZE, 16,
WX_GL_STENCIL_SIZE, 8,
WX_GL_SAMPLES, 0,
WX_GL_SAMPLE_BUFFERS, 1,
0, 0
}

Attributes list to be passed to a wxGLCanvas creation.

This array should be 2*n+1 Sadly wxwidgets / glx < 13 allowed a thing named "boolean attributes" that don't take a value. (See src/unix/glx11.cpp -> wxGLCanvasX11::ConvertWXAttrsToGL() ). To avoid problems due to this, just specify those attributes twice. Only WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_STEREO are such boolean attributes.

Definition at line 70 of file cogl_att_list.h.

Referenced by GetAttributesList().

◆ m_openGL_attributes_list_to_use

int COGL_ATT_LIST::m_openGL_attributes_list_to_use = { 0 }
staticprivate

Attributes list that was (eventualy) changed and are passed to creation.

Definition at line 75 of file cogl_att_list.h.

Referenced by GetAttributesList().


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