32#define GL_SILENCE_DEPRECATION 1
62using namespace std::placeholders;
70#include <glsl_kicad_frag.h>
71#include <glsl_kicad_vert.h>
75static const int glAttributes[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 8, 0 };
120 glDeleteTextures( 1, &bitmap.second.id );
126#ifndef DISABLE_BITMAP_CACHE
132 if( glIsTexture( it->second.id ) )
134 return it->second.id;
139 glDeleteTextures( 1, &it->second.id );
167 return std::numeric_limits< GLuint >::max();
169 const wxImage& imgData = *imgPtr;
171 bmp.
w = imgData.GetSize().x;
172 bmp.
h = imgData.GetSize().y;
178 glGenTextures( 1, &textureID );
186 bmp.
size = bmp.
w * bmp.
h * 4;
187 auto buf = std::make_unique<uint8_t[]>( bmp.
size );
189 for(
int y = 0; y < bmp.
h; y++ )
191 for(
int x = 0; x < bmp.
w; x++ )
193 uint8_t* p = buf.get() + ( bmp.
w * y + x ) * 4;
195 p[0] = imgData.GetRed( x, y );
196 p[1] = imgData.GetGreen( x, y );
197 p[2] = imgData.GetBlue( x, y );
199 if( imgData.HasAlpha() )
200 p[3] = imgData.GetAlpha( x, y );
201 else if( imgData.HasMask() && p[0] == imgData.GetMaskRed()
202 && p[1] == imgData.GetMaskGreen() && p[2] == imgData.GetMaskBlue() )
203 p[3] = wxALPHA_TRANSPARENT;
205 p[3] = wxALPHA_OPAQUE;
209 glBindTexture( GL_TEXTURE_2D, textureID );
210 glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, bmp.
w, bmp.
h, 0, GL_RGBA, GL_UNSIGNED_BYTE,
213 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
214 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
218#ifndef DISABLE_BITMAP_CACHE
230 glDeleteTextures( 1, &cachedBitmap.
id );
243 wxEvtHandler* aMouseListener, wxEvtHandler* aPaintListener,
244 const wxString& aName ) :
245 GAL( aDisplayOptions ),
249 m_mouseListener( aMouseListener ),
250 m_paintListener( aPaintListener ),
251 m_currentManager( nullptr ),
252 m_cachedManager( nullptr ),
253 m_nonCachedManager( nullptr ),
254 m_overlayManager( nullptr ),
255 m_tempManager( nullptr ),
257 m_overlayBuffer( 0 ),
259 m_isContextLocked( false ),
260 m_lockClientCookie( 0 )
267 throw std::runtime_error(
"Could not create the main OpenGL context" );
276 throw std::runtime_error(
"Could not create a private OpenGL context" );
320#if defined _WIN32 || defined _WIN64
324 SetSize( aParent->GetClientSize() );
335 gluTessProperty(
m_tesselator, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE );
396 wxString retVal = wxEmptyString;
398 wxFrame* testFrame =
new wxFrame(
nullptr, wxID_ANY, wxT(
"" ), wxDefaultPosition,
399 wxSize( 1, 1 ), wxFRAME_TOOL_WINDOW | wxNO_BORDER );
414 catch( std::runtime_error& err )
417 retVal = wxString( err.what() );
481#ifdef KICAD_GAL_PROFILE
482 PROF_TIMER totalRealTime(
"OPENGL_GAL::beginDrawing()",
true );
485 wxASSERT_MSG(
m_isContextLocked,
"GAL_DRAWING_CONTEXT RAII object should have locked context. "
486 "Calling GAL::beginDrawing() directly is not allowed." );
488 wxASSERT_MSG(
IsVisible(),
"GAL::beginDrawing() must not be entered when GAL is not visible. "
489 "Other drawing routines will expect everything to be initialized "
490 "which will not be the case." );
496 glMatrixMode( GL_PROJECTION );
512 catch(
const std::runtime_error& )
514 wxLogVerbose(
"Could not create a framebuffer for diff mode blending.\n" );
521 catch(
const std::runtime_error& )
523 wxLogVerbose(
"Could not create a framebuffer for overlays.\n" );
533 glDisable( GL_TEXTURE_2D );
535 glShadeModel( GL_FLAT );
538 glEnable( GL_DEPTH_TEST );
539 glDepthFunc( GL_LESS );
542 glEnable( GL_BLEND );
543 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
545 glMatrixMode( GL_MODELVIEW );
549 GLdouble matrixData[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };
559 glLoadMatrixd( matrixData );
578 const GLint FONT_TEXTURE_UNIT = 2;
583 glActiveTexture( GL_TEXTURE0 + FONT_TEXTURE_UNIT );
588 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
589 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
590 checkGlError(
"loading bitmap font", __FILE__, __LINE__ );
592 glActiveTexture( GL_TEXTURE0 );
598 glActiveTexture( GL_TEXTURE0 + FONT_TEXTURE_UNIT );
600 glActiveTexture( GL_TEXTURE0 );
615 checkGlError(
"setting bitmap font sampler as shader parameter", __FILE__, __LINE__ );
628 renderingOffset.
x *= screenPixelSize.
x;
629 renderingOffset.
y *= screenPixelSize.
y;
635 glActiveTexture( GL_TEXTURE0 );
640#ifdef KICAD_GAL_PROFILE
641 totalRealTime.
Stop();
642 wxLogTrace(
traceGalProfile, wxT(
"OPENGL_GAL::beginDrawing(): %.1f ms" ),
643 totalRealTime.
msecs() );
654 PROF_TIMER cntEndNoncached(
"gl-end-noncached");
663 cntEndNoncached.
Start();
665 cntEndNoncached.
Stop();
667 cntEndCached.
Start();
671 cntEndOverlay.
Start();
677 cntEndOverlay.
Stop();
679 cntComposite.
Start();
681 glColor4d( 1.0, 1.0, 1.0, 1.0 );
718 wxASSERT_MSG(
m_isContextLocked,
"Context not locked. A GAL_CONTEXT_LOCKER RAII object must "
719 "be stacked rather than making separate lock/unlock calls." );
721 wxASSERT_MSG(
m_lockClientCookie == aClientCookie,
"Context was locked by a different client. "
722 "Should not be possible with RAII objects." );
732 wxASSERT_MSG(
m_isContextLocked,
"GAL_UPDATE_CONTEXT RAII object should have locked context. "
733 "Calling this from anywhere else is not allowed." );
735 wxASSERT_MSG(
IsVisible(),
"GAL::beginUpdate() must not be entered when GAL is not visible. "
736 "Other update routines will expect everything to be initialized "
737 "which will not be the case." );
773 VECTOR2D startEndVector = aEndPoint - aStartPoint;
776 float startx = aStartPoint.
x;
777 float starty = aStartPoint.
y;
778 float endx = aStartPoint.
x + lineLength;
779 float endy = aStartPoint.
y + lineLength;
784 if( startx == endx || starty == endy )
786 drawCircle( aStartPoint, aWidth / 2, aReserve );
901 double startAngle = aStartAngle.
AsRadians();
902 double endAngle = startAngle + aAngle.
AsRadians();
905 SWAP( startAngle, >, endAngle );
919 for( alpha = startAngle; ( alpha + alphaIncrement ) < endAngle; )
925 alpha += alphaIncrement;
931 const VECTOR2D endPoint( cos( endAngle ) * aRadius, sin( endAngle ) * aRadius );
944 VECTOR2D p( cos( startAngle ) * aRadius, sin( startAngle ) * aRadius );
947 for( alpha = startAngle + alphaIncrement; alpha <= endAngle; alpha += alphaIncrement )
949 VECTOR2D p_next( cos( alpha ) * aRadius, sin( alpha ) * aRadius );
956 if( alpha != endAngle )
958 VECTOR2D p_last( cos( endAngle ) * aRadius, sin( endAngle ) * aRadius );
969 double aWidth,
double aMaxError )
980 double startAngle = aStartAngle.
AsRadians();
981 double endAngle = startAngle + aAngle.
AsRadians();
984 SWAP( startAngle, >, endAngle );
989 double alphaIncrement = 2.0 * M_PI / segCount360;
994 int seg_count =
KiROUND( ( endAngle - startAngle ) / alphaIncrement );
996 if( seg_count % 2 != 0 )
1001 alphaIncrement = ( endAngle - startAngle ) / seg_count;
1011 double width = aWidth / 2.0;
1012 VECTOR2D startPoint( cos( startAngle ) * aRadius, sin( startAngle ) * aRadius );
1013 VECTOR2D endPoint( cos( endAngle ) * aRadius, sin( endAngle ) * aRadius );
1018 VECTOR2D pOuter( cos( startAngle ) * ( aRadius + width ),
1019 sin( startAngle ) * ( aRadius + width ) );
1021 VECTOR2D pInner( cos( startAngle ) * ( aRadius - width ),
1022 sin( startAngle ) * ( aRadius - width ) );
1026 for( alpha = startAngle + alphaIncrement; alpha <= endAngle; alpha += alphaIncrement )
1028 VECTOR2D pNextOuter( cos( alpha ) * ( aRadius + width ),
1029 sin( alpha ) * ( aRadius + width ) );
1030 VECTOR2D pNextInner( cos( alpha ) * ( aRadius - width ),
1031 sin( alpha ) * ( aRadius - width ) );
1036 pOuter = pNextOuter;
1037 pInner = pNextInner;
1041 if( alpha != endAngle )
1043 VECTOR2D pLastOuter( cos( endAngle ) * ( aRadius + width ),
1044 sin( endAngle ) * ( aRadius + width ) );
1045 VECTOR2D pLastInner( cos( endAngle ) * ( aRadius - width ),
1046 sin( endAngle ) * ( aRadius - width ) );
1058 VECTOR2D p( cos( startAngle ) * aRadius, sin( startAngle ) * aRadius );
1063 for( alpha = startAngle + alphaIncrement; alpha <= endAngle; alpha += alphaIncrement )
1069 if( alpha != endAngle )
1076 for( alpha = startAngle + alphaIncrement; alpha <= endAngle; alpha += alphaIncrement )
1078 VECTOR2D p_next( cos( alpha ) * aRadius, sin( alpha ) * aRadius );
1085 if( alpha != endAngle )
1087 VECTOR2D p_last( cos( endAngle ) * aRadius, sin( endAngle ) * aRadius );
1099 VECTOR2D diagonalPointA( aEndPoint.
x, aStartPoint.
y );
1100 VECTOR2D diagonalPointB( aStartPoint.
x, aEndPoint.
y );
1124 std::deque<VECTOR2D> pointList;
1125 pointList.push_back( aStartPoint );
1126 pointList.push_back( diagonalPointA );
1127 pointList.push_back( aEndPoint );
1128 pointList.push_back( diagonalPointB );
1129 pointList.push_back( aStartPoint );
1140 return aPointList[idx];
1142 aPointList.size(), aWidth );
1156 return aLineChain.
CPoint( idx );
1158 numPoints, aWidth );
1167 return aPointList[idx];
1169 aPointList.size() );
1178 return aPointList[idx];
1180 aPointList.size() );
1189 return aPointList[idx];
1205 return aLineChain.
CPoint( idx );
1213 int lineQuadCount = 0;
1215 for(
const std::vector<VECTOR2D>& points : aPointList )
1216 lineQuadCount += points.size() - 1;
1220 for(
const std::vector<VECTOR2D>& points : aPointList )
1227 points.size(),
false );
1234 wxCHECK( aPointList.size() >= 2, );
1235 auto points = std::unique_ptr<GLdouble[]>(
new GLdouble[3 * aPointList.size()] );
1236 GLdouble* ptr = points.get();
1238 for(
const VECTOR2D& p : aPointList )
1251 wxCHECK( aListSize >= 2, );
1252 auto points = std::unique_ptr<GLdouble[]>(
new GLdouble[3 * aListSize] );
1253 GLdouble* target = points.get();
1256 for(
int i = 0; i < aListSize; ++i )
1269 bool aStrokeTriangulation )
1276 int totalTriangleCount = 0;
1291 for(
size_t i = 0; i < triPoly->GetTriangleCount(); i++ )
1294 triPoly->GetTriangle( i, a, b, c );
1306 const auto& poly = aPolySet.
Polygon( j );
1308 for(
const auto& lc : poly )
1317 aStrokeTriangulation =
true;
1321 if( aStrokeTriangulation )
1332 for(
size_t i = 0; i < triPoly->GetTriangleCount(); i++ )
1335 triPoly->GetTriangle( i, a, b, c );
1369 std::unique_ptr<GLdouble[]> points(
new GLdouble[3 * pointCount] );
1370 GLdouble* ptr = points.get();
1372 for(
int i = 0; i < pointCount; ++i )
1386 double aFilterValue )
1388 std::vector<VECTOR2D> output;
1389 std::vector<VECTOR2D> pointCtrl;
1391 pointCtrl.push_back( aStartPoint );
1392 pointCtrl.push_back( aControlPointA );
1393 pointCtrl.push_back( aControlPointB );
1394 pointCtrl.push_back( aEndPoint );
1397 converter.
GetPoly( output, aFilterValue );
1405 GLfloat alpha = std::clamp( alphaBlend, 0.0, 1.0 );
1415 glm::vec4 v0 = xform * glm::vec4( -w / 2, -h / 2, 0.0, 0.0 );
1416 glm::vec4
v1 = xform * glm::vec4( w / 2, h / 2, 0.0, 0.0 );
1417 glm::vec4 trans = xform[3];
1421 if( !glIsTexture( texture_id ) )
1424 glDisable( GL_DEPTH_TEST );
1426 glMatrixMode( GL_TEXTURE );
1428 glTranslated( 0.5, 0.5, 0.5 );
1430 glTranslated( -0.5, -0.5, -0.5 );
1432 glMatrixMode( GL_MODELVIEW );
1434 glTranslated( trans.x, trans.y, trans.z );
1436 glEnable( GL_TEXTURE_2D );
1437 glActiveTexture( GL_TEXTURE0 );
1438 glBindTexture( GL_TEXTURE_2D, texture_id );
1440 float texStartX = aBitmap.
IsMirroredX() ? 1.0 : 0.0;
1441 float texEndX = aBitmap.
IsMirroredX() ? 0.0 : 1.0;
1442 float texStartY = aBitmap.
IsMirroredY() ? 1.0 : 0.0;
1443 float texEndY = aBitmap.
IsMirroredY() ? 0.0 : 1.0;
1445 glBegin( GL_QUADS );
1446 glColor4f( 1.0, 1.0, 1.0, alpha );
1447 glTexCoord2f( texStartX, texStartY );
1449 glColor4f( 1.0, 1.0, 1.0, alpha );
1450 glTexCoord2f( texEndX, texStartY);
1452 glColor4f( 1.0, 1.0, 1.0, alpha );
1453 glTexCoord2f( texEndX, texEndY);
1455 glColor4f( 1.0, 1.0, 1.0, alpha );
1456 glTexCoord2f( texStartX, texEndY);
1460 glBindTexture( GL_TEXTURE_2D, 0 );
1462#ifdef DISABLE_BITMAP_CACHE
1463 glDeleteTextures( 1, &texture_id );
1468 glMatrixMode( GL_TEXTURE );
1470 glMatrixMode( GL_MODELVIEW );
1472 glEnable( GL_DEPTH_TEST );
1481 || aText.Contains( wxT(
"^{" ) )
1482 || aText.Contains( wxT(
"_{" ) )
1483 || aText.Contains( wxT(
"\n" ) ) )
1494 double overbarHeight = textSize.
y;
1537 overbarHeight = -textSize.
y / 2.0;
1541 int overbarLength = 0;
1542 int overbarDepth = -1;
1543 int braceNesting = 0;
1545 auto iterateString =
1546 [&]( std::function<void(
int aOverbarLength,
int aOverbarHeight )> overbarFn,
1547 std::function<int(
unsigned long aChar )> bitmapCharFn )
1551 wxASSERT_MSG( *chIt !=
'\n' && *chIt !=
'\r',
1552 "No support for multiline bitmap text yet" );
1554 if( *chIt ==
'~' && overbarDepth == -1 )
1558 if( ++lookahead != end && *lookahead ==
'{' )
1561 overbarDepth = braceNesting;
1566 else if( *chIt ==
'{' )
1570 else if( *chIt ==
'}' )
1572 if( braceNesting > 0 )
1575 if( braceNesting == overbarDepth )
1577 overbarFn( overbarLength, overbarHeight );
1585 if( overbarDepth != -1 )
1586 overbarLength += bitmapCharFn( *chIt );
1588 bitmapCharFn( *chIt );
1595 int overbarsCount = 0;
1598 [&overbarsCount](
int aOverbarLength,
int aOverbarHeight )
1602 [&charsCount](
unsigned long aChar ) ->
int
1618 [&](
int aOverbarLength,
int aOverbarHeight )
1622 [&](
unsigned long aChar ) ->
int
1630 if( overbarDepth != -1 && overbarLength > 0 )
1645 float minorLineWidth = std::fmax( 1.0f,
1647 float majorLineWidth = minorLineWidth * 2.0f;
1682 SWAP( gridStartX, >, gridEndX );
1683 SWAP( gridStartY, >, gridEndY );
1691 glDisable( GL_DEPTH_TEST );
1692 glDisable( GL_TEXTURE_2D );
1696 glEnable( GL_STENCIL_TEST );
1697 glStencilFunc( GL_ALWAYS, 1, 1 );
1698 glStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
1699 glColor4d( 0.0, 0.0, 0.0, 0.0 );
1711 for(
int j = gridStartY; j <= gridEndY; j++ )
1717 for(
int i = gridStartX; i <= gridEndX; i++ )
1720 SetLineWidth( ( ( tickX && tickY ) ? majorLineWidth : minorLineWidth ) );
1734 for(
int j = gridStartY; j <= gridEndY; j++ )
1753 glStencilFunc( GL_NOTEQUAL, 0, 1 );
1759 for(
int i = gridStartX; i <= gridEndX; i++ )
1776 glDisable( GL_STENCIL_TEST );
1779 glEnable( GL_DEPTH_TEST );
1780 glEnable( GL_TEXTURE_2D );
1793 wxGLCanvas::SetSize( aWidth, aHeight );
1799 bool s = wxGLCanvas::Show( aShow );
1802 wxGLCanvas::Raise();
1820 glClearColor( 0, 0, 0, 1 );
1821 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
1827 GLdouble matrixData[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };
1829 matrixData[0] = aTransformation.
m_data[0][0];
1830 matrixData[1] = aTransformation.
m_data[1][0];
1831 matrixData[2] = aTransformation.
m_data[2][0];
1832 matrixData[4] = aTransformation.
m_data[0][1];
1833 matrixData[5] = aTransformation.
m_data[1][1];
1834 matrixData[6] = aTransformation.
m_data[2][1];
1835 matrixData[12] = aTransformation.
m_data[0][2];
1836 matrixData[13] = aTransformation.
m_data[1][2];
1837 matrixData[14] = aTransformation.
m_data[2][2];
1839 glMultMatrixd( matrixData );
1877 std::shared_ptr<VERTEX_ITEM> newItem = std::make_shared<VERTEX_ITEM>( *
m_cachedManager );
1879 m_groups.insert( std::make_pair( groupNumber, newItem ) );
2021 glBlendEquation( GL_MAX );
2023 glBlendEquation( GL_FUNC_ADD );
2030 glBlendFunc( GL_SRC_ALPHA, GL_ONE );
2032 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
2069 const bool aReserve )
2087 * glm::vec4( aStartPoint.
x, aStartPoint.
y, 0.0, 0.0 );
2089 * glm::vec4( aEndPoint.
x, aEndPoint.
y, 0.0, 0.0 );
2173 double outerRadius = aRadius + (
m_lineWidth / 2 );
2219 GLdouble* point = aPoints;
2221 for(
int i = 0; i < aPointCount; ++i )
2239 return VECTOR2D( aPoints[idx * 3], aPoints[idx * 3 + 1] );
2249 wxCHECK( aPointCount > 0, );
2253 if( aPointCount == 1 )
2255 drawLineQuad( aPointGetter( 0 ), aPointGetter( 0 ), aReserve );
2264 for(
int i = 1; i < aPointCount; ++i )
2266 auto start = aPointGetter( i - 1 );
2267 auto end = aPointGetter( i );
2275 int aPointCount,
double aWidth,
bool aReserve )
2277 wxCHECK( aPointCount >= 2, );
2283 for(
int i = 1; i < aPointCount; ++i )
2285 auto start = aPointGetter( i - 1 );
2286 auto end = aPointGetter( i );
2288 VECTOR2D startEndVector = end - start;
2291 float startx = start.x;
2292 float starty = start.y;
2293 float endx = start.x + lineLength;
2294 float endy = start.y + lineLength;
2299 if( startx == endx || starty == endy )
2311 vertices += 6 + 6 + 3 + 3;
2317 for(
int i = 1; i < aPointCount; ++i )
2319 auto start = aPointGetter( i - 1 );
2320 auto end = aPointGetter( i );
2339 double spaceWidth = g->
advance * 0.74;
2357 const float XOFF = glyph->
minx;
2360 const float round_adjust = ( glyph->
maxy - glyph->
miny )
2363 const float YOFF = round_adjust + top_adjust;
2412 const float H = glyph->
maxy - glyph->
miny;
2442 float commonOffset = std::numeric_limits<float>::max();
2444 int overbarDepth = -1;
2445 int braceNesting = 0;
2449 if( *chIt ==
'~' && overbarDepth == -1 )
2453 if( ++lookahead != end && *lookahead ==
'{' )
2456 overbarDepth = braceNesting;
2461 else if( *chIt ==
'{' )
2465 else if( *chIt ==
'}' )
2467 if( braceNesting > 0 )
2470 if( braceNesting == overbarDepth )
2480 || *chIt ==
'-' || *chIt ==
'_' )
2482 glyph = defaultGlyph;
2489 textSize.
y = std::max<float>( textSize.
y, charHeight );
2491 textSize.
y -= commonOffset;
2493 return std::make_pair( textSize, commonOffset );
2522 VECTOR2D cursorCenter = ( cursorBegin + cursorEnd ) / 2;
2525 const COLOR4D color( cColor.
r * cColor.
a, cColor.
g * cColor.
a, cColor.
b * cColor.
a, 1.0 );
2527 glActiveTexture( GL_TEXTURE0 );
2528 glDisable( GL_TEXTURE_2D );
2532 glBegin( GL_LINES );
2533 glVertex2d( cursorCenter.
x, cursorBegin.
y );
2534 glVertex2d( cursorCenter.
x, cursorEnd.
y );
2536 glVertex2d( cursorBegin.
x, cursorCenter.
y );
2537 glVertex2d( cursorEnd.
x, cursorCenter.
y );
2544 wxASSERT_MSG(
m_groups.size() < std::numeric_limits<unsigned int>::max(),
2545 wxT(
"There are no free slots to store a group" ) );
2556#ifndef KICAD_USE_EGL
2557 wxASSERT( IsShownOnScreen() );
2560 wxASSERT_MSG(
m_isContextLocked,
"This should only be called from within a locked context." );
2564 throw std::runtime_error(
"Could not create the tesselator" );
2565 GLenum err = glewInit();
2569 for(
int i = 0; i < 10; i++ )
2571 if( GLEW_OK == err )
2574 std::this_thread::sleep_for( std::chrono::milliseconds( 250 ) );
2580 if( GLEW_OK != err )
2581 throw std::runtime_error( (
const char*) glewGetErrorString( err ) );
2584 if( !GLEW_VERSION_2_1 )
2585 throw std::runtime_error(
"OpenGL 2.1 or higher is required!" );
2587#if defined( __LINUX__ )
2589 if( GLEW_ARB_debug_output )
2595 if( !GLEW_EXT_framebuffer_object )
2596 throw std::runtime_error(
"Framebuffer objects are not supported!" );
2599 if( !GLEW_ARB_vertex_buffer_object )
2600 throw std::runtime_error(
"Vertex buffer objects are not supported!" );
2605 BUILTIN_SHADERS::glsl_kicad_vert ) )
2607 throw std::runtime_error(
"Cannot compile vertex shader!" );
2612 BUILTIN_SHADERS::glsl_kicad_frag ) )
2614 throw std::runtime_error(
"Cannot compile fragment shader!" );
2618 throw std::runtime_error(
"Cannot link the shaders!" );
2622 glGetIntegerv( GL_MAX_TEXTURE_SIZE, &maxTextureSize );
2628 throw std::runtime_error(
"Requested texture size is not supported" );
2651 GLdouble* vertex =
static_cast<GLdouble*
>( aVertexPtr );
2655 assert( vboManager );
2656 vboManager->
Vertex( vertex[0], vertex[1], vertex[2] );
2661 GLdouble** dataOut,
void* aData )
2663 GLdouble* vertex =
new GLdouble[3];
2669 param->
intersectPoints.emplace_back( vertex, std::default_delete<GLdouble[]>() );
2671 memcpy( vertex, coords, 3 *
sizeof( GLdouble ) );
2708 return ( ceil( f / r ) - 0.5 ) * r;
2741 outlineGlyph.Triangulate(
2756 if( aGlyphs.empty() )
2759 bool allGlyphsAreStroke =
true;
2760 bool allGlyphsAreOutline =
true;
2762 for(
const std::unique_ptr<KIFONT::GLYPH>& glyph : aGlyphs )
2764 if( !glyph->IsStroke() )
2766 allGlyphsAreStroke =
false;
2771 for(
const std::unique_ptr<KIFONT::GLYPH>& glyph : aGlyphs )
2773 if( !glyph->IsOutline() )
2775 allGlyphsAreOutline =
false;
2780 if( allGlyphsAreStroke )
2783 int lineQuadCount = 0;
2785 for(
const std::unique_ptr<KIFONT::GLYPH>& glyph : aGlyphs )
2789 for(
const std::vector<VECTOR2D>& points : strokeGlyph )
2790 lineQuadCount += points.size() - 1;
2795 for(
const std::unique_ptr<KIFONT::GLYPH>& glyph : aGlyphs )
2799 for(
const std::vector<VECTOR2D>& points : strokeGlyph )
2806 points.size(),
false );
2812 else if( allGlyphsAreOutline )
2815 int triangleCount = 0;
2817 if( aGlyphs.size() > 0 )
2821 tp.push_loop( aGlyphs.size(),
2822 [&](
const int a,
const int b)
2824 for( int ii = a; ii < b; ++ii )
2826 auto glyph = static_cast<KIFONT::OUTLINE_GLYPH*>( aGlyphs.at( ii ).get() );
2831 if( glyph->TriangulatedPolyCount() == 0 )
2832 glyph->CacheTriangulation( false );
2835 tp.wait_for_tasks();
2838 for(
const std::unique_ptr<KIFONT::GLYPH>& glyph : aGlyphs )
2842 for(
unsigned int i = 0; i < outlineGlyph.TriangulatedPolyCount(); i++ )
2845 outlineGlyph.TriangulatedPolygon( i );
2856 for(
const std::unique_ptr<KIFONT::GLYPH>& glyph : aGlyphs )
2860 for(
unsigned int i = 0; i < outlineGlyph.TriangulatedPolyCount(); i++ )
2863 outlineGlyph.TriangulatedPolygon( i );
2880 for(
size_t i = 0; i < aGlyphs.size(); i++ )
2881 DrawGlyph( *aGlyphs[i], i, aGlyphs.size() );
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
Bezier curves to polygon converter.
void GetPoly(std::vector< VECTOR2I > &aOutput, int aMinSegLen=0, int aMaxSegCount=32)
Convert a Bezier curve to a polygon.
This class handle bitmap images in KiCad.
const wxImage * GetOriginalImageData() const
VECTOR2I GetSizePixels() const
EDA_ANGLE Rotation() const
static const wxCursor GetCursor(KICURSOR aCursorType)
void UnlockCtx(wxGLContext *aContext)
Allow other canvases to bind an OpenGL context.
void DestroyCtx(wxGLContext *aContext)
Destroy a managed OpenGL context.
void LockCtx(wxGLContext *aContext, wxGLCanvas *aCanvas)
Set a context as current and prevents other canvases from switching it.
static GL_CONTEXT_MANAGER & Get()
Return the GL_CONTEXT_MANAGER instance (singleton).
wxGLContext * CreateCtx(wxGLCanvas *aCanvas, const wxGLContext *aOther=nullptr)
Create a managed OpenGL context.
static int SetSwapInterval(int aVal)
Attempts to set the OpenGL swap interval.
wxGLCanvas wrapper for HiDPI/Retina support.
void SetScaleFactor(double aFactor)
Set the canvas scale factor, probably for a hi-DPI display.
virtual wxSize GetNativePixelSize() const
double GetScaleFactor() const
Get the current scale factor.
virtual bool IsStroke() const
virtual bool IsOutline() const
A color representation with 4 components: red, green, blue, alpha.
static const COLOR4D BLACK
OPENGL_ANTIALIASING_MODE gl_antialiasing_mode
Abstract interface for drawing on a 2D-surface.
bool IsTextMirrored() const
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
bool IsCursorEnabled() const
Return information about cursor visibility.
MATRIX3x3D m_worldScreenMatrix
World transformation.
VECTOR2D GetVisibleGridSize() const
Return the visible grid size in x and y directions.
double m_layerDepth
The actual layer depth.
MATRIX3x3D m_screenWorldMatrix
Screen transformation.
bool m_axesEnabled
Should the axes be drawn.
float m_gridLineWidth
Line width of the grid.
VECTOR2I m_screenSize
Screen size in screen coordinates.
GR_TEXT_H_ALIGN_T GetHorizontalJustify() const
VECTOR2D m_depthRange
Range of the depth.
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
GRID_STYLE m_gridStyle
Grid display style.
COLOR4D m_axesColor
Color of the axes.
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
float m_lineWidth
The line width.
void computeWorldScale()
Compute the scaling factor for the world->screen matrix.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
VECTOR2D m_gridSize
The grid size.
COLOR4D getCursorColor() const
Get the actual cursor color to draw.
COLOR4D m_fillColor
The fill color.
double m_worldUnitLength
The unit length of the world coordinates [inch].
virtual bool updatedGalDisplayOptions(const GAL_DISPLAY_OPTIONS &aOptions)
Handle updating display options.
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
VECTOR2D m_cursorPosition
Current cursor position (world coordinates)
const VECTOR2I & GetGlyphSize() const
int m_gridTick
Every tick line gets the double width.
double m_worldScale
The scale factor world->screen.
virtual bool SetNativeCursorStyle(KICURSOR aCursor)
Set the cursor in the native panel.
VECTOR2D m_gridOrigin
The grid origin.
KICURSOR m_currentNativeCursor
Current cursor.
bool m_globalFlipY
Flag for Y axis flipping.
bool m_fullscreenCursor
Shape of the cursor (fullscreen or small cross)
bool m_isFillEnabled
Is filling of graphic objects enabled ?
virtual void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.
COLOR4D m_gridColor
Color of the grid.
COLOR4D m_strokeColor
The color of the outlines.
bool m_isStrokeEnabled
Are the outlines stroked ?
GAL_DISPLAY_OPTIONS & m_options
bool m_gridVisibility
Should the grid be shown.
virtual void BitmapText(const wxString &aText, const VECTOR2I &aPosition, const EDA_ANGLE &aAngle)
Draw a text using a bitmap font.
float GetLineWidth() const
Get the line width.
bool m_globalFlipX
Flag for X axis flipping.
GR_TEXT_V_ALIGN_T GetVerticalJustify() const
VECTOR2D m_lookAtPoint
Point to be looked at in world space.
GLuint cacheBitmap(const BITMAP_BASE *aBitmap)
const size_t m_cacheMaxElements
GLuint RequestBitmap(const BITMAP_BASE *aBitmap)
std::list< GLuint > m_freedTextureIds
const size_t m_cacheMaxSize
std::map< const KIID, CACHED_BITMAP > m_bitmaps
std::list< KIID > m_cacheLru
VECTOR2D GetAntialiasRenderingOffset() const
virtual void Begin() override
Call this at the beginning of each frame.
static const unsigned int DIRECT_RENDERING
virtual unsigned int GetBuffer() const override
Return currently used buffer handle.
OPENGL_ANTIALIASING_MODE GetAntialiasingMode() const
void SetAntialiasingMode(OPENGL_ANTIALIASING_MODE aMode)
virtual void Present() override
Call this to present the output buffer to the screen.
virtual void Initialize() override
Perform primary initialization, necessary to use the object.
virtual void ClearBuffer(const COLOR4D &aColor) override
Clear the selected buffer (set by the SetBuffer() function).
virtual void Resize(unsigned int aWidth, unsigned int aHeight) override
Clear the state of COMPOSITOR, so it has to be reinitialized again with the new dimensions.
virtual void DrawBuffer(unsigned int aBufferHandle) override
Draw the selected buffer to the output buffer.
int GetAntialiasSupersamplingFactor() const
virtual void SetBuffer(unsigned int aBufferHandle) override
Set the selected buffer as the rendering target.
virtual unsigned int CreateBuffer() override
Prepare a new buffer that may be used as a rendering target.
OpenGL implementation of the Graphics Abstraction Layer.
void Transform(const MATRIX3x3D &aTransformation) override
Transform the context.
void drawPolygon(GLdouble *aPoints, int aPointCount)
Draw a filled polygon.
void ChangeGroupDepth(int aGroupNumber, int aDepth) override
Change the depth (Z-axis position) of the group.
void skipMouseEvent(wxMouseEvent &aEvent)
Skip the mouse event to the parent.
void drawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth, bool aReserve=true)
Internal method for segment drawing.
unsigned int m_groupCounter
Counter used for generating keys for groups.
void EndDiffLayer() override
Ends rendering of a differential layer.
VERTEX_MANAGER * m_overlayManager
Container for storing overlaid VERTEX_ITEMs.
void Scale(const VECTOR2D &aScale) override
Scale the context.
bool m_isInitialized
Basic initialization flag, has to be done when the window is visible.
VERTEX_MANAGER * m_currentManager
Currently used VERTEX_MANAGER (for storing VERTEX_ITEMs).
void drawCircle(const VECTOR2D &aCenterPoint, double aRadius, bool aReserve=true)
Internal method for circle drawing.
std::deque< std::shared_ptr< GLdouble > > m_tessIntersects
void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius) override
Draw a circle using world coordinates.
void LockContext(int aClientCookie) override
Use GAL_CONTEXT_LOCKER RAII object unless you know what you're doing.
unsigned int m_mainBuffer
Main rendering target.
std::unique_ptr< GL_BITMAP_CACHE > m_bitmapCache
std::pair< VECTOR2D, float > computeBitmapTextSize(const UTF8 &aText) const
Compute a size of text drawn using bitmap font with current text setting applied.
void SetTarget(RENDER_TARGET aTarget) override
Set the target for rendering.
void blitCursor()
Blit cursor into the current screen.
static wxString CheckFeatures(GAL_DISPLAY_OPTIONS &aOptions)
Checks OpenGL features.
void ClearTarget(RENDER_TARGET aTarget) override
Clear the target for rendering.
void drawBitmapOverbar(double aLength, double aHeight, bool aReserve=true)
Draw an overbar over the currently drawn text.
void EndGroup() override
End the group.
bool m_isBitmapFontInitialized
Is the shader set to use bitmap fonts?
void drawSegmentChain(const std::function< VECTOR2D(int)> &aPointGetter, int aPointCount, double aWidth, bool aReserve=true)
Generic way of drawing a chain of segments stored in different containers.
void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aWidth, double aMaxError) override
Draw an arc segment.
void BitmapText(const wxString &aText, const VECTOR2I &aPosition, const EDA_ANGLE &aAngle) override
Draw a text using a bitmap font.
bool updatedGalDisplayOptions(const GAL_DISPLAY_OPTIONS &aOptions) override
Handle updating display options.
unsigned int m_overlayBuffer
Auxiliary rendering target (for menus etc.)
void PostPaint(wxPaintEvent &aEvent)
Function PostPaint posts an event to m_paint_listener.
OPENGL_COMPOSITOR * m_compositor
Handles multiple rendering targets.
VERTEX_MANAGER * m_cachedManager
Container for storing cached VERTEX_ITEMs.
void Translate(const VECTOR2D &aTranslation) override
Translate the context.
void DrawPolyline(const std::deque< VECTOR2D > &aPointList) override
Draw a polyline.
void DrawCurve(const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint, double aFilterValue=0.0) override
Draw a cubic bezier spline.
void drawFilledSemiCircle(const VECTOR2D &aCenterPoint, double aRadius, double aAngle)
Draw a filled semicircle.
void onPaint(wxPaintEvent &aEvent)
This is the OnPaint event handler.
void DrawGroup(int aGroupNumber) override
Draw the stored group.
void Restore() override
Restore the context.
void DrawSegmentChain(const std::vector< VECTOR2D > &aPointList, double aWidth) override
Draw a chain of rounded segments.
void drawStrokedSemiCircle(const VECTOR2D &aCenterPoint, double aRadius, double aAngle, bool aReserve=true)
Draw a stroked semicircle.
unsigned int getNewGroupNumber()
Return a valid key that can be used as a new group number.
void Flush() override
Force all remaining objects to be drawn.
GLint ufm_antialiasingOffset
void DeleteGroup(int aGroupNumber) override
Delete the group from the memory.
bool IsVisible() const override
Return true if the GAL canvas is visible on the screen.
wxEvtHandler * m_mouseListener
int m_swapInterval
Used to store swap interval information.
void ClearCache() override
Delete all data created during caching of graphic items.
double getWorldPixelSize() const
void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth) override
Draw a rounded segment.
GROUPS_MAP m_groups
Stores information about VBO objects (groups)
void endUpdate() override
void ClearScreen() override
Clear the screen.
void ResizeScreen(int aWidth, int aHeight) override
Resizes the canvas.
void DrawPolygon(const std::deque< VECTOR2D > &aPointList) override
Draw a polygon.
void drawTriangulatedPolyset(const SHAPE_POLY_SET &aPoly, bool aStrokeTriangulation)
Draw a set of polygons with a cached triangulation.
void DrawCursor(const VECTOR2D &aCursorPosition) override
Draw the cursor.
void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
Draw a rectangle.
VERTEX_MANAGER * m_nonCachedManager
Container for storing non-cached VERTEX_ITEMs.
int drawBitmapChar(unsigned long aChar, bool aReserve=true)
Draw a single character using bitmap font.
GLUtesselator * m_tesselator
wxEvtHandler * m_paintListener
void StartDiffLayer() override
Begins rendering of a differential layer.
bool m_isContextLocked
Used for assertion checking.
void Save() override
Save the context.
wxCursor m_currentwxCursor
wxCursor showing the current native cursor
bool m_isFramebufferInitialized
Are the framebuffers initialized?
void ComputeWorldScreenMatrix() override
Compute the world <-> screen transformation matrix.
bool Show(bool aShow) override
Shows/hides the GAL canvas.
static GLuint g_fontTexture
Bitmap font texture handle (shared)
virtual bool HasTarget(RENDER_TARGET aTarget) override
Return true if the target exists.
void reserveLineQuads(const int aLineCount)
Reserves specified number of line quads.
void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
Draw a line.
OPENGL_GAL(const KIGFX::VC_SETTINGS &aVcSettings, GAL_DISPLAY_OPTIONS &aDisplayOptions, wxWindow *aParent, wxEvtHandler *aMouseListener=nullptr, wxEvtHandler *aPaintListener=nullptr, const wxString &aName=wxT("GLCanvas"))
void beginUpdate() override
double calcAngleStep(double aRadius) const
Compute the angle step when drawing arcs/circles approximated with lines.
virtual void DrawGlyph(const KIFONT::GLYPH &aGlyph, int aNth, int aTotal) override
Draw a polygon representing a font glyph.
bool m_isGrouping
Was a group started?
void BeginDrawing() override
Start/end drawing functions, draw calls can be only made in between the calls to BeginDrawing()/EndDr...
GLint ufm_screenPixelSize
void Rotate(double aAngle) override
Rotate the context.
int BeginGroup() override
Begin a group.
GLint ufm_pixelSizeMultiplier
VECTOR2D getScreenPixelSize() const
bool SetNativeCursorStyle(KICURSOR aCursor) override
Set the cursor in the native panel.
void DrawBitmap(const BITMAP_BASE &aBitmap, double alphaBlend=1.0) override
Draw a bitmap image.
void drawPolyline(const std::function< VECTOR2D(int)> &aPointGetter, int aPointCount, bool aReserve=true)
Generic way of drawing a polyline stored in different containers.
RENDER_TARGET GetTarget() const override
Get the currently used target for rendering.
void UnlockContext(int aClientCookie) override
void drawSemiCircle(const VECTOR2D &aCenterPoint, double aRadius, double aAngle)
Draw a semicircle.
void drawLineQuad(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, bool aReserve=true)
Draw a quad for the line.
VERTEX_MANAGER * m_tempManager
Container for storing temp (diff mode) VERTEX_ITEMs.
virtual void DrawGlyphs(const std::vector< std::unique_ptr< KIFONT::GLYPH > > &aGlyphs) override
Draw polygons representing font glyphs.
void onSetNativeCursor(wxSetCursorEvent &aEvent)
Give the correct cursor image when the native widget asks for it.
void EnableDepthTest(bool aEnabled=false) override
void EndDrawing() override
End the drawing, needs to be called for every new frame.
SHADER * m_shader
There is only one shader used for different objects.
void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle) override
Draw an arc.
void DrawPolylines(const std::vector< std::vector< VECTOR2D > > &aPointLists) override
Draw multiple polylines.
RENDER_TARGET m_currentTarget
Current rendering target.
wxGLContext * m_glPrivContext
Canvas-specific OpenGL context.
void ChangeGroupColor(int aGroupNumber, const COLOR4D &aNewColor) override
Change the color used to draw the group.
static bool m_isBitmapFontLoaded
Is the bitmap font texture loaded?
static wxGLContext * m_glMainContext
Parent OpenGL context.
unsigned int m_tempBuffer
Temporary rendering target (for diffing etc.)
void init()
Basic OpenGL initialization and feature checks.
static int m_instanceCounter
GL GAL instance counter.
Provide the access to the OpenGL shaders.
bool IsLinked() const
Return true if shaders are linked correctly.
void SetParameter(int aParameterNumber, float aValue) const
Set a parameter of the shader.
bool Link()
Link the shaders.
void Use()
Use the shader.
bool LoadShaderFromStrings(SHADER_TYPE aShaderType, Args &&... aArgs)
Add a shader and compile the shader sources.
int AddParameter(const std::string &aParameterName)
Add a parameter to the parameter queue.
void Deactivate()
Deactivate the shader and use the default OpenGL program.
Class to control vertex container and GPU with possibility of emulating old-style OpenGL 1....
void EndDrawing() const
Finish drawing operations.
bool Vertex(const VERTEX &aVertex)
Add a vertex with the given coordinates to the currently set item.
const glm::mat4 & GetTransformation() const
void Map()
Map vertex buffer.
void Clear() const
Remove all the stored vertices from the container.
void BeginDrawing() const
Prepare buffers and items to start drawing.
void ChangeItemColor(const VERTEX_ITEM &aItem, const COLOR4D &aColor) const
Change the color of all vertices owned by an item.
void Color(const COLOR4D &aColor)
Changes currently used color that will be applied to newly added vertices.
bool Reserve(unsigned int aSize)
Allocate space for vertices, so it will be used with subsequent Vertex() calls.
void FinishItem() const
Clean after adding an item.
void ChangeItemDepth(const VERTEX_ITEM &aItem, GLfloat aDepth) const
Change the depth of all vertices owned by an item.
void Rotate(GLfloat aAngle, GLfloat aX, GLfloat aY, GLfloat aZ)
Multiply the current matrix by a rotation matrix, so the newly vertices will be rotated by the given ...
void EnableDepthTest(bool aEnabled)
Enable/disable Z buffer depth test.
void PopMatrix()
Pop the current transformation matrix stack.
void Shader(GLfloat aShaderType, GLfloat aParam1=0.0f, GLfloat aParam2=0.0f, GLfloat aParam3=0.0f)
Change currently used shader and its parameters that will be applied to newly added vertices.
void PushMatrix()
Push the current transformation matrix stack.
void Scale(GLfloat aX, GLfloat aY, GLfloat aZ)
Multiply the current matrix by a scaling matrix, so the newly vertices will be scaled by the given fa...
void Unmap()
Unmap vertex buffer.
void SetShader(SHADER &aShader) const
Set a shader program that is going to be used during rendering.
void Translate(GLfloat aX, GLfloat aY, GLfloat aZ)
Multiply the current matrix by a translation matrix, so newly vertices will be translated by the give...
void DrawItem(const VERTEX_ITEM &aItem) const
Draw an item to the buffer.
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
A small class to help profiling.
void Stop()
Save the time when this function was called, and set the counter stane to stop.
void Start()
Start or restart the counter.
double msecs(bool aSinceLast=false)
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
bool IsClosed() const override
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
int SegmentCount() const
Return the number of segments in this line chain.
size_t GetTriangleCount() const
void GetTriangle(int index, VECTOR2I &a, VECTOR2I &b, VECTOR2I &c) const
Represent a set of closed polygons.
bool IsTriangulationUpToDate() const
POLYGON & Polygon(int aIndex)
Return the aIndex-th subpolygon in the set.
const TRIANGULATED_POLYGON * TriangulatedPolygon(int aIndex) const
unsigned int TriangulatedPolyCount() const
Return the number of triangulated polygons.
int OutlineCount() const
Return the number of outlines in the set.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
uni_iter is a non-mutating iterator that walks through unicode code points in the UTF8 encoded string...
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
uni_iter uend() const
Return a uni_iter initialized to the end of "this" UTF8 byte sequence.
uni_iter ubegin() const
Returns a uni_iter initialized to the start of "this" UTF8 byte sequence.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
#define SWAP(varA, condition, varB)
Swap the variables if a condition is met.
static constexpr EDA_ANGLE & FULL_CIRCLE
a few functions useful in geometry calculations.
int GetArcToSegmentCount(int aRadius, int aErrorMax, const EDA_ANGLE &aArcAngle)
const wxChar *const traceGalProfile
Flag to enable debug output of GAL performance profiling.
This file contains miscellaneous commonly used macros and functions.
FONT_IMAGE_TYPE font_image
const FONT_GLYPH_TYPE * LookupGlyph(unsigned int aCodepoint)
FONT_INFO_TYPE font_information
The Cairo implementation of the graphics abstraction layer.
static LIB_SYMBOL * dummy()
Used when a LIB_SYMBOL is not found in library to draw a dummy shape.
@ SMALL_CROSS
Use small cross instead of dots for the grid.
@ DOTS
Use dots for the grid.
@ SHADER_TYPE_VERTEX
Vertex shader.
@ SHADER_TYPE_FRAGMENT
Fragment shader.
RENDER_TARGET
RENDER_TARGET: Possible rendering targets.
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
@ TARGET_TEMP
Temporary target for drawing in separate layer.
@ TARGET_CACHED
Main rendering target (cached)
@ TARGET_OVERLAY
Items that may change while the view stays the same (noncached)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
static void InitTesselatorCallbacks(GLUtesselator *aTesselator)
void CALLBACK CombineCallback(GLdouble coords[3], GLdouble *vertex_data[4], GLfloat weight[4], GLdouble **dataOut, void *aData)
void CALLBACK VertexCallback(GLvoid *aVertexPtr, void *aData)
void CALLBACK EdgeCallback(GLboolean aEdgeFlag)
void CALLBACK ErrorCallback(GLenum aErrorCode)
double round_to_half_pixel(double f, double r)
static const int glAttributes[]
#define SEG_PER_CIRCLE_COUNT
#define CALLBACK
The default number of points for circle approximation.
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
unsigned char pixels[1024 *1024 *3]
unsigned int smooth_pixels
VERTEX_MANAGER * vboManager
Manager used for storing new vertices.
std::deque< std::shared_ptr< GLdouble > > & intersectPoints
Intersect points, that have to be freed after tessellation.
Structure to keep VIEW_CONTROLS settings for easy store/restore operations.
VECTOR2I v2(1, 0)
Test suite for KiCad math code.
BS::thread_pool thread_pool
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
wxLogTrace helper definitions.
#define KI_TRACE(aWhat,...)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
void enableGlDebug(bool aEnable)
Enable or disable OpenGL driver messages output.
int checkGlError(const std::string &aInfo, const char *aFile, int aLine, bool aThrow)
Check if a recent OpenGL operation has failed.
VECTOR2< double > VECTOR2D
VECTOR2I ToVECTOR2I(const wxSize &aSize)