View Full Version : developing OpenGL mid level api

03-30-2001, 12:11 PM
I started programming OpenGL in last november
using c++ on win32. While doing so it got nasty for me to use the OpenGL functions to setup lighting for example. So I tried to "develop" an "api" (well it sounds big, but perhaps it could get so) to avoid this
using c++ with some classes loosely built around glFunctions();
but I think it would be better if some guys could help me, because if more people participate more ideas are realised and less errors occur.
If some people are interested i could send them the main header via email (21k)
here is a "snippet"( comments are in german but classes all in english)
(template <class number,dimension>VVector is my selfmade vector mathmatics "library")
but please pay attention: this isn't meant as a concurrence to OpenInventor , ist just my way to handle glFuncrions() more easy !!!

// Vektoren
template <class number> class OGLVector2; // x, y
template <class number> class OGLVector3; // x, y, z
template <class number> class OGLVector4; // x, y, z, w

// Matrix
class OGLMatrix; // 4x4Matrix

// Farben
template <class number> class OGLColor3; // RGB
template <class number> class OGLColor4; // RGBA
// OGLVector
typedef OGLVector3<GLfloat> OGLVector3f;
typedef OGLVector4<GLdouble> OGLVector4d;

typedef OGLColor3<GLfloat> OGLColor3f;

typedef OGLColor4<GLbyte> OGLColor4b;
// Funktionen

// oglColor typunabhängig
void oglColor( OGLColor3f color);
void oglColor( OGLColor3d color);
void oglColor( OGLColor3i color);

void oglVertex(OGLVector3f vertex);
void oglVertex(OGLVector3d vertex);
void oglNormal(OGLVector3i normal);
void oglNormal(OGLVector3s normal);

// Transformationen

void oglRotate(GLfloat angle, OGLVector3f axis);
void oglRotate(GLdouble angle, OGLVector3d axis);

// OGLVector3
template <class number> class OGLVector3: public VVector3D<number>
OGLVector3(); // Default Constructor

OGLVector3(number x,number y,number z); // Constructor
OGLVector3(number x1,number y1,number z1,number x2,number y2, number z);// 3 Punkte

OGLVector3(const OGLVector3& other); // Copy Constructor
OGLVector3(const OGLVector3& p1,const OGLVector3& p3); // zwei Punkte

OGLVector3(const VVector3D<number>& other); // Cast Constructor
OGLVector3(const VVector<number,3>& other); // Cast Constructor

void Set(number x, number y, number z);

number& X(); // X
number& Y(); // Y
number& Z(); // Z
number W(); // 1

operator OGLVector4<number>()
OGLVector4<number> tmp;
return tmp;