34#include <glm/geometric.hpp>
45#define UNITS3D_TO_UNITSPCB ( pcbIUScale.IU_PER_MM )
51 wxLogTrace(
m_logTrace, wxT(
"RENDER_3D_OPENGL::RENDER_3D_OPENGL" ) );
81 wxLogTrace(
m_logTrace, wxT(
"RENDER_3D_OPENGL::RENDER_3D_OPENGL" ) );
110 glEnable( GL_LIGHT0 );
112 glDisable( GL_LIGHT0 );
119 glEnable( GL_LIGHT1 );
121 glDisable( GL_LIGHT1 );
128 glEnable( GL_LIGHT2 );
130 glDisable( GL_LIGHT2 );
138 glDisable( GL_CULL_FACE );
142 glClear( GL_DEPTH_BUFFER_BIT );
144 glMatrixMode( GL_PROJECTION );
148 glMatrixMode( GL_MODELVIEW );
151 const glm::mat4 TranslationMatrix =
152 glm::translate( glm::mat4( 1.0f ),
SFVEC3F( 0.0f, 0.0f, -( arrow_size * 2.75f ) ) );
156 glLoadMatrixf( glm::value_ptr( ViewMatrix ) );
160 glColor3f( 0.9f, 0.0f, 0.0f );
163 glColor3f( 0.0f, 0.9f, 0.0f );
166 glColor3f( 0.0f, 0.0f, 0.9f );
169 glEnable( GL_CULL_FACE );
198 m_materials.m_Copper.m_Shininess = shininessfactor * 128.0f;
207 m_materials.m_NonPlatedCopper.m_Shininess = 0.1f * 128.0f;
238 m_materials.m_SilkSTop.m_Shininess = 0.078125f * 128.0f;
254 m_materials.m_SilkSBot.m_Shininess = 0.078125f * 128.0f;
257 m_materials.m_SolderMask.m_Shininess = 0.8f * 128.0f;
267 m_materials.m_EpoxyBoard.m_Shininess = 0.1f * 128.0f;
274 const float matShininess = 0.1f * 128.0f;
278 m_materials.m_Copper.m_Specular = matSpecularColor;
289 m_materials.m_SilkSTop.m_Ambient = matAmbientColor;
290 m_materials.m_SilkSTop.m_Specular = matSpecularColor;
295 m_materials.m_SilkSBot.m_Ambient = matAmbientColor;
296 m_materials.m_SilkSBot.m_Specular = matSpecularColor;
301 m_materials.m_SolderMask.m_Ambient = matAmbientColor;
302 m_materials.m_SolderMask.m_Specular = matSpecularColor;
303 m_materials.m_SolderMask.m_Shininess = matShininess;
307 m_materials.m_EpoxyBoard.m_Ambient = matAmbientColor;
308 m_materials.m_EpoxyBoard.m_Specular = matSpecularColor;
309 m_materials.m_EpoxyBoard.m_Shininess = matShininess;
316 m_materials.m_GrayMaterial.m_Shininess = 0.01f * 128.0f;
334 m_materials.m_SolderMask.m_Transparency = 1.0f - layerColor.a;
386 m_materials.m_Plastic.m_Shininess = 0.078125f * 128.0f;
460 const GLfloat ambient[] = { 0.084f, 0.084f, 0.084f, 1.0f };
461 const GLfloat diffuse0[] = { 0.3f, 0.3f, 0.3f, 1.0f };
462 const GLfloat specular0[] = { 0.5f, 0.5f, 0.5f, 1.0f };
464 glLightfv( GL_LIGHT0, GL_AMBIENT, ambient );
465 glLightfv( GL_LIGHT0, GL_DIFFUSE, diffuse0 );
466 glLightfv( GL_LIGHT0, GL_SPECULAR, specular0 );
468 const GLfloat diffuse12[] = { 0.7f, 0.7f, 0.7f, 1.0f };
469 const GLfloat specular12[] = { 0.7f, 0.7f, 0.7f, 1.0f };
472 GLfloat position[4] = { 0.0f, 0.0f, 1.0f, 0.0f };
476 glm::pi<float>() * 0.25f );
478 position[0] = vectorLight.x;
479 position[1] = vectorLight.y;
480 position[2] = vectorLight.z;
482 glLightfv( GL_LIGHT1, GL_AMBIENT, ambient );
483 glLightfv( GL_LIGHT1, GL_DIFFUSE, diffuse12 );
484 glLightfv( GL_LIGHT1, GL_SPECULAR, specular12 );
485 glLightfv( GL_LIGHT1, GL_POSITION, position );
488 position[2] = -position[2];
490 glLightfv( GL_LIGHT2, GL_AMBIENT, ambient );
491 glLightfv( GL_LIGHT2, GL_DIFFUSE, diffuse12 );
492 glLightfv( GL_LIGHT2, GL_SPECULAR, specular12 );
493 glLightfv( GL_LIGHT2, GL_POSITION, position );
495 const GLfloat lmodel_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
497 glLightModelfv( GL_LIGHT_MODEL_AMBIENT, lmodel_ambient );
499 glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
511 glEnable( GL_POLYGON_OFFSET_FILL );
512 glPolygonOffset( -0.1f, -2.0f );
519 glDisable( GL_POLYGON_OFFSET_FILL );
534 if( aSkipRenderHoles )
565 if( aStatusReporter )
566 aStatusReporter->
Report(
_(
"Loading..." ) );
568 reload( aStatusReporter, aWarningReporter );
588 glDepthFunc( GL_LESS );
589 glEnable( GL_CULL_FACE );
590 glFrontFace( GL_CCW );
591 glEnable( GL_NORMALIZE );
595 glDisable( GL_MULTISAMPLE );
597 glEnable( GL_MULTISAMPLE );
600 glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
601 glClearDepth( 1.0f );
602 glClearStencil( 0x00 );
603 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
611 glEnable( GL_DEPTH_TEST );
614 glMatrixMode( GL_PROJECTION );
616 glMatrixMode( GL_MODELVIEW );
625 glEnable( GL_LIGHTING );
634 if( cameraPos.z > 0.0f )
635 zpos = glm::max( cameraPos.z, 0.5f ) + cameraPos.z * cameraPos.z;
637 zpos = glm::min( cameraPos.z,-0.5f ) - cameraPos.z * cameraPos.z;
640 const GLfloat headlight_pos[] = { cameraPos.x, cameraPos.y, zpos, 1.0f };
642 glLightfv( GL_LIGHT0, GL_POSITION, headlight_pos );
649 bool drawMiddleSegments = !skipThickness;
661 if( !( skipRenderVias || skipRenderHoles ) &&
m_vias )
668 for( MAP_OGL_DISP_LISTS::const_iterator ii =
m_layers.begin(); ii !=
m_layers.end(); ++ii )
679 const double opacity_min = 0.8;
684 if( ( layer_id >
F_Cu ) && ( layer_id <
B_Cu ) )
692 if( ( layer_id >=
F_Cu ) && ( layer_id <=
B_Cu ) )
704 if( skipRenderHoles )
713 drawMiddleSegments );
719 drawMiddleSegments );
744 wxASSERT( viasHolesLayer !=
nullptr );
746 if( viasHolesLayer !=
nullptr )
811 if( throughHolesOuter )
839 throughHolesOuter, anti_board );
843 if( !skipRenderHoles && throughHolesOuter
854 if( !( skipRenderHoles && ( layer_id ==
B_Paste || layer_id ==
F_Paste ) ) )
866 glm::mat4 cameraViewMatrix;
868 glGetFloatv( GL_MODELVIEW_MATRIX, glm::value_ptr( cameraViewMatrix ) );
882 glEnable( GL_POLYGON_OFFSET_FILL );
883 glPolygonOffset( 0.0f, -2.0f );
888 drawMiddleSegments, skipRenderHoles );
891 drawMiddleSegments, skipRenderHoles );
896 drawMiddleSegments, skipRenderHoles );
899 drawMiddleSegments, skipRenderHoles );
902 glDisable( GL_POLYGON_OFFSET_FILL );
903 glPolygonOffset( 0.0f, 0.0f );
909 glDepthMask( GL_FALSE );
910 glEnable( GL_BLEND );
911 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
914 glEnable( GL_TEXTURE_2D );
915 glActiveTexture( GL_TEXTURE0 );
918 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
919 glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE );
920 glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE );
922 glTexEnvi( GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PRIMARY_COLOR );
923 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR );
925 glTexEnvi( GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS );
926 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR );
928 glTexEnvi( GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PRIMARY_COLOR );
929 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA );
930 glTexEnvi( GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_CONSTANT );
931 glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA );
935 glDisable( GL_BLEND );
938 glDepthMask( GL_TRUE );
943 glDisable( GL_LIGHTING );
948 glEnable( GL_LIGHTING );
965 glEnable( GL_LINE_SMOOTH );
966 glShadeModel( GL_SMOOTH );
969 glPixelStorei( GL_UNPACK_ALIGNMENT, 4 );
990 delete circleImageBlured;
991 circleImageBlured =
nullptr;
994 circleImage =
nullptr;
1008 glEnable( GL_COLOR_MATERIAL );
1009 glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
1016 glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r );
1017 glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, 96.0f );
1019 glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r );
1020 glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r );
1021 glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, &emissive.r );
1028 glDeleteLists(
m_grid, 1 );
1032 for( MAP_OGL_DISP_LISTS::const_iterator ii =
m_layers.begin(); ii !=
m_layers.end(); ++ii )
1035 delete pLayerDispList;
1047 for(
const std::pair<const PCB_LAYER_ID, OPENGL_RENDER_LIST*> entry :
m_outerLayerHoles )
1048 delete entry.second;
1052 for(
const std::pair<const PCB_LAYER_ID, OPENGL_RENDER_LIST*> entry :
m_innerLayerHoles )
1053 delete entry.second;
1062 for(
const std::pair<const wxString, MODEL_3D*>& entry :
m_3dModelMap )
1063 delete entry.second;
1096 bool aDrawMiddleSegments,
bool aSkipRenderHoles )
1098 wxASSERT( (aLayerID ==
B_Mask) || (aLayerID ==
F_Mask) );
1117 if( aSkipRenderHoles )
1139 if( aSkipRenderHoles )
1154 bool aGetTop,
bool aGetBot,
bool aRenderTransparentOnly,
1155 bool aRenderSelectedOnly )
1157 wxASSERT( ( aGetTop ==
true ) || ( aGetBot ==
true ) );
1165 bool highlight =
false;
1169 if( fp->IsSelected() )
1178 if( aRenderSelectedOnly != highlight )
1182 if( !fp->Models().empty() )
1186 const bool isFlipped = fp->IsFlipped();
1188 if( ( aGetTop == !isFlipped ) ||
1189 ( aGetBot == isFlipped ) )
1198 const FOOTPRINT* aFootprint,
bool aRenderTransparentOnly,
1201 if( !aFootprint->
Models().empty() )
1207 glm::mat4 fpMatrix( 1.0f );
1209 fpMatrix = glm::translate( fpMatrix,
1216 fpMatrix = glm::rotate( fpMatrix,
1218 SFVEC3F( 0.0f, 0.0f, 1.0f ) );
1223 fpMatrix = glm::rotate( fpMatrix, glm::pi<float>(),
SFVEC3F( 0.0f, 1.0f, 0.0f ) );
1224 fpMatrix = glm::rotate( fpMatrix, glm::pi<float>(),
SFVEC3F( 0.0f, 0.0f, 1.0f ) );
1231 SFVEC3F( modelunit_to_3d_units_factor ) );
1236 if( !sM.m_Show || sM.m_Filename.empty() )
1245 if(
const MODEL_3D* modelPtr = cache_i->second )
1247 bool opaque = sM.m_Opacity >= 1.0;
1249 if( ( !aRenderTransparentOnly && modelPtr->HasOpaqueMeshes() && opaque ) ||
1250 ( aRenderTransparentOnly && ( modelPtr->HasTransparentMeshes() || !opaque ) ) )
1252 glm::mat4 modelworldMatrix = fpMatrix;
1254 const SFVEC3F offset =
SFVEC3F( sM.m_Offset.x, sM.m_Offset.y, sM.m_Offset.z );
1255 const SFVEC3F rotation =
SFVEC3F( sM.m_Rotation.x, sM.m_Rotation.y, sM.m_Rotation.z );
1258 std::vector<float> key = { offset.x, offset.y, offset.z,
1259 rotation.x, rotation.y, rotation.z,
1266 modelworldMatrix *= it->second;
1270 glm::mat4 mtx( 1.0f );
1271 mtx = glm::translate( mtx, offset );
1272 mtx = glm::rotate( mtx, glm::radians( -rotation.z ), { 0.0f, 0.0f, 1.0f } );
1273 mtx = glm::rotate( mtx, glm::radians( -rotation.y ), { 0.0f, 1.0f, 0.0f } );
1274 mtx = glm::rotate( mtx, glm::radians( -rotation.x ), { 1.0f, 0.0f, 0.0f } );
1278 modelworldMatrix *= mtx;
1281 if( aRenderTransparentOnly )
1283 aDstRenderList.emplace_back( modelworldMatrix,
1291 aDstRenderList.emplace_back( modelworldMatrix,
1310 std::list<MODELTORENDER> renderList;
1318 if( !renderList.empty() )
1324 renderModel( aCameraViewMatrix, mtr, selColor,
nullptr );
1334 if( !renderList.empty() )
1340 renderModel( aCameraViewMatrix, mtr, selColor,
nullptr );
1354 std::list<MODELTORENDER> renderListModels;
1365 if( renderListModels.empty() )
1368 std::vector<std::pair<const MODELTORENDER *, float>> transparentModelList;
1370 transparentModelList.reserve( renderListModels.size() );
1377 const BBOX_3D& bBox = mtr.m_model->GetBBox();
1379 const SFVEC3F bBoxWorld = mtr.m_modelWorldMat * glm::vec4( bBoxCenter, 1.0f );
1381 const float distanceToCamera = glm::length( cameraPos - bBoxWorld );
1383 transparentModelList.emplace_back( &mtr, distanceToCamera );
1387 std::sort( transparentModelList.begin(), transparentModelList.end(),
1388 [&]( std::pair<const MODELTORENDER *, float>& a,
1389 std::pair<const MODELTORENDER *, float>& b ) {
1390 return a.second > b.second;
1396 bool isUsingColorInformation = !( transparentModelList.begin()->first->m_isSelected &&
1401 for(
const std::pair<const MODELTORENDER *, float>& mtr : transparentModelList )
1406 if( !isUsingColorInformation && !mtr.first->m_isSelected )
1408 isUsingColorInformation =
true;
1410 glEnableClientState( GL_COLOR_ARRAY );
1411 glEnableClientState( GL_TEXTURE_COORD_ARRAY );
1412 glEnable( GL_COLOR_MATERIAL );
1416 if( isUsingColorInformation && mtr.first->m_isSelected )
1418 isUsingColorInformation =
false;
1420 glDisableClientState( GL_COLOR_ARRAY );
1421 glDisableClientState( GL_TEXTURE_COORD_ARRAY );
1422 glDisable( GL_COLOR_MATERIAL );
1429 renderModel( aCameraViewMatrix, *mtr.first, selColor, &cameraPos );
1441 const SFVEC3F *aCameraWorldPos )
1443 const glm::mat4 modelviewMatrix = aCameraViewMatrix * aModelToRender.
m_modelWorldMat;
1445 glLoadMatrixf( glm::value_ptr( modelviewMatrix ) );
1456 const bool wasBlendEnabled = glIsEnabled( GL_BLEND );
1458 if( !wasBlendEnabled )
1460 glEnable( GL_BLEND );
1461 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1464 glDisable( GL_LIGHTING );
1472 glEnable( GL_LIGHTING );
1474 if( !wasBlendEnabled )
1476 glDisable( GL_BLEND );
1485 glDeleteLists(
m_grid, 1 );
1492 m_grid = glGenLists( 1 );
1494 if( !glIsList(
m_grid ) )
1497 glNewList(
m_grid, GL_COMPILE );
1499 glEnable( GL_BLEND );
1500 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1502 const double zpos = 0.0;
1510 const GLfloat transparency = 0.35f;
1512 double griSizeMM = 0.0;
1533 glNormal3f( 0.0, 0.0, 1.0 );
1538 brd_center_pos.
y = -brd_center_pos.
y;
1544 double xmin = ( brd_center_pos.
x - xsize / 2 ) *
scale;
1545 double xmax = ( brd_center_pos.
x + xsize / 2 ) *
scale;
1546 double ymin = ( brd_center_pos.
y - ysize / 2 ) *
scale;
1547 double ymax = ( brd_center_pos.
y + ysize / 2 ) *
scale;
1555 for(
int ii = 0; ; ii++ )
1558 glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1560 glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b,
1565 if(
delta <= xsize / 2 )
1567 glBegin( GL_LINES );
1568 glVertex3f( (brd_center_pos.
x +
delta) *
scale, -ymin, zpos );
1569 glVertex3f( (brd_center_pos.
x +
delta) *
scale, -ymax, zpos );
1574 glBegin( GL_LINES );
1575 glVertex3f( (brd_center_pos.
x -
delta) *
scale, -ymin, zpos );
1576 glVertex3f( (brd_center_pos.
x -
delta) *
scale, -ymax, zpos );
1581 if(
delta <= ysize / 2 )
1583 glBegin( GL_LINES );
1584 glVertex3f( xmin, -( brd_center_pos.
y +
delta ) *
scale, zpos );
1585 glVertex3f( xmax, -( brd_center_pos.
y +
delta ) *
scale, zpos );
1590 glBegin( GL_LINES );
1591 glVertex3f( xmin, -( brd_center_pos.
y -
delta ) *
scale, zpos );
1592 glVertex3f( xmax, -( brd_center_pos.
y -
delta ) *
scale, zpos );
1597 if( (
delta > ysize / 2 ) && (
delta > xsize / 2 ) )
1602 glNormal3f( 0.0, -1.0, 0.0 );
1605 double posy = -brd_center_pos.
y *
scale;
1607 for(
int ii = 0; ; ii++ )
1610 glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1612 glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b,
1617 glBegin( GL_LINES );
1620 glVertex3f( xmax, posy, zmin );
1621 glVertex3f( xmax, posy, zmax );
1626 glBegin( GL_LINES );
1628 glVertex3f( xmin, posy, zmin );
1629 glVertex3f( xmin, posy, zmax );
1633 if(
delta > xsize / 2.0f )
1638 for(
int ii = 0; ; ii++ )
1641 glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
1643 glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b, transparency );
1650 glBegin( GL_LINES );
1651 glVertex3f( xmin, posy,
delta );
1652 glVertex3f( xmax, posy,
delta );
1656 if(
delta <= -zmin && ( ii != 0 ) )
1659 glBegin( GL_LINES );
1660 glVertex3f( xmin, posy, -
delta );
1661 glVertex3f( xmax, posy, -
delta );
1669 glDisable( GL_BLEND );
Defines math related functions.
float mapf(float x, float in_min, float in_max, float out_min, float out_max)
SFVEC3F SphericalToCartesian(float aInclination, float aAzimuth)
https://en.wikipedia.org/wiki/Spherical_coordinate_system
constexpr EDA_IU_SCALE pcbIUScale
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
Helper class to handle information needed to display 3D board.
double BiuTo3dUnits() const noexcept
Board integer units To 3D units.
SFVEC4F m_BgColorTop
background top color
SFVEC4F m_SolderPasteColor
in realistic mode: solder paste color
bool IsFootprintShown(FOOTPRINT_ATTR_T aFPAttributes) const
Test if footprint should be displayed in relation to attributes and the flags.
VECTOR2I GetBoardSize() const noexcept
Get the board size.
SFVEC4F m_SolderMaskColorBot
in realistic mode: solder mask color ( bot )
VECTOR2I GetBoardPos() const noexcept
Get the board center.
float GetLayerBottomZPos(PCB_LAYER_ID aLayerId) const noexcept
Get the bottom z position.
SFVEC4F m_SolderMaskColorTop
in realistic mode: solder mask color ( top )
SFVEC4F GetColor(const COLOR4D &aColor) const
SFVEC4F m_CopperColor
in realistic mode: copper color
const BOARD * GetBoard() const noexcept
float GetFootprintZPos(bool aIsFlipped) const
Get the position of the footprint in 3d integer units considering if it is flipped or not.
float GetNonCopperLayerThickness() const noexcept
Get the non copper layers thickness (in 3D units).
float GetLayerTopZPos(PCB_LAYER_ID aLayerId) const noexcept
Get the top z position.
EDA_3D_VIEWER_SETTINGS * m_Cfg
SFVEC4F m_SilkScreenColorTop
in realistic mode: SilkScreen color ( top )
SFVEC4F m_SilkScreenColorBot
in realistic mode: SilkScreen color ( bot )
float GetBoardBodyThickness() const noexcept
Get the board body thickness, including internal copper layers (in 3D units).
SFVEC4F m_BoardBodyColor
in realistic mode: FR4 board color
SFVEC4F GetLayerColor(PCB_LAYER_ID aLayerId) const
Get the technical color of a layer.
SFVEC4F m_BgColorBot
background bottom color
FOOTPRINTS & Footprints()
A class used to derive camera objects from.
glm::mat4 GetRotationMatrix() const
Get the rotation matrix to be applied in a transformation camera.
const glm::mat4 & GetProjectionMatrix() const
const SFVEC3F & GetPos() const
const glm::mat4 & GetViewMatrix() const
Implement a canvas based on a wxGLCanvas.
Manage an 8-bit channel image.
void CircleFilled(int aCx, int aCy, int aRadius, unsigned char aValue)
void EfxFilter_SkipCenter(IMAGE *aInImg, IMAGE_FILTER aFilterType, unsigned int aRadius)
Apply a filter to the input image and store it in the image class.
unsigned int GetHeight() const
unsigned int GetWidth() const
void DrawBbox() const
Draw main bounding box of the model.
static void EndDrawMulti()
Cleanup render states after drawing multiple models.
void Draw(bool aTransparent, float aOpacity, bool aUseSelectedMaterial, const SFVEC3F &aSelectionColor, const glm::mat4 *aModelWorldMatrix, const SFVEC3F *aCameraWorldPos) const
Render the model into the current context.
static void BeginDrawMulti(bool aUseColorInformation)
Set some basic render states before drawing multiple models.
void DrawBboxes() const
Draw individual bounding boxes of each mesh.
Store the OpenGL display lists to related with a layer.
void DrawAllCameraCulledSubtractLayer(bool aDrawMiddle, const OPENGL_RENDER_LIST *aLayerToSubtractA=nullptr, const OPENGL_RENDER_LIST *aLayerToSubtractB=nullptr, const OPENGL_RENDER_LIST *aLayerToSubtractC=nullptr, const OPENGL_RENDER_LIST *aLayerToSubtractD=nullptr) const
void DrawAllCameraCulled(float zCameraPos, bool aDrawMiddle=true) const
Draw all layers if they are visible by the camera if camera position is above the layer.
void ApplyScalePosition(float aZposition, float aZscale)
void SetItIsTransparent(bool aSetTransparent)
void DrawAll(bool aDrawMiddle=true) const
Call to draw all the display lists.
This is a base class to hold data and functions for render targets.
CAMERA & m_camera
Flag if the opengl specific for this render was already initialized.
std::unique_ptr< BUSY_INDICATOR > CreateBusyIndicator() const
Return a created busy indicator, if a factory has been set, else a null pointer.
bool m_reloadRequested
The window size that this camera is working.
bool m_is_opengl_initialized
BOARD_ADAPTER & m_boardAdapter
OPENGL_RENDER_LIST * m_board
void reload(REPORTER *aStatusReporter, REPORTER *aWarningReporter)
OPENGL_RENDER_LIST * m_vias
OPENGL_RENDER_LIST * m_outerThroughHoleRings
GRID3D_TYPE m_lastGridType
Stores the last grid type.
void renderOpaqueModels(const glm::mat4 &aCameraViewMatrix)
void generate3dGrid(GRID3D_TYPE aGridType)
Create a 3D grid to an OpenGL display list.
void setLightFront(bool enabled)
bool Redraw(bool aIsMoving, REPORTER *aStatusReporter, REPORTER *aWarningReporter) override
Redraw the view.
MAP_OGL_DISP_LISTS m_layers
MAP_OGL_DISP_LISTS m_innerLayerHoles
OPENGL_RENDER_LIST * m_boardWithHoles
RENDER_3D_OPENGL(EDA_3D_CANVAS *aCanvas, BOARD_ADAPTER &aAdapter, CAMERA &aCamera)
MAP_OGL_DISP_LISTS m_outerLayerHoles
BOARD_ITEM * m_currentRollOverItem
void renderBoardBody(bool aSkipRenderHoles)
LIST_TRIANGLES m_triangles
store pointers so can be deleted latter
OPENGL_RENDER_LIST * m_outerViaThroughHoles
OPENGL_RENDER_LIST * m_outerThroughHoles
void setLayerMaterial(PCB_LAYER_ID aLayerID)
std::map< wxString, MODEL_3D * > m_3dModelMap
OPENGL_RENDER_LIST * m_platedPadsFront
void renderSolderMaskLayer(PCB_LAYER_ID aLayerID, float aZPosition, bool aDrawMiddleSegments, bool aSkipRenderHoles)
void renderModel(const glm::mat4 &aCameraViewMatrix, const MODELTORENDER &aModelToRender, const SFVEC3F &aSelColor, const SFVEC3F *aCameraWorldPos)
int GetWaitForEditingTimeOut() override
Give the interface the time (in ms) that it should wait for editing or movements before (this works f...
void renderTransparentModels(const glm::mat4 &aCameraViewMatrix)
std::map< std::vector< float >, glm::mat4 > m_3dModelMatrixMap
void get3dModelsSelected(std::list< MODELTORENDER > &aDstRenderList, bool aGetTop, bool aGetBot, bool aRenderTransparentOnly, bool aRenderSelectedOnly)
SFVEC4F getLayerColor(PCB_LAYER_ID aLayerID)
void setPlatedCopperAndDepthOffset(PCB_LAYER_ID aLayer_id)
OPENGL_RENDER_LIST * m_antiBoard
void SetCurWindowSize(const wxSize &aSize) override
Before each render, the canvas will tell the render what is the size of its windows,...
OPENGL_RENDER_LIST * m_padHoles
GLuint m_grid
oGL list that stores current grid
OPENGL_RENDER_LIST * m_platedPadsBack
void get3dModelsFromFootprint(std::list< MODELTORENDER > &aDstRenderList, const FOOTPRINT *aFootprint, bool aRenderTransparentOnly, bool aIsSelected)
struct RENDER_3D_OPENGL::@2 m_materials
void setLightBottom(bool enabled)
void setLightTop(bool enabled)
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
PCB_LAYER_ID
A quick note on layer IDs:
void OglResetTextureState()
Reset to default state the texture settings.
void OglDrawBackground(const SFVEC3F &aTopColor, const SFVEC3F &aBotColor)
void OglSetMaterial(const SMATERIAL &aMaterial, float aOpacity, bool aUseSelectedMaterial, SFVEC3F aSelectionColor)
Set OpenGL materials.
GLuint OglLoadTexture(const IMAGE &aImage)
Generate a new OpenGL texture.
Define generic OpenGL functions that are common to any OpenGL target.
void DrawRoundArrow(SFVEC3F aPosition, SFVEC3F aTargetPos, float aSize)
Draw a round arrow.
#define UNITS3D_TO_UNITSPCB
Scale conversion from 3d model units to pcb units.
#define SIZE_OF_CIRCLE_TEXTURE
Manage a bounding box defined by two SFVEC3F min max points.
SFVEC3F GetCenter() const
Return the center point of the bounding box.
bool opengl_thickness_disableOnMove
bool opengl_highlight_on_rollover
KIGFX::COLOR4D opengl_selection_color
bool opengl_show_model_bbox
bool subtract_mask_from_silk
bool renderPlatedPadsAsPlated
bool clip_silk_on_via_annulus
bool opengl_holes_disableOnMove
bool opengl_AA_disableOnMove
bool opengl_vias_disableOnMove
constexpr int mmToIU(double mm) const
glm::mat4 m_modelWorldMat
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".