CMSC23700 Common Code Library
Support code for CS23700 programming projects
cs237 Namespace Reference

Namespaces

 __detail
 

Classes

struct  color3f
 
struct  color3ub
 
struct  color4f
 
struct  color4ub
 
class  FragmentShader
 
class  GeometryShader
 
class  image1d
 
class  image2d
 
class  ShaderProgram
 
struct  Sphere
 A spherical mesh. More...
 
class  texture1D
 wrapper class for OpenGL 1D textures More...
 
class  texture2D
 wrapper class for OpenGL 2D textures More...
 
class  VertexShader
 
class  Window
 abstract base class for simple GLFW windows used to view buffers, etc. More...
 

Typedefs

typedef __detail::AABB< float > AABBf
 Single-precision axis-aligned bounding boxes. More...
 
typedef __detail::AABB< double > AABBd
 Double-precision axis-aligned bounding boxes. More...
 
typedef __detail::mat2x2< float > mat2x2f
 Single-precision 2x2 matrices. More...
 
typedef __detail::mat2x2< double > mat2x2d
 Double-precision 2x2 matrices. More...
 
typedef mat2x2f mat2f
 Single-precision 2x2 matrices (the same as mat2x2f) More...
 
typedef mat2x2d mat2d
 Double-precision 2x2 matrices (the same as mat2x2d) More...
 
typedef __detail::mat2x3< float > mat2x3f
 Single-precision 2x3 matrices. More...
 
typedef __detail::mat2x3< double > mat2x3d
 Double-precision 2x3 matrices. More...
 
typedef __detail::mat3x2< float > mat3x2f
 Single-precision 3x2 matrices. More...
 
typedef __detail::mat3x2< double > mat3x2d
 Double-precision 3x2 matrices. More...
 
typedef __detail::mat3x3< float > mat3x3f
 Single-precision 3x3 matrices. More...
 
typedef __detail::mat3x3< double > mat3x3d
 Double-precision 3x3 matrices. More...
 
typedef mat3x3f mat3f
 Single-precision 3x3 matrices (the same as mat3x3f) More...
 
typedef mat3x3d mat3d
 Double-precision 3x3 matrices (the same as mat3x3f) More...
 
typedef __detail::mat4x4< float > mat4x4f
 Single-precision 4x4 matrices. More...
 
typedef __detail::mat4x4< double > mat4x4d
 Double-precision 4x4 matrices. More...
 
typedef mat4x4f mat4f
 Single-precision 4x4 matrices (the same as mat4x4f) More...
 
typedef mat4x4d mat4d
 Double-precision 4x4 matrices (the same as mat4x4d) More...
 
typedef __detail::quat< float > quatf
 Single-precision quaternions. More...
 
typedef __detail::quat< double > quatd
 Double-precision quaternions. More...
 
typedef __detail::vec2< float > vec2f
 Two-element, single-precision floating-point vectors. More...
 
typedef __detail::vec2< double > vec2d
 Two-element, double-precision floating-point vectors. More...
 
typedef __detail::vec3< float > vec3f
 Three-element, single-precision floating-point vectors. More...
 
typedef __detail::vec3< double > vec3d
 Three-element, double-precision floating-point vectors. More...
 
typedef __detail::vec4< float > vec4f
 Four-element, single-precision floating-point vectors. More...
 
typedef __detail::vec4< double > vec4d
 Four-element, double-precision floating-point vectors. More...
 

Functions

std::ostream & operator<< (std::ostream &s, color3ub const &c)
 output the color to a stream More...
 
std::ostream & operator<< (std::ostream &s, color4ub const &c)
 output the color to a stream More...
 
std::ostream & operator<< (std::ostream &s, color3f const &c)
 output the color to a stream More...
 
std::ostream & operator<< (std::ostream &s, color4f const &c)
 output the color to a stream More...
 
color3f operator+ (color3f const &c1, color3f const &c2)
 
color3f operator- (color3f const &c1, color3f const &c2)
 
color3f operator* (color3f const &c1, color3f const &c2)
 
color3f mix (color3f const &c1, float t, color3f const &c2)
 
void setUniform (int loc, int const &v)
 
void setUniform (int loc, int const &v1, int const &v2)
 
void setUniform (int loc, int const &v1, int const &v2, int const &v3)
 
void setUniform (int loc, int const &v1, int const &v2, int const &v3, int const &v4)
 
void setUniform (int loc, unsigned int const &v)
 
void setUniform (int loc, unsigned int const &v1, unsigned int const &v2)
 
void setUniform (int loc, unsigned int const &v1, unsigned int const &v2, unsigned int const &v3)
 
void setUniform (int loc, unsigned int const &v1, unsigned int const &v2, unsigned int const &v3, unsigned int const &v4)
 
void setUniform (int loc, float const &v)
 
void setUniform (int loc, vec2f const &v)
 
void setUniform (int loc, vec3f const &v)
 
void setUniform (int loc, vec4f const &v)
 
void setUniform (int loc, mat2x2f const &v)
 
void setUniform (int loc, mat3x3f const &v)
 
void setUniform (int loc, mat4x4f const &v)
 
void setUniform (int loc, color3ub const &v)
 
void setUniform (int loc, color3f const &v)
 
void setUniform (int loc, color4ub const &v)
 
void setUniform (int loc, color4f const &v)
 
void setAttribute (int loc, int const &v)
 
void setAttribute (int loc, unsigned int const &v)
 
void setAttribute (int loc, float const &v)
 
void setAttribute (int loc, vec2f const &v)
 
void setAttribute (int loc, vec3f const &v)
 
void setAttribute (int loc, vec4f const &v)
 
template<typename T >
__detail::mat4x4< T > scale (T s)
 
template<typename T >
__detail::mat4x4< T > scale (__detail::mat4x4< T > const &m, T s)
 
template<typename T >
__detail::mat4x4< T > scale (__detail::vec3< T > const &s)
 
template<typename T >
__detail::mat4x4< T > scale (__detail::mat4x4< T > const &m, __detail::vec3< T > const &s)
 
template<typename T >
__detail::mat4x4< T > rotateX (T theta)
 
template<typename T >
__detail::mat4x4< T > rotateX (__detail::mat4x4< T > const &m, T theta)
 
template<typename T >
__detail::mat4x4< T > rotateY (T theta)
 
template<typename T >
__detail::mat4x4< T > rotateY (__detail::mat4x4< T > const &m, T theta)
 
template<typename T >
__detail::mat4x4< T > rotateZ (T theta)
 
template<typename T >
__detail::mat4x4< T > rotateZ (__detail::mat4x4< T > const &m, T theta)
 
template<typename T >
__detail::mat4x4< T > rotate (T theta, __detail::vec3< T > const &axis)
 
template<typename T >
__detail::mat4x4< T > rotate (__detail::mat4x4< T > const &m, T theta, __detail::vec3< T > const &axis)
 
template<typename T >
__detail::mat4x4< T > translate (__detail::vec3< T > const &offset)
 
template<typename T >
__detail::mat4x4< T > translate (__detail::mat4x4< T > const &m, __detail::vec3< T > const &offset)
 
template<typename T >
__detail::mat4x4< T > lookAt (__detail::vec3< T > const &eye, __detail::vec3< T > const &center, __detail::vec3< T > const &up)
 build a a viewing matrix derived from an eye point, a reference point indicating the center of the scene, and an up vector. More...
 
template<typename T >
__detail::mat4x4< T > ortho (T const &left, T const &right, T const &bottom, T const &top, T const &nearVal, T const &farVal)
 
template<typename T >
__detail::mat4x4< T > ortho2D (T const &left, T const &right, T const &bottom, T const &top)
 set up a transformation matrix that produces two-dimensional orthographic viewing region More...
 
template<typename T >
__detail::mat4x4< T > perspective (T const &fov, T const &aspect, T const &zNear, T const &zFar)
 specifies a perspective projection matrix More...
 
template<typename T >
__detail::mat4x4< T > frustum (T const &left, T const &right, T const &bottom, T const &top, T const &nearVal, T const &farVal)
 specifies a viewing frustum into the world coordinate system More...
 
float clamp (float f)
 clamp a value to the range [0..1]. More...
 
double clamp (double f)
 clamp a value to the range [0..1]. More...
 
float radians (float theta)
 convert an angle from degrees to radians More...
 
double radians (double theta)
 convert an angle from degrees to radians More...
 
float degrees (float theta)
 convert an angle from radians to degrees More...
 
double degrees (double theta)
 convert an angle from radians to degrees More...
 
float mix (float a, float t, float b)
 scalar linear interpolation More...
 
double mix (double a, double t, double b)
 scalar linear interpolation More...
 
int min (int a, int b)
 minimum at various types More...
 
float min (float a, float b)
 
double min (double a, double b)
 
int max (int a, int b)
 maximum at various types More...
 
float max (float a, float b)
 
double max (double a, double b)
 
int abs (int a)
 absolute value at various types More...
 
float abs (float a)
 
double abs (double a)
 
vec2f toFloat (vec2d const &v)
 
vec3f toFloat (vec3d const &v)
 
vec4f toFloat (vec4d const &v)
 
vec2d toDouble (vec2f const &v)
 
vec3d toDouble (vec3f const &v)
 
vec4d toDouble (vec4f const &v)
 
void DumpGLState (std::ostream &os)
 

Typedef Documentation

typedef __detail::AABB<double> cs237::AABBd

Double-precision axis-aligned bounding boxes.

typedef __detail::AABB<float> cs237::AABBf

Single-precision axis-aligned bounding boxes.

Double-precision 2x2 matrices (the same as mat2x2d)

Single-precision 2x2 matrices (the same as mat2x2f)

Double-precision 2x2 matrices.

Single-precision 2x2 matrices.

Double-precision 2x3 matrices.

Single-precision 2x3 matrices.

Double-precision 3x3 matrices (the same as mat3x3f)

Single-precision 3x3 matrices (the same as mat3x3f)

Double-precision 3x2 matrices.

Single-precision 3x2 matrices.

Double-precision 3x3 matrices.

Single-precision 3x3 matrices.

Double-precision 4x4 matrices (the same as mat4x4d)

Single-precision 4x4 matrices (the same as mat4x4f)

Double-precision 4x4 matrices.

Single-precision 4x4 matrices.

typedef __detail::quat<double> cs237::quatd

Double-precision quaternions.

typedef __detail::quat<float> cs237::quatf

Single-precision quaternions.

typedef __detail::vec2<double> cs237::vec2d

Two-element, double-precision floating-point vectors.

typedef __detail::vec2<float> cs237::vec2f

Two-element, single-precision floating-point vectors.

typedef __detail::vec3<double> cs237::vec3d

Three-element, double-precision floating-point vectors.

typedef __detail::vec3<float> cs237::vec3f

Three-element, single-precision floating-point vectors.

typedef __detail::vec4<double> cs237::vec4d

Four-element, double-precision floating-point vectors.

typedef __detail::vec4<float> cs237::vec4f

Four-element, single-precision floating-point vectors.

Function Documentation

int cs237::abs ( int  a)
inline

absolute value at various types

float cs237::abs ( float  a)
inline
double cs237::abs ( double  a)
inline
float cs237::clamp ( float  f)
inline

clamp a value to the range [0..1].

Parameters
fthe value to clamp
Returns
the clamped value
double cs237::clamp ( double  f)
inline

clamp a value to the range [0..1].

Parameters
fthe value to clamp
Returns
the clamped value
float cs237::degrees ( float  theta)
inline

convert an angle from radians to degrees

Parameters
thetathe angle to convert
Returns
the angle in degrees
double cs237::degrees ( double  theta)
inline

convert an angle from radians to degrees

Parameters
thetathe angle to convert
Returns
the angle in degrees
void cs237::DumpGLState ( std::ostream &  os)

Dump the current OpenGL state to the given output stream

Parameters
osthe output stream to dump the state to

This function dumps partial information about the current state of OpenGL to an output stream. The information includes things like the current VAO. There is lots of information that is not dumped.

template<typename T >
__detail::mat4x4<T> cs237::frustum ( T const &  left,
T const &  right,
T const &  bottom,
T const &  top,
T const &  nearVal,
T const &  farVal 
)

specifies a viewing frustum into the world coordinate system

template<typename T >
__detail::mat4x4<T> cs237::lookAt ( __detail::vec3< T > const &  eye,
__detail::vec3< T > const &  center,
__detail::vec3< T > const &  up 
)

build a a viewing matrix derived from an eye point, a reference point indicating the center of the scene, and an up vector.

Parameters
[in]eyespecifies the position of the eye point
[in]centerspecifies the point that is being looked at
[in]upspecifies the up direction of the viewer
int cs237::max ( int  a,
int  b 
)
inline

maximum at various types

float cs237::max ( float  a,
float  b 
)
inline
double cs237::max ( double  a,
double  b 
)
inline
int cs237::min ( int  a,
int  b 
)
inline

minimum at various types

float cs237::min ( float  a,
float  b 
)
inline
double cs237::min ( double  a,
double  b 
)
inline
float cs237::mix ( float  a,
float  t,
float  b 
)
inline

scalar linear interpolation

Parameters
avalue for t = 0
tinterpolation factor
bvalue for t = 1
double cs237::mix ( double  a,
double  t,
double  b 
)
inline

scalar linear interpolation

Parameters
avalue for t = 0
tinterpolation factor
bvalue for t = 10
color3f cs237::mix ( color3f const &  c1,
float  t,
color3f const &  c2 
)
inline
color3f cs237::operator* ( color3f const &  c1,
color3f const &  c2 
)
inline
color3f cs237::operator+ ( color3f const &  c1,
color3f const &  c2 
)
inline
color3f cs237::operator- ( color3f const &  c1,
color3f const &  c2 
)
inline
std::ostream& cs237::operator<< ( std::ostream &  s,
color3ub const &  c 
)

output the color to a stream

Parameters
sthe stream to print to
cthe color to print
std::ostream& cs237::operator<< ( std::ostream &  s,
color4ub const &  c 
)

output the color to a stream

Parameters
sthe stream to print to
cthe color to print
std::ostream& cs237::operator<< ( std::ostream &  s,
color3f const &  c 
)

output the color to a stream

Parameters
sthe stream to print to
cthe color to print
std::ostream& cs237::operator<< ( std::ostream &  s,
color4f const &  c 
)

output the color to a stream

Parameters
sthe stream to print to
cthe color to print
template<typename T >
__detail::mat4x4<T> cs237::ortho ( T const &  left,
T const &  right,
T const &  bottom,
T const &  top,
T const &  nearVal,
T const &  farVal 
)

set up a transformation matrix that produces a parallel projection

Parameters
leftspecify the coordinates for the left vertical clipping plane
rightspecify the coordinates for the right vertical clipping plane
bottomspecify the coordinates for the bottom horizontal clipping plane
topspecify the coordinates for the top horizontal clipping plane
nearValspecify the distance to the nearer depth clipping plane
farValspecify the distance to the farther depth clipping plane

The nearVal and farVal values are negative if the plane is to be behind the viewer.

template<typename T >
__detail::mat4x4<T> cs237::ortho2D ( T const &  left,
T const &  right,
T const &  bottom,
T const &  top 
)

set up a transformation matrix that produces two-dimensional orthographic viewing region

template<typename T >
__detail::mat4x4<T> cs237::perspective ( T const &  fov,
T const &  aspect,
T const &  zNear,
T const &  zFar 
)

specifies a perspective projection matrix

Parameters
[in]fovthe vertical field of view; i.e., the angle in degrees between the XZ plane and the top of the vew frustum.
[in]aspectthe aspect ratio (width/height)
[in]zNearthe distance from the viewer to the near clipping plane
[in]zFarthe distance from the viewer to the far clipping plane
float cs237::radians ( float  theta)
inline

convert an angle from degrees to radians

Parameters
thetathe angle to convert
Returns
the angle in radians
double cs237::radians ( double  theta)
inline

convert an angle from degrees to radians

Parameters
thetathe angle to convert
Returns
the angle in radians
template<typename T >
__detail::mat4x4<T> cs237::rotate ( theta,
__detail::vec3< T > const &  axis 
)

create a rotation about an arbitrary axis matrix

Parameters
thetathe angle of rotation in degrees
axisthe axis of rotation
template<typename T >
__detail::mat4x4<T> cs237::rotate ( __detail::mat4x4< T > const &  m,
theta,
__detail::vec3< T > const &  axis 
)

apply a rotation about an arbitrary axis to a matrix

Parameters
mthe matrix to transform
thetathe angle of rotation in degrees
axisthe axis of rotation
template<typename T >
__detail::mat4x4<T> cs237::rotateX ( theta)

create a rotation about the X axis matrix

Parameters
thetathe angle of rotation in degrees
template<typename T >
__detail::mat4x4<T> cs237::rotateX ( __detail::mat4x4< T > const &  m,
theta 
)

apply rotation about the X axis matrix to a matrix

Parameters
mthe matrix to transform
thetathe angle of rotation in degrees

The expression cs237::rotateX(m, theta) is equivalent to m * cs237::rotateX(theta)

template<typename T >
__detail::mat4x4<T> cs237::rotateY ( theta)

create a rotation about the Y axis matrix

Parameters
thetathe angle of rotation in degrees
template<typename T >
__detail::mat4x4<T> cs237::rotateY ( __detail::mat4x4< T > const &  m,
theta 
)

apply rotation about the Y axis matrix to a matrix

Parameters
mthe matrix to transform
thetathe angle of rotation in degrees

The expression cs237::rotateY(m, theta) is equivalent to m * cs237::rotateY(theta)

template<typename T >
__detail::mat4x4<T> cs237::rotateZ ( theta)

create a rotation about the Z axis matrix

Parameters
thetathe angle of rotation in degrees
template<typename T >
__detail::mat4x4<T> cs237::rotateZ ( __detail::mat4x4< T > const &  m,
theta 
)

apply rotation about the Z axis matrix to a matrix

Parameters
mthe matrix to transform
thetathe angle of rotation in degrees

The expression cs237::rotateZ(m, theta) is equivalent to m * cs237::rotateZ(theta)

template<typename T >
__detail::mat4x4<T> cs237::scale ( s)

create an isotropic (uniform) scaling matrix

Parameters
sthe scaling factor
template<typename T >
__detail::mat4x4<T> cs237::scale ( __detail::mat4x4< T > const &  m,
s 
)

apply isotropic (uniform) scaling to a matrix

Parameters
mthe matrix to transform
sthe scaling factor

The expression cs237::scale(m, s) is equivalent to m * cs237::scale(s)

template<typename T >
__detail::mat4x4<T> cs237::scale ( __detail::vec3< T > const &  s)

create an anisotropic (non-uniform) scaling matrix

Parameters
sthe vector of scaling factors
template<typename T >
__detail::mat4x4<T> cs237::scale ( __detail::mat4x4< T > const &  m,
__detail::vec3< T > const &  s 
)

apply anisotropic (non-uniform) scaling to a matrix

Parameters
mthe matrix to transform
sthe vector of scaling factors

The expression cs237::scale(m, s) is equivalent to m * cs237::scale(s)

void cs237::setAttribute ( int  loc,
int const &  v 
)
inline
void cs237::setAttribute ( int  loc,
unsigned int const &  v 
)
inline
void cs237::setAttribute ( int  loc,
float const &  v 
)
inline
void cs237::setAttribute ( int  loc,
vec2f const &  v 
)
inline
void cs237::setAttribute ( int  loc,
vec3f const &  v 
)
inline
void cs237::setAttribute ( int  loc,
vec4f const &  v 
)
inline
void cs237::setUniform ( int  loc,
int const &  v 
)
inline

set the specified int uniform variable for current shader

Parameters
locthe location of the uniform variable
vthe integer value bound to the variable
void cs237::setUniform ( int  loc,
int const &  v1,
int const &  v2 
)
inline

set the specified int2 uniform variable for current shader

Parameters
locthe location of the uniform variable
v1the first component of the vector bound to the variable
v2the second component of the vector bound to the variable
void cs237::setUniform ( int  loc,
int const &  v1,
int const &  v2,
int const &  v3 
)
inline

set the specified int3 uniform variable for current shader

Parameters
locthe location of the uniform variable
v1the first component of the vector bound to the variable
v2the second component of the vector bound to the variable
v3the third component of the vector bound to the variable
void cs237::setUniform ( int  loc,
int const &  v1,
int const &  v2,
int const &  v3,
int const &  v4 
)
inline

set the specified int4 uniform variable for current shader

Parameters
locthe location of the uniform variable
v1the first component of the vector bound to the variable
v2the second component of the vector bound to the variable
v3the third component of the vector bound to the variable
v4the fourth component of the vector bound to the variable
void cs237::setUniform ( int  loc,
unsigned int const &  v 
)
inline

set the specified unsigned int uniform variable for current shader

Parameters
locthe location of the uniform variable
vthe unsigned integer value bound to the variable
void cs237::setUniform ( int  loc,
unsigned int const &  v1,
unsigned int const &  v2 
)
inline

set the specified uint2 uniform variable for current shader

Parameters
locthe location of the uniform variable
v1the first component of the vector bound to the variable
v2the second component of the vector bound to the variable
void cs237::setUniform ( int  loc,
unsigned int const &  v1,
unsigned int const &  v2,
unsigned int const &  v3 
)
inline

set the specified uint3 uniform variable for current shader

Parameters
locthe location of the uniform variable
v1the first component of the vector bound to the variable
v2the second component of the vector bound to the variable
v3the third component of the vector bound to the variable
void cs237::setUniform ( int  loc,
unsigned int const &  v1,
unsigned int const &  v2,
unsigned int const &  v3,
unsigned int const &  v4 
)
inline

set the specified uint4 uniform variable for current shader

Parameters
locthe location of the uniform variable
v1the first component of the vector bound to the variable
v2the second component of the vector bound to the variable
v3the third component of the vector bound to the variable
v4the fourth component of the vector bound to the variable
void cs237::setUniform ( int  loc,
float const &  v 
)
inline

set the specified float uniform variable for current shader

Parameters
locthe location of the uniform variable
vthe float value bound to the variable
void cs237::setUniform ( int  loc,
vec2f const &  v 
)
inline
void cs237::setUniform ( int  loc,
vec3f const &  v 
)
inline
void cs237::setUniform ( int  loc,
vec4f const &  v 
)
inline
void cs237::setUniform ( int  loc,
mat2x2f const &  v 
)
inline
void cs237::setUniform ( int  loc,
mat3x3f const &  v 
)
inline
void cs237::setUniform ( int  loc,
mat4x4f const &  v 
)
inline
void cs237::setUniform ( int  loc,
color3ub const &  v 
)
inline
void cs237::setUniform ( int  loc,
color3f const &  v 
)
inline
void cs237::setUniform ( int  loc,
color4ub const &  v 
)
inline
void cs237::setUniform ( int  loc,
color4f const &  v 
)
inline
vec2d cs237::toDouble ( vec2f const &  v)
inline

convert a single-precision vec2f value to double precision

Parameters
vthe vector to convert
Returns
the converted value
vec3d cs237::toDouble ( vec3f const &  v)
inline

convert a single-precision vec3f value to double precision

Parameters
vthe vector to convert
Returns
the converted value
vec4d cs237::toDouble ( vec4f const &  v)
inline

convert a single-precision vec4f value to double precision

Parameters
vthe vector to convert
Returns
the converted value
vec2f cs237::toFloat ( vec2d const &  v)
inline

convert a double-precision vec2d value to single precision

Parameters
vthe vector to convert
Returns
the converted value
vec3f cs237::toFloat ( vec3d const &  v)
inline

convert a double-precision vec3d value to single precision

Parameters
vthe vector to convert
Returns
the converted value
vec4f cs237::toFloat ( vec4d const &  v)
inline

convert a double-precision vec4d value to single precision

Parameters
vthe vector to convert
Returns
the converted value
template<typename T >
__detail::mat4x4<T> cs237::translate ( __detail::vec3< T > const &  offset)

create a translation by the given offset vector

Parameters
offsetthe vector that defines the translation
template<typename T >
__detail::mat4x4<T> cs237::translate ( __detail::mat4x4< T > const &  m,
__detail::vec3< T > const &  offset 
)

apply a translation by an offset vector to a matrix

Parameters
mthe matrix to transform
offsetthe vector that defines the translation

The expression cs237::translate(m, offset) is equivalent to m * cs237::translate(offset)