27 #if defined( CINDER_MAC )
28 #include <OpenGL/gl.h>
29 #include <OpenGL/glext.h>
30 #elif defined( CINDER_MSW )
47 #if defined( CINDER_MSW )
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>
61 class Camera;
class TriMesh2d;
class TriMesh;
class Sphere;
69 namespace cinder {
namespace gl {
112 void setMatricesWindowPersp(
int screenWidth,
int screenHeight,
float fovDegrees = 60.0
f,
float nearPlane = 1.0
f,
float farPlane = 1000.0
f,
bool originUpperLeft =
true );
114 inline void setMatricesWindowPersp(
const Vec2i &screenSize,
float fovDegrees = 60.0
f,
float nearPlane = 1.0
f,
float farPlane = 1000.0
f,
bool originUpperLeft =
true )
117 void setMatricesWindow(
int screenWidth,
int screenHeight,
bool originUpperLeft =
true );
151 #if ! defined( CINDER_GLES )
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.0
f ); }
176 inline void color(
float r,
float g,
float b,
float a ) { glColor4f( r, g, b, a ); }
204 #if ! defined( CINDER_GLES )
209 #endif // ! defined( CINDER_GLES )
236 void drawSphere(
const Vec3f ¢er,
float radius,
int segments = 12 );
238 void draw(
const class Sphere &sphere,
int segments = 12 );
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 );
277 void draw(
const class Path2d &path2d,
float approximationScale = 1.0
f );
279 void draw(
const class Shape2d &shape2d,
float approximationScale = 1.0
f );
282 void drawSolid(
const class Path2d &path2d,
float approximationScale = 1.0
f );
295 void drawRange(
const TriMesh &mesh,
size_t startTriangle,
size_t triangleCount );
297 #if ! defined ( CINDER_GLES )
298 void draw(
const VboMesh &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 ); }
375 #if defined( CINDER_MSW )
376 void initializeGlee();
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 ); }
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 ); }
404 #endif // ! defined( CINDER_GLES )
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 ¢er, 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 ¢er, 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 ¢er, 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
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 ¢er, 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 ¢er, 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
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
~SaveColorState()
Definition: gl.cpp:1602
void drawSolidEllipse(const Vec2f ¢er, 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
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
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
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
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 ¢er, 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 ¢er, 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
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
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