Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
gl.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2010, The Barbarian Group
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
6  the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and
9  the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
11  the following disclaimer in the documentation and/or other materials provided with the distribution.
12 
13  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
14  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
15  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
16  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
17  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
19  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
20  POSSIBILITY OF SUCH DAMAGE.
21 */
22 
23 #pragma once
24 
25 #include "cinder/Cinder.h"
26 
27 #if defined( CINDER_MAC )
28  #include <OpenGL/gl.h>
29  #include <OpenGL/glext.h>
30 #elif defined( CINDER_MSW )
31  #include "cinder/gl/GLee.h"
32 #else
33  #define CINDER_GLES
34  #define CINDER_GLES1
35 #endif
36 
37 #include "cinder/Exception.h"
38 #include "cinder/Quaternion.h"
39 #include "cinder/Matrix.h"
40 #include "cinder/Vector.h"
41 #include "cinder/Color.h"
42 #include "cinder/Rect.h"
43 #include "cinder/Font.h"
44 #include "cinder/PolyLine.h"
45 #include "cinder/AxisAlignedBox.h"
46 
47 #if defined( CINDER_MSW )
48  #include <windows.h>
49  #undef min
50  #undef max
51  #include <gl/gl.h>
52 #elif defined( CINDER_COCOA_TOUCH )
53  #include <OpenGLES/ES1/gl.h>
54  #include <OpenGLES/ES1/glext.h>
55 #elif defined( CINDER_MAC )
56  #include <OpenGL/gl.h>
57 #endif
58 
59 // forward declarations
60 namespace cinder {
61  class Camera; class TriMesh2d; class TriMesh; class Sphere;
62  namespace gl {
63  class VboMesh; class Texture;
64  typedef std::shared_ptr<Texture> TextureRef;
65  typedef std::shared_ptr<VboMesh> VboMeshRef;
66  }
67 } // namespace cinder
68 
69 namespace cinder { namespace gl {
70 
72 bool isExtensionAvailable( const std::string &extName );
73 
75 void clear( const ColorA &color = ColorA::black(), bool clearDepthBuffer = true );
76 
78 void enableVerticalSync( bool enable = true );
80 inline void disableVerticalSync() { enableVerticalSync( false ); }
83 
85 void setMatrices( const Camera &cam );
87 void setModelView( const Camera &cam );
89 void setProjection( const Camera &cam );
91 void pushModelView();
93 void popModelView();
95 void pushModelView( const Camera &cam );
97 void pushProjection( const Camera &cam );
99 void pushMatrices();
101 void popMatrices();
103 void multModelView( const Matrix44f &mtx );
105 void multProjection( const Matrix44f &mtx );
110 
112 void setMatricesWindowPersp( int screenWidth, int screenHeight, float fovDegrees = 60.0f, float nearPlane = 1.0f, float farPlane = 1000.0f, bool originUpperLeft = true );
114 inline void setMatricesWindowPersp( const Vec2i &screenSize, float fovDegrees = 60.0f, float nearPlane = 1.0f, float farPlane = 1000.0f, bool originUpperLeft = true )
115  { setMatricesWindowPersp( screenSize.x, screenSize.y, fovDegrees, nearPlane, farPlane ); }
117 void setMatricesWindow( int screenWidth, int screenHeight, bool originUpperLeft = true );
119 inline void setMatricesWindow( const Vec2i &screenSize, bool originUpperLeft = true ) { setMatricesWindow( screenSize.x, screenSize.y, originUpperLeft ); }
120 
122 Area getViewport();
124 void setViewport( const Area &area );
125 
127 void translate( const Vec2f &pos );
129 inline void translate( float x, float y ) { translate( Vec2f( x, y ) ); }
131 void translate( const Vec3f &pos );
133 inline void translate( float x, float y, float z ) { translate( Vec3f( x, y, z ) ); }
134 
136 void scale( const Vec3f &scl );
138 inline void scale( const Vec2f &scl ) { scale( Vec3f( scl.x, scl.y, 1 ) ); }
140 inline void scale( float x, float y ) { scale( Vec3f( x, y, 1 ) ); }
142 inline void scale( float x, float y, float z ) { scale( Vec3f( x, y, z ) ); }
143 
145 void rotate( const Vec3f &xyz );
147 void rotate( const Quatf &quat );
149 inline void rotate( float degrees ) { rotate( Vec3f( 0, 0, degrees ) ); }
150 
151 #if ! defined( CINDER_GLES )
152 inline void begin( GLenum mode ) { glBegin( mode ); }
155 inline void end() { glEnd(); }
157 inline void vertex( const Vec2f &v ) { glVertex2fv( &v.x ); }
159 inline void vertex( float x, float y ) { glVertex2f( x, y ); }
161 inline void vertex( const Vec3f &v ) { glVertex3fv( &v.x ); }
163 inline void vertex( float x, float y, float z ) { glVertex3f( x, y, z ); }
165 inline void texCoord( float x, float y ) { glTexCoord2f( x, y ); }
167 inline void texCoord( const Vec2f &v ) { glTexCoord2f( v.x, v.y ); }
169 inline void texCoord( float x, float y, float z ) { glTexCoord3f( x, y, z ); }
171 inline void texCoord( const Vec3f &v ) { glTexCoord3f( v.x, v.y, v.z ); }
172 #endif // ! defined( CINDER_GLES )
173 inline void color( float r, float g, float b ) { glColor4f( r, g, b, 1.0f ); }
176 inline void color( float r, float g, float b, float a ) { glColor4f( r, g, b, a ); }
178 inline void color( const Color8u &c ) { glColor4ub( c.r, c.g, c.b, 255 ); }
180 inline void color( const ColorA8u &c ) { glColor4ub( c.r, c.g, c.b, c.a ); }
182 inline void color( const Color &c ) { glColor4f( c.r, c.g, c.b, 1.0f ); }
184 inline void color( const ColorA &c ) { glColor4f( c.r, c.g, c.b, c.a ); }
185 
187 inline void enable( GLenum state ) { glEnable( state ); }
189 inline void disable( GLenum state ) { glDisable( state ); }
190 
192 void enableAlphaBlending( bool premultiplied = false );
194 void disableAlphaBlending();
197 
200 void enableAlphaTest( float value = 0.5f, int func = GL_GREATER );
202 void disableAlphaTest();
203 
204 #if ! defined( CINDER_GLES )
205 void enableWireframe();
208 void disableWireframe();
209 #endif // ! defined( CINDER_GLES )
210 
212 void disableDepthRead();
214 void disableDepthWrite();
216 void enableDepthRead( bool enable = true );
218 void enableDepthWrite( bool enable = true );
219 
221 inline void lineWidth( float width ) { glLineWidth( width ); }
222 
224 void drawLine( const Vec2f &start, const Vec2f &end );
226 void drawLine( const Vec3f &start, const Vec3f &end );
228 void drawCube( const Vec3f &center, const Vec3f &size );
230 void drawColorCube( const Vec3f &center, const Vec3f &size );
232 void drawStrokedCube( const Vec3f &center, const Vec3f &size );
234 inline void drawStrokedCube( const AxisAlignedBox3f &aab ) { drawStrokedCube( aab.getCenter(), aab.getSize() ); }
236 void drawSphere( const Vec3f &center, float radius, int segments = 12 );
238 void draw( const class Sphere &sphere, int segments = 12 );
240 void drawSolidCircle( const Vec2f &center, float radius, int numSegments = 0 );
242 void drawStrokedCircle( const Vec2f &center, float radius, int numSegments = 0 );
244 void drawSolidEllipse( const Vec2f &center, float radiusX, float radiusY, int numSegments = 0 );
246 void drawStrokedEllipse( const Vec2f &center, float radiusX, float radiusY, int numSegments = 0 );
248 void drawSolidRect( const Rectf &rect, bool textureRectangle = false );
250 void drawStrokedRect( const Rectf &rect );
251 void drawSolidRoundedRect( const Rectf &r, float cornerRadius, int numSegmentsPerCorner = 0 );
252 void drawStrokedRoundedRect( const Rectf &r, float cornerRadius, int numSegmentsPerCorner = 0 );
255 void drawSolidTriangle( const Vec2f &pt1, const Vec2f &pt2, const Vec2f &pt3 );
256 void drawSolidTriangle( const Vec2f pts[3] );
258 void drawSolidTriangle( const Vec2f &pt1, const Vec2f &pt2, const Vec2f &pt3, const Vec2f &texPt1, const Vec2f &texPt2, const Vec2f &texPt3 );
259 void drawSolidTriangle( const Vec2f pts[3], const Vec2f texCoord[3] );
261 void drawStrokedTriangle( const Vec2f &pt1, const Vec2f &pt2, const Vec2f &pt3 );
262 void drawStrokedTriangle( const Vec2f pts[3] );
263 void drawCoordinateFrame( float axisLength = 1.0f, float headLength = 0.2f, float headRadius = 0.05f );
265 void drawVector( const Vec3f &start, const Vec3f &end, float headLength = 0.2f, float headRadius = 0.05f );
267 void drawFrustum( const Camera &cam );
269 void drawTorus( float outterRadius, float innerRadius, int longitudeSegments = 12, int latitudeSegments = 12 );
271 void drawCylinder( float baseRadius, float topRadius, float height, int slices = 12, int stacks = 1 );
273 void draw( const class PolyLine<Vec2f> &polyLine );
275 void draw( const class PolyLine<Vec3f> &polyLine );
277 void draw( const class Path2d &path2d, float approximationScale = 1.0f );
279 void draw( const class Shape2d &shape2d, float approximationScale = 1.0f );
280 
282 void drawSolid( const class Path2d &path2d, float approximationScale = 1.0f );
284 void drawSolid( const class Shape2d &shape2d, float approximationScale = 1.0f );
286 void drawSolid( const PolyLine2f &polyLine );
287 
289 void draw( const TriMesh2d &mesh );
291 void drawRange( const TriMesh2d &mesh, size_t startTriangle, size_t triangleCount );
293 void draw( const TriMesh &mesh );
295 void drawRange( const TriMesh &mesh, size_t startTriangle, size_t triangleCount );
296 
297 #if ! defined ( CINDER_GLES )
298 void draw( const VboMesh &vbo );
300 inline void draw( const VboMeshRef &vbo ) { draw( *vbo ); }
302 void drawRange( const VboMesh &vbo, size_t startIndex, size_t indexCount, int vertexStart = -1, int vertexEnd = -1 );
303 inline void drawRange( const VboMeshRef &vbo, size_t startIndex, size_t indexCount, int vertexStart = -1, int vertexEnd = -1 ) { drawRange( *vbo, startIndex, indexCount, vertexStart, vertexEnd ); }
305 void drawArrays( const VboMesh &vbo, GLint first, GLsizei count );
306 inline void drawArrays( const VboMeshRef &vbo, GLint first, GLsizei count ) { drawArrays( *vbo, first, count ); }
307 #endif
308 
310 void drawBillboard( const Vec3f &pos, const Vec2f &scale, float rotationDegrees, const Vec3f &bbRight, const Vec3f &bbUp );
312 void draw( const Texture &texture );
313 inline void draw( const TextureRef &texture ) { draw( *texture ); }
315 void draw( const Texture &texture, const Vec2f &pos );
316 inline void draw( const TextureRef &texture, const Vec2f &pos ) { draw( *texture, pos ); }
318 void draw( const Texture &texture, const Rectf &rect );
319 inline void draw( const TextureRef &texture, const Rectf &rect ) { draw( *texture, rect ); }
321 void draw( const Texture &texture, const Area &srcArea, const Rectf &destRect );
322 inline void draw( const TextureRef &texture, const Area &srcArea, const Rectf &destRect ) { draw( *texture, srcArea, destRect ); }
323 
325 void drawString( const std::string &str, const Vec2f &pos, const ColorA &color = ColorA( 1, 1, 1, 1 ), Font font = Font() );
327 void drawStringCentered( const std::string &str, const Vec2f &pos, const ColorA &color = ColorA( 1, 1, 1, 1 ), Font font = Font() );
329 void drawStringRight( const std::string &str, const Vec2f &pos, const ColorA &color = ColorA( 1, 1, 1, 1 ), Font font = Font() );
330 
331 
336  private:
337  GLint mTarget;
338  GLint mOldID;
339 };
340 
342 struct BoolState {
344  ~BoolState();
345  private:
346  GLint mTarget;
347  GLboolean mOldValue;
348 };
349 
354  private:
355  GLint mTarget;
356  GLboolean mOldValue;
357 };
358 
361  SaveColorState();
362  ~SaveColorState();
363  private:
364  GLfloat mOldValues[4];
365 };
366 
371  private:
372  GLint mOldValue;
373 };
374 
375 #if defined( CINDER_MSW )
376 void initializeGlee();
378 #endif
379 
380 class Exception : public cinder::Exception {
381 };
382 
384 };
385 
386 } } // namespace cinder::gl
387 
389 #if ! defined( CINDER_GLES )
391 inline void glVertex2f( const cinder::Vec2f &v ) { glVertex2f( v.x, v.y ); }
392 inline void glVertex3f( const cinder::Vec3f &v ) { glVertex3f( v.x, v.y, v.z ); }
393 inline void glVertex4f( const cinder::Vec4f &v ) { glVertex4f( v.x, v.y, v.z, v.w ); }
394 inline void glNormal3f( const cinder::Vec3f &v ) { glNormal3f( v.x, v.y, v.z ); }
395 inline void glColor3f( const cinder::Color &c ) { glColor3f( c.r, c.g, c.b ); }
396 inline void glColor4f( const cinder::ColorA &c ) { glColor4f( c.r, c.g, c.b, c.a ); }
397 inline void glTexCoord2f( const cinder::Vec2f &v ) { glTexCoord2f( v.x, v.y ); }
398 inline void glTexCoord3f( const cinder::Vec3f &v ) { glTexCoord3f( v.x, v.y, v.z ); }
399 inline void glTexCoord4f( const cinder::Vec4f &v ) { glTexCoord4f( v.x, v.y, v.z, v.w ); }
400 // This style of definition conflicts with GLee
401 //inline void glMultiTexCoord2f( GLenum target, const cinder::Vec2f &v ) { glMultiTexCoord2f( target, v.x, v.y ); }
402 //inline void glMultiTexCoord3f( GLenum target, const cinder::Vec3f &v ) { glMultiTexCoord3f( target, v.x, v.y, v.z ); }
403 //inline void glMultiTexCoord4f( GLenum target, const cinder::Vec4f &v ) { glMultiTexCoord4f( target, v.x, v.y, v.z, v.w ); }
404 #endif // ! defined( CINDER_GLES )
405 inline void glTranslatef( const cinder::Vec3f &v ) { glTranslatef( v.x, v.y, v.z ); }
406 inline void glScalef( const cinder::Vec3f &v ) { glScalef( v.x, v.y, v.z ); }
407 inline void glRotatef( float angle, const cinder::Vec3f &v ) { glRotatef( angle, v.x, v.y, v.z ); }
408 inline void glRotatef( const cinder::Quatf &quat ) { cinder::Vec3f axis; float angle; quat.getAxisAngle( &axis, &angle ); glRotatef( cinder::toDegrees( angle ), axis.x, axis.y, axis.z ); }
409 inline void glMultMatrixf( const cinder::Matrix44f &m ) { glMultMatrixf( m.m ); }
410 inline void glLoadMatrixf( const cinder::Matrix44f &m ) { glLoadMatrixf( m.m ); }
411 //@}
Convenience class which pushes and pops the currently bound framebuffer.
Definition: gl.h:368
void rotate(const Vec3f &xyz)
Produces a rotation around the X-axis by xyz.x degrees, the Y-axis by xyz.y degrees and the Z-axis by...
Definition: gl.cpp:405
GLdouble GLdouble GLdouble r
Definition: GLee.h:1474
void multProjection(const Matrix44f &mtx)
Multiplies the current PROJECTION matrix with mtx. Leaves the MatrixMode as MODELVIEW.
Definition: gl.cpp:323
void setProjection(const Camera &cam)
Sets the PROJECTION matrix to reflect the values of cam. Leaves the MatrixMode as PROJECTION...
Definition: gl.cpp:263
void enable(GLenum state)
Enables the OpenGL State state. Equivalent to calling to glEnable( state );.
Definition: gl.h:187
T x
Definition: Vector.h:694
void enableDepthWrite(bool enable=true)
Enables writing to the depth buffer when enable.
Definition: gl.cpp:477
GLenum GLint GLint y
Definition: GLee.h:987
T b
Definition: Color.h:216
GLenum mode
Definition: GLee.h:3042
~SaveTextureBindState()
Definition: gl.cpp:1554
void drawStrokedCube(const Vec3f &center, const Vec3f &size)
Renders a stroked cube centered at center of size size.
Definition: gl.cpp:586
void scale(const Vec3f &scl)
Produces a scale by scale in the current matrix.
Definition: gl.cpp:400
void drawStringRight(const std::string &str, const Vec2f &pos, const ColorA &color=ColorA(1, 1, 1, 1), Font font=Font())
Draws a right-justified string str with the center of its located at pos. Optional font and color aff...
Definition: gl.cpp:1531
void drawStrokedEllipse(const Vec2f &center, float radiusX, float radiusY, int numSegments=0)
Renders a stroked circle using a line loop. The default value of zero for numSegments automatically d...
Definition: gl.cpp:733
float toDegrees(float x)
Definition: CinderMath.h:137
void drawStrokedCircle(const Vec2f &center, float radius, int numSegments=0)
Renders a stroked circle using a line loop. The default value of zero for numSegments automatically d...
Definition: gl.cpp:689
void color(float r, float g, float b)
Sets the current color and the alpha value to 1.0.
Definition: gl.h:174
Matrix44f getModelView()
Returns the value of the current MODELVIEW matrix as a Matrix44f.
Definition: gl.cpp:329
GLuint start
Definition: GLee.h:963
~SaveFramebufferBinding()
Definition: gl.cpp:1619
Vec2< float > Vec2f
Definition: Vector.h:1314
Convenience class designed to push and pop the current color.
Definition: gl.h:360
Definition: Area.h:37
GLenum GLenum GLuint texture
Definition: GLee.h:5383
GLsizei const GLchar ** string
Definition: GLee.h:2427
void drawString(const std::string &str, const Vec2f &pos, const ColorA &color=ColorA(1, 1, 1, 1), Font font=Font())
Draws a string str with its lower left corner located at pos. Optional font and color affect the styl...
Definition: gl.cpp:1521
T y
Definition: Vector.h:694
void drawSolidCircle(const Vec2f &center, float radius, int numSegments=0)
Renders a solid circle using triangle fans. The default value of zero for numSegments automatically d...
Definition: gl.cpp:666
void drawSolidTriangle(const Vec2f &pt1, const Vec2f &pt2, const Vec2f &pt3)
Definition: gl.cpp:859
T z
Definition: Vector.h:694
ClientBoolState(GLint target)
Definition: gl.cpp:1577
void drawFrustum(const Camera &cam)
Draws a wireframe representation of the frustum defined by cam.
Definition: gl.cpp:954
void enableDepthRead(bool enable=true)
Enables reading from the depth buffer when enable, enabling z-testing.
Definition: gl.cpp:469
GLenum GLsizei width
Definition: GLee.h:969
T z
Definition: Vector.h:321
T w
Definition: Vector.h:694
#define GL_GREATER
Definition: gldx.h:79
T x
Definition: Vector.h:321
Matrix44f getProjection()
Returns the value of the current PROJECTION matrix as a Matrix44f.
Definition: gl.cpp:336
Area getViewport()
Returns the current OpenGL Viewport as an Area.
Definition: gl.cpp:377
T b
Definition: Color.h:44
std::shared_ptr< VboMesh > VboMeshRef
Definition: gl.h:65
void drawArrays(const VboMesh &vbo, GLint first, GLsizei count)
Definition: gl.cpp:1408
T x
Definition: Vector.h:71
GLfloat angle
Definition: GLee.h:13523
void drawCube(const Vec3f &center, const Vec3f &size)
Renders a solid cube centered at center of size size. Normals and created texture coordinates are gen...
Definition: gl.cpp:576
void popMatrices()
Pops the MODELVIEW and PROJECTION matrices off their stacks, restoring the values saved with the prev...
Definition: gl.cpp:309
GLenum target
Definition: GLee.h:13607
T y
Definition: Vector.h:321
void setMatrices(const Camera &cam)
Sets the MODELVIEW and PROJECTION matrices to reflect the values of cam. Leaves the MatrixMode as MOD...
Definition: gl.cpp:269
Definition: Color.h:214
T m[16]
Definition: Matrix44.h:66
void enableWireframe()
Definition: gl.cpp:453
void vertex(const Vec2f &v)
Definition: dx.cpp:749
float GLfloat
Definition: gldx.h:56
void glScalef(const cinder::Vec3f &v)
Global overloads for OpenGL free functions to allow the use of Cinder types natively.
Definition: gl.h:406
void multModelView(const Matrix44f &mtx)
Multiplies the current MODELVIEW matrix with mtx. Leaves the MatrixMode as MODELVIEW.
Definition: gl.cpp:317
Definition: Camera.h:36
~SaveColorState()
Definition: gl.cpp:1602
void drawSolidEllipse(const Vec2f &center, float radiusX, float radiusY, int numSegments=0)
Renders a solid ellipse using triangle fans. The default value of zero for numSegments automatically ...
Definition: gl.cpp:710
void clear(const ColorA &color=ColorA::black(), bool clearDepthBuffer=true)
Clears the OpenGL color buffer using color and optionally clears the depth buffer when clearDepthBuff...
Definition: gl.cpp:218
void drawRange(const TriMesh2d &mesh, size_t startTriangle, size_t triangleCount)
Draws a range of triangles starting with triangle # startTriangle and a count of triangleCount from c...
Definition: gl.cpp:1239
T g
Definition: Color.h:44
void getAxisAngle(Vec3< T > *axis, T *radians) const
Definition: Quaternion.h:332
void drawStrokedRect(const Rectf &rect)
Renders a stroked rectangle.
Definition: gl.cpp:777
Vec3< float > Vec3f
Definition: Vector.h:1317
void setMatricesWindow(int screenWidth, int screenHeight, bool originUpperLeft=true)
Sets the viewport and MODELVIEW and PROJECTION matrices to orthographic with the upper-left corner at...
Definition: gl.cpp:358
void glLoadMatrixf(const cinder::Matrix44f &m)
Global overloads for OpenGL free functions to allow the use of Cinder types natively.
Definition: gl.h:410
SaveFramebufferBinding()
Definition: gl.cpp:1610
ColorAT< float > ColorA
Definition: Color.h:408
Represents an OpenGL Texture. Implicitly shared object.
Definition: Texture.h:41
Vec3f getCenter() const
Definition: AxisAlignedBox.h:39
Definition: Vbo.h:73
GLint * first
Definition: GLee.h:1725
bool isVerticalSyncEnabled()
Returns whether vertical sync is enabled for the current context.
Definition: gl.cpp:241
void drawStringCentered(const std::string &str, const Vec2f &pos, const ColorA &color=ColorA(1, 1, 1, 1), Font font=Font())
Draws a string str with the horizontal center of its baseline located at pos. Optional font and color...
Definition: gl.cpp:1526
GLboolean GLboolean g
Definition: GLee.h:2964
GLenum GLsizei GLsizei height
Definition: GLee.h:1029
Vec3f getSize() const
Definition: AxisAlignedBox.h:40
std::shared_ptr< Texture > TextureRef
Definition: gl.h:63
Represents an instance of a font at a point size. Implicitly shared object.
Definition: Font.h:63
void glTranslatef(const cinder::Vec3f &v)
Global overloads for OpenGL free functions to allow the use of Cinder types natively.
Definition: gl.h:405
void drawSolidRect(const Rectf &rect, bool textureRectangle=false)
Renders a solid rectangle. Texture coordinates in the range [0,1] are generated unless textureRectang...
Definition: gl.cpp:754
Definition: gl.h:380
void drawSolid(const class Path2d &path2d, float approximationScale=1.0f)
Draws a solid (filled) Path2d path2d using approximation scale approximationScale. 1.0 corresponds to screenspace, 2.0 is double screen resolution, etc. Performance warning: This routine tesselates the polygon into triangles. Consider using Triangulator directly.
GLenum GLint x
Definition: GLee.h:987
void glMultMatrixf(const cinder::Matrix44f &m)
Global overloads for OpenGL free functions to allow the use of Cinder types natively.
Definition: gl.h:409
GLuint GLuint GLsizei count
Definition: GLee.h:963
Convenience class designed to push and pop a boolean OpenGL state.
Definition: gl.h:342
void pushModelView()
Pushes the MODELVIEW matrix onto its stack, preserving the current values. Leaves the MatrixMode as M...
Definition: gl.cpp:275
void disable(GLenum state)
Disables the OpenGL State state. Equivalent to calling to glDisable( state );.
Definition: gl.h:189
Definition: Sphere.h:32
int GLsizei
Definition: gldx.h:52
void disableWireframe()
Definition: gl.cpp:458
SaveColorState()
Definition: gl.cpp:1597
bool isExtensionAvailable(const std::string &extName)
Returns whether a particular OpenGL extension is available. Caches results.
Definition: gl.cpp:192
const GLdouble * v
Definition: GLee.h:1384
void drawSolidRoundedRect(const Rectf &r, float cornerRadius, int numSegmentsPerCorner=0)
Definition: gl.cpp:790
void drawTorus(float outterRadius, float innerRadius, int longitudeSegments=12, int latitudeSegments=12)
Draws a torus at the origin, with an outter radius outterRadius and an inner radius innerRadius...
Definition: gl.cpp:1019
void disableVerticalSync()
Disables wait for vertical sync.
Definition: gl.h:80
GLdouble GLdouble z
Definition: GLee.h:1911
void enableAdditiveBlending()
Enables alpha blending and selects a BlendFunc for additive blending.
Definition: gl.cpp:435
GLboolean GLboolean GLboolean b
Definition: GLee.h:2964
void enableVerticalSync(bool enable=true)
Enables or disables wait for vertical sync.
Definition: gl.cpp:229
T y
Definition: Vector.h:71
GLsizei const GLfloat * value
Definition: GLee.h:2487
GLuint GLuint end
Definition: GLee.h:963
void begin(GLenum mode)
Definition: dx.cpp:588
void drawStrokedRoundedRect(const Rectf &r, float cornerRadius, int numSegmentsPerCorner=0)
Definition: gl.cpp:828
void glRotatef(float angle, const cinder::Vec3f &v)
Global overloads for OpenGL free functions to allow the use of Cinder types natively.
Definition: gl.h:407
const GLubyte * c
Definition: GLee.h:8491
void drawStrokedTriangle(const Vec2f &pt1, const Vec2f &pt2, const Vec2f &pt3)
Renders a stroked triangle.
Definition: gl.cpp:891
Definition: Path2d.h:35
Convenience class designed to push and pop a boolean OpenGL state.
Definition: gl.h:351
GLboolean GLboolean GLboolean GLboolean a
Definition: GLee.h:2964
T a
Definition: Color.h:216
void popModelView()
Pops the MODELVIEW matrix off of its stack, restoring the values saved with the previous push...
Definition: gl.cpp:281
T r
Definition: Color.h:216
void disableAlphaBlending()
Disables alpha blending.
Definition: gl.cpp:430
void drawSphere(const Vec3f &center, float radius, int segments=12)
Renders a solid sphere centered at center of radius radius. segments defines how many segments the sp...
Definition: gl.cpp:609
int GLint
Definition: gldx.h:51
void setMatricesWindowPersp(int screenWidth, int screenHeight, float fovDegrees=60.0f, float nearPlane=1.0f, float farPlane=1000.0f, bool originUpperLeft=true)
Sets the viepwort and MODELVIEW and PROJECTION matrices to be a perspective projection with the upper...
Definition: gl.cpp:343
void pushMatrices()
Pushes the MODELVIEW and PROJECTION matrices onto their stacks, preserving the current values...
Definition: gl.cpp:301
void drawCoordinateFrame(float axisLength=1.0f, float headLength=0.2f, float headRadius=0.05f)
Definition: gl.cpp:905
void drawLine(const Vec2f &start, const Vec2f &end)
Draws a line from start to end.
Definition: gl.cpp:487
void lineWidth(float width)
Specifies the rasterized width of both aliased and antialiased lines.
Definition: gl.h:221
Definition: Exception.h:32
void drawVector(const Vec3f &start, const Vec3f &end, float headLength=0.2f, float headRadius=0.05f)
Draws a vector starting at start and ending at end. An arrowhead is drawn at the end of radius headRa...
Definition: gl.cpp:915
void setModelView(const Camera &cam)
Sets the MODELVIEW matrix to reflect the values of cam. Leaves the MatrixMode as MODELVIEW.
Definition: gl.cpp:257
const GLfloat * m
Definition: GLee.h:13493
unsigned char GLboolean
Definition: gldx.h:47
static ColorAT< float > black()
Definition: Color.h:351
void disableDepthWrite()
Disables writing to the depth buffer.
Definition: gl.cpp:482
Definition: AxisAlignedBox.h:31
GLenum GLenum GLenum GLenum GLenum scale
Definition: GLee.h:8937
void setViewport(const Area &area)
Sets the current OpenGL Viewport to area.
Definition: gl.cpp:385
Definition: TriMesh.h:167
void disableAlphaTest()
Disables alpha testing.
Definition: gl.cpp:447
void drawCylinder(float baseRadius, float topRadius, float height, int slices=12, int stacks=1)
Draws a open-ended cylinder, with base radius baseRadius and top radius topRadius, with height height, subdivided into slices and stacks. Normals and texture coordinates in the range [0,1] are generated.
Definition: gl.cpp:1077
SaveTextureBindState(GLint target)
Definition: gl.cpp:1538
void drawColorCube(const Vec3f &center, const Vec3f &size)
Renders a solid cube centered at center of size size. Each face is assigned a unique color...
Definition: gl.cpp:581
GLclampf f
Definition: GLee.h:15307
Convenience class designed to push and pop the currently bound texture for a given texture unit...
Definition: gl.h:333
~BoolState()
Definition: gl.cpp:1567
T r
Definition: Color.h:44
Definition: Shape2d.h:34
T g
Definition: Color.h:216
GLsizeiptr size
Definition: GLee.h:2089
void texCoord(float x, float y)
Definition: dx.cpp:782
void translate(const Vec2f &pos)
Produces a translation by pos in the current matrix.
Definition: gl.cpp:390
unsigned int GLenum
Definition: gldx.h:46
void enableAlphaTest(float value=0.5f, int func=GL_GREATER)
Enables alpha testing and sets the AlphaFunc to test for values which are func than value...
Definition: gl.cpp:441
Definition: TriMesh.h:66
void drawBillboard(const Vec3f &pos, const Vec2f &scale, float rotationDegrees, const Vec3f &bbRight, const Vec3f &bbUp)
Draws a textured quad of size scale that is aligned with the vectors bbRight and bbUp at pos...
Definition: gl.cpp:1420
~ClientBoolState()
Definition: gl.cpp:1587
void disableDepthRead()
Disables reading from the depth buffer, disabling z-testing.
Definition: gl.cpp:464
void enableAlphaBlending(bool premultiplied=false)
Enables alpha blending. Selects a BlendFunc that is appropriate for premultiplied-alpha when premulti...
Definition: gl.cpp:421
void pushProjection(const Camera &cam)
Pushes the PROJECTION matrix onto its stack, preserving the current values, and then sets the matrix ...
Definition: gl.cpp:294
BoolState(GLint target)
Definition: gl.cpp:1561
GLuint color
Definition: GLee.h:3198
void draw(const class Sphere &sphere, int segments=12)
Renders a solid sphere. segments defines how many segments the sphere is subdivided into...
Definition: gl.cpp:661