KiCad PCB EDA Suite
c3d_render_ogl_legacy.cpp File Reference
#include "c3d_render_ogl_legacy.h"
#include "ogl_legacy_utils.h"
#include "common_ogl/ogl_utils.h"
#include "../cimage.h"
#include <class_board.h>
#include <class_module.h>
#include <3d_math.h>
#include <base_units.h>

Go to the source code of this file.

Macros

#define UNITS3D_TO_UNITSPCB   (IU_PER_MM)
 Scale convertion from 3d model units to pcb units. More...
 

Functions

void init_lights (void)
 

Macro Definition Documentation

#define UNITS3D_TO_UNITSPCB   (IU_PER_MM)

Scale convertion from 3d model units to pcb units.

Definition at line 44 of file c3d_render_ogl_legacy.cpp.

Referenced by C3D_RENDER_OGL_LEGACY::render_3D_module().

Function Documentation

void init_lights ( void  )

Definition at line 414 of file c3d_render_ogl_legacy.cpp.

References SphericalToCartesian().

Referenced by C3D_RENDER_OGL_LEGACY::initializeOpenGL().

415 {
416  // Setup light
417  // https://www.opengl.org/sdk/docs/man2/xhtml/glLight.xml
418  // /////////////////////////////////////////////////////////////////////////
419  const GLfloat ambient[] = { 0.084f, 0.084f, 0.084f, 1.0f };
420  const GLfloat diffuse0[] = { 0.3f, 0.3f, 0.3f, 1.0f };
421  const GLfloat specular0[] = { 0.5f, 0.5f, 0.5f, 1.0f };
422 
423  glLightfv( GL_LIGHT0, GL_AMBIENT, ambient );
424  glLightfv( GL_LIGHT0, GL_DIFFUSE, diffuse0 );
425  glLightfv( GL_LIGHT0, GL_SPECULAR, specular0 );
426 
427  const GLfloat diffuse12[] = { 0.7f, 0.7f, 0.7f, 1.0f };
428  const GLfloat specular12[] = { 0.7f, 0.7f, 0.7f, 1.0f };
429 
430  // defines a directional light that points along the negative z-axis
431  GLfloat position[4] = { 0.0f, 0.0f, 1.0f, 0.0f };
432 
433  // This makes a vector slight not perpendicular with XZ plane
434  const SFVEC3F vectorLight = SphericalToCartesian( glm::pi<float>() * 0.03f,
435  glm::pi<float>() * 0.25f );
436 
437  position[0] = vectorLight.x;
438  position[1] = vectorLight.y;
439  position[2] = vectorLight.z;
440 
441  glLightfv( GL_LIGHT1, GL_AMBIENT, ambient );
442  glLightfv( GL_LIGHT1, GL_DIFFUSE, diffuse12 );
443  glLightfv( GL_LIGHT1, GL_SPECULAR, specular12 );
444  glLightfv( GL_LIGHT1, GL_POSITION, position );
445 
446 
447  // defines a directional light that points along the positive z-axis
448  position[2] = -position[2];
449 
450  glLightfv( GL_LIGHT2, GL_AMBIENT, ambient );
451  glLightfv( GL_LIGHT2, GL_DIFFUSE, diffuse12 );
452  glLightfv( GL_LIGHT2, GL_SPECULAR, specular12 );
453  glLightfv( GL_LIGHT2, GL_POSITION, position );
454 
455  const GLfloat lmodel_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
456 
457  glLightModelfv( GL_LIGHT_MODEL_AMBIENT, lmodel_ambient );
458 
459  glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
460 }
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
SFVEC3F SphericalToCartesian(float aInclination, float aAzimuth)
SphericalToCartesian.
Definition: 3d_math.h:43