KrisLibrary  1.0.0
drawextra.h
1 #ifndef GL_DRAWEXTRA_H
2 #define GL_DRAWEXTRA_H
3 
4 #include "GL.h"
6 
8 #define GLDRAW_USE_FLOATS_ONLY 1
9 
10 namespace GLDraw {
11 
12 using namespace Math3D;
13 
14 void drawPoint(const Vector3& pt);
15 void drawLineSegment(const Vector3& a,const Vector3& b);
16 void drawTriangle(const Vector3& a,const Vector3& b,const Vector3& c);
17 void drawQuad(const Vector3& a,const Vector3& b,const Vector3& c,const Vector3& d);
18 
19 void drawWireCircle2D(const Vector2& center,float r,int numIncrements=16);
20 void drawWireCircle(const Vector3& axis,float r, int numIncrements=16);
21 void drawWireSphere(float r, int numIncrements=16);
22 void drawWireArc(float r, const Vector3& axis, const Vector3& dir, float min, float max);
23 void drawOrientedWireSphere(float r, const Matrix4& basis);
24 void drawWirePyramid(float l, float w, float h);
25 void drawWireBox(float l, float w, float h);
26 void drawWireBoxCorner(float l, float w, float h);
27 void drawOrientedWireBox(float l, float w, float h, const Matrix4& basis);
28 void drawWireBoundingBox(const Vector3& bmin,const Vector3& bmax);
29 void drawWireOctahedron(float l, float w, float h);
30 void drawWireCylinder(const Vector3& h,Real r,int numSteps=16);
31 void drawWireCone(const Vector3& h, float r, int numSteps=16);
32 void drawWireConeFlipped(const Vector3& h, float r, int numSteps=16);
33 
34 void drawCircle2D(const Vector2& center,float r,int numIncrements=16);
35 void drawCircle(const Vector3& axis,float r, int numIncrements=16);
36 void drawSphere(float r, int numSlices, int numStacks);
37 void drawArc(float r1,float r2, const Vector3& axis, const Vector3& dir, float min, float max);
38 void drawPyramid(float l, float w, float h);
39 void drawBox(float l, float w, float h);
40 void drawBoxCorner(float l, float w, float h);
41 void drawOrientedBox(float l, float w, float h, const Matrix4& basis);
42 void drawBoundingBox(const Vector3& bmin,const Vector3& bmax);
43 void drawOctahedron(float l, float w, float h);
44 void drawCylinder(const Vector3& h,Real r,int numSteps=16);
45 void drawCone(const Vector3& h, float r, int numSteps=16);
46 void drawConeFlipped(const Vector3& h, float r, int numSteps=16);
47 
48 void drawCoords(float len);
49 void drawCoordWidget(float len,float axisWidth=0.05,float arrowLen=0.2,float arrowWidth=0.1);
50 void drawXYGrid(int n, float spacing);
51 void drawXZGrid(int n, float spacing);
52 void drawXYCheckerboard(int n, float spacing, float col1[4],float col2[4]);
53 
54 
55 //overloaded aliases for float/double objects
56 
57 inline void glTexCoord2v(const GLfloat* v) { glTexCoord2fv(v); }
58 inline void glTexCoord3v(const GLfloat* v) { glTexCoord3fv(v); }
59 inline void glTexCoord4v(const GLfloat* v) { glTexCoord4fv(v); }
60 
61 inline void glNormal3v(const GLfloat* v) { glNormal3fv(v); }
62 
63 inline void glVertex2v(const GLfloat* v) { glVertex2fv(v); }
64 inline void glVertex3v(const GLfloat* v) { glVertex3fv(v); }
65 inline void glVertex4v(const GLfloat* v) { glVertex4fv(v); }
66 
67 inline void glRasterPos2v(const GLfloat* v) { glRasterPos2fv(v); }
68 inline void glRasterPos3v(const GLfloat* v) { glRasterPos3fv(v); }
69 inline void glRasterPos4v(const GLfloat* v) { glRasterPos4fv(v); }
70 
71 inline void glLoadMatrix(const GLfloat* m) { glLoadMatrixf(m); }
72 inline void glMultMatrix(const GLfloat* m) { glMultMatrixf(m); }
73 
74 inline void glTranslate(const GLfloat* t) { glTranslatef(t[0],t[1],t[2]); }
75 #if GLDRAW_USE_FLOATS_ONLY
76 inline void glTexCoord2v(const GLdouble* v) { glTexCoord2f((GLfloat)v[0],(GLfloat)v[1]); }
77 inline void glTexCoord3v(const GLdouble* v) { glTexCoord3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]); }
78 inline void glTexCoord4v(const GLdouble* v) { glTexCoord4f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2],(GLfloat)v[3]); }
79 inline void glNormal3v(const GLdouble* v) { glNormal3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]); }
80 inline void glVertex2v(const GLdouble* v) { glVertex2f((GLfloat)v[0],(GLfloat)v[1]); }
81 inline void glVertex3v(const GLdouble* v) { glVertex3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]); }
82 inline void glVertex4v(const GLdouble* v) { glVertex4f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2],(GLfloat)v[3]); }
83 inline void glRasterPos2v(const GLdouble* v) { glRasterPos2f((GLfloat)v[0],(GLfloat)v[1]); }
84 inline void glRasterPos3v(const GLdouble* v) { glRasterPos3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]); }
85 inline void glRasterPos4v(const GLdouble* v) { glRasterPos4f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2],(GLfloat)v[3]); }
86 #else
87 inline void glTexCoord2v(const GLdouble* v) { glTexCoord2dv(v); }
88 inline void glTexCoord3v(const GLdouble* v) { glTexCoord3dv(v); }
89 inline void glTexCoord4v(const GLdouble* v) { glTexCoord4dv(v); }
90 inline void glNormal3v(const GLdouble* v) { glNormal3dv(v); }
91 inline void glVertex2v(const GLdouble* v) { glVertex2dv(v); }
92 inline void glVertex3v(const GLdouble* v) { glVertex3dv(v); }
93 inline void glVertex4v(const GLdouble* v) { glVertex4dv(v); }
94 inline void glRasterPos2v(const GLdouble* v) { glRasterPos2dv(v); }
95 inline void glRasterPos3v(const GLdouble* v) { glRasterPos3dv(v); }
96 inline void glRasterPos4v(const GLdouble* v) { glRasterPos4dv(v); }
97 #endif //GLDRAW_USE_FLOATS_ONLY
98 inline void glLoadMatrix(const GLdouble* m) { glLoadMatrixd(m); }
99 inline void glMultMatrix(const GLdouble* m) { glMultMatrixd(m); }
100 inline void glTranslate(const GLdouble* t) { glTranslated(t[0],t[1],t[2]); }
101 
102 } //namespace GLDraw
103 
104 #endif
A 3D vector class.
Definition: math3d/primitives.h:136
Class declarations for useful 3D math types.
A 4x4 matrix class.
Definition: math3d/primitives.h:626
Contains all the definitions in the Math3D package.
Definition: AnyGeometry.h:13
Contains all definitions in the GLDraw package.
Definition: AnyGeometry.h:14
A 2D vector class.
Definition: math3d/primitives.h:41