LeapUtilGL.h
Go to the documentation of this file.
1 /******************************************************************************\
2 * Copyright (C) Leap Motion, Inc. 2011-2013. *
3 * Leap Motion proprietary and confidential. Not for distribution. *
4 * Use subject to the terms of the Leap Motion SDK Agreement available at *
5 * https://developer.leapmotion.com/sdk_agreement, or another agreement between *
6 * Leap Motion and you, your company or other organization. *
7 \******************************************************************************/
8 
9 #ifndef __LeapUtilGL_h__
10 #define __LeapUtilGL_h__
11 
12 #if !defined(__GL_H__)
13  #if defined(WIN32)
14  #include <windows.h>
15  #include <GL/gl.h>
16  #elif defined(__MACH__)
17  #include <OpenGL/gl.h>
18  #else
19  #include <GL/gl.h>
20  #endif
21 #endif // !__GL_H__
22 
23 #include "LeapUtil.h"
24 
25 namespace LeapUtilGL {
26 
31 
33 
35 
37 
39 void drawGrid( ePlane plane, unsigned int horizSubDivs, unsigned int vertSubDivs );
40 
41 void drawSphere( eStyle style );
42 
44 void drawQuad( eStyle style, ePlane plane );
45 
46 void drawBox( eStyle style );
47 
48 void drawCylinder( eStyle style, eAxis axis );
49 
51 void drawDisk( eStyle style, ePlane plane );
52 
54 void drawArrow( eAxis axis );
55 
56 void drawAxes();
57 
62 {
63  GLVector4fv() : x(0), y(0), z(0), w(0) {}
64  GLVector4fv( float _x, float _y, float _z, float _w=1.0f ) : x(_x), y(_y), z(_z), w(_w) {}
65  GLVector4fv( const Leap::Vector& vRHS, float _w=1.0f ) : x(vRHS.x), y(vRHS.y), z(vRHS.z), w(_w) {}
66  static const GLVector4fv& One() { static const GLVector4fv s_one(1.0f, 1.0f, 1.0f, 1.0f); return s_one; }
67  operator const GLfloat*() const { return &x; }
68 
69  GLfloat x, y, z, w;
70 };
71 
73 void drawSphere(eStyle style, const Leap::Vector& vCenter, float fRadius);
74 
75 void drawCylinder(eStyle style, const Leap::Vector& vBottom, const Leap::Vector& vTop, float fRadius);
76 
78 void drawSkeletonHand(const Leap::Hand& hand, const GLVector4fv& vBoneColor = GLVector4fv::One(), const GLVector4fv& vJointColor = GLVector4fv::One());
79 
82 {
83 public:
84  GLMatrixScope() { glPushMatrix(); }
85  ~GLMatrixScope() { glPopMatrix(); }
86 
87 private:
88  // some compilers don't like zero sized objects.
89  int m_dummy;
90 };
91 
94 {
95 public:
96  GLAttribScope( GLbitfield flags )
97  {
98  glPushAttrib( flags );
99  }
100 
102  {
103  glPopAttrib();
104  }
105 
106 private:
107  // some compilers don't like zero sized objects.
108  int m_dummy;
109 };
110 
112 {
113 public:
114  CameraGL() {}
115 
116  static void ResetGLProjection()
117  {
118  glMatrixMode( GL_PROJECTION );
119  glLoadIdentity();
120  }
121 
122  static void ResetGLView()
123  {
124  glMatrixMode( GL_MODELVIEW );
125  glLoadIdentity();
126  }
127 
128  void SetupGLProjection() const;
129 
130  void SetupGLView() const;
131 };
132 
133 }
134 
135 #endif // __LeapUtilGL_h__
void drawCylinder(eStyle style, eAxis axis)
Definition: LeapUtilGL.cpp:375
void drawSkeletonHand(const Leap::Hand &hand, const GLVector4fv &vBoneColor, const GLVector4fv &vJointColor)
utility for drawing a skeleton API hand as seen in diagnostic visualizer
Definition: LeapUtilGL.cpp:566
GLVector4fv(const Leap::Vector &vRHS, float _w=1.0f)
Definition: LeapUtilGL.h:65
f
void drawGrid(ePlane plane, unsigned int horizSubdivs, unsigned int vertSubdivs)
grid is drawn with unlit colored lines.
Definition: LeapUtilGL.cpp:59
void drawSphere(eStyle style)
Definition: LeapUtilGL.cpp:121
GLAttribScope(GLbitfield flags)
Definition: LeapUtilGL.h:96
static void ResetGLView()
Definition: LeapUtilGL.h:122
void drawBox(eStyle style)
Definition: LeapUtilGL.cpp:237
utility class for caching and restoring GL attributes via the glPushAttrib/glPopAttrib calls...
Definition: LeapUtilGL.h:93
void drawAxes()
Definition: LeapUtilGL.cpp:519
GLVector4fv(float _x, float _y, float _z, float _w=1.0f)
Definition: LeapUtilGL.h:64
void drawDisk(eStyle style, ePlane plane)
disk is double-side
Definition: LeapUtilGL.cpp:431
void drawArrow(eAxis axis)
arrow is drawn with unlit colored lines.
Definition: LeapUtilGL.cpp:475
static const GLVector4fv & One()
Definition: LeapUtilGL.h:66
static void ResetGLProjection()
Definition: LeapUtilGL.h:116
void drawQuad(eStyle style, ePlane plane)
quad is double-sided.
Definition: LeapUtilGL.cpp:149
utility class for keeping the gl matrix stack push/pop operations paired up correctly.
Definition: LeapUtilGL.h:81


leap_motion
Author(s): Florian Lier , Mirza Shah , Isaac IY Saito
autogenerated on Tue Jun 2 2020 03:58:01