libcvd
Modules | Classes | 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...

Collaboration diagram for GL helper functions and classes.:

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)
 Specify the (x,y) co-ordinates of a vertex. More...
 
void CVD::glTexCoord (const ImageRef &i)
 Specify the (s,t) texture co-ordinates. More...
 
void CVD::glRasterPos (const ImageRef &i)
 Specify the (x,y) co-ordinates of the current raster position. More...
 
void CVD::glRect (const ImageRef &p, const ImageRef &q)
 Draws a rectangle by specifing two opposing vertices. More...
 
template<class P1 , class P2 >
void CVD::glLine (const P1 &x1, const P2 &x2)
 draws a line from x1 to x2 any type that is accepted by glVertex is possible
 
template<class C >
void CVD::glVertex (const C &list)
 sets a whole list of vertices stored in a std::vector. More...
 
void CVD::glColor (const CVD::Rgb< byte > &c)
 Set the new colour to the red, green, blue components given (where 0 represents zero intensity and 255 full intensity) More...
 
void CVD::glColor (const CVD::Rgb< float > &c)
 Set the new colour to the red, green and blue components given (where 0.0 represents zero intensity and 1.0 full intensity) More...
 
void CVD::glColor3 (const CVD::Rgb8 &c)
 Set the new colour to the red, green and blue components given (where 0.0 represents zero intensity and 1.0 full intensity). More...
 
void CVD::glColor4 (const CVD::Rgb8 &c)
 Set the new colour to the red, green, blue and alpha components given (where 0.0 represents zero intensity and 1.0 full intensity) More...
 
void CVD::glColor (const CVD::Rgba< unsigned char > &c)
 Set the new colour to the red, green, blue and alpha components given (where 0 represents zero intensity and 255 full intensity) More...
 
void CVD::glColor (const CVD::Rgba< float > &c)
 Set the new colour to the red, green, blue and alpha components given (where 0.0 represents zero intensity and 1.0 full intensity) More...
 
template<class C >
void CVD::glDrawPixels (const BasicImage< C > &i)
 Draw an image to the frame buffer at the current raster position. More...
 
template<class C >
void CVD::glReadPixels (BasicImage< C > &i, ImageRef origin=ImageRef(0, 0))
 Read the current image from the colour buffer specified by glReadBuffer. More...
 
template<class C >
Image< C > CVD::glReadPixels (ImageRef size, ImageRef origin=ImageRef(0, 0))
 Read the current image from the colour buffer specified by glReadBuffer. More...
 
template<class C >
void CVD::glTexSubImage2D (const BasicImage< C > &i, GLint xoffset=0, GLint yoffset=0, GLenum target=GL_TEXTURE_2D, GLint level=0)
 Sets an image as a texture sub region. More...
 
template<class C >
void CVD::glTexImage2D (const BasicImage< C > &i, GLint border=0, GLenum target=GL_TEXTURE_2D, GLint level=0)
 Sets an image as a texture. More...
 
void CVD::glPrintErrors (void)
 Prints the current errors on the gl error stack.
 
void CVD::glTranslate (const ImageRef &v)
 add a translation specified by an ImageRef More...
 
template<int N, typename P , typename A >
void CVD::glTranslate (const TooN::Vector< N, P, A > &v)
 add a translation specified from the first three coordinates of a vector More...
 
template<typename P , typename A >
void CVD::glTranslate (const TooN::Vector< 2, P, A > &v)
 add a translation specified from the first two coordinates of a 2-vector z is set to zero here More...
 
template<typename P , typename A >
void CVD::glTranslate (const TooN::Vector< 1, P, A > &v)
 add a translation specified from the first coordinate of a 1-vector Y and Z are zero here More...
 
template<int N, class P , class A >
void CVD::glMultMatrix (const TooN::Matrix< N, N, P, A > &m)
 multiply a TooN matrix onto the current matrix stack. More...
 
template<class P , class A >
void CVD::glMultMatrix (const TooN::Matrix< 3, 3, P, A > &m)
 multiply a TooN 3x3 matrix onto the current matrix stack. More...
 
template<class P , class A >
void CVD::glMultMatrix (const TooN::Matrix< 2, 2, P, A > &m)
 multiply a TooN 2x2 matrix onto the current matrix stack. More...
 
template<typename P >
void CVD::glMultMatrix (const TooN::SO3< P > &so3)
 multiplies a SO3 onto the current matrix stack More...
 
template<typename P >
void CVD::glMultMatrix (const TooN::SE3< P > &se3)
 multiplies a SE3 onto the current matrix stack. More...
 
template<typename P >
void CVD::glMultMatrix (const TooN::SO2< P > &so2)
 multiplies a SO2 onto the current matrix stack More...
 
template<typename P >
void CVD::glMultMatrix (const TooN::SE2< P > &se2)
 multiplies a SE2 onto the current matrix stack. More...
 
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)
 sets a gl frustum from the linear camera parameters, image size and near and far plane. More...
 
template<class CAMERA >
void CVD::glFrustum (const CAMERA &camera, const float width, const float height, const float nearPlane=0.1, const float farPlane=100)
 sets a gl frustum taking the first 4 parameters from the camera model. More...
 
template<typename P , typename A >
void CVD::glColor (const TooN::Vector< 3, P, A > &v)
 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) More...
 
template<typename P , typename A >
void CVD::glColor (const TooN::Vector< 4, P, A > &v)
 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) More...
 
template<typename P , typename A >
void CVD::glClearColor (const TooN::Vector< 4, P, A > &v)
 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) More...
 
template<typename P , typename A >
void CVD::glClearColor (const TooN::Vector< 3, P, A > &v)
 Set the new clear colour to the red, green, blue components given in the Vector alpha is set to 1. More...
 
template<typename P , typename A >
void CVD::glColor (const TooN::Vector<-1, P, A > &v)
 glColor version for dynamic TooN::Vector, will test for 3 or 4 components More...
 
template<class C >
void CVD::glTexBasicImage2D (const BasicImage< C > &i, GLint xoffset=0, GLint yoffset=0, GLenum target=GL_TEXTURE_2D, GLint level=0)
 Sets an image as a texture sub region. More...
 

Detailed Description

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

Function Documentation

◆ glClearColor() [1/2]

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

◆ glClearColor() [2/2]

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

◆ glColor() [1/7]

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

◆ glColor() [2/7]

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

◆ glColor() [3/7]

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

◆ glColor() [4/7]

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

◆ glColor() [5/7]

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

◆ glColor() [6/7]

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

◆ glColor() [7/7]

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

◆ glColor3()

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

◆ glColor4()

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

◆ glDrawPixels()

template<class C >
void CVD::glDrawPixels ( const BasicImage< 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

◆ glFrustum() [1/2]

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

◆ glFrustum() [2/2]

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

◆ glMultMatrix() [1/7]

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

◆ glMultMatrix() [2/7]

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

◆ glMultMatrix() [3/7]

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

◆ glMultMatrix() [4/7]

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

multiplies a SO3 onto the current matrix stack

Parameters
so3the SO3

◆ glMultMatrix() [5/7]

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

◆ glMultMatrix() [6/7]

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

multiplies a SO2 onto the current matrix stack

Parameters
so2the SO2

◆ glMultMatrix() [7/7]

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

◆ glRasterPos()

void CVD::glRasterPos ( const ImageRef i)
inline

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

Parameters
iThe raster position

◆ glReadPixels() [1/2]

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

◆ glReadPixels() [2/2]

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

◆ glRect()

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

◆ glTexBasicImage2D()

template<class C >
void CVD::glTexBasicImage2D ( const BasicImage< 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

◆ glTexCoord()

void CVD::glTexCoord ( const ImageRef i)
inline

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

Parameters
iThe texture coordinates

◆ glTexImage2D()

template<class C >
void CVD::glTexImage2D ( const BasicImage< 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

◆ glTexSubImage2D()

template<class C >
void CVD::glTexSubImage2D ( const BasicImage< 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

◆ glTranslate() [1/4]

void CVD::glTranslate ( const ImageRef v)
inline

add a translation specified by an ImageRef

Parameters
vthe translation ImageRef

◆ glTranslate() [2/4]

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

◆ glTranslate() [3/4]

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

◆ glTranslate() [4/4]

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

◆ glVertex() [1/2]

void CVD::glVertex ( const ImageRef i)
inline

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

Parameters
iThe vertex location

◆ glVertex() [2/2]

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