00001 /* 00002 File: VLgl.h 00003 00004 Function: Provides some handy wrappers for using vl with 00005 OpenGL. 00006 00007 Author: Andrew Willmott 00008 00009 Copyright: (c) 2000, Andrew Willmott 00010 */ 00011 00012 #ifndef __VLgl__ 00013 #define __VLgl__ 00014 00015 // float versions 00016 00017 inline Void glVertex(const Vec2f &a) 00018 { glVertex2fv(a.Ref()); } 00019 00020 inline Void glVertex(const Vec3f &a) 00021 { glVertex3fv(a.Ref()); } 00022 00023 inline Void glVertex(const Vec4f &a) 00024 { glVertex4fv(a.Ref()); } 00025 00026 inline Void glColor(const Vec3f &a) 00027 { glColor3fv(a.Ref()); } 00028 00029 inline Void glColor(const Vec4f &a) 00030 { glColor4fv(a.Ref()); } 00031 00032 inline Void glNormal(const Vec3f &a) 00033 { glNormal3fv(a.Ref()); } 00034 00035 inline Void glTexCoord(const Vec2f &a) 00036 { glTexCoord2fv(a.Ref()); } 00037 00038 inline Void glLoadMatrix(const Mat4f &m) 00039 { 00040 #ifdef VL_ROW_ORIENT 00041 glLoadMatrixf(m.Ref()); 00042 #else 00043 glLoadMatrixf(trans(m).Ref()); 00044 #endif 00045 } 00046 00047 inline Void glMultMatrix(const Mat4f &m) 00048 { 00049 #ifdef VL_ROW_ORIENT 00050 glMultMatrixf(m.Ref()); 00051 #else 00052 glMultMatrixf(trans(m).Ref()); 00053 #endif 00054 } 00055 00056 // double versions 00057 00058 inline Void glVertex(const Vec2d &a) 00059 { glVertex2dv(a.Ref()); } 00060 00061 inline Void glVertex(const Vec3d &a) 00062 { glVertex3dv(a.Ref()); } 00063 00064 inline Void glVertex(const Vec4d &a) 00065 { glVertex4dv(a.Ref()); } 00066 00067 inline Void glColor(const Vec3d &a) 00068 { glColor3dv(a.Ref()); } 00069 00070 inline Void glColor(const Vec4d &a) 00071 { glColor4dv(a.Ref()); } 00072 00073 inline Void glNormal(const Vec3d &a) 00074 { glNormal3dv(a.Ref()); } 00075 00076 inline Void glTexCoord(const Vec2d &a) 00077 { glTexCoord2dv(a.Ref()); } 00078 00079 inline Void glLoadMatrix(const Mat4d &m) 00080 { 00081 #ifdef VL_ROW_ORIENT 00082 glLoadMatrixd(m.Ref()); 00083 #else 00084 glLoadMatrixd(trans(m).Ref()); 00085 #endif 00086 } 00087 00088 inline Void glMultMatrix(const Mat4d &m) 00089 { 00090 #ifdef VL_ROW_ORIENT 00091 glMultMatrixd(m.Ref()); 00092 #else 00093 glMultMatrixd(trans(m).Ref()); 00094 #endif 00095 } 00096 00097 // Note: glLoadMatrix[fd] expects matrices in column-major 00098 // order, not row-order, hence the VL_ROW_ORIENT dependencies. 00099 // OpenGL internally operates with row vectors (just like 00100 // the original GL), and transformation matrices stored in 00101 // row-major order. However, externally they pretend that 00102 // they use column vectors; everything still works, but 00103 // because trans(Av) = trans(v) trans(A), it appears that 00104 // matrices are stored in column major order. 00105 00106 #endif