Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-01-30 17:36:03 +0000
committerStijn Buys <ingar@osirion.org>2008-01-30 17:36:03 +0000
commitd584d29ac49182130d643c9221047e0acb5cfa01 (patch)
tree06f23cb1cae0a1945e88ea7f19ad80394cb35d6b /src
parentbac8343bbc9f1e4cf97a561c732054539f21f03d (diff)
accomodate the new modules
Diffstat (limited to 'src')
-rw-r--r--src/gl/Makefile.am13
-rw-r--r--src/gl/box.cc5
-rw-r--r--src/gl/box.h20
-rw-r--r--src/gl/gllib.cc151
-rw-r--r--src/gl/gllib.h (renamed from src/gl/osiriongl.h)80
-rw-r--r--src/gl/osiriongl.cc233
-rw-r--r--src/gl/sphere.cc8
-rw-r--r--src/gl/sphere.h16
8 files changed, 223 insertions, 303 deletions
diff --git a/src/gl/Makefile.am b/src/gl/Makefile.am
index 291565d..7c1445e 100644
--- a/src/gl/Makefile.am
+++ b/src/gl/Makefile.am
@@ -1,9 +1,10 @@
-
METASOURCES = AUTO
+INCLUDES = -I$(top_srcdir)/src
-libosiriongl_la_LDFLAGS = -avoid-version -no-undefined
-noinst_LTLIBRARIES = libosiriongl.la
+libgl_la_SOURCES = box.cc sphere.cc gllib.cc
+libgl_la_LDFLAGS = -avoid-version -no-undefined @GL_LIBS@
+libgl_la_CXXFLAGS = @GL_CFLAGS@
+
+noinst_LTLIBRARIES = libgl.la
+noinst_HEADERS = box.h gllib.h sphere.h
-INCLUDES = -I$(top_srcdir)/src
-libosiriongl_la_SOURCES = box.cc sphere.cc osiriongl.cc
-noinst_HEADERS = box.h osiriongl.h sphere.h
diff --git a/src/gl/box.cc b/src/gl/box.cc
index fea5d28..12507df 100644
--- a/src/gl/box.cc
+++ b/src/gl/box.cc
@@ -5,10 +5,13 @@
*/
// project headers
-#include "box.h"
+#include "gl/box.h"
namespace gl {
+using math::Vector3f;
+using math::Color;
+
Box::Box(Vector3f const & tl, Vector3f const &br) :
topleft(tl), bottomright(br)
{
diff --git a/src/gl/box.h b/src/gl/box.h
index 8fb4c45..ce4a650 100644
--- a/src/gl/box.h
+++ b/src/gl/box.h
@@ -4,10 +4,11 @@
the terms of the GNU General Public License version 2
*/
-#ifndef __INCLUDED_BOX_H__
-#define __INCLUDED_BOX_H__
+#ifndef __INCLUDED_GL_BOX_H__
+#define __INCLUDED_GL_BOX_H__
-#include "osiriongl.h"
+#include "gl/gllib.h"
+#include "math/mathlib.h"
namespace gl {
@@ -16,7 +17,7 @@ class Box
{
public:
/// create a new standard cube with edge length 1
- Box(Vector3f const & tl, Vector3f const &br);
+ Box(math::Vector3f const & tl, math::Vector3f const &br);
/// copy constructor
Box(const Box &other);
@@ -24,19 +25,20 @@ public:
Box& operator=(const Box &other);
/// top left vertex (1,1,1)
- Vector3f topleft;
+ math::Vector3f topleft;
/// bottom right vertex (-1,-1,-1)
- Vector3f bottomright;
+ math::Vector3f bottomright;
/// draw the block
void draw();
/// Top color
- Color topcolor;
+ math::Color topcolor;
/// bottom color
- Color bottomcolor;
+ math::Color bottomcolor;
};
} // namespace gl
-#endif // __INCLUDED_BOX_H__
+#endif // __INCLUDED_GL_BOX_H__
+
diff --git a/src/gl/gllib.cc b/src/gl/gllib.cc
new file mode 100644
index 0000000..32aa55e
--- /dev/null
+++ b/src/gl/gllib.cc
@@ -0,0 +1,151 @@
+/*
+ gl/gllib.cc
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+// project includes
+#include "gl/gllib.h"
+#include "common/common.h"
+
+// system includes
+#include "GL/gl.h"
+
+using math::Vector3f;
+using math::Color;
+
+namespace gl
+{
+
+void init()
+{
+ con_debug << "Initiliazing gl..." << std::endl;
+}
+
+void shutdown()
+{
+ con_debug << "Shutting down gl..." << std::endl;
+}
+
+void begin(Primitive primitive) {
+ glBegin(primitive);
+}
+
+void end() {
+ glEnd();
+}
+
+void viewport(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ glViewport(x, y, width, height);
+}
+
+void depthmask(GLenum mode)
+{
+ glDepthMask(mode);
+}
+
+
+void frontface(GLenum mode)
+{
+ glFrontFace(mode);
+}
+
+void cullface(GLenum mode)
+{
+ glCullFace(mode);
+}
+
+void shademodel(GLenum mode)
+{
+ glShadeModel(mode);
+}
+
+void blendfunc(GLenum sfactor, GLenum dfactor)
+{
+ glBlendFunc(sfactor, dfactor);
+}
+
+void enable(GLenum cap)
+{
+ glEnable(cap);
+}
+
+void disable(GLenum cap)
+{
+ glDisable(cap);
+}
+
+void clear (GLbitfield mask) {
+ glClear(mask);
+}
+
+void clearcolor(Color const & color) {
+ glClearColor(color.red(), color.green(), color.blue(), color.alpha());
+}
+
+void clearcolor(const float r, const float g, const float b, const float a) {
+ glClearColor(r,g,b, a);
+}
+
+void rotate(const float angle, const Vector3f& vector) {
+ glRotatef(angle, vector[0], vector[1], vector[2]);
+}
+
+void rotate(const float angle, const float x, const float y, const float z) {
+ glRotatef(angle, x, y, z);
+}
+
+void translate(const Vector3f& vector) {
+ glTranslatef(vector[0], vector[1], vector[2]);
+}
+
+void translate(const float x, const float y, const float z) {
+ glTranslatef(x, y, z);
+}
+void scale(const Vector3f& vector) {
+ glScalef(vector[0], vector[1], vector[2]);
+}
+
+void scale(const float x, const float y, const float z) {
+ glScalef(x, y, z);
+}
+
+void vertex(const Vector3f& vector) {
+ glVertex3f(vector[0], vector[1], vector[2]);
+}
+
+void vertex(const float x, const float y, const float z) {
+ glVertex3f(x, y, z);
+}
+
+void push() {
+ glPushMatrix();
+}
+
+void pop() {
+ glPopMatrix();
+}
+
+void color(const float r, const float g, const float b, const float a) {
+ glColor4f(r,g,b,a);
+}
+void color(Color const & color) {
+ glColor4f(color.red(), color.green(), color.blue(), color.alpha());
+}
+
+void matrixmode(GLenum mode) {
+ glMatrixMode(mode);
+}
+
+void loadidentity() {
+ glLoadIdentity();
+}
+
+void frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble znear, GLdouble zfar)
+{
+ glFrustum(left, right, bottom, top, znear, zfar);
+}
+
+} // namespace gl
+
diff --git a/src/gl/osiriongl.h b/src/gl/gllib.h
index 5a1f9f9..d8f146a 100644
--- a/src/gl/osiriongl.h
+++ b/src/gl/gllib.h
@@ -1,28 +1,25 @@
/*
- gl/osiriongl.h
+ gl/gllib.h
This file is part of the Osirion project and is distributed under
the terms of the GNU General Public License version 2
*/
-#ifndef __INCLUDED_OSIRIONGL_H__
-#define __INCLUDED_OSIRIONGL_H__
+#ifndef __INCLUDED_GL_GLLIB_H__
+#define __INCLUDED_GL_GLLIB_H__
// project headers
-#include "common/vector3f.h"
-#include "common/color.h"
+#include "math/vector3f.h"
+#include "math/color.h"
// OpenGL headers
#include <GL/gl.h>
/// wrapper namespace for OpenGL operations
-/*! The GL namespace provides a wrapper to the OpenGL library functions.
+/** The gl namespace provides a wrapper to the OpenGL library functions.
* All methods take floats or Vector3f and Color as parameters.
*/
namespace gl
{
- using common::Vector3f;
- using common::Color;
-
/// initialize the OpenGL subsystem
void init();
@@ -43,13 +40,11 @@ namespace gl
Polygon=GL_POLYGON
};
-
/// glViewPort
void viewport(GLint x, GLint y, GLsizei width, GLsizei height );
/// set the color used to clear to buffer
- void clearcolor(Color const &color);
- /// set the color used to clear to buffer
+ void clearcolor(math::Color const &color);
void clearcolor(const float r, const float g, const float b, const float a);
/// clear buffers to preset values
@@ -73,7 +68,6 @@ namespace gl
/// glFrontFace
void frontface(GLenum mode);
-
/// glDepthMask
void depthmask(GLenum mode);
@@ -81,72 +75,70 @@ namespace gl
void blendfunc(GLenum sfactor, GLenum dfactor);
/// Delimite the start of a sequence of verteces describing a primitive or group of primitives
- /*! @param primitive The type of drawing primitive
+ /** @param primitive The type of drawing primitive
* @see end()
*/
void begin(Primitive primitive);
- /// Delimit the end of a sequence of verteces describing a primitive or group of primitives
- /*! @see begin()
+ /// delimit the end of a sequence of verteces describing a primitive or group of primitives
+ /** @see begin()
*/
void end();
/// Add the next vertex the the current drawing operation
- /*! From the glVertex() description:
+ /** From the glVertex() description:
* vertex() commands are used within begin()/end() pairs to specify point,
- * line, and polygon vertices. The current color, normal, and texture
- * coordinates are associated with the vertex when vertex() is called.
+ * line, and polygon vertices. The current color, normal, and texture
+ * coordinates are associated with the vertex when vertex() is called.
*/
- void vertex(const Vector3f& vector);
+ void vertex(const math::Vector3f& vector);
void vertex(const float x, const float y, const float z);
- /// Multiply the current matrix by a general rotation matrix
- /*! @param angle The angle of the rotation, in degrees [0-360]
+ /// multiply the current matrix by a general rotation matrix
+ /** @param angle The angle of the rotation, in degrees [0-360]
* @param vector The rotation axes, relative to the origin (0,0,0)
*/
- void rotate(const float angle, const Vector3f& vector);
+ void rotate(const float angle, const math::Vector3f& vector);
- /// Multiply the current matrix by a general rotation matrix
- /*! @param angle The angle of the rotation, in degrees
+ /// multiply the current matrix by a general rotation matrix
+ /** @param angle The angle of the rotation, in degrees
* @param x The x-coordinate of the rotation vector
* @param y The y-coordinate of the rotation vector
* @param z The z-coordinate of the rotation vector
*/
void rotate(const float angle, const float x, const float y, const float z);
- /// Multiply the current matrix by a general translation matrix
- /*! @param vector The translation vector, relative to the origin (0,0,0)
+ /// multiply the current matrix by a general translation matrix
+ /** @param vector The translation vector, relative to the origin (0,0,0)
*/
- void translate(const Vector3f& vector);
+ void translate(const math::Vector3f& vector);
- /// Multiply the current matrix by a general translation matrix
- /*!
- * @param x The x-coordinate of the translation vector
- * @param y The y-coordinate of the translation vector
- * @param z The z-coordinate of the translation vector
+ /// multiply the current matrix by a general translation matrix
+ /** @param x The x-coordinate of the translation vector
+ * @param y The y-coordinate of the translation vector
+ * @param z The z-coordinate of the translation vector
*/
void translate(const float x, const float y, const float z);
- /// Multiply the current matrix by a general scaling matrix
- /*! @param vector The scale factor for all 3 axes
+ /// multiply the current matrix by a general scaling matrix
+ /** @param vector The scale factor for all 3 axes
*/
- void scale(const Vector3f& vector);
+ void scale(const math::Vector3f& vector);
- /// Multiply the current matrix by a general scaling matrix
- /*!
- * @param x x-scaling factor
+ /// multiply the current matrix by a general scaling matrix
+ /** @param x x-scaling factor
* @param y y-scaling factor
* @param z z-scaling factor
*/
void scale(const float x, const float y, const float z);
- /// Specify the drawing color for the next GL functions
- /*! @param color the new drawing color
+ /// specify the drawing color for the next GL functions
+ /** @param color the new drawing color
*/
- void color(Color const & color);
+ void color(math::Color const & color);
- /*! @param r red value of the new drawing color
+ /** @param r red value of the new drawing color
* @param g green value of the new drawing color
* @param b blue value of the new drawing color
* @param a alpha value of the new drawing color
@@ -166,4 +158,4 @@ namespace gl
void frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble znear, GLdouble zfar);
};
-#endif // __INCLUDED_OSIRIONGL_H__
+#endif // __INCLUDED_GL_GLLIB_H__
diff --git a/src/gl/osiriongl.cc b/src/gl/osiriongl.cc
deleted file mode 100644
index 08462e7..0000000
--- a/src/gl/osiriongl.cc
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- gl/osiriongl.cc
- This file is part of the Osirion project and is distributed under
- the terms of the GNU General Public License version 2
-*/
-
-#include "osiriongl.h"
-
-#include <SDL/SDL.h>
-
-namespace gl
-{
-
-typedef void (APIENTRY *glBegin_func)(GLenum);
-typedef void (APIENTRY *glEnd_func)();
-typedef void (APIENTRY *glViewport_func)(GLint, GLint, GLsizei, GLsizei);
-typedef void (APIENTRY *glDepthMask_func)(GLenum);
-typedef void (APIENTRY *glFrontFace_func)(GLenum);
-typedef void (APIENTRY *glCullFace_func)(GLenum);
-typedef void (APIENTRY *glShadeModel_func)(GLenum);
-typedef void (APIENTRY *glEnable_func)(GLenum);
-typedef void (APIENTRY *glDisable_func)(GLenum);
-typedef void (APIENTRY *glBlendFunc_func)(GLenum, GLenum);
-typedef void (APIENTRY *glClear_func)(GLbitfield);
-typedef void (APIENTRY *glClearColor_func)(GLclampf, GLclampf, GLclampf,GLclampf);
-typedef void (APIENTRY *glRotatef_func)(GLfloat, GLfloat, GLfloat, GLfloat);
-typedef void (APIENTRY *glTranslatef_func)(GLfloat, GLfloat, GLfloat);
-typedef void (APIENTRY *glScalef_func)(GLfloat, GLfloat, GLfloat);
-typedef void (APIENTRY *glVertex3f_func)(GLfloat, GLfloat, GLfloat);
-typedef void (APIENTRY *glPushMatrix_func)();
-typedef void (APIENTRY *glPopMatrix_func)();
-typedef void (APIENTRY *glColor4f_func)(GLfloat, GLfloat, GLfloat, GLfloat);
-typedef void (APIENTRY *glMatrixMode_func)(GLenum);
-typedef void (APIENTRY *glLoadIdentity_func)();
-typedef void (APIENTRY *glFrustum_func)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
-
-glBegin_func osglBegin = 0;
-glEnd_func osglEnd = 0;
-glViewport_func osglViewport = 0;
-glDepthMask_func osglDepthMask = 0;
-glFrontFace_func osglFrontFace = 0;
-glCullFace_func osglCullFace = 0;
-glShadeModel_func osglShadeModel = 0;
-glEnable_func osglEnable = 0;
-glDisable_func osglDisable = 0;
-glBlendFunc_func osglBlendFunc = 0;
-glClear_func osglClear = 0;
-glClearColor_func osglClearColor = 0;
-glRotatef_func osglRotatef = 0;
-glTranslatef_func osglTranslatef = 0;
-glScalef_func osglScalef = 0;
-glVertex3f_func osglVertex3f = 0;
-glPushMatrix_func osglPushMatrix = 0;
-glPopMatrix_func osglPopMatrix = 0;
-glColor4f_func osglColor4f = 0;
-glMatrixMode_func osglMatrixMode = 0;
-glLoadIdentity_func osglLoadIdentity = 0;
-glFrustum_func osglFrustum = 0;
-
-// ------------- INITIALIZE FUNCTION POINTERS --------------//
-void init()
-{
- osglBegin = (glBegin_func) SDL_GL_GetProcAddress("glBegin");
- osglEnd = (glEnd_func) SDL_GL_GetProcAddress("glEnd");
- osglViewport = (glViewport_func) SDL_GL_GetProcAddress("glViewport");
- osglDepthMask = (glDepthMask_func) SDL_GL_GetProcAddress("glDepthMask");
- osglFrontFace = (glFrontFace_func) SDL_GL_GetProcAddress("glFrontFace");
- osglCullFace = (glCullFace_func) SDL_GL_GetProcAddress("glCullFace");
- osglShadeModel = (glShadeModel_func) SDL_GL_GetProcAddress("glShadeModel");
- osglEnable = (glEnable_func) SDL_GL_GetProcAddress("glEnable");
- osglDisable = (glDisable_func) SDL_GL_GetProcAddress("glDisable");
- osglBlendFunc = (glBlendFunc_func ) SDL_GL_GetProcAddress("glBlendFunc");
- osglClear = (glClear_func) SDL_GL_GetProcAddress("glClear");
- osglClearColor = (glClearColor_func) SDL_GL_GetProcAddress("glClearColor");
- osglRotatef = (glRotatef_func) SDL_GL_GetProcAddress("glRotatef");
- osglTranslatef = (glTranslatef_func) SDL_GL_GetProcAddress("glTranslatef");
- osglScalef = (glScalef_func) SDL_GL_GetProcAddress("glScalef");
- osglVertex3f = (glVertex3f_func) SDL_GL_GetProcAddress("glVertex3f");
- osglPushMatrix = (glPushMatrix_func) SDL_GL_GetProcAddress("glPushMatrix");
- osglPopMatrix = (glPopMatrix_func) SDL_GL_GetProcAddress("glPopMatrix");
- osglColor4f = (glColor4f_func) SDL_GL_GetProcAddress("glColor4f");
- osglMatrixMode = (glMatrixMode_func) SDL_GL_GetProcAddress("glMatrixMode");
- osglLoadIdentity = (glLoadIdentity_func) SDL_GL_GetProcAddress("glLoadIdentity");
- osglFrustum = (glFrustum_func) SDL_GL_GetProcAddress("glFrustum");
-}
-
-
-void shutdown()
-{
- osglBegin = 0;
- osglEnd = 0;
- osglViewport = 0;
- osglDepthMask = 0;
- osglFrontFace = 0;
- osglCullFace = 0;
- osglShadeModel = 0;
- osglEnable = 0;
- osglDisable = 0;
- osglBlendFunc = 0;
- osglClear = 0;
- osglClearColor = 0;
- osglRotatef = 0;
- osglTranslatef = 0;
- osglScalef = 0;
- osglVertex3f = 0;
- osglPushMatrix = 0;
- osglPopMatrix = 0;
- osglColor4f = 0;
- osglMatrixMode = 0;
- osglLoadIdentity = 0;
-}
-
-void begin(Primitive primitive) {
- osglBegin(primitive);
-}
-
-void end() {
- osglEnd();
-}
-
-void viewport(GLint x, GLint y, GLsizei width, GLsizei height)
-{
- osglViewport(x, y, width, height);
-}
-
-void depthmask(GLenum mode)
-{
- osglDepthMask(mode);
-}
-
-
-void frontface(GLenum mode)
-{
- osglFrontFace(mode);
-}
-
-void cullface(GLenum mode)
-{
- osglCullFace(mode);
-}
-
-void shademodel(GLenum mode)
-{
- osglShadeModel(mode);
-}
-
-void blendfunc(GLenum sfactor, GLenum dfactor)
-{
- osglBlendFunc(sfactor, dfactor);
-}
-
-void enable(GLenum cap)
-{
- osglEnable(cap);
-}
-
-void disable(GLenum cap)
-{
- osglDisable(cap);
-}
-
-void clear (GLbitfield mask) {
- osglClear(mask);
-}
-
-void clearcolor(Color const & color) {
- osglClearColor(color.red(), color.green(), color.blue(), color.alpha());
-}
-
-void clearcolor(const float r, const float g, const float b, const float a) {
- osglClearColor(r,g,b, a);
-}
-
-void rotate(const float angle, const Vector3f& vector) {
- osglRotatef(angle, vector[0], vector[1], vector[2]);
-}
-
-void rotate(const float angle, const float x, const float y, const float z) {
- osglRotatef(angle, x, y, z);
-}
-
-void translate(const Vector3f& vector) {
- osglTranslatef(vector[0], vector[1], vector[2]);
-}
-
-void translate(const float x, const float y, const float z) {
- osglTranslatef(x, y, z);
-}
-void scale(const Vector3f& vector) {
- osglScalef(vector[0], vector[1], vector[2]);
-}
-
-void scale(const float x, const float y, const float z) {
- osglScalef(x, y, z);
-}
-
-void vertex(const Vector3f& vector) {
- osglVertex3f(vector[0], vector[1], vector[2]);
-}
-
-void vertex(const float x, const float y, const float z) {
- osglVertex3f(x, y, z);
-}
-
-void push() {
- osglPushMatrix();
-}
-
-void pop() {
- osglPopMatrix();
-}
-
-void color(const float r, const float g, const float b, const float a) {
- osglColor4f(r,g,b,a);
-}
-void color(Color const & color) {
- osglColor4f(color.red(), color.green(), color.blue(), color.alpha());
-}
-
-void matrixmode(GLenum mode) {
- osglMatrixMode(mode);
-}
-
-void loadidentity() {
- osglLoadIdentity();
-}
-
-void frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble znear, GLdouble zfar)
-{
- osglFrustum(left, right, bottom, top, znear, zfar);
-}
-
-} // namespace gl
diff --git a/src/gl/sphere.cc b/src/gl/sphere.cc
index 1c21ee5..e28e495 100644
--- a/src/gl/sphere.cc
+++ b/src/gl/sphere.cc
@@ -4,8 +4,11 @@
the terms of the GNU General Public License version 2
*/
-#include "sphere.h"
-#include "common/functions.h"
+#include "gl/sphere.h"
+#include "math/mathlib.h"
+
+using math::Vector3f;
+using math::Color;
namespace gl {
@@ -42,6 +45,7 @@ Sphere& Sphere::operator=(const Sphere &other)
{
position = other.position;
radius = other.radius;
+ return (*this);
}
void Sphere::draw()
diff --git a/src/gl/sphere.h b/src/gl/sphere.h
index 2e237c5..b448a88 100644
--- a/src/gl/sphere.h
+++ b/src/gl/sphere.h
@@ -4,10 +4,10 @@
the terms of the GNU General Public License version 2
*/
-#ifndef __INCLUDED_SPHERE_H__
-#define __INCLUDED_SPHERE_H__
+#ifndef __INCLUDED_GL_SPHERE_H__
+#define __INCLUDED_GL_SPHERE_H__
-#include "osiriongl.h"
+#include "gl/gllib.h"
namespace gl {
@@ -16,7 +16,7 @@ class Sphere
{
public:
/// create a new sphere
- Sphere(Vector3f p = Vector3f(), float r = 1.0f);
+ Sphere(math::Vector3f p = math::Vector3f(), float r = 1.0f);
/// copy constructor
Sphere(const Sphere &other);
@@ -31,15 +31,15 @@ public:
float radius;
/// position of the sphere
- Vector3f position;
+ math::Vector3f position;
/// draw the sphere
void draw();
/// Top color
- Color topcolor;
+ math::Color topcolor;
/// bottom color
- Color bottomcolor;
+ math::Color bottomcolor;
private:
float *sintable;
@@ -48,4 +48,4 @@ private:
} // namespace gl
-#endif // __INCLUDED_SPHERE_H__
+#endif // __INCLUDED_GL_SPHERE_H__