diff options
82 files changed, 3694 insertions, 3796 deletions
diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..df2202e --- /dev/null +++ b/.clang-format @@ -0,0 +1,83 @@ +# Google C/C++ Code Style settings +# https://clang.llvm.org/docs/ClangFormatStyleOptions.html +# Author: Kehan Xue, kehan.xue (at) gmail.com + +Language: Cpp +BasedOnStyle: Google +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: None +AlignOperands: Align +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: Never # To avoid conflict, set this "Never" and each "if statement" should include brace when coding +AllowShortLambdasOnASingleLine: Inline +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType: None +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: true +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterStruct: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakBeforeBinaryOperators: None +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +ColumnLimit: 80 +CompactNamespaces: false +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false # Make sure the * or & align on the left +EmptyLineBeforeAccessModifier: LogicalBlock +FixNamespaceComments: true +IncludeBlocks: Preserve +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 2 +KeepEmptyLinesAtTheStartOfBlocks: true +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PointerAlignment: Left +ReflowComments: false +# SeparateDefinitionBlocks: Always # Only support since clang-format 14 +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInContainerLiterals: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: c++11 +TabWidth: 4 +UseTab: Never @@ -1,3 +1,5 @@ *~ *.swp *.swo + +Makefile @@ -4,15 +4,15 @@ * will be the base class for this */ #include "glox/GloxCommon.hpp" #include "slox/SloxApplication.hpp" -#include "slox/SloxTextureFactory.hpp" #include "slox/SloxRawEventHandler.hpp" +#include "slox/SloxTextureFactory.hpp" #include "slox/events/SloxFunctionQuitListener.hpp" -#include "glox/GloxViewport.hpp" -#include "glox/GloxFirstPersonPerspective.hpp" -#include "glox/objects/GloxTexturedCube.hpp" #include "glox/GloxColor.hpp" +#include "glox/GloxFirstPersonPerspective.hpp" #include "glox/GloxLookAtPerspective.hpp" +#include "glox/GloxViewport.hpp" +#include "glox/objects/GloxTexturedCube.hpp" #include "sons_of_sol/SonsOfSolApplication.hpp" @@ -20,13 +20,13 @@ using namespace slox; using namespace glox; using namespace std; -void exit( const SDL_QuitEvent& evt ) { - (void) evt; - exit( 0 ); +void exit(const SDL_QuitEvent& evt) { + (void)evt; + exit(0); } -int main ( int argc, char ** argv ) { - SonsOfSolApplication game; - game.run( argc, argv ); - return 0; +int main(int argc, char** argv) { + SonsOfSolApplication game; + game.run(argc, argv); + return 0; } diff --git a/Makefile b/Makefile deleted file mode 100644 index ebc57b9..0000000 --- a/Makefile +++ /dev/null @@ -1,58 +0,0 @@ -CPPC?=g++ -AR?=ar -OPTFLAGS?=-g3 -ggdb -CFLAGS= -Wall -Wextra -I. $(OPTFLAGS) -D DEBUG_LEVEL_TRACE -Islox -Iglox -LDFLAGS= -Lslox -Lglox -lslox -lglox -lGL -lGLU -lSDL -lm -ljpeg -lSDL_image -lGLEW -OBJECTS=obs/Main.o obs/AIShip.o obs/ControlMultiplexer.o obs/PlayerShip.o obs/ApplicationInit.o obs/SonsOfSolApplication.o obs/Projectile.o obs/ApplicationDisplay.o -BINARY=SonsOfSol -all: submodules setup $(OBJECTS) - $(CPPC) -o $(BINARY) $(OBJECTS) $(LDFLAGS) - -genmake: - find . -name genmake.sh -exec {} \; - -setup: - mkdir -p obs/ - -submodules: - for i in $$(find */ -name Makefile) ; do \ - cd $$(dirname $$i) && make && cd ..; \ - done - -clean: - - rm -rf obs $(BINARY) - for i in $$(find */ -name Makefile) ; do \ - cd $$(dirname $$i) && make clean && cd ..; \ - done -obs/Main.o: Main.cpp \ - sons_of_sol/SonsOfSolApplication.hpp - $(CPPC) $(CFLAGS) -o $@ -c $< - -obs/AIShip.o: sons_of_sol/private_db/AIShip.cpp \ - sons_of_sol/AIShip.hpp - $(CPPC) $(CFLAGS) -o $@ -c $< - -obs/ControlMultiplexer.o: sons_of_sol/private_db/ControlMultiplexer.cpp \ - sons_of_sol/ControlMultiplexer.hpp - $(CPPC) $(CFLAGS) -o $@ -c $< - -obs/PlayerShip.o: sons_of_sol/private_db/PlayerShip.cpp \ - sons_of_sol/PlayerShip.hpp - $(CPPC) $(CFLAGS) -o $@ -c $< - -obs/ApplicationInit.o: sons_of_sol/private_db/ApplicationInit.cpp \ - sons_of_sol/SonsOfSolApplication.hpp - $(CPPC) $(CFLAGS) -o $@ -c $< - -obs/SonsOfSolApplication.o: sons_of_sol/private_db/SonsOfSolApplication.cpp \ - sons_of_sol/SonsOfSolApplication.hpp - $(CPPC) $(CFLAGS) -o $@ -c $< - -obs/Projectile.o: sons_of_sol/private_db/Projectile.cpp \ - sons_of_sol/Projectile.hpp - $(CPPC) $(CFLAGS) -o $@ -c $< - -obs/ApplicationDisplay.o: sons_of_sol/private_db/ApplicationDisplay.cpp \ - sons_of_sol/SonsOfSolApplication.hpp - $(CPPC) $(CFLAGS) -o $@ -c $< - 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: <description> */ -#include "glox/GloxPoint.hpp" #include "glox/GloxColor.hpp" +#include "glox/GloxPoint.hpp" #include "glox/GloxRenderable.hpp" #include <map> @@ -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<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; + 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; }; -} +} // 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 |