KiCad PCB EDA Suite
c3d_render_ogl_legacy.cpp File Reference
#include <GL/glew.h>
#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 <math/util.h>
#include <base_units.h>

Go to the source code of this file.

Macros

#define GL_SILENCE_DEPRECATION   1
 
#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

◆ GL_SILENCE_DEPRECATION

#define GL_SILENCE_DEPRECATION   1

Definition at line 33 of file c3d_render_ogl_legacy.cpp.

◆ UNITS3D_TO_UNITSPCB

#define UNITS3D_TO_UNITSPCB   (IU_PER_MM)

Scale convertion from 3d model units to pcb units.

Definition at line 50 of file c3d_render_ogl_legacy.cpp.

Function Documentation

◆ init_lights()

void init_lights ( void  )

Definition at line 480 of file c3d_render_ogl_legacy.cpp.

481 {
482  // Setup light
483  // https://www.opengl.org/sdk/docs/man2/xhtml/glLight.xml
484  // /////////////////////////////////////////////////////////////////////////
485  const GLfloat ambient[] = { 0.084f, 0.084f, 0.084f, 1.0f };
486  const GLfloat diffuse0[] = { 0.3f, 0.3f, 0.3f, 1.0f };
487  const GLfloat specular0[] = { 0.5f, 0.5f, 0.5f, 1.0f };
488 
489  glLightfv( GL_LIGHT0, GL_AMBIENT, ambient );
490  glLightfv( GL_LIGHT0, GL_DIFFUSE, diffuse0 );
491  glLightfv( GL_LIGHT0, GL_SPECULAR, specular0 );
492 
493  const GLfloat diffuse12[] = { 0.7f, 0.7f, 0.7f, 1.0f };
494  const GLfloat specular12[] = { 0.7f, 0.7f, 0.7f, 1.0f };
495 
496  // defines a directional light that points along the negative z-axis
497  GLfloat position[4] = { 0.0f, 0.0f, 1.0f, 0.0f };
498 
499  // This makes a vector slight not perpendicular with XZ plane
500  const SFVEC3F vectorLight = SphericalToCartesian( glm::pi<float>() * 0.03f,
501  glm::pi<float>() * 0.25f );
502 
503  position[0] = vectorLight.x;
504  position[1] = vectorLight.y;
505  position[2] = vectorLight.z;
506 
507  glLightfv( GL_LIGHT1, GL_AMBIENT, ambient );
508  glLightfv( GL_LIGHT1, GL_DIFFUSE, diffuse12 );
509  glLightfv( GL_LIGHT1, GL_SPECULAR, specular12 );
510  glLightfv( GL_LIGHT1, GL_POSITION, position );
511 
512 
513  // defines a directional light that points along the positive z-axis
514  position[2] = -position[2];
515 
516  glLightfv( GL_LIGHT2, GL_AMBIENT, ambient );
517  glLightfv( GL_LIGHT2, GL_DIFFUSE, diffuse12 );
518  glLightfv( GL_LIGHT2, GL_SPECULAR, specular12 );
519  glLightfv( GL_LIGHT2, GL_POSITION, position );
520 
521  const GLfloat lmodel_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
522 
523  glLightModelfv( GL_LIGHT_MODEL_AMBIENT, lmodel_ambient );
524 
525  glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
526 }
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
SFVEC3F SphericalToCartesian(float aInclination, float aAzimuth)
SphericalToCartesian.
Definition: 3d_math.h:43

References SphericalToCartesian().

Referenced by C3D_RENDER_OGL_LEGACY::initializeOpenGL().