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 (bool aUseAntiAliasing)
 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 42 of file cogl_att_list.h.

Member Function Documentation

const int * COGL_ATT_LIST::GetAttributesList ( bool  aUseAntiAliasing)
static

Get a list of attributes to pass to wxGLCanvas.

Parameters
aUseAntiAliasing= if true 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 81 of file cogl_att_list.cpp.

References 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 EDA_3D_VIEWER::EDA_3D_VIEWER(), PANEL_PREV_3D::PANEL_PREV_3D(), and wxBEGIN_EVENT_TABLE().

82 {
86 
87  if( aUseAntiAliasing )
88  {
89  // There is a bug on wxGLCanvas that makes IsDisplaySupported fail
90  // while testing for antialiasing.
91  // http://trac.wxwidgets.org/ticket/16909
92  // this next code will only work after this bug is fixed
93  //
94  // On my experience (Mario) it was only working on Linux but failing on
95  // Windows, so there was no AA.
96 
97 
98  // Check if the canvas supports multisampling.
99  if( wxGLCanvas::IsDisplaySupported( m_openGL_attributes_list_to_use ) )
100  {
101  // Check for possible sample sizes, start form the top.
102  int maxSamples = 8; // Any higher doesn't change anything.
103 
105 
106  for( ; (maxSamples > 0) &&
107  ( !wxGLCanvas::IsDisplaySupported( m_openGL_attributes_list_to_use ) );
108  maxSamples = maxSamples >> 1 )
109  {
111  }
112  }
113  else
114  {
115  DBG( printf("GetAttributesList: AntiAliasing is not supported.\n") );
116  aUseAntiAliasing = false;
117  }
118  }
119 
120  // Disable antialising if it failed or was not requested
121  if( !aUseAntiAliasing )
122  {
123  // Remove multisampling information
124  // (hoping that the GPU driver will decide what is best)
129  }
130 
132 }
#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:66
#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:71
#define DBG(x)
Definition: fctsys.h:33
#define ATT_WX_GL_SAMPLE_BUFFERS_OFFSET

Member Data Documentation

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 66 of file cogl_att_list.h.

Referenced by GetAttributesList().

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 71 of file cogl_att_list.h.

Referenced by GetAttributesList().


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