diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gl/Makefile.am | 11 | ||||
-rw-r--r-- | src/gl/box.cc | 100 | ||||
-rw-r--r-- | src/gl/box.h | 44 | ||||
-rw-r--r-- | src/gl/gllib.cc | 165 | ||||
-rw-r--r-- | src/gl/gllib.h | 0 | ||||
-rw-r--r-- | src/gl/sphere.cc | 93 | ||||
-rw-r--r-- | src/gl/sphere.h | 51 |
7 files changed, 0 insertions, 464 deletions
diff --git a/src/gl/Makefile.am b/src/gl/Makefile.am deleted file mode 100644 index 7ddb67b..0000000 --- a/src/gl/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -METASOURCES = AUTO -INCLUDES = -I$(top_srcdir)/src - -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 - -libgl_la_LIBADD = $(top_builddir)/src/math/libmath.la diff --git a/src/gl/box.cc b/src/gl/box.cc deleted file mode 100644 index 12507df..0000000 --- a/src/gl/box.cc +++ /dev/null @@ -1,100 +0,0 @@ -/* - gl/box.cc - This file is part of the Osirion project and is distributed under - the terms of the GNU General Public License version 2 -*/ - -// project headers -#include "gl/box.h" - -namespace gl { - -using math::Vector3f; -using math::Color; - -Box::Box(Vector3f const & tl, Vector3f const &br) : - topleft(tl), bottomright(br) -{ - topcolor = Color::White(); - bottomcolor= Color::White() * 0.7f; -} - -Box::Box(const Box & other) -{ - (*this) = other; -} - -Box& Box::operator=(const Box &other) -{ - bottomcolor = other.bottomcolor; - topcolor = other.topcolor; - - topleft = other.topleft; - bottomright = other.bottomright; - return (*this); -} - -void Box::draw() -{ - Vector3f v0(topleft.x, bottomright.y, bottomright.z); - Vector3f v1(topleft.x, topleft.y, bottomright.z); - Vector3f v2(topleft.x, topleft.y, topleft.z); - Vector3f v3(topleft.x, bottomright.y, topleft.z); - - Vector3f v4(bottomright.x, bottomright.y, bottomright.z); - Vector3f v5(bottomright.x, topleft.y, bottomright.z); - Vector3f v6(bottomright.x, topleft.y, topleft.z); - Vector3f v7(bottomright.x, bottomright.y, topleft.z); - - begin(Quads); - - // top - color(topcolor); - vertex(v2); - vertex(v1); - vertex(v5); - vertex(v6); - - // sides - color(bottomcolor); - vertex(v0); - color(topcolor); - vertex(v1); - vertex(v2); - color(bottomcolor); - vertex(v3); - - vertex(v3); - color(topcolor); - vertex(v2); - vertex(v6); - color(bottomcolor); - vertex(v7); - - vertex(v4); - color(topcolor); - vertex(v5); - vertex(v1); - color(bottomcolor); - vertex(v0); - - vertex(v7); - color(topcolor); - vertex(v6); - vertex(v5); - color(bottomcolor); - vertex(v4); - - // bottom - color(bottomcolor); - vertex(v4); - vertex(v0); - vertex(v3); - vertex(v7); - - end(); - -} - -} // namespace gl - diff --git a/src/gl/box.h b/src/gl/box.h deleted file mode 100644 index ce4a650..0000000 --- a/src/gl/box.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - gl/box.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_GL_BOX_H__ -#define __INCLUDED_GL_BOX_H__ - -#include "gl/gllib.h" -#include "math/mathlib.h" - -namespace gl { - -/// a drawable OpenGL block shape -class Box -{ -public: - /// create a new standard cube with edge length 1 - Box(math::Vector3f const & tl, math::Vector3f const &br); - /// copy constructor - Box(const Box &other); - - /// assignment operator - Box& operator=(const Box &other); - - /// top left vertex (1,1,1) - math::Vector3f topleft; - /// bottom right vertex (-1,-1,-1) - math::Vector3f bottomright; - - /// draw the block - void draw(); - - /// Top color - math::Color topcolor; - /// bottom color - math::Color bottomcolor; -}; - -} // namespace gl - -#endif // __INCLUDED_GL_BOX_H__ - diff --git a/src/gl/gllib.cc b/src/gl/gllib.cc deleted file mode 100644 index b8ca232..0000000 --- a/src/gl/gllib.cc +++ /dev/null @@ -1,165 +0,0 @@ -/* - 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 "sys/sys.h" - -// system includes -#include "GL/gl.h" - -using math::Vector3f; -using math::Color; - -namespace gl -{ - -std::string renderer; -std::string version; -std::string extensions; -std::string vendor; - -void init() -{ - con_debug << "Initializing gl..." << std::endl; - - renderer = std::string ((char *)glGetString(GL_RENDERER)); - vendor = std::string ((char *)glGetString(GL_VENDOR)); - version = std::string ((char *)glGetString(GL_VERSION)); - extensions = std::string ((char *)glGetString(GL_EXTENSIONS)); - - con_print << "Renderer: " << renderer << std::endl; - con_print << "Vendor: " << vendor << std::endl; - con_print << "Version: " << version << 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/gllib.h b/src/gl/gllib.h deleted file mode 100644 index e69de29..0000000 --- a/src/gl/gllib.h +++ /dev/null diff --git a/src/gl/sphere.cc b/src/gl/sphere.cc deleted file mode 100644 index e28e495..0000000 --- a/src/gl/sphere.cc +++ /dev/null @@ -1,93 +0,0 @@ -/* - gl/sphere.cc - This file is part of the Osirion project and is distributed under - the terms of the GNU General Public License version 2 -*/ - -#include "gl/sphere.h" -#include "math/mathlib.h" - -using math::Vector3f; -using math::Color; - -namespace gl { - -const int segments = 33; - -Sphere::Sphere(Vector3f p , float r) -{ - position = p; - radius = r; - - // TODO make global sine-cosine lists - sintable = new float[segments]; - costable = new float[segments]; - float d = 2 * M_PI / segments; - - for (int i=0; i < segments; i++) { - sintable[i] = sin( d * (float) i ); - costable[i] = cos ( d * (float) i ); - } -} - -Sphere::~Sphere() -{ - delete[] sintable; - delete[] costable; -} - -Sphere::Sphere(const Sphere &other) -{ - (*this) = other; -} - -Sphere& Sphere::operator=(const Sphere &other) -{ - position = other.position; - radius = other.radius; - return (*this); -} - -void Sphere::draw() -{ - // draw top - // TODO upside-down - float r = radius*sintable[1]; - float h = radius*costable[1]; - - begin(LineLoop); - //begin(Polygon); - for (int i = segments-1; i >= 0; i--) - vertex(r*costable[i], h, r*sintable[i]); - end(); - - // draw bottom - // TODO upside-down - begin(LineLoop); - for (int i = 0; i< segments; i++) - vertex(r*costable[i], -h, r*sintable[i]); - end(); - - // draw body - for (int j=1; j < segments-1; j++) { - r = radius*sintable[j]; - float r1 = radius*sintable[j+1]; - - begin(QuadStrip); - vertex(r1, radius*costable[j+1], 0); - vertex(r, radius*costable[j], 0); - - for (int i = segments-1; i >= 0; i--) { - vertex(r1*costable[i], radius*costable[j+1], r1*sintable[i]); - vertex(r*costable[i], radius*costable[j], r*sintable[i]); - //vertex(r*costable[i-1], radius*costable[j], r*sintable[i-1]); - //vertex(r1*costable[i-1], radius*costable[j+1], r1*sintable[i-1]); - } - end(); - - } -} - - -} // namespace gl - diff --git a/src/gl/sphere.h b/src/gl/sphere.h deleted file mode 100644 index b448a88..0000000 --- a/src/gl/sphere.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - gl/sphere.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_GL_SPHERE_H__ -#define __INCLUDED_GL_SPHERE_H__ - -#include "gl/gllib.h" - -namespace gl { - -/// a drawable OpenGL block shape -class Sphere -{ -public: - /// create a new sphere - Sphere(math::Vector3f p = math::Vector3f(), float r = 1.0f); - - /// copy constructor - Sphere(const Sphere &other); - - /// destructor - ~Sphere(); - - /// assignment operator - Sphere& operator=(const Sphere &other); - - /// radius of the sphere - float radius; - - /// position of the sphere - math::Vector3f position; - - /// draw the sphere - void draw(); - - /// Top color - math::Color topcolor; - /// bottom color - math::Color bottomcolor; - -private: - float *sintable; - float *costable; -}; - -} // namespace gl - -#endif // __INCLUDED_GL_SPHERE_H__ |