21 #ifndef CVD_GL_HELPERS_H
22 #define CVD_GL_HELPERS_H
34 #import <OpenGLES/ES1/gl.h>
35 #import <OpenGLES/ES1/glext.h>
60 glTexCoord2i(i.
x, i.
y);
68 glRasterPos2i(i.
x, i.
y);
77 glRecti(p.
x, p.
y, q.
x, q.
y);
85 glVertex2d(v[0], v[1]);
93 glVertex3d(v[0], v[1], v[2]);
101 glVertex4d(v[0], v[1], v[2], v[3]);
109 glTexCoord2d(v[0], v[1]);
117 glTexCoord3d(v[0], v[1], v[2]);
125 glTexCoord4d(v[0], v[1], v[2], v[3]);
134 glRectd(p[0], p[1], q[0], q[1]);
137 #ifdef GL_GLEXT_PROTOTYPES
144 glMultiTexCoord2d(unit, v[0], v[1]);
153 glMultiTexCoord3d(unit, v[0], v[1], v[2]);
162 glMultiTexCoord4d(unit, v[0], v[1], v[2], v[3]);
171 glRasterPos2d(v[0], v[1]);
179 glRasterPos3d(v[0], v[1], v[2]);
187 glRasterPos4d(v[0], v[1], v[2], v[3]);
195 glNormal3d(n[0], n[1], n[2]);
203 glTranslatef( static_cast<GLfloat>(v.
x), static_cast<GLfloat>(v.
y), 0);
211 glTranslated(v[0], v[1], v[2]);
220 glTranslated(v[0], v[1], 0);
229 glTranslated(v[0], 0, 0);
240 glm[0] = m[0][0]; glm[1] = m[1][0]; glm[2] = m[2][0]; glm[3] = m[3][0];
241 glm[4] = m[0][1]; glm[5] = m[1][1]; glm[6] = m[2][1]; glm[7] = m[3][1];
242 glm[8] = m[0][2]; glm[9] = m[1][2]; glm[10] = m[2][2]; glm[11] = m[3][2];
243 glm[12] = m[0][3]; glm[13] = m[1][3]; glm[14] = m[2][3]; glm[15] = m[3][3];
255 glm[0] = m[0][0]; glm[1] = m[1][0]; glm[2] = m[2][0]; glm[3] = 0;
256 glm[4] = m[0][1]; glm[5] = m[1][1]; glm[6] = m[2][1]; glm[7] = 0;
257 glm[8] = m[0][2]; glm[9] = m[1][2]; glm[10] = m[2][2]; glm[11] = 0;
258 glm[12] = 0; glm[13] = 0; glm[14] = 0; glm[15] = 1;
270 glm[0] = m[0][0]; glm[1] = m[1][0]; glm[2] = 0; glm[3] = 0;
271 glm[4] = m[0][1]; glm[5] = m[1][1]; glm[6] = 0; glm[7] = 0;
272 glm[8] = 0; glm[9] = 0; glm[10] = 1; glm[11] = 0;
273 glm[12] = 0; glm[13] = 0; glm[14] = 0; glm[15] = 1;
280 template <
typename P>
290 template <
typename P>
300 template <
typename P>
310 template <
typename P>
326 ::glOrtho( -0.375, size.
x - 0.375, size.
y - 0.375, -0.375, nearPlane, farPlane );
335 ::glOrtho( param[0], param[1], param[2], param[3], param[4], param[5]);
350 template <
typename P,
typename A>
353 GLdouble left, right, bottom, top;
354 left = -nearPlane * params[2] / params[0];
355 top = nearPlane * params[3] / params[1];
356 right = nearPlane * ( width - params[2] ) / params[0];
357 bottom = - nearPlane * ( height - params[3] ) / params[1];
358 ::glFrustum( left, right, bottom, top, nearPlane, farPlane );
369 template <
class CAMERA>
inline void glFrustum(
const CAMERA & camera,
double width,
double height,
double nearPlane = 0.1,
double farPlane = 100)
371 glFrustum( camera.get_parameters().template slice<0,4>(), width, height, nearPlane, farPlane);
380 ::glFrustum( param[0], param[1], param[2], param[3], param[4], param[5]);
389 glColor3d(v[0], v[1], v[2]);
398 glColor4d(v[0], v[1], v[2], v[3]);
407 ::glClearColor((GLclampf)v[0], (GLclampf)v[1], (GLclampf)v[2], (GLclampf)v[3]);
416 ::glClearColor((GLclampf)v[0], (GLclampf)v[1], (GLclampf)v[2], 0);
427 case 3: glColor3d(v[0], v[1], v[2]);
429 case 4: glColor4d(v[0], v[1], v[2], v[3]);
438 template <
class P1,
class P2>
inline void glLine(
const P1& x1,
const P2& x2) {
449 template<
class C>
inline void glVertex(
const C & list )
451 for(
typename C::const_iterator v = list.begin(); v != list.end(); ++v)
515 ::glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
516 ::glPixelStorei(GL_UNPACK_ROW_LENGTH, i.
row_stride());
518 ::glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
545 template<
class C>
inline void glTexSubImage2D(
const SubImage<C> &i, GLint xoffset = 0, GLint yoffset = 0, GLenum target = GL_TEXTURE_2D, GLint level = 0)
547 ::glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
548 ::glPixelStorei(GL_UNPACK_ROW_LENGTH, i.
row_stride());
550 ::glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
557 template<
class C>
inline void glTexImage2D(
const SubImage<C> &i, GLint border = 0, GLenum target = GL_TEXTURE_2D, GLint level = 0)
559 ::glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
560 ::glPixelStorei(GL_UNPACK_ROW_LENGTH, i.
row_stride());
562 ::glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
569 while((code = glGetError()) != GL_NO_ERROR){
570 std::cout <<
"GL:" << code <<
":" << gluGetString(code) << std::endl;
580 void glSetFont(
const std::string & fontname );
601 std::pair<double, double>
glDrawText(
const std::string & text,
enum TEXT_STYLE style =
NICE,
double spacing = 1.5,
double kerning = 0.1);
604 std::pair<double, double>
glGetExtends(
const std::string & text,
double spacing = 1.5,
double kerning = 0.1);
SO3< Precision > & get_rotation()
Returns the rotation part of the transformation as a SO3.
void glDrawPixels(const SubImage< C > &i)
unsigned char dummy
The 4th byte, usually either ignored or used to represent the alpha value.
const std::string & glGetFont()
returns the name of the currently active font
void glClearColor(const TooN::Vector< 4 > &v)
void glReadPixels(BasicImage< C > &i, ImageRef origin=ImageRef(0, 0))
void glColor3(const CVD::Rgb8 &c)
T green
The green component.
std::pair< double, double > glGetExtends(const std::string &text, double spacing=1.5, double kerning=0.1)
returns the size of the bounding box of a text to be rendered, similar to glDrawText but without any ...
std::pair< double, double > glDrawText(const std::string &text, enum TEXT_STYLE style=NICE, double spacing=1.5, double kerning=0.1)
SO2< Precision > & get_rotation()
Returns the rotation part of the transformation as a SO2.
renders glyphs as filled polygons
int row_stride() const
What is the row stride of the image?
T blue
The blue component.
void glTexSubImage2D(const SubImage< C > &i, GLint xoffset=0, GLint yoffset=0, GLenum target=GL_TEXTURE_2D, GLint level=0)
void glNormal(const TooN::Vector< 3 > &n)
void glOrtho(const CVD::ImageRef &size, const double nearPlane=-1.0, const double farPlane=1.0)
void glColor(const TooN::Vector< 3 > &v)
void glVertex(const ImageRef &i)
void glSetFont(const std::string &fontname)
unsigned char green
The green component.
void glRect(const ImageRef &p, const ImageRef &q)
void glRasterPos(const ImageRef &i)
void glTranslate(const ImageRef &v)
ImageRef size() const
What is the size of this image?
void glFrustum(const TooN::Vector< 4, P, A > ¶ms, double width, double height, double nearPlane=0.1, double farPlane=100)
T alpha
The alpha component.
const T * data() const
Returns the raw image data.
unsigned char red
The red component.
Vector< 2, Precision > & get_translation()
Returns the translation part of the transformation as a Vector.
Vector< 3, Precision > & get_translation()
Returns the translation part of the transformation as a Vector.
void glTexCoord(const ImageRef &i)
T green
The green component.
Vector< Size, Precision > unit(const Vector< Size, Precision, Base > &v)
TEXT_STYLE
different style for font rendering
void glTexImage2D(const SubImage< C > &i, GLint border=0, GLenum target=GL_TEXTURE_2D, GLint level=0)
unsigned char blue
The blue component.
void glMultMatrix(const TooN::Matrix< N, N, P, A > &m)
renders glyphs filled with antialiased outlines
const Matrix< 3, 3, Precision > & get_matrix() const
Returns the SO3 as a Matrix<3>
const Matrix< 2, 2, Precision > & get_matrix() const
Returns the SO2 as a Matrix<2>
void glLine(const P1 &x1, const P2 &x2)
renders glyphs as outlines with GL_LINES
void glColor4(const CVD::Rgb8 &c)
T blue
The blue component.