KiCad PCB EDA Suite
OGL_ATT_LIST Class Reference

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

#include <ogl_attr_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 (eventually) changed and are passed to creation. More...
 

Detailed Description

Helper class to create an attribute list.

Definition at line 45 of file ogl_attr_list.h.

Member Function Documentation

◆ GetAttributesList()

const int * OGL_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 73 of file ogl_attr_list.cpp.

74 {
75  wxASSERT( aAntiAliasingMode <= ANTIALIASING_MODE::AA_8X );
76 
79 
80  if( aAntiAliasingMode > ANTIALIASING_MODE::AA_NONE )
81  {
82  // There is a bug on wxGLCanvas that makes IsDisplaySupported fail
83  // while testing for antialiasing.
84  // http://trac.wxwidgets.org/ticket/16909
85  // this next code will only work after this bug is fixed
86  //
87  // On my experience (Mario) it was only working on Linux but failing on
88  // Windows, so there was no AA.
89 
90 
91  // Check if the canvas supports multisampling.
92  if( wxGLCanvas::IsDisplaySupported( m_openGL_attributes_list_to_use ) )
93  {
94  static const int aaSamples[4] = {0, 2, 4, 8};
95 
96  // Check for possible sample sizes, start form the requested.
97  int maxSamples = aaSamples[static_cast<int>( aAntiAliasingMode )];
98 
100 
101  for( ; (maxSamples > 0) &&
102  ( !wxGLCanvas::IsDisplaySupported( m_openGL_attributes_list_to_use ) );
103  maxSamples = maxSamples >> 1 )
104  {
106  }
107  }
108  else
109  {
110  aAntiAliasingMode = ANTIALIASING_MODE::AA_NONE;
111  }
112  }
113 
114  // Disable antialising if it failed or was not requested
115  if( aAntiAliasingMode == ANTIALIASING_MODE::AA_NONE )
116  {
117  // Remove multisampling information
118  // (hoping that the GPU driver will decide what is best)
123  }
124 
126 }
static int m_openGL_attributes_list_to_use[]
Attributes list that was (eventually) changed and are passed to creation.
Definition: ogl_attr_list.h:75
#define ATT_WX_GL_SAMPLES_OFFSET
static const int m_openGL_attributes_list[]
Attributes list to be passed to a wxGLCanvas creation.
Definition: ogl_attr_list.h:70
#define ATT_WX_GL_SAMPLE_BUFFERS_OFFSET
#define ATT_WX_GL_SAMPLES_OFFSET_DATA
#define ATT_WX_GL_SAMPLE_BUFFERS_DATA

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, m_openGL_attributes_list, and m_openGL_attributes_list_to_use.

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

Member Data Documentation

◆ m_openGL_attributes_list

const int OGL_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 ogl_attr_list.h.

Referenced by GetAttributesList().

◆ m_openGL_attributes_list_to_use

int OGL_ATT_LIST::m_openGL_attributes_list_to_use = { 0 }
staticprivate

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

Definition at line 75 of file ogl_attr_list.h.

Referenced by GetAttributesList().


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