diff options
| author | Josh Rahm <rahm@google.com> | 2025-12-23 12:55:48 -0700 |
|---|---|---|
| committer | Josh Rahm <rahm@google.com> | 2025-12-23 12:55:48 -0700 |
| commit | 306bb687414f54177eb37ab7cd744e491c397c31 (patch) | |
| tree | bbe456fb2cd044dcd4790849122d3b718cee0540 | |
| parent | 6af9c3a9191e8a00f616ba321b2d5e407bb12ab3 (diff) | |
| download | SonsOfSol-306bb687414f54177eb37ab7cd744e491c397c31.tar.gz SonsOfSol-306bb687414f54177eb37ab7cd744e491c397c31.tar.bz2 SonsOfSol-306bb687414f54177eb37ab7cd744e491c397c31.zip | |
Inline submodules. Slox and Glox are not used anywhere else anymore
73 files changed, 4634 insertions, 6 deletions
diff --git a/.gitmodules b/.gitmodules index f1226c5..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +0,0 @@ -[submodule "glox"] - path = glox - url = git@github.com:joshuarahm/glox.git -[submodule "slox"] - path = slox - url = git@github.com:joshuarahm/slox.git diff --git a/glox b/glox deleted file mode 160000 -Subproject f095e4f1231278a2e5937500dfc72d393c3ed45 diff --git a/glox/Makefile b/glox/Makefile new file mode 100644 index 0000000..262a94b --- /dev/null +++ b/glox/Makefile @@ -0,0 +1,66 @@ +CPPC?=g++ +AR?=ar +OPTFLAGS?=-g3 -ggdb +CFLAGS= -Wall -Wextra -Icompat -I. $(OPTFLAGS) -D DEBUG_LEVEL_TRACE -Islox -Iglox +LDFLAGS= +OBJECTS=obs/GloxCube.o obs/GloxFirstPersonPerspective.o obs/GloxTexturedCube.o obs/GloxShader.o obs/GloxCylinder.o obs/GloxProgram.o obs/GloxLightSource.o obs/GloxTexturedSphere.o obs/GloxLightSourceManager.o obs/GloxTextureFactory.o +BINARY=libglox.a +all: setup $(OBJECTS) + $(AR) -r $(BINARY) $(OBJECTS) + +setup: + mkdir -p obs/ + +clean: + - rm -rf obs $(BINARY) + +obs/GloxCube.o: ./glox/src/GloxCube.cpp \ + glox/GloxScopedBegin.hpp + $(CPPC) $(CFLAGS) -o $@ -c $< + +obs/GloxFirstPersonPerspective.o: ./glox/src/GloxFirstPersonPerspective.cpp \ + glox/GloxCommon.hpp \ + glox/GloxFirstPersonPerspective.hpp \ + glox/GloxState.hpp \ + glox/GloxDebug.hpp + $(CPPC) $(CFLAGS) -o $@ -c $< + +obs/GloxTexturedCube.o: ./glox/src/GloxTexturedCube.cpp \ + glox/GloxScopedBegin.hpp + $(CPPC) $(CFLAGS) -o $@ -c $< + +obs/GloxShader.o: ./glox/src/GloxShader.cpp \ + glox/GloxShader.hpp + $(CPPC) $(CFLAGS) -o $@ -c $< + +obs/GloxCylinder.o: ./glox/src/GloxCylinder.cpp \ + glox/GloxDebug.hpp + $(CPPC) $(CFLAGS) -o $@ -c $< + +obs/GloxProgram.o: ./glox/src/GloxProgram.cpp \ + glox/GloxProgram.hpp + $(CPPC) $(CFLAGS) -o $@ -c $< + +obs/GloxLightSource.o: ./glox/src/GloxLightSource.cpp \ + glox/GloxDebug.hpp + $(CPPC) $(CFLAGS) -o $@ -c $< + +obs/GloxTexturedSphere.o: ./glox/src/GloxTexturedSphere.cpp \ + glox/GloxCommon.hpp \ + glox/GloxPoint.hpp \ + glox/GloxNormal.hpp \ + glox/GloxPointNormalTexture.hpp \ + glox/GloxScopedAttributes.hpp + $(CPPC) $(CFLAGS) -o $@ -c $< + +obs/GloxLightSourceManager.o: ./glox/src/GloxLightSourceManager.cpp \ + glox/GloxState.hpp + $(CPPC) $(CFLAGS) -o $@ -c $< + +obs/GloxTextureFactory.o: ./glox/src/GloxTextureFactory.cpp \ + glox/GloxTextureFactory.hpp \ + glox/GloxTexture.hpp \ + glox/GloxCommon.hpp \ + glox/GloxDebug.hpp + $(CPPC) $(CFLAGS) -o $@ -c $< + diff --git a/glox/README.txt b/glox/README.txt new file mode 100644 index 0000000..895b44c --- /dev/null +++ b/glox/README.txt @@ -0,0 +1,39 @@ +LibGlox - GL Object eXtension +----------------------------- + +LibGlox is an extension to OpenGL which wraps the +API in a friendlier, object-oriented framework which +abstracts away much of the OpenGL state machine to +make it harder to shoot yourself in the foot. + +Much of library is inlined, which means that the performance +hit from the abstraction layer is minimal. + +In order to build LibGlox, you must first generate the Makfile; this +is easy, just run ./genmake.sh from terminal then run make. + +This will produce a static library to statically link against, unfortunately +as of now, there is no shared library :-( It should, however, be trivial to change +the makefile to build one. + + +Developer Stuff +--------------- + +There are 3 main types of "drawable" objects in Glox. + +The first class is Plottable (GloxPlottable) objects. These +objects will simply and dumbly plot, they effect the OpenGL state +machine minimally; mostly restricted to points and normals. +However; plottable objects are very dependent +on the state of the state machine before they plot. Examples +of plottable objects are GloxPoint and GloxNormal. + +The second class is Renderable (GloxRenderable) objects. These +objects will change the state of the GL state machine. Examples +of renderable objects are GloxPerspective and GloxColor. + +Finally, the third class is full blown objects (GloxObjects) they are +similar to plottable, however they should not depend on the +original state of the StateMachine and ideally should restore +the StateMachine to the state it was in if possible diff --git a/glox/compat/glox/GloxLightSource.hpp b/glox/compat/glox/GloxLightSource.hpp new file mode 100644 index 0000000..59331f9 --- /dev/null +++ b/glox/compat/glox/GloxLightSource.hpp @@ -0,0 +1,95 @@ +#ifndef GLOXLIGHT_HPP_ +#define GLOXLIGHT_HPP_ + +/* + * Author: jrahm + * created: 2013/10/22 + * GloxLight.hpp: <description> + */ + +#include "glox/GloxPoint.hpp" +#include "glox/GloxColor.hpp" +#include "glox/GloxRenderable.hpp" + +#include <map> + +namespace glox { + +class GloxLightSource { +public: + /* Create a new light source using the light_id + * that is to be used in OpenGl */ + inline GloxLightSource( GLenum light_id ) : + m_light( light_id ) {} + + /* Sets the color of this light + * source */; + void setColor( const GloxColor& color ); + + /* Sets the position of a point */ + void setPosition( const GloxPoint<>& position, bool directional=false ) { + m_pos = position; + this->directional = directional; + } + + inline const GloxPointf& getPosition() { return m_pos ; } + + /* Sets whether this light is + * enabled or not */ + inline void setEnabled( bool enabled ) { + this->enabled = enabled; + } + + /* True if this light is enabled */ + inline bool isEnabled() const { + return this->enabled; + } + + inline void setAmbient( const GloxColor& color ) { + this->ambient = color; + } + + inline void setDiffuse( const GloxColor& color ) { + this->diffuse = color; + } + + inline void setSpecular( const GloxColor& color ) { + this->specular = color; + } + + inline void setLightModelAttribute( GLenum attr, float value ) { + lightModelsAttrs[attr] = value; + } + + inline void setLightModelAttribute( GLenum attr, const GloxColor& color ) { + lightModelsAttrs_vectors[attr] = color; + } + + /* Reder this light source */ + void render() const ; + +private: + typedef std::map<GLenum,float> M_lm_map_t; + typedef std::map< GLenum,GloxColor > M_lm_map_vec_t; + + GLenum m_light; + + GloxPoint<> m_pos; + bool directional; + + /* The index of this light source */ + int index; + bool enabled; + + /* Colors for different attributes */ + GloxColor ambient; + GloxColor diffuse; + GloxColor specular; + + M_lm_map_t lightModelsAttrs; + M_lm_map_vec_t lightModelsAttrs_vectors; +}; + +} + +#endif /* GLOXLIGHT_HPP_ */ diff --git a/glox/compat/glox/GloxLightSourceManager.hpp b/glox/compat/glox/GloxLightSourceManager.hpp new file mode 100644 index 0000000..27037c5 --- /dev/null +++ b/glox/compat/glox/GloxLightSourceManager.hpp @@ -0,0 +1,50 @@ +#ifndef GLOXLIGHTSOURCEMANAGER_HPP_ +#define GLOXLIGHTSOURCEMANAGER_HPP_ + +#define GLOX_MAX_NUM_LIGHTS 8 + +/* + * Author: jrahm + * created: 2013/10/23 + * GloxLightSourceManager.hpp: <description> + */ + +#include "glox/GloxCommon.hpp" +#include "glox/GloxLightSource.hpp" +#include "glox/GloxRenderable.hpp" + +namespace glox { + +/* Since there are a finite number of light + * sources in OpenGL, they must be managed + * and allocated through this GloxLightSourceManager + */ +class GloxLightSourceManager : public GloxRenderable { +public: + inline GloxLightSourceManager() { + /* Initialize the arry of LightSources to + * NULL */ + for( size_t i = 0; i < GLOX_MAX_NUM_LIGHTS; ++ i ) { + m_sources[i] = NULL; + } + } + + /* Renders the lighting for this GloxLightSourceManager. + * This will render the scene with the lights in this + * manager and only the lights in this manager */ + void render() const ; + + /* Returns the light source with + * the ID `id'. Valid ID's are + * 0-7. An invalid id will return + * NULL. */ + GloxLightSource* getLightSource( int id ) ; + +private: + /* The sources of light */ + GloxLightSource* m_sources[ GLOX_MAX_NUM_LIGHTS ]; +}; + +} + +#endif /* GLOXLIGHTSOURCEMANAGER_HPP_ */ diff --git a/glox/compat/glox/objects/GloxCube.hpp b/glox/compat/glox/objects/GloxCube.hpp new file mode 100644 index 0000000..f0e8f51 --- /dev/null +++ b/glox/compat/glox/objects/GloxCube.hpp @@ -0,0 +1,56 @@ +#ifndef GLOXCUBE_HPP_ +#define GLOXCUBE_HPP_ + +/* + * Author: jrahm + * created: 2013/10/28 + * GloxCube.hpp: This header contains the header for a cube class. + * This cube class does not have textures. For a textured cube, use + * GloxTexturedCube in GloxTexturedCube.hpp + */ + +#include "glox/GloxCommon.hpp" +#include "glox/GloxNormal.hpp" +#include "glox/GloxPoint.hpp" +#include "glox/GloxObject.hpp" +#include "glox/GloxColor.hpp" +#include "glox/GloxPointCollection.hpp" +#include "glox/GloxScopedAttributes.hpp" + +namespace glox { + +class GloxCube : public GloxObject { +public: + /* Creates a new cube with the size + * `size`. The size is the length of + * each side of the cube */ + GloxCube( float x, float y, float z, const GloxColor& color ); + + inline GloxCube( const GloxCube& other ) { + m_disp_list = other.m_disp_list ; + m_color = other.m_color; + } + + /* Draw this cube */ + void draw() const ; + + /* Sets the color of this cube */ + inline void setColor( const GloxColor& color ) { + m_color = color; + } + + /* Returns the color of this cube */ + inline const GloxColor& getColor() const { + return m_color; + } + +private: + int m_disp_list ; + /* The color of this cube */ + GloxColor m_color; +}; + +} + +#endif /* GLOXCUBE_HPP_ */ + diff --git a/glox/compat/glox/objects/GloxSphere.hpp b/glox/compat/glox/objects/GloxSphere.hpp new file mode 100644 index 0000000..cd1a97a --- /dev/null +++ b/glox/compat/glox/objects/GloxSphere.hpp @@ -0,0 +1,20 @@ +#ifndef GLOXSPHERE_HPP_ +#define GLOXSPHERE_HPP_ + +/* + * Author: jrahm + * created: 2013/10/22 + * GloxSphere.hpp: Better implemenation of + * the Sphere.hpp + */ + +#include "glox/GloxObject" + +class GloxSphere : public GloxObject { +public: + GloxSphere( float radius, float res=2 ); + + void setTexture( const GloxTexture* texture ); +} + +#endif /* GLOXSPHERE_HPP_ */ diff --git a/glox/compat/glox/objects/GloxTexturedCube.hpp b/glox/compat/glox/objects/GloxTexturedCube.hpp new file mode 100644 index 0000000..c162fde --- /dev/null +++ b/glox/compat/glox/objects/GloxTexturedCube.hpp @@ -0,0 +1,125 @@ +#ifndef GLOXTEXTUREDCUBE_HPP_ +#define GLOXTEXTUREDCUBE_HPP_ + +/* + * Author: jrahm + * created: 2013/10/28 + * GloxTexturedCube.hpp: This header contains the header for a cube class. + * This cube class does not have textures. For a textured cube, use + * GloxTexturedCube in GloxTexturedCube.hpp + */ + +#include "glox/GloxCommon.hpp" +#include "glox/GloxNormal.hpp" +#include "glox/GloxPoint.hpp" +#include "glox/GloxObject.hpp" +#include "glox/GloxColor.hpp" +#include "glox/GloxPointCollection.hpp" +#include "glox/GloxScopedAttributes.hpp" +#include "glox/GloxTextureRepeat.hpp" +#include "glox/GloxPointNormalTexture.hpp" +#include "glox/GloxDebug.hpp" + +namespace glox { + +class GloxTexturedCube : public GloxObject { +public: + /* Creates a new cube with the size + * `size`. The size is the length of + * each side of the cube */ + GloxTexturedCube( float size, const GloxColor& color, + const GloxTextureRepeat& topTex = GloxTextureRepeat(NULL), + const GloxTextureRepeat& botTex = GloxTextureRepeat(NULL), + const GloxTextureRepeat& frontTex = GloxTextureRepeat(NULL), + const GloxTextureRepeat& backTex = GloxTextureRepeat(NULL), + const GloxTextureRepeat& leftTex = GloxTextureRepeat(NULL), + const GloxTextureRepeat& rightTex = GloxTextureRepeat(NULL) ); + + /* Draw this cube */ + void draw() const ; + + /* Sets the color of this cube */ + inline void setColor( const GloxColor& color ) { + m_color = color; + } + + /* Returns the color of this cube */ + inline const GloxColor& getColor() const { + return m_color; + } + + inline void setTopTexture( const GloxTextureRepeat& top_tex ) { + m_top_tex = top_tex; + update_top(); + } + + inline void setBottomTexture( const GloxTextureRepeat& tex ) { + m_bottom_tex = tex; + update_bottom(); + } + + inline void setFrontTexture( const GloxTextureRepeat& tex ) { + m_front_tex = tex; + update_front(); + } + + inline void setBackTexture( const GloxTextureRepeat& tex ) { + m_back_tex = tex; + update_back(); + } + + inline void setRightTexture( const GloxTextureRepeat& tex ) { + m_right_tex = tex; + update_right(); + } + + inline void setLeftTexture( const GloxTextureRepeat& tex ) { + m_left_tex = tex; + update_left(); + } + +private: + void update_top(); + void update_bottom(); + void update_front(); + void update_back(); + void update_right(); + void update_left(); + + /* A typedef to make my life easier */ + typedef GloxPointCollection< GloxPointNormalTexture > _M_Square; + + inline void plot_with( const _M_Square& face, const GloxTextureRepeat& tex ) const; + + /* +/- y axis */ + _M_Square m_top; + _M_Square m_bottom; + + /* -/+ z axis */ + _M_Square m_front; + _M_Square m_back; + + /* -/+ x axis */ + _M_Square m_left; + _M_Square m_right; + + /* The textures for the various faces of + * the cube */ + GloxTextureRepeat m_top_tex; + GloxTextureRepeat m_bottom_tex; + GloxTextureRepeat m_front_tex; + GloxTextureRepeat m_back_tex; + GloxTextureRepeat m_left_tex; + GloxTextureRepeat m_right_tex; + + /* The color of this cube */ + GloxColor m_color; + + + float m_half; +}; + +} + +#endif /* GLOXTEXTUREDCUBE_HPP_ */ + diff --git a/glox/compat/glox/objects/GloxTexturedSphere.hpp b/glox/compat/glox/objects/GloxTexturedSphere.hpp new file mode 100644 index 0000000..d7a17e8 --- /dev/null +++ b/glox/compat/glox/objects/GloxTexturedSphere.hpp @@ -0,0 +1,52 @@ +#ifndef GLOXTEXTUREDSPHERE_HPP_ +#define GLOXTEXTUREDSPHERE_HPP_ + +/* + * Author: jrahm + * created: 2013/11/07 + * GloxTexturedSphere.hpp: <description> + */ + +#include "glox/GloxTexture.hpp" +#include "glox/GloxObject.hpp" + +namespace glox { + +/* A sphere that has a texture mapped to it. + * The texture is mapped using a mercader projection + */ +class GloxTexturedSphere : public GloxObject { +public: + /* Create a new GloxTexturedSphere + * radius: the radius of the sphere + * res: the resolution of the sphere. Should + * be a factor of 360 + * */ + GloxTexturedSphere( float radius, float res, const GloxTexture& texture ); + + /* Draw this sphere */ + void draw() const; + + /* Returns teh radius of the sphere */ + inline float getRadius() const { return m_radius; } + + /* Set the radius of this sphere */ + inline void setRadius( float radius ) { m_radius = radius; } + + |