Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

vecgl.h

Go to the documentation of this file.
00001 // vecgl.h
00002 //
00003 // Copyright (C) 2000, Chris Laurel <claurel@shatters.net>
00004 //
00005 // Overloaded versions of GL functions
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 
00012 #ifndef _VECGL_H_
00013 #define _VECGL_H_
00014 
00015 #include <celmath/vecmath.h>
00016 #include <celmath/quaternion.h>
00017 #include <celutil/color.h>
00018 
00019 
00020 inline void glVertex(const Point3f& p)
00021 {
00022     glVertex3fv(&p.x);
00023 }
00024 
00025 inline void glVertex(const Vec3f& v)
00026 {
00027     glVertex3fv(&v.x);
00028 }
00029 
00030 inline void glNormal(const Vec3f& n)
00031 {
00032     glNormal3fv(&n.x);
00033 }
00034 
00035 inline void glTexCoord(const Point2f& p)
00036 {
00037     glTexCoord2fv(&p.x);
00038 }
00039 
00040 inline void glColor(const Color& c)
00041 {
00042     glColor4f(c.red(), c.green(), c.blue(), c.alpha());
00043 }
00044 
00045 inline void glColor(const Color& c, float a)
00046 {
00047     glColor4f(c.red(), c.green(), c.blue(), c.alpha() * a);
00048 }
00049 
00050 
00051 inline void glMatrix(const Mat4f& m)
00052 {
00053     Mat4f trans = m.transpose();
00054     glMultMatrixf(&trans[0].x);
00055 }
00056 
00057 
00058 inline void glMatrix(const Mat4d& m)
00059 {
00060     Mat4d trans = m.transpose();
00061     glMultMatrixd(&trans[0].x);
00062 }
00063 
00064 
00065 inline void glRotate(const Quatf& q)
00066 {
00067     glMatrix(q.toMatrix4());
00068 }
00069 
00070 inline void glRotate(const Quatd& q)
00071 {
00072     glMatrix(q.toMatrix4());
00073 }
00074 
00075 inline void glTranslate(const Vec3f& v)
00076 {
00077     glTranslatef(v.x, v.y, v.z);
00078 }
00079 
00080 inline void glTranslate(const Point3f& p)
00081 {
00082     glTranslatef(p.x, p.y, p.z);
00083 }
00084 
00085 inline void glScale(const Vec3f& v)
00086 {
00087     glScalef(v.x, v.y, v.z);
00088 }
00089 
00090 inline void glLightDirection(GLenum light, const Vec3f& dir)
00091 {
00092     glLightfv(light, GL_POSITION, &(Vec4f(dir.x, dir.y, dir.z, 0.0f).x));
00093 }
00094 
00095 inline void glLightPosition(GLenum light, const Point3f& pos)
00096 {
00097     glLightfv(light, GL_POSITION, &(Vec4f(pos.x, pos.y, pos.z, 1.0f).x));
00098 }
00099 
00100 inline void glLightColor(GLenum light, GLenum which, const Vec3f& color)
00101 {
00102     glLightfv(light, which, &(Vec4f(color.x, color.y, color.z, 1.0f).x));
00103 }
00104 
00105 inline void glLightColor(GLenum light, GLenum which, const Vec4f& color)
00106 {
00107     glLightfv(light, which, &color.x);
00108 }
00109 
00110 inline void glLightColor(GLenum light, GLenum which, const Color& color)
00111 {
00112     glLightfv(light, which,
00113               &(Vec4f(color.red(), color.green(), color.blue(), color.alpha()).x));
00114 }
00115 
00116 inline void glAmbientLightColor(const Color& color)
00117 {
00118     glLightModelfv(GL_LIGHT_MODEL_AMBIENT,
00119                    &(Vec4f(color.red(), color.green(), color.blue(),
00120                            color.alpha()).x));
00121 }
00122 
00123 #endif // _VECGL_H_
00124 

Generated on Sat Jan 14 22:30:29 2006 for Celestia by  doxygen 1.4.1