KiCad PCB EDA Suite
cogl_att_list.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
5  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
30 #include "cogl_att_list.h"
31 #include <fctsys.h>
32 
45 
46  // Boolean attributes (using itself at padding):
47 
48  // 0 1
49  WX_GL_RGBA, WX_GL_RGBA,
50  // 2 3
51  WX_GL_DOUBLEBUFFER, WX_GL_DOUBLEBUFFER,
52 
53 
54  // Normal attributes with values:
55 
56  // 4 5
57  WX_GL_DEPTH_SIZE, 16,
58  // 6 7
59  WX_GL_STENCIL_SIZE, 8,
60 
61 
62  // This ones need to be the last in the list (as the tags will set to 0 if AA fails)
63 
64  // 8 9
65  WX_GL_SAMPLES, 0, // Disable AA for the start.
66  //10 11
67  WX_GL_SAMPLE_BUFFERS, 1, // Enable multisampling support (antialiasing).
68 
69  0, 0 // NULL termination
70 };
71 
72 #define ATT_WX_GL_SAMPLES_OFFSET 8
73 #define ATT_WX_GL_SAMPLES_OFFSET_DATA 9
74 #define ATT_WX_GL_SAMPLE_BUFFERS_OFFSET 10
75 #define ATT_WX_GL_SAMPLE_BUFFERS_DATA 11
76 
79 
80 
81 const int *COGL_ATT_LIST::GetAttributesList( bool aUseAntiAliasing )
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 DIM(x)
of elements in an array
Definition: macros.h:98
static const int * GetAttributesList(bool aUseAntiAliasing)
Get a list of attributes to pass to wxGLCanvas.
#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
Declaration of the cogl_att_list class.
#define DBG(x)
Definition: fctsys.h:33
#define ATT_WX_GL_SAMPLE_BUFFERS_OFFSET