GL helper functions and classes.


Detailed Description

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


Modules

 OpenGL text rendering

Classes

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

Functions

void CVD::glVertex (const ImageRef &i)
void CVD::glTexCoord (const ImageRef &i)
void CVD::glRasterPos (const ImageRef &i)
template<class P1, class P2>
void CVD::glLine (const P1 &x1, const P2 &x2)
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::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 A>
void CVD::glMultMatrix (const TooN::FixedMatrix< N, N, A > &m)
template<class A>
void CVD::glMultMatrix (const TooN::FixedMatrix< 3, 3, A > &m)
template<class A>
void CVD::glMultMatrix (const TooN::FixedMatrix< 2, 2, A > &m)
void CVD::glMultMatrix (const CVD::SO3 &so3)
void CVD::glMultMatrix (const CVD::SE3 &se3)
void CVD::glMultMatrix (const CVD::SO2 &so2)
void CVD::glMultMatrix (const CVD::SE2 &se2)
template<class A>
void CVD::glFrustum (const TooN::FixedVector< 4, A > &params, double width, double height, double near=0.1, double far=100)
template<class CAMERA>
void CVD::glFrustum (const CAMERA &camera, double width, double height, double near=0.1, double far=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 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)


Function Documentation

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

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

Parameters:
i The vertex location

Definition at line 56 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:
i The texture coordinates

Definition at line 64 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:
i The raster position

Definition at line 82 of file gl_helpers.h.

template<class P1, class P2>
void CVD::glLine ( const P1 &  x1,
const P2 &  x2 
) [inline]

draws a line from x1 to x2 any type that is accepted by glVertex is possible

Definition at line 90 of file gl_helpers.h.

References CVD::glVertex().

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

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

Parameters:
v The vertex location

Definition at line 101 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:
v The vertex location

Definition at line 109 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:
v The vertex location

Definition at line 117 of file gl_helpers.h.

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

Specify the (s,t) texture coordinates.

Parameters:
v The texture coordinates

Definition at line 125 of file gl_helpers.h.

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

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

Parameters:
v The texture coordinates

Definition at line 133 of file gl_helpers.h.

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

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

Parameters:
v The texture coordinates

Definition at line 141 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:
v The raster position

Definition at line 178 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:
v The raster position

Definition at line 186 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:
v The raster position

Definition at line 194 of file gl_helpers.h.

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

Specify the current vertex normal.

Parameters:
n The normal vector

Definition at line 202 of file gl_helpers.h.

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

add a translation specified by an ImageRef

Parameters:
v the translation ImageRef

Definition at line 210 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:
v the translation vector

Definition at line 218 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:
v the translation vector

Definition at line 227 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:
v the translation vector

Definition at line 236 of file gl_helpers.h.

template<int N, class A>
void CVD::glMultMatrix ( const TooN::FixedMatrix< N, N, 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:
m the transformation matrix

Definition at line 246 of file gl_helpers.h.

Referenced by CVD::glMultMatrix().

template<class A>
void CVD::glMultMatrix ( const TooN::FixedMatrix< 3, 3, 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:
m the transformation matrix

Definition at line 261 of file gl_helpers.h.

template<class A>
void CVD::glMultMatrix ( const TooN::FixedMatrix< 2, 2, 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:
m the transformation matrix

Definition at line 276 of file gl_helpers.h.

void CVD::glMultMatrix ( const CVD::SO3 &  so3  )  [inline]

multiplies a SO3 onto the current matrix stack

Parameters:
so3 the SO3

Definition at line 289 of file gl_helpers.h.

References CVD::glMultMatrix().

void CVD::glMultMatrix ( const CVD::SE3 &  se3  )  [inline]

multiplies a SE3 onto the current matrix stack.

This multiplies the SO3 and the translation in order.

Parameters:
se3 the SE3

Definition at line 298 of file gl_helpers.h.

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

void CVD::glMultMatrix ( const CVD::SO2 &  so2  )  [inline]

multiplies a SO2 onto the current matrix stack

Parameters:
so2 the SO2

Definition at line 307 of file gl_helpers.h.

References CVD::glMultMatrix().

void CVD::glMultMatrix ( const CVD::SE2 &  se2  )  [inline]

multiplies a SE2 onto the current matrix stack.

This multiplies the SO2 and the translation in order.

Parameters:
se3 the SE2

Definition at line 316 of file gl_helpers.h.

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

template<class A>
void CVD::glFrustum ( const TooN::FixedVector< 4, A > &  params,
double  width,
double  height,
double  near = 0.1,
double  far = 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:
params vector containing fu, fv, pu, pv as in the linear part of camera parameters
width width of the image plane in pixels, here the viewport for example
height height of the image plane in pixels, here the viewport for example
near near clipping plane
far far clipping plane

Definition at line 356 of file gl_helpers.h.

Referenced by CVD::glFrustum().

template<class CAMERA>
void CVD::glFrustum ( const CAMERA &  camera,
double  width,
double  height,
double  near = 0.1,
double  far = 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:
camera camera supplying the parameters for the frustum
width width of the image plane in pixels, here the viewport for example
height height of the image plane in pixels, here the viewport for example
near near clipping plane
far far clipping plane

Definition at line 374 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:
v The new colour

Definition at line 392 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:
v The new colour

Definition at line 401 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:
v The new colour

Definition at line 410 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:
v The new colour

Definition at line 419 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:
v The new colour

Definition at line 429 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:
list the list of vertices

Definition at line 444 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:
c The new colour

Definition at line 454 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:
c The new colour

Definition at line 463 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).

The Rgb8::dummy member is ignored

Parameters:
c The new colour

Definition at line 472 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).

Parameters:
c The new colour

Definition at line 481 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:
c The new colour

Definition at line 490 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:
c The new colour

Definition at line 499 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:
i The image to draw

Definition at line 508 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:
i The image to write the image data into. This must already be initialised to be an BasicImage (or Image) of the right size.
origin The window co-ordinate of the first pixel to be read from the frame buffer

Definition at line 520 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:
size The size of the area to read.
origin The window co-ordinate of the first pixel to be read from the frame buffer

Definition at line 529 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:
i the image to set as texture

Definition at line 540 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:
i the image to set as texture

Definition at line 552 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.

void CVD::glPrintErrors ( void   )  [inline]

Prints the current errors on the gl error stack.

Definition at line 562 of file gl_helpers.h.


Generated on Wed Feb 18 10:23:03 2009 for CVD by  doxygen 1.5.3