Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ROADMAP47
-rw-r--r--configure.in2
-rw-r--r--osirion.kdevelop10
-rw-r--r--osirion.kdevelop.pcsbin235690 -> 265729 bytes
-rw-r--r--osirion.kdevses30
-rw-r--r--src/Makefile.am2
-rw-r--r--src/client/Makefile.am6
-rw-r--r--src/client/camera.cc2
-rw-r--r--src/client/camera.h2
-rw-r--r--src/client/shipdrawer.cc61
-rw-r--r--src/client/stardrawer.cc4
-rw-r--r--src/client/stardrawer.h4
-rw-r--r--src/client/video.cc8
-rw-r--r--src/client/view.cc4
-rw-r--r--src/render/Makefile.am7
-rw-r--r--src/render/box.cc102
-rw-r--r--src/render/box.h44
-rw-r--r--src/render/gl.cc163
-rw-r--r--src/render/gl.h168
-rw-r--r--src/render/render.cc27
-rw-r--r--src/render/render.h22
-rw-r--r--src/render/sphere.cc95
-rw-r--r--src/render/sphere.h51
23 files changed, 783 insertions, 78 deletions
diff --git a/ROADMAP b/ROADMAP
index ca01134..1922191 100644
--- a/ROADMAP
+++ b/ROADMAP
@@ -1,3 +1,44 @@
-M1:
- Multiple ships, one ship controlled by the player
- Load ship specs and model
+SUBSYSTEMS
+
+core::
+ Cvar
+ Func
+ CommandBuffer
+ Entity
+ seperate client:: and game::
+
+network::
+ connections
+ protocal
+ chat, channels
+ rcon, commands
+
+* VERSION 0.1
+
+Description:
+ The game takes place in a simple solar system with one star,
+ one planet, one space station and one piece of yet-to-determine
+ decoration.
+
+ Multiple players can conect to the dedicated server. They can
+ fly around and see each other. They can use chat to communicate,
+ they can use private chat or global chat.
+
+Requires:
+ Network subsystem
+ Ship instances
+
+* VERSION 0.2
+ Players can shoot at each other. They can crash into the star
+ or the planet.
+
+
+* VERSION 0.3
+ Players can dock at the space station.
+
+
+* VERSION 0.4
+
+
+* VERSION 0.5
+ The game is ready to add data. \ No newline at end of file
diff --git a/configure.in b/configure.in
index e4854e4..d94f05e 100644
--- a/configure.in
+++ b/configure.in
@@ -137,7 +137,7 @@ CXXFLAGS="-pipe $DEBUG_CFLAGS $WARN_CFLAGS $CXXFLAGS"
AC_SUBST(CXXFLAGS)
AC_OUTPUT(Makefile src/Makefile src/client/Makefile src/core/Makefile \
- src/filesystem/Makefile src/game/Makefile src/gl/Makefile src/math/Makefile src/server/Makefile \
+ src/filesystem/Makefile src/game/Makefile src/math/Makefile src/render/Makefile src/server/Makefile \
src/sys/Makefile)
AC_MSG_RESULT([
diff --git a/osirion.kdevelop b/osirion.kdevelop
index 7032509..0a41004 100644
--- a/osirion.kdevelop
+++ b/osirion.kdevelop
@@ -21,7 +21,7 @@
</general>
<kdevautoproject>
<general>
- <activetarget>src/sys/libsys.la</activetarget>
+ <activetarget>src/render/librender.la</activetarget>
<useconfiguration>debug</useconfiguration>
</general>
<run>
@@ -29,12 +29,12 @@
<terminal>true</terminal>
<directoryradio>executable</directoryradio>
<runarguments>
- <osirion></osirion>
- <osiriond></osiriond>
+ <osirion/>
+ <osiriond/>
</runarguments>
<debugarguments>
- <osiriond></osiriond>
- <osirion></osirion>
+ <osiriond/>
+ <osirion/>
</debugarguments>
<cwd>
<osiriond>/home/ingar/projects/osirion/osirion-work/debug/src/</osiriond>
diff --git a/osirion.kdevelop.pcs b/osirion.kdevelop.pcs
index 67d2f75..6b83196 100644
--- a/osirion.kdevelop.pcs
+++ b/osirion.kdevelop.pcs
Binary files differ
diff --git a/osirion.kdevses b/osirion.kdevses
index 753d24f..520a288 100644
--- a/osirion.kdevses
+++ b/osirion.kdevses
@@ -1,34 +1,10 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession>
<KDevPrjSession>
- <DocsAndViews NumberOfDocuments="9" >
- <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/filesystem/file.cc" >
- <View0 Encoding="" line="7" Type="Source" />
+ <DocsAndViews NumberOfDocuments="1" >
+ <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/render/gl.cc" >
+ <View0 Encoding="" line="30" Type="Source" />
</Doc0>
- <Doc1 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/filesystem/filesystem.cc" >
- <View0 Encoding="" line="22" Type="Source" />
- </Doc1>
- <Doc2 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/filesystem/path.cc" >
- <View0 Encoding="" line="18" Type="Source" />
- </Doc2>
- <Doc3 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/applicationinterface.cc" >
- <View0 Encoding="" line="8" Type="Source" />
- </Doc3>
- <Doc4 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/game/game.h" >
- <View0 Encoding="" line="13" Type="Source" />
- </Doc4>
- <Doc5 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/game/game.cc" >
- <View0 Encoding="" line="23" Type="Source" />
- </Doc5>
- <Doc6 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/gl/gllib.cc" >
- <View0 Encoding="" line="8" Type="Source" />
- </Doc6>
- <Doc7 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/video.cc" >
- <View0 Encoding="" line="8" Type="Source" />
- </Doc7>
- <Doc8 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/client/view.cc" >
- <View0 Encoding="" line="45" Type="Source" />
- </Doc8>
</DocsAndViews>
<pluginList>
<kdevdebugger>
diff --git a/src/Makefile.am b/src/Makefile.am
index cd06cd7..eae6f48 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,7 @@
# set the include path found by configure
AM_CPPFLAGS = $(DEBUG_CFLAGS) $(WARN_CFLAGS) $(all_includes)
INCLUDES = -I$(top_srcdir)/src
-SUBDIRS = math sys filesystem core game server gl client
+SUBDIRS = math sys filesystem core game server render client
noinst_HEADERS = config.h
bin_PROGRAMS = osiriond osirion
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index f1a3f9d..4c20c54 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -8,6 +8,6 @@ libclient_la_LDFLAGS = -avoid-version -no-undefined $(GL_LIBS) $(LIBSDL_LIBS)
noinst_LTLIBRARIES = libclient.la
noinst_HEADERS = application.h camera.h client.h console.h input.h shipdrawer.h stardrawer.h \
video.h view.h
-libclient_la_LIBADD = $(top_builddir)/src/math/libmath.la \
- $(top_builddir)/src/sys/libsys.la $(top_builddir)/src/filesystem/libfilesystem.la \
- $(top_builddir)/src/core/libcore.la $(top_builddir)/src/game/libgame.la $(top_builddir)/src/gl/libgl.la
+libclient_la_LIBADD = $(top_builddir)/src/render/librender.la \
+ $(top_builddir)/src/core/libcore.la $(top_builddir)/src/filesystem/libfilesystem.la \
+ $(top_builddir)/src/game/libgame.la $(top_builddir)/src/math/libmath.la $(top_builddir)/src/sys/libsys.la
diff --git a/src/client/camera.cc b/src/client/camera.cc
index 08c60fa..5355a26 100644
--- a/src/client/camera.cc
+++ b/src/client/camera.cc
@@ -11,6 +11,8 @@
using math::degrees360f;
using math::degrees180f;
+using namespace render;
+
namespace client
{
diff --git a/src/client/camera.h b/src/client/camera.h
index da0890b..1a25689 100644
--- a/src/client/camera.h
+++ b/src/client/camera.h
@@ -7,7 +7,7 @@
#ifndef __INCLUDED_CLIENT_CAMERA_H__
#define __INCLUDED_CLIENT_CAMERA_H__
-#include "gl/gllib.h"
+#include "render/render.h"
namespace client {
diff --git a/src/client/shipdrawer.cc b/src/client/shipdrawer.cc
index e1c9adf..074dbd8 100644
--- a/src/client/shipdrawer.cc
+++ b/src/client/shipdrawer.cc
@@ -5,14 +5,15 @@
*/
#include "client/shipdrawer.h"
-#include "gl/gllib.h"
-#include "gl/box.h"
+#include "render/render.h"
+#include "render/box.h"
#include <iostream>
namespace client {
-using namespace gl;
+using namespace render;
+
using math::Vector3f;
using math::Color;
@@ -40,12 +41,12 @@ void ShipDrawer::draw(float elapsed)
{
gl::push();
- rotate(ship->yaw(), 0.0f, 1.0f, 0.0f );
+ gl::rotate(ship->yaw(), 0.0f, 1.0f, 0.0f );
Vector3f tl(0.25, 0.125, 0.125);
Vector3f br(-0.25, -0.125, -0.125);
- gl::Box box(tl, br);
+ Box box(tl, br);
box.draw();
tl = Vector3f(0, 0.07, 0.25);
@@ -70,43 +71,43 @@ void ShipDrawer::draw(float elapsed)
cockpit.draw();
if(ship->thrust() > 0 ) {
- color(1.0f,0 ,0 );
- begin(Lines);
- vertex(-0.5f, 0, 0.185);
- vertex(-0.5f-0.25f*ship->thrust(), 0, 0.185);
+ gl::color(1.0f,0 ,0 );
+ gl::begin(gl::Lines);
+ gl::vertex(-0.5f, 0, 0.185);
+ gl::vertex(-0.5f-0.25f*ship->thrust(), 0, 0.185);
- vertex(-0.5f, 0, -0.185f);
- vertex(-0.5f-0.25f*ship->thrust(), 0, -0.185f);
- end();
+ gl::vertex(-0.5f, 0, -0.185f);
+ gl::vertex(-0.5f-0.25f*ship->thrust(), 0, -0.185f);
+ gl::end();
}
// shield rotation
- rotate(angle, 0.0f, 1.0f, 0.0f );
+ gl::rotate(angle, 0.0f, 1.0f, 0.0f );
angle += 180.0f * elapsed;
if( angle > 360.0f ) {
angle -= 360.0f;
}
// draw the shield
- color(Color(0.0f, 1.0f ,0.0f , 0.5f));
+ gl::color(Color(0.0f, 1.0f ,0.0f , 0.5f));
+
+ gl::begin(gl::LineStrip);
+ gl::vertex(v0);
+ gl::vertex(v1);
+ gl::vertex(v2);
+ gl::vertex(v3);
+ gl::vertex(v0);
+ gl::end();
- begin(LineStrip);
- vertex(v0);
- vertex(v1);
- vertex(v2);
- vertex(v3);
- vertex(v0);
- end();
-
- begin(LineStrip);
- vertex(v4);
- vertex(v5);
- vertex(v6);
- vertex(v7);
- vertex(v4);
- end();
+ gl::begin(gl::LineStrip);
+ gl::vertex(v4);
+ gl::vertex(v5);
+ gl::vertex(v6);
+ gl::vertex(v7);
+ gl::vertex(v4);
+ gl::end();
gl::pop();
}
-} // namespace client
+}
diff --git a/src/client/stardrawer.cc b/src/client/stardrawer.cc
index 0f591bf..534c1e6 100644
--- a/src/client/stardrawer.cc
+++ b/src/client/stardrawer.cc
@@ -5,10 +5,12 @@
// projet headers
#include "client/stardrawer.h"
-#include "gl/gllib.h"
+#include "render/render.h"
namespace client {
+using namespace render;
+
StarDrawer::StarDrawer(game::Star *s) {
star = s;
sphere.radius = s->radius;
diff --git a/src/client/stardrawer.h b/src/client/stardrawer.h
index 6042659..dbfd91a 100644
--- a/src/client/stardrawer.h
+++ b/src/client/stardrawer.h
@@ -6,7 +6,7 @@
#ifndef __INCLUDED_STARDRAWER_H__
#define __INCLUDED_STARDRAWER_H__
-#include "gl/gllib.h"
+#include "render/sphere.h"
#include "game/star.h"
namespace client {
@@ -22,7 +22,7 @@ public:
private:
game::Star *star;
- gl::Sphere sphere;
+ render::Sphere sphere;
};
} // namespace client
diff --git a/src/client/video.cc b/src/client/video.cc
index ca0401f..5772961 100644
--- a/src/client/video.cc
+++ b/src/client/video.cc
@@ -5,11 +5,13 @@
*/
#include "client/client.h"
-#include "gl/gllib.h"
+#include "render/render.h"
#include "sys/sys.h"
#include <SDL/SDL.h>
+using namespace render;
+
namespace client {
Video::Video()
@@ -90,7 +92,7 @@ void Video::init()
return;
}
- gl::init();
+ render::init();
initialized = true;
view.init();
@@ -107,7 +109,7 @@ void Video::draw(float elapsed)
void Video::shutdown()
{
view.shutdown();
- gl::shutdown();
+ render::shutdown();
initialized = false;
width = 0;
diff --git a/src/client/view.cc b/src/client/view.cc
index 30dd6d6..8754549 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -7,13 +7,15 @@
#include "client/client.h"
#include "client/shipdrawer.h"
#include "client/stardrawer.h"
+#include "render/render.h"
#include "game/game.h"
-#include "gl/gllib.h"
#include "sys/sys.h"
#include "math/mathlib.h"
#include <SDL/SDL.h>
+using namespace render;
+
namespace client
{
diff --git a/src/render/Makefile.am b/src/render/Makefile.am
new file mode 100644
index 0000000..a993703
--- /dev/null
+++ b/src/render/Makefile.am
@@ -0,0 +1,7 @@
+INCLUDES = -I$(top_srcdir)/src
+METASOURCES = AUTO
+noinst_LTLIBRARIES = librender.la
+librender_la_LDFLAGS = -avoid-version -no-undefined @GL_LIBS@
+librender_la_LIBADD = $(top_builddir)/src/math/libmath.la
+librender_la_SOURCES = box.cc gl.cc render.cc sphere.cc
+noinst_HEADERS = box.h gl.h render.h sphere.h
diff --git a/src/render/box.cc b/src/render/box.cc
new file mode 100644
index 0000000..8819a40
--- /dev/null
+++ b/src/render/box.cc
@@ -0,0 +1,102 @@
+/*
+ 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 "render/box.h"
+
+namespace render {
+
+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()
+{
+ using namespace gl;
+
+ 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();
+
+}
+
+}
+
diff --git a/src/render/box.h b/src/render/box.h
new file mode 100644
index 0000000..9552b78
--- /dev/null
+++ b/src/render/box.h
@@ -0,0 +1,44 @@
+/*
+ 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 "render/render.h"
+#include "math/mathlib.h"
+
+namespace render {
+
+/// 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;
+};
+
+}
+
+#endif // __INCLUDED_GL_BOX_H__
+
diff --git a/src/render/gl.cc b/src/render/gl.cc
new file mode 100644
index 0000000..6eb91b1
--- /dev/null
+++ b/src/render/gl.cc
@@ -0,0 +1,163 @@
+/*
+ render/gl.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 "render/gl.h"
+
+// system includes
+#include "GL/gl.h"
+
+using math::Vector3f;
+using math::Color;
+
+namespace render {
+
+namespace gl {
+
+std::string renderer()
+{
+ return std::string ((char *)glGetString(GL_RENDERER));
+}
+
+std::string vendor()
+{
+ return std::string ((char *)glGetString(GL_VENDOR));
+}
+
+std::string version()
+{
+ return std::string ((char *)glGetString(GL_VERSION));
+}
+
+std::string extensions()
+{
+ return std::string ((char *)glGetString(GL_EXTENSIONS));
+}
+
+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
+
+} // namespace render
diff --git a/src/render/gl.h b/src/render/gl.h
new file mode 100644
index 0000000..0513410
--- /dev/null
+++ b/src/render/gl.h
@@ -0,0 +1,168 @@
+/*
+ render/gl.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_RENDER_GL_H__
+#define __INCLUDED_RENDER_GL_H__
+
+// project headers
+#include "math/vector3f.h"
+#include "math/color.h"
+
+// OpenGL headers
+#include <GL/gl.h>
+
+namespace render {
+
+/// wrapper namespace for OpenGL operations
+/** The gl namespace provides a wrapper to the OpenGL library functions.
+ * All methods take floats or Vector3f and Color as parameters.
+ */
+namespace gl
+{
+ /// name of the hardware OpenGL renderer
+ std::string renderer();
+ /// vender of the system OpenGL implementation
+ std::string vendor();
+ /// version of the system OpenGL implementation
+ std::string version();
+ /// Opengl Extensions string
+ std::string extensions();
+
+ /// enum to denote Vertex drawing modes
+ enum Primitive {
+ Points=GL_POINTS,
+ Lines=GL_LINES,
+ LineStrip=GL_LINE_STRIP,
+ LineLoop=GL_LINE_LOOP,
+ Triangles=GL_TRIANGLES,
+ TriangleStrip=GL_TRIANGLE_STRIP,
+ TriangleFan=GL_TRIANGLE_FAN,
+ Quads=GL_QUADS,
+ QuadStrip=GL_QUAD_STRIP,
+ Polygon=GL_POLYGON
+ };
+
+ /// glViewPort
+ void viewport(GLint x, GLint y, GLsizei width, GLsizei height );
+
+ /// 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
+ void clear (GLbitfield mask);
+
+ /// glMatrixMode
+ void matrixmode(GLenum mode);
+
+ /// glEnable
+ void enable(GLenum cap);
+
+ /// glDisable
+ void disable(GLenum cap);
+
+ /// glShadeModel
+ void shademodel(GLenum mode);
+
+ /// glCullFace
+ void cullface(GLenum mode);
+
+ /// glFrontFace
+ void frontface(GLenum mode);
+
+ /// glDepthMask
+ void depthmask(GLenum mode);
+
+ /// glBlendFunc
+ 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
+ * @see end()
+ */
+ void begin(Primitive primitive);
+
+ /// 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:
+ * 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.
+ */
+ 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]
+ * @param vector The rotation axes, relative to the origin (0,0,0)
+ */
+ 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
+ * @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)
+ */
+ 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
+ */
+ 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
+ */
+ void scale(const math::Vector3f& vector);
+
+ /// 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
+ */
+ void color(math::Color const & 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
+ */
+ void color(const float r, const float g, const float b, const float a=1.0f);
+
+ /// Push the current transformation matrix to the stack
+ void push();
+
+ /// Replace the transformation matrix with the top from the stack
+ void pop();
+
+ /// Replace the transformation matrix with the identity matrtix
+ void loadidentity();
+
+ /// Perspective matrix
+ void frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble znear, GLdouble zfar);
+}
+
+}
+
+#endif // __INCLUDED_RENDER_GL_H__
diff --git a/src/render/render.cc b/src/render/render.cc
new file mode 100644
index 0000000..2440b25
--- /dev/null
+++ b/src/render/render.cc
@@ -0,0 +1,27 @@
+/*
+ render/render.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 "render/render.h"
+#include "sys/sys.h"
+
+namespace render {
+
+void init()
+{
+ con_debug << "Initializing render..." << std::endl;
+
+ con_print << "Renderer: " << gl::renderer() << std::endl;
+ con_print << "Vendor: " << gl::vendor() << std::endl;
+ con_print << "Version: " << gl::version() << std::endl;
+}
+
+void shutdown()
+{
+ con_debug << "Shutting down render..." << std::endl;
+}
+
+}
diff --git a/src/render/render.h b/src/render/render.h
new file mode 100644
index 0000000..eaaef73
--- /dev/null
+++ b/src/render/render.h
@@ -0,0 +1,22 @@
+/*
+ render/render.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_RENDER_H__
+#define __INCLUDED_RENDER_H__
+
+
+namespace render {
+
+ /// initialize the render subsystem
+ void init();
+
+ /// shutdown the render subsystem
+ void shutdown();
+}
+
+#include "render/gl.h"
+
+#endif // __INCLUDED_RENDER_H__
diff --git a/src/render/sphere.cc b/src/render/sphere.cc
new file mode 100644
index 0000000..1715263
--- /dev/null
+++ b/src/render/sphere.cc
@@ -0,0 +1,95 @@
+/*
+ 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 "render/sphere.h"
+#include "math/mathlib.h"
+
+using math::Vector3f;
+using math::Color;
+
+namespace render {
+
+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()
+{
+ using namespace gl;
+
+ // 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();
+
+ }
+}
+
+
+}
+
diff --git a/src/render/sphere.h b/src/render/sphere.h
new file mode 100644
index 0000000..b3ac826
--- /dev/null
+++ b/src/render/sphere.h
@@ -0,0 +1,51 @@
+/*
+ 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 "render/gl.h"
+
+namespace render {
+
+/// 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__