KiCad PCB EDA Suite
opengl_gal.cpp File Reference
#include <gl_utils.h>
#include <advanced_config.h>
#include <gal/opengl/opengl_gal.h>
#include <gal/opengl/utils.h>
#include <gal/definitions.h>
#include <gl_context_mgr.h>
#include <geometry/shape_poly_set.h>
#include <bitmap_base.h>
#include <bezier_curves.h>
#include <math/util.h>
#include <trace_helpers.h>
#include <wx/frame.h>
#include <macros.h>
#include <geometry/geometry_utils.h>
#include <profile.h>
#include <functional>
#include <limits>
#include <memory>
#include "gl_resources.h"
#include "gl_builtin_shaders.h"

Go to the source code of this file.

Classes

class  KIGFX::GL_BITMAP_CACHE
 
struct  KIGFX::GL_BITMAP_CACHE::CACHED_BITMAP
 

Namespaces

 KIGFX
 The Cairo implementation of the graphics abstraction layer.
 

Macros

#define DISABLE_BITMAP_CACHE
 

Functions

static void InitTesselatorCallbacks (GLUtesselator *aTesselator)
 
void CALLBACK VertexCallback (GLvoid *aVertexPtr, void *aData)
 
void CALLBACK CombineCallback (GLdouble coords[3], GLdouble *vertex_data[4], GLfloat weight[4], GLdouble **dataOut, void *aData)
 
void CALLBACK EdgeCallback (GLboolean aEdgeFlag)
 
void CALLBACK ErrorCallback (GLenum aErrorCode)
 
double round_to_half_pixel (double f, double r)
 

Variables

static const int glAttributes [] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 8, 0 }
 

Macro Definition Documentation

◆ DISABLE_BITMAP_CACHE

#define DISABLE_BITMAP_CACHE

Definition at line 70 of file opengl_gal.cpp.

Function Documentation

◆ CombineCallback()

void CALLBACK CombineCallback ( GLdouble  coords[3],
GLdouble *  vertex_data[4],
GLfloat  weight[4],
GLdouble **  dataOut,
void *  aData 
)

Definition at line 2339 of file opengl_gal.cpp.

2341 {
2342  GLdouble* vertex = new GLdouble[3];
2343  OPENGL_GAL::TessParams* param = static_cast<OPENGL_GAL::TessParams*>( aData );
2344 
2345  // Save the pointer so we can delete it later
2346  param->intersectPoints.emplace_back( vertex );
2347 
2348  memcpy( vertex, coords, 3 * sizeof( GLdouble ) );
2349 
2350  *dataOut = vertex;
2351 }
std::deque< boost::shared_array< GLdouble > > & intersectPoints
Intersect points, that have to be freed after tessellation.
Definition: opengl_gal.h:309

References KIGFX::OPENGL_GAL::TessParams::intersectPoints.

Referenced by InitTesselatorCallbacks().

◆ EdgeCallback()

void CALLBACK EdgeCallback ( GLboolean  aEdgeFlag)

Definition at line 2354 of file opengl_gal.cpp.

2355 {
2356  // This callback is needed to force GLU tesselator to use triangles only
2357 }

Referenced by InitTesselatorCallbacks().

◆ ErrorCallback()

void CALLBACK ErrorCallback ( GLenum  aErrorCode)

Definition at line 2360 of file opengl_gal.cpp.

2361 {
2362  //throw std::runtime_error( std::string( "Tessellation error: " ) +
2363  //std::string( (const char*) gluErrorString( aErrorCode ) );
2364 }

Referenced by InitTesselatorCallbacks().

◆ InitTesselatorCallbacks()

static void InitTesselatorCallbacks ( GLUtesselator *  aTesselator)
static

Definition at line 2367 of file opengl_gal.cpp.

2368 {
2369  gluTessCallback( aTesselator, GLU_TESS_VERTEX_DATA, (void( CALLBACK* )()) VertexCallback );
2370  gluTessCallback( aTesselator, GLU_TESS_COMBINE_DATA, (void( CALLBACK* )()) CombineCallback );
2371  gluTessCallback( aTesselator, GLU_TESS_EDGE_FLAG, (void( CALLBACK* )()) EdgeCallback );
2372  gluTessCallback( aTesselator, GLU_TESS_ERROR, (void( CALLBACK* )()) ErrorCallback );
2373 }
void CALLBACK EdgeCallback(GLboolean aEdgeFlag)
void CALLBACK VertexCallback(GLvoid *aVertexPtr, void *aData)
void CALLBACK ErrorCallback(GLenum aErrorCode)
void CALLBACK CombineCallback(GLdouble coords[3], GLdouble *vertex_data[4], GLfloat weight[4], GLdouble **dataOut, void *aData)
#define CALLBACK
The default number of points for circle approximation.
Definition: opengl_gal.h:49

References CALLBACK, CombineCallback(), EdgeCallback(), ErrorCallback(), and VertexCallback().

Referenced by KIGFX::OPENGL_GAL::OPENGL_GAL().

◆ round_to_half_pixel()

double round_to_half_pixel ( double  f,
double  r 
)
inline

Definition at line 2383 of file opengl_gal.cpp.

2384 {
2385  return ( ceil( f / r ) - 0.5 ) * r;
2386 }
E_SERIE r
Definition: eserie.cpp:41

References r.

Referenced by KIGFX::OPENGL_GAL::ComputeWorldScreenMatrix().

◆ VertexCallback()

void CALLBACK VertexCallback ( GLvoid *  aVertexPtr,
void *  aData 
)

Definition at line 2328 of file opengl_gal.cpp.

2329 {
2330  GLdouble* vertex = static_cast<GLdouble*>( aVertexPtr );
2331  OPENGL_GAL::TessParams* param = static_cast<OPENGL_GAL::TessParams*>( aData );
2332  VERTEX_MANAGER* vboManager = param->vboManager;
2333 
2334  assert( vboManager );
2335  vboManager->Vertex( vertex[0], vertex[1], vertex[2] );
2336 }
bool Vertex(const VERTEX &aVertex)
Add a vertex with the given coordinates to the currently set item.
VERTEX_MANAGER * vboManager
Manager used for storing new vertices.
Definition: opengl_gal.h:306
Class to control vertex container and GPU with possibility of emulating old-style OpenGL 1....

References KIGFX::OPENGL_GAL::TessParams::vboManager, and KIGFX::VERTEX_MANAGER::Vertex().

Referenced by InitTesselatorCallbacks().

Variable Documentation

◆ glAttributes

const int glAttributes[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 8, 0 }
static

Definition at line 79 of file opengl_gal.cpp.