CVD 0.8
Classes | Modules | Functions
GL helper functions and classes.

Overloaded versions of GL functions to use CVD classes and datatypes, and other helpful GL classes and functions. More...

Classes

class  CVD::VideoDisplay
 A cheap and cheerful GL display window using X and the GLX library. More...

Modules

 OpenGL text rendering

Functions

void CVD::glVertex (const ImageRef &i)
void CVD::glTexCoord (const ImageRef &i)
void CVD::glRasterPos (const ImageRef &i)
void CVD::glRect (const ImageRef &p, const ImageRef &q)
void CVD::glVertex (const TooN::Vector< 2 > &v)
void CVD::glVertex (const TooN::Vector< 3 > &v)
void CVD::glVertex (const TooN::Vector< 4 > &v)
void CVD::glTexCoord (const TooN::Vector< 2 > &v)
void CVD::glTexCoord (const TooN::Vector< 3 > &v)
void CVD::glTexCoord (const TooN::Vector< 4 > &v)
void CVD::glRect (const TooN::Vector< 2 > &p, const TooN::Vector< 2 > &q)
void CVD::glRasterPos (const TooN::Vector< 2 > &v)
void CVD::glRasterPos (const TooN::Vector< 3 > &v)
void CVD::glRasterPos (const TooN::Vector< 4 > &v)
void CVD::glNormal (const TooN::Vector< 3 > &n)
void CVD::glTranslate (const ImageRef &v)
template<int N>
void CVD::glTranslate (const TooN::Vector< N > &v)
template<>
void CVD::glTranslate (const TooN::Vector< 2 > &v)
template<>
void CVD::glTranslate (const TooN::Vector< 1 > &v)
template<int N, class P , class A >
void CVD::glMultMatrix (const TooN::Matrix< N, N, P, A > &m)
template<class P , class A >
void CVD::glMultMatrix (const TooN::Matrix< 3, 3, P, A > &m)
template<class P , class A >
void CVD::glMultMatrix (const TooN::Matrix< 2, 2, P, A > &m)
template<typename P >
void CVD::glMultMatrix (const TooN::SO3< P > &so3)
template<typename P >
void CVD::glMultMatrix (const TooN::SE3< P > &se3)
template<typename P >
void CVD::glMultMatrix (const TooN::SO2< P > &so2)
template<typename P >
void CVD::glMultMatrix (const TooN::SE2< P > &se2)
template<typename P , typename A >
void CVD::glFrustum (const TooN::Vector< 4, P, A > &params, double width, double height, double nearPlane=0.1, double farPlane=100)
template<class CAMERA >
void CVD::glFrustum (const CAMERA &camera, double width, double height, double nearPlane=0.1, double farPlane=100)
void CVD::glColor (const TooN::Vector< 3 > &v)
void CVD::glColor (const TooN::Vector< 4 > &v)
void CVD::glClearColor (const TooN::Vector< 4 > &v)
void CVD::glClearColor (const TooN::Vector< 3 > &v)
void CVD::glColor (const TooN::Vector<-1 > &v)
template<class P1 , class P2 >
void CVD::glLine (const P1 &x1, const P2 &x2)
template<class C >
void CVD::glVertex (const C &list)
void CVD::glColor (const CVD::Rgb< byte > &c)
void CVD::glColor (const CVD::Rgb< float > &c)
void CVD::glColor3 (const CVD::Rgb8 &c)
void CVD::glColor4 (const CVD::Rgb8 &c)
void CVD::glColor (const CVD::Rgba< unsigned char > &c)
void CVD::glColor (const CVD::Rgba< float > &c)
template<class C >
void CVD::glDrawPixels (const SubImage< C > &i)
template<class C >
void CVD::glReadPixels (BasicImage< C > &i, ImageRef origin=ImageRef(0, 0))
template<class C >
Image< C > CVD::glReadPixels (ImageRef size, ImageRef origin=ImageRef(0, 0))
template<class C >
void CVD::glTexSubImage2D (const SubImage< C > &i, GLint xoffset=0, GLint yoffset=0, GLenum target=GL_TEXTURE_2D, GLint level=0)
template<class C >
void CVD::glTexImage2D (const SubImage< C > &i, GLint border=0, GLenum target=GL_TEXTURE_2D, GLint level=0)
void CVD::glPrintErrors (void)
template<int N, typename P , typename A >
void CVD::glTranslate (const TooN::Vector< N, P, A > &v)
template<typename P , typename A >
void CVD::glTranslate (const TooN::Vector< 2, P, A > &v)
template<typename P , typename A >
void CVD::glTranslate (const TooN::Vector< 1, P, A > &v)
template<typename P , typename A >
void CVD::glFrustum (const TooN::Vector< 4, P, A > &params, const float width, const float height, const float nearPlane=0.1, const float farPlane=100)
template<class CAMERA >
void CVD::glFrustum (const CAMERA &camera, const float width, const float height, const float nearPlane=0.1, const float farPlane=100)
template<typename P , typename A >
void CVD::glColor (const TooN::Vector< 3, P, A > &v)
template<typename P , typename A >
void CVD::glColor (const TooN::Vector< 4, P, A > &v)
template<typename P , typename A >
void CVD::glClearColor (const TooN::Vector< 4, P, A > &v)
template<typename P , typename A >
void CVD::glClearColor (const TooN::Vector< 3, P, A > &v)
template<typename P , typename A >
void CVD::glColor (const TooN::Vector<-1, P, A > &v)

Detailed Description

Overloaded versions of GL functions to use CVD classes and datatypes, and other helpful GL classes and functions.


Function Documentation

void CVD::glVertex ( const ImageRef &  i) [inline]

Specify the (x,y) co-ordinates of a vertex.

Parameters:
iThe vertex location

Definition at line 66 of file gl_helpers.h.

References CVD::ImageRef::x, and CVD::ImageRef::y.

Referenced by CVD::glLine(), and CVD::glVertex().

void CVD::glTexCoord ( const ImageRef &  i) [inline]

Specify the (s,t) texture co-ordinates.

Parameters:
iThe texture coordinates

Definition at line 74 of file gl_helpers.h.

References CVD::ImageRef::x, and CVD::ImageRef::y.

void CVD::glRasterPos ( const ImageRef &  i) [inline]

Specify the (x,y) co-ordinates of the current raster position.

Parameters:
iThe raster position

Definition at line 92 of file gl_helpers.h.

References CVD::ImageRef::x, and CVD::ImageRef::y.

void CVD::glRect ( const ImageRef &  p,
const ImageRef &  q 
) [inline]

Draws a rectangle by specifing two opposing vertices.

Parameters:
pthe first vertex
qthe second vertex

Definition at line 101 of file gl_helpers.h.

References CVD::ImageRef::x, and CVD::ImageRef::y.

void CVD::glVertex ( const TooN::Vector< 2 > &  v) [inline]

Specify the (x,y) co-ordinates of a vertex.

Parameters:
vThe vertex location

Definition at line 110 of file gl_helpers.h.

void CVD::glVertex ( const TooN::Vector< 3 > &  v) [inline]

Specify the (x,y,z) co-ordinates of a vertex.

Parameters:
vThe vertex location

Definition at line 118 of file gl_helpers.h.

void CVD::glVertex ( const TooN::Vector< 4 > &  v) [inline]

Specify the (x,y,z,w) co-ordinates of a vertex.

Parameters:
vThe vertex location

Definition at line 126 of file gl_helpers.h.

void CVD::glTexCoord ( const TooN::Vector< 2 > &  v) [inline]

Specify the (s,t) texture coordinates.

Parameters:
vThe texture coordinates

Definition at line 134 of file gl_helpers.h.

void CVD::glTexCoord ( const TooN::Vector< 3 > &  v) [inline]

Specify the (s,t,r) texture coordinates.

Parameters:
vThe texture coordinates

Definition at line 142 of file gl_helpers.h.

void CVD::glTexCoord ( const TooN::Vector< 4 > &  v) [inline]

Specify the (s,t,r,q) texture coordinates.

Parameters:
vThe texture coordinates

Definition at line 150 of file gl_helpers.h.

void CVD::glRect ( const TooN::Vector< 2 > &  p,
const TooN::Vector< 2 > &  q 
) [inline]

Draws a rectangle by specifing two opposing vertices.

Parameters:
pthe first vertex
qthe second vertex

Definition at line 159 of file gl_helpers.h.

void CVD::glRasterPos ( const TooN::Vector< 2 > &  v) [inline]

Specify the (x,y) co-ordinates of the current raster position.

Parameters:
vThe raster position

Definition at line 196 of file gl_helpers.h.

void CVD::glRasterPos ( const TooN::Vector< 3 > &  v) [inline]

Specify the (x,y,z) co-ordinates of the current raster position.

Parameters:
vThe raster position

Definition at line 204 of file gl_helpers.h.

void CVD::glRasterPos ( const TooN::Vector< 4 > &  v) [inline]

Specify the (x,y,z,w) co-ordinates of the current raster position.

Parameters:
vThe raster position

Definition at line 212 of file gl_helpers.h.

void CVD::glNormal ( const TooN::Vector< 3 > &  n) [inline]

Specify the current vertex normal.

Parameters:
nThe normal vector

Definition at line 220 of file gl_helpers.h.

void CVD::glTranslate ( const ImageRef &  v) [inline]

add a translation specified by an ImageRef

Parameters:
vthe translation ImageRef

Definition at line 228 of file gl_helpers.h.

References CVD::ImageRef::x, and CVD::ImageRef::y.

Referenced by CVD::glMultMatrix().

template<int N>
void CVD::glTranslate ( const TooN::Vector< N > &  v) [inline]

add a translation specified from the first three coordinates of a vector

Parameters:
vthe translation vector

Definition at line 236 of file gl_helpers.h.

template<>
void CVD::glTranslate ( const TooN::Vector< 2 > &  v) [inline]

add a translation specified from the first two coordinates of a 2-vector z is set to zero here

Parameters:
vthe translation vector

Definition at line 245 of file gl_helpers.h.

template<>
void CVD::glTranslate ( const TooN::Vector< 1 > &  v) [inline]

add a translation specified from the first coordinate of a 1-vector Y and Z are zero here

Parameters:
vthe translation vector

Definition at line 254 of file gl_helpers.h.

template<int N, class P , class A >
void CVD::glMultMatrix ( const TooN::Matrix< N, N, P, A > &  m) [inline]

multiply a TooN matrix onto the current matrix stack.

Works for matrizes of size n >= 4 and uses the upper left 4x4 submatrix. The matrix is also transposed to account for GL's column major format.

Parameters:
mthe transformation matrix

Definition at line 264 of file gl_helpers.h.

Referenced by CVD::glMultMatrix().

template<class P , class A >
void CVD::glMultMatrix ( const TooN::Matrix< 3, 3, P, A > &  m) [inline]

multiply a TooN 3x3 matrix onto the current matrix stack.

The GL matrix last column and row are set to 0 with the lower right element to 1. The matrix is also transposed to account for GL's column major format.

Parameters:
mthe transformation matrix

Definition at line 279 of file gl_helpers.h.

template<class P , class A >
void CVD::glMultMatrix ( const TooN::Matrix< 2, 2, P, A > &  m) [inline]

multiply a TooN 2x2 matrix onto the current matrix stack.

The TooN matrix will only occupy the upper left hand block, the remainder will be from the identity matrix. The matrix is also transposed to account for GL's column major format.

Parameters:
mthe transformation matrix

Definition at line 294 of file gl_helpers.h.

template<typename P >
void CVD::glMultMatrix ( const TooN::SO3< P > &  so3) [inline]

multiplies a SO3 onto the current matrix stack

Parameters:
so3the SO3

Definition at line 308 of file gl_helpers.h.

References CVD::glMultMatrix().

template<typename P >
void CVD::glMultMatrix ( const TooN::SE3< P > &  se3) [inline]

multiplies a SE3 onto the current matrix stack.

This multiplies the SO3 and the translation in order.

Parameters:
se3the SE3

Definition at line 318 of file gl_helpers.h.

References CVD::glMultMatrix(), and CVD::glTranslate().

template<typename P >
void CVD::glMultMatrix ( const TooN::SO2< P > &  so2) [inline]

multiplies a SO2 onto the current matrix stack

Parameters:
so2the SO2

Definition at line 328 of file gl_helpers.h.

References CVD::glMultMatrix().

template<typename P >
void CVD::glMultMatrix ( const TooN::SE2< P > &  se2) [inline]

multiplies a SE2 onto the current matrix stack.

This multiplies the SO2 and the translation in order.

Parameters:
se3the SE2

Definition at line 338 of file gl_helpers.h.

References CVD::glMultMatrix(), and CVD::glTranslate().

template<typename P , typename A >
void CVD::glFrustum ( const TooN::Vector< 4, P, A > &  params,
double  width,
double  height,
double  nearPlane = 0.1,
double  farPlane = 100 
) [inline]

sets a gl frustum from the linear camera parameters, image size and near and far plane.

The camera will be in OpenGL style with camera center in the origin and the viewing direction down the negative z axis, with y pointing upwards and x pointing to the left and the image plane at z=-1. Images coordinates need to be rotated around the x axis to make sense here, because typically the camera is described as y going down (pixel lines) and image plane at z=1.

Parameters:
paramsvector containing fu, fv, pu, pv as in the linear part of camera parameters
widthwidth of the image plane in pixels, here the viewport for example
heightheight of the image plane in pixels, here the viewport for example
nearnear clipping plane
farfar clipping plane

Definition at line 378 of file gl_helpers.h.

Referenced by CVD::glFrustum().

template<class CAMERA >
void CVD::glFrustum ( const CAMERA &  camera,
double  width,
double  height,
double  nearPlane = 0.1,
double  farPlane = 100 
) [inline]

sets a gl frustum taking the first 4 parameters from the camera model.

see

See also:
glFrustum for details on the created frustum.
Parameters:
cameracamera supplying the parameters for the frustum
widthwidth of the image plane in pixels, here the viewport for example
heightheight of the image plane in pixels, here the viewport for example
nearnear clipping plane
farfar clipping plane

Definition at line 396 of file gl_helpers.h.

References CVD::glFrustum().

void CVD::glColor ( const TooN::Vector< 3 > &  v) [inline]

Set the new colour to the red, green and blue components given in the Vector (where 0.0 represents zero intensity and 1.0 full intensity)

Parameters:
vThe new colour

Definition at line 414 of file gl_helpers.h.

void CVD::glColor ( const TooN::Vector< 4 > &  v) [inline]

Set the new colour to the red, green, blue and alpha components given in the Vector (where 0.0 represents zero intensity and 1.0 full intensity)

Parameters:
vThe new colour

Definition at line 423 of file gl_helpers.h.

void CVD::glClearColor ( const TooN::Vector< 4 > &  v) [inline]

Set the new clear colour to the red, green, blue and alpha components given in the Vector (where 0.0 represents zero intensity and 1.0 full intensity)

Parameters:
vThe new colour

Definition at line 432 of file gl_helpers.h.

Referenced by CVD::glClearColor().

void CVD::glClearColor ( const TooN::Vector< 3 > &  v) [inline]

Set the new clear colour to the red, green, blue components given in the Vector alpha is set to 0.

Parameters:
vThe new colour

Definition at line 441 of file gl_helpers.h.

References CVD::glClearColor().

void CVD::glColor ( const TooN::Vector<-1 > &  v) [inline]

glColor version for dynamic TooN::Vector, will test for 3 or 4 components

Parameters:
vThe new colour

Definition at line 451 of file gl_helpers.h.

template<class C >
void CVD::glVertex ( const C &  list) [inline]

sets a whole list of vertices stored in a std::vector.

It uses the various glVertex helpers defined in this header file.

Parameters:
listthe list of vertices

Definition at line 476 of file gl_helpers.h.

References CVD::glVertex().

void CVD::glColor ( const CVD::Rgb< byte > &  c) [inline]

Set the new colour to the red, green, blue components given (where 0 represents zero intensity and 255 full intensity)

Parameters:
cThe new colour

Definition at line 486 of file gl_helpers.h.

References CVD::Rgb< T >::blue, CVD::Rgb< T >::green, and CVD::Rgb< T >::red.

void CVD::glColor ( const CVD::Rgb< float > &  c) [inline]

Set the new colour to the red, green and blue components given (where 0.0 represents zero intensity and 1.0 full intensity)

Parameters:
cThe new colour

Definition at line 495 of file gl_helpers.h.

References CVD::Rgb< T >::blue, CVD::Rgb< T >::green, and CVD::Rgb< T >::red.

void CVD::glColor3 ( const CVD::Rgb8 c) [inline]

Set the new colour to the red, green and blue components given (where 0.0 represents zero intensity and 1.0 full intensity).

Set the new colour to the red, green and blue components given (where 0.0 represents zero intensity and 255 full intensity).

The Rgb8::dummy member is ignored

Parameters:
cThe new colour

Definition at line 504 of file gl_helpers.h.

References CVD::Rgb8::blue, CVD::Rgb8::green, and CVD::Rgb8::red.

void CVD::glColor4 ( const CVD::Rgb8 c) [inline]

Set the new colour to the red, green, blue and alpha components given (where 0.0 represents zero intensity and 1.0 full intensity)

Set the new colour to the red, green, blue and alpha components given (where 0.0 represents zero intensity and 255 full intensity)

Parameters:
cThe new colour

Definition at line 513 of file gl_helpers.h.

References CVD::Rgb8::blue, CVD::Rgb8::dummy, CVD::Rgb8::green, and CVD::Rgb8::red.

void CVD::glColor ( const CVD::Rgba< unsigned char > &  c) [inline]

Set the new colour to the red, green, blue and alpha components given (where 0 represents zero intensity and 255 full intensity)

Parameters:
cThe new colour

Definition at line 522 of file gl_helpers.h.

References CVD::Rgba< T >::alpha, CVD::Rgba< T >::blue, CVD::Rgba< T >::green, and CVD::Rgba< T >::red.

void CVD::glColor ( const CVD::Rgba< float > &  c) [inline]

Set the new colour to the red, green, blue and alpha components given (where 0.0 represents zero intensity and 1.0 full intensity)

Parameters:
cThe new colour

Definition at line 531 of file gl_helpers.h.

References CVD::Rgba< T >::alpha, CVD::Rgba< T >::blue, CVD::Rgba< T >::green, and CVD::Rgba< T >::red.

template<class C >
void CVD::glDrawPixels ( const SubImage< C > &  i) [inline]

Draw an image to the frame buffer at the current raster position.

Use glRasterPos to set the current raster position

Parameters:
iThe image to draw

Definition at line 558 of file gl_helpers.h.

References CVD::SubImage< T >::data(), CVD::SubImage< T >::row_stride(), CVD::SubImage< T >::size(), CVD::ImageRef::x, and CVD::ImageRef::y.

template<class C >
void CVD::glReadPixels ( BasicImage< C > &  i,
ImageRef  origin = ImageRef(0,0) 
) [inline]

Read the current image from the colour buffer specified by glReadBuffer.

Parameters:
iThe image to write the image data into. This must already be initialised to be an BasicImage (or Image) of the right size.
originThe window co-ordinate of the first pixel to be read from the frame buffer

Definition at line 570 of file gl_helpers.h.

References CVD::SubImage< T >::data(), CVD::SubImage< T >::size(), CVD::ImageRef::x, and CVD::ImageRef::y.

Referenced by CVD::glReadPixels().

template<class C >
Image< C > CVD::glReadPixels ( ImageRef  size,
ImageRef  origin = ImageRef(0,0) 
) [inline]

Read the current image from the colour buffer specified by glReadBuffer.

Parameters:
sizeThe size of the area to read.
originThe window co-ordinate of the first pixel to be read from the frame buffer

Definition at line 579 of file gl_helpers.h.

References CVD::SubImage< T >::data(), CVD::glReadPixels(), CVD::SubImage< T >::size(), CVD::ImageRef::x, and CVD::ImageRef::y.

template<class C >
void CVD::glTexSubImage2D ( const SubImage< C > &  i,
GLint  xoffset = 0,
GLint  yoffset = 0,
GLenum  target = GL_TEXTURE_2D,
GLint  level = 0 
) [inline]

Sets an image as a texture sub region.

note the reordering of the various parameters to make better use of default parameters

Parameters:
ithe image to set as texture

Definition at line 590 of file gl_helpers.h.

References CVD::SubImage< T >::data(), CVD::SubImage< T >::row_stride(), CVD::SubImage< T >::size(), CVD::ImageRef::x, and CVD::ImageRef::y.

template<class C >
void CVD::glTexImage2D ( const SubImage< C > &  i,
GLint  border = 0,
GLenum  target = GL_TEXTURE_2D,
GLint  level = 0 
) [inline]

Sets an image as a texture.

note the reordering of the various parameters to make better use of default parameters

Parameters:
ithe image to set as texture

Definition at line 602 of file gl_helpers.h.

References CVD::SubImage< T >::data(), CVD::SubImage< T >::row_stride(), CVD::SubImage< T >::size(), CVD::ImageRef::x, and CVD::ImageRef::y.

template<int N, typename P , typename A >
void CVD::glTranslate ( const TooN::Vector< N, P, A > &  v) [inline]

add a translation specified from the first three coordinates of a vector

Parameters:
vthe translation vector

Definition at line 61 of file gles1_helpers.h.

template<typename P , typename A >
void CVD::glTranslate ( const TooN::Vector< 2, P, A > &  v) [inline]

add a translation specified from the first two coordinates of a 2-vector z is set to zero here

Parameters:
vthe translation vector

Definition at line 70 of file gles1_helpers.h.

template<typename P , typename A >
void CVD::glTranslate ( const TooN::Vector< 1, P, A > &  v) [inline]

add a translation specified from the first coordinate of a 1-vector Y and Z are zero here

Parameters:
vthe translation vector

Definition at line 79 of file gles1_helpers.h.

template<typename P , typename A >
void CVD::glFrustum ( const TooN::Vector< 4, P, A > &  params,
const float  width,
const float  height,
const float  nearPlane = 0.1,
const float  farPlane = 100 
) [inline]

sets a gl frustum from the linear camera parameters, image size and near and far plane.

The camera will be in OpenGL style with camera center in the origin and the viewing direction down the negative z axis, with y pointing upwards and x pointing to the left and the image plane at z=-1. Images coordinates need to be rotated around the x axis to make sense here, because typically the camera is described as y going down (pixel lines) and image plane at z=1.

Parameters:
paramsvector containing fu, fv, pu, pv as in the linear part of camera parameters
widthwidth of the image plane in pixels, here the viewport for example
heightheight of the image plane in pixels, here the viewport for example
nearnear clipping plane
farfar clipping plane

Definition at line 203 of file gles1_helpers.h.

template<class CAMERA >
void CVD::glFrustum ( const CAMERA &  camera,
const float  width,
const float  height,
const float  nearPlane = 0.1,
const float  farPlane = 100 
) [inline]

sets a gl frustum taking the first 4 parameters from the camera model.

see

See also:
glFrustum for details on the created frustum.
Parameters:
cameracamera supplying the parameters for the frustum
widthwidth of the image plane in pixels, here the viewport for example
heightheight of the image plane in pixels, here the viewport for example
nearnear clipping plane
farfar clipping plane

Definition at line 221 of file gles1_helpers.h.

References CVD::glFrustum().

template<typename P , typename A >
void CVD::glColor ( const TooN::Vector< 3, P, A > &  v) [inline]

Set the new colour to the red, green and blue components given in the Vector (where 0.0 represents zero intensity and 1.0 full intensity)

Parameters:
vThe new colour

Definition at line 239 of file gles1_helpers.h.

template<typename P , typename A >
void CVD::glColor ( const TooN::Vector< 4, P, A > &  v) [inline]

Set the new colour to the red, green, blue and alpha components given in the Vector (where 0.0 represents zero intensity and 1.0 full intensity)

Parameters:
vThe new colour

Definition at line 248 of file gles1_helpers.h.

template<typename P , typename A >
void CVD::glClearColor ( const TooN::Vector< 4, P, A > &  v) [inline]

Set the new clear colour to the red, green, blue and alpha components given in the Vector (where 0.0 represents zero intensity and 1.0 full intensity)

Parameters:
vThe new colour

Definition at line 257 of file gles1_helpers.h.

References CVD::glClearColor().

template<typename P , typename A >
void CVD::glClearColor ( const TooN::Vector< 3, P, A > &  v) [inline]

Set the new clear colour to the red, green, blue components given in the Vector alpha is set to 1.

Parameters:
vThe new colour

Definition at line 266 of file gles1_helpers.h.

References CVD::glClearColor().

template<typename P , typename A >
void CVD::glColor ( const TooN::Vector<-1, P, A > &  v) [inline]

glColor version for dynamic TooN::Vector, will test for 3 or 4 components

Parameters:
vThe new colour

Definition at line 274 of file gles1_helpers.h.