From 46efbf05fcade8199035f956e20a63ca91fc88fd Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Tue, 23 Dec 2025 12:59:23 -0700 Subject: Run clang-format and add .clang-format --- glox/compat/glox/GloxLightSource.hpp | 135 +++++++-------- glox/compat/glox/GloxLightSourceManager.hpp | 28 ++-- glox/compat/glox/objects/GloxCube.hpp | 55 +++--- glox/compat/glox/objects/GloxSphere.hpp | 6 +- glox/compat/glox/objects/GloxTexturedCube.hpp | 185 ++++++++++----------- glox/compat/glox/objects/GloxTexturedSphere.hpp | 42 ++--- glox/compat/glox/objects/examples/GloxCylinder.hpp | 77 +++++---- 7 files changed, 254 insertions(+), 274 deletions(-) (limited to 'glox/compat') diff --git a/glox/compat/glox/GloxLightSource.hpp b/glox/compat/glox/GloxLightSource.hpp index 59331f9..ad159c8 100644 --- a/glox/compat/glox/GloxLightSource.hpp +++ b/glox/compat/glox/GloxLightSource.hpp @@ -7,8 +7,8 @@ * GloxLight.hpp: */ -#include "glox/GloxPoint.hpp" #include "glox/GloxColor.hpp" +#include "glox/GloxPoint.hpp" #include "glox/GloxRenderable.hpp" #include @@ -16,80 +16,71 @@ namespace glox { class GloxLightSource { -public: - /* Create a new light source using the light_id + 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 + 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 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; + 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 M_lm_map_t; + typedef std::map 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; }; -} +} // namespace glox #endif /* GLOXLIGHT_HPP_ */ diff --git a/glox/compat/glox/GloxLightSourceManager.hpp b/glox/compat/glox/GloxLightSourceManager.hpp index 27037c5..e084907 100644 --- a/glox/compat/glox/GloxLightSourceManager.hpp +++ b/glox/compat/glox/GloxLightSourceManager.hpp @@ -20,31 +20,31 @@ namespace glox { * and allocated through this GloxLightSourceManager */ class GloxLightSourceManager : public GloxRenderable { -public: - inline GloxLightSourceManager() { - /* Initialize the arry of LightSources to + 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; - } + for (size_t i = 0; i < GLOX_MAX_NUM_LIGHTS; ++i) { + m_sources[i] = NULL; } + } - /* Renders the lighting for this GloxLightSourceManager. + /* 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 ; + void render() const; - /* Returns the light source with + /* Returns the light source with * the ID `id'. Valid ID's are * 0-7. An invalid id will return * NULL. */ - GloxLightSource* getLightSource( int id ) ; + GloxLightSource* getLightSource(int id); -private: - /* The sources of light */ - GloxLightSource* m_sources[ GLOX_MAX_NUM_LIGHTS ]; + private: + /* The sources of light */ + GloxLightSource* m_sources[GLOX_MAX_NUM_LIGHTS]; }; -} +} // namespace glox #endif /* GLOXLIGHTSOURCEMANAGER_HPP_ */ diff --git a/glox/compat/glox/objects/GloxCube.hpp b/glox/compat/glox/objects/GloxCube.hpp index f0e8f51..764f993 100644 --- a/glox/compat/glox/objects/GloxCube.hpp +++ b/glox/compat/glox/objects/GloxCube.hpp @@ -9,48 +9,43 @@ * GloxTexturedCube in GloxTexturedCube.hpp */ +#include "glox/GloxColor.hpp" #include "glox/GloxCommon.hpp" #include "glox/GloxNormal.hpp" -#include "glox/GloxPoint.hpp" #include "glox/GloxObject.hpp" -#include "glox/GloxColor.hpp" +#include "glox/GloxPoint.hpp" #include "glox/GloxPointCollection.hpp" #include "glox/GloxScopedAttributes.hpp" namespace glox { class GloxCube : public GloxObject { -public: - /* Creates a new cube with the size + 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; + 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; }; -} +} // namespace glox #endif /* GLOXCUBE_HPP_ */ - diff --git a/glox/compat/glox/objects/GloxSphere.hpp b/glox/compat/glox/objects/GloxSphere.hpp index cd1a97a..720fef0 100644 --- a/glox/compat/glox/objects/GloxSphere.hpp +++ b/glox/compat/glox/objects/GloxSphere.hpp @@ -11,10 +11,10 @@ #include "glox/GloxObject" class GloxSphere : public GloxObject { -public: - GloxSphere( float radius, float res=2 ); + public: + GloxSphere(float radius, float res = 2); - void setTexture( const GloxTexture* texture ); + void setTexture(const GloxTexture* texture); } #endif /* GLOXSPHERE_HPP_ */ diff --git a/glox/compat/glox/objects/GloxTexturedCube.hpp b/glox/compat/glox/objects/GloxTexturedCube.hpp index c162fde..759dfa2 100644 --- a/glox/compat/glox/objects/GloxTexturedCube.hpp +++ b/glox/compat/glox/objects/GloxTexturedCube.hpp @@ -9,117 +9,112 @@ * GloxTexturedCube in GloxTexturedCube.hpp */ +#include "glox/GloxColor.hpp" #include "glox/GloxCommon.hpp" +#include "glox/GloxDebug.hpp" #include "glox/GloxNormal.hpp" -#include "glox/GloxPoint.hpp" #include "glox/GloxObject.hpp" -#include "glox/GloxColor.hpp" +#include "glox/GloxPoint.hpp" #include "glox/GloxPointCollection.hpp" +#include "glox/GloxPointNormalTexture.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 + 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 + 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 _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; + 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; + /* The color of this cube */ + GloxColor m_color; - - float m_half; + float m_half; }; -} +} // namespace glox #endif /* GLOXTEXTUREDCUBE_HPP_ */ - diff --git a/glox/compat/glox/objects/GloxTexturedSphere.hpp b/glox/compat/glox/objects/GloxTexturedSphere.hpp index d7a17e8..593c370 100644 --- a/glox/compat/glox/objects/GloxTexturedSphere.hpp +++ b/glox/compat/glox/objects/GloxTexturedSphere.hpp @@ -7,8 +7,8 @@ * GloxTexturedSphere.hpp: */ -#include "glox/GloxTexture.hpp" #include "glox/GloxObject.hpp" +#include "glox/GloxTexture.hpp" namespace glox { @@ -16,37 +16,37 @@ namespace glox { * The texture is mapped using a mercader projection */ class GloxTexturedSphere : public GloxObject { -public: - /* Create a new GloxTexturedSphere + 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 ); + GloxTexturedSphere(float radius, float res, const GloxTexture& texture); + + /* Draw this sphere */ + void draw() const; - /* Draw this sphere */ - void draw() const; + /* Returns teh radius of the sphere */ + inline float getRadius() const { return m_radius; } - /* 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; } - /* Set the radius of this sphere */ - inline void setRadius( float radius ) { m_radius = radius; } + /* Returns the texture */ + inline const GloxTexture& getTexture() const { return m_texture; } - /* Returns the texture */ - inline const GloxTexture& getTexture() const { return m_texture; } + private: + /* The texture of the sphere */ + GloxTexture m_texture; -private: - /* The texture of the sphere */ - GloxTexture m_texture; + /* The radius */ + float m_radius; - /* The radius */ - float m_radius; - - /* The display list of this sphere */ - int m_disp_list; + /* The display list of this sphere */ + int m_disp_list; }; -} +} // namespace glox #endif /* GLOXTEXTUREDSPHERE_HPP_ */ diff --git a/glox/compat/glox/objects/examples/GloxCylinder.hpp b/glox/compat/glox/objects/examples/GloxCylinder.hpp index 7436f8e..e7e0f32 100644 --- a/glox/compat/glox/objects/examples/GloxCylinder.hpp +++ b/glox/compat/glox/objects/examples/GloxCylinder.hpp @@ -10,11 +10,11 @@ #include "glox/GloxObject.hpp" #include "glox/GloxPointNormalTexture.hpp" -#include "glox/GloxTexture.hpp" #include "glox/GloxQuadStrip.hpp" +#include "glox/GloxTexture.hpp" -#include "glox/GloxScopedTranslation.hpp" #include "glox/GloxColor.hpp" +#include "glox/GloxScopedTranslation.hpp" #include "glox/GloxPoint.hpp" @@ -28,56 +28,55 @@ namespace glox { * a cylinder. This object supports lighting * and texturing */ class GloxCylinder : public GloxObject { -public: - /* Creates a cylinder with the radius r and the height + public: + /* Creates a cylinder with the radius r and the height * h. th_res specifies the radial resolution of this * cylinder */ - GloxCylinder( const GloxPoint& pos, float r, float h, - float th_res=6, const GloxTexture* texture=NULL, bool normals=true, float rep=1, float repy=1 ); + GloxCylinder(const GloxPoint& pos, float r, float h, float th_res = 6, + const GloxTexture* texture = NULL, bool normals = true, + float rep = 1, float repy = 1); - /* Get the position of this + /* Get the position of this * Cylinder */ - inline const GloxPoint& getPosition() const { - return m_position; - } - - /* Sets the position of this Cylinder */ - inline void setPosition( const GloxPoint& new_pos ) { - m_position = new_pos; + inline const GloxPoint& getPosition() const { return m_position; } + + /* Sets the position of this Cylinder */ + inline void setPosition(const GloxPoint& new_pos) { + m_position = new_pos; + } + + inline void draw() const { + if (m_texture) { + glEnable(GL_TEXTURE_2D); + m_texture->bind(); + } else { + glDisable(GL_TEXTURE_2D); } - - inline void draw() const { - if( m_texture ) { - glEnable(GL_TEXTURE_2D); - m_texture->bind(); - } else { - glDisable(GL_TEXTURE_2D); - } - /* Color of the tree without a texture */ - static const GloxColor brown( 139, 69, 19 ); - /* Translate to the position of + /* Color of the tree without a texture */ + static const GloxColor brown(139, 69, 19); + /* Translate to the position of * this object */ - GloxScopedTranslation trans( m_position ); + GloxScopedTranslation trans(m_position); - /* Set the OpenGL state machine to + /* Set the OpenGL state machine to * use brown as the color */ - m_body.plot(); - glDisable(GL_TEXTURE_2D); - } + m_body.plot(); + glDisable(GL_TEXTURE_2D); + } -private: - /* The position of this cylinder */ - GloxPoint m_position; - - /* the cylinder is basically just a quad + private: + /* The position of this cylinder */ + GloxPoint m_position; + + /* the cylinder is basically just a quad * strip. This object supports lighting, * so the components are PointNormals */ - GloxQuadStrip< GloxPointNormalTexture > m_body; + GloxQuadStrip m_body; - /* the texture used for ths cylinder */ - const GloxTexture* m_texture; + /* the texture used for ths cylinder */ + const GloxTexture* m_texture; }; -}; +}; // namespace glox #endif /* GLOXCYLINDER_HPP_ */ -- cgit