aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2025-12-23 12:59:23 -0700
committerJosh Rahm <rahm@google.com>2025-12-23 12:59:23 -0700
commit46efbf05fcade8199035f956e20a63ca91fc88fd (patch)
tree9e3f3e297ea66e442e1a11b5ad16ad8ed6fc7fb7
parent306bb687414f54177eb37ab7cd744e491c397c31 (diff)
downloadSonsOfSol-46efbf05fcade8199035f956e20a63ca91fc88fd.tar.gz
SonsOfSol-46efbf05fcade8199035f956e20a63ca91fc88fd.tar.bz2
SonsOfSol-46efbf05fcade8199035f956e20a63ca91fc88fd.zip
Run clang-format and add .clang-format
-rw-r--r--.clang-format83
-rw-r--r--.gitignore2
-rw-r--r--Main.cpp22
-rw-r--r--Makefile58
-rw-r--r--glox/compat/glox/GloxLightSource.hpp135
-rw-r--r--glox/compat/glox/GloxLightSourceManager.hpp28
-rw-r--r--glox/compat/glox/objects/GloxCube.hpp55
-rw-r--r--glox/compat/glox/objects/GloxSphere.hpp6
-rw-r--r--glox/compat/glox/objects/GloxTexturedCube.hpp185
-rw-r--r--glox/compat/glox/objects/GloxTexturedSphere.hpp42
-rw-r--r--glox/compat/glox/objects/examples/GloxCylinder.hpp77
-rw-r--r--glox/glox/GloxColor.hpp165
-rw-r--r--glox/glox/GloxCommon.hpp89
-rw-r--r--glox/glox/GloxDebug.hpp84
-rw-r--r--glox/glox/GloxFirstPersonPerspective.hpp73
-rw-r--r--glox/glox/GloxLookAtPerspective.hpp75
-rw-r--r--glox/glox/GloxNormal.hpp135
-rw-r--r--glox/glox/GloxObject.hpp8
-rw-r--r--glox/glox/GloxPerspective.hpp35
-rw-r--r--glox/glox/GloxPlottable.hpp8
-rw-r--r--glox/glox/GloxPoint.hpp298
-rw-r--r--glox/glox/GloxPointCollection.hpp111
-rw-r--r--glox/glox/GloxPointNormal.hpp77
-rw-r--r--glox/glox/GloxPointNormalTexture.hpp51
-rw-r--r--glox/glox/GloxProgram.hpp96
-rw-r--r--glox/glox/GloxQuadStrip.hpp49
-rw-r--r--glox/glox/GloxRenderable.hpp6
-rw-r--r--glox/glox/GloxRotation.hpp43
-rw-r--r--glox/glox/GloxScopedAttributes.hpp16
-rw-r--r--glox/glox/GloxScopedBegin.hpp12
-rw-r--r--glox/glox/GloxScopedRotation.hpp28
-rw-r--r--glox/glox/GloxScopedTranslation.hpp16
-rw-r--r--glox/glox/GloxShader.hpp40
-rw-r--r--glox/glox/GloxStandardProjection.hpp77
-rw-r--r--glox/glox/GloxState.hpp64
-rw-r--r--glox/glox/GloxTexture.hpp18
-rw-r--r--glox/glox/GloxTextureFactory.hpp28
-rw-r--r--glox/glox/GloxTextureRepeat.hpp61
-rw-r--r--glox/glox/GloxVector3.hpp126
-rw-r--r--glox/glox/GloxVector4.hpp86
-rw-r--r--glox/glox/GloxVectorizable.hpp18
-rw-r--r--glox/glox/GloxViewport.hpp45
-rw-r--r--glox/glox/src/GloxCube.cpp128
-rw-r--r--glox/glox/src/GloxCylinder.cpp74
-rw-r--r--glox/glox/src/GloxFirstPersonPerspective.cpp38
-rw-r--r--glox/glox/src/GloxLightSource.cpp81
-rw-r--r--glox/glox/src/GloxLightSourceManager.cpp49
-rw-r--r--glox/glox/src/GloxProgram.cpp110
-rw-r--r--glox/glox/src/GloxShader.cpp89
-rw-r--r--glox/glox/src/GloxTextureFactory.cpp238
-rw-r--r--glox/glox/src/GloxTexturedCube.cpp248
-rw-r--r--glox/glox/src/GloxTexturedSphere.cpp72
-rw-r--r--slox/slox/SloxApplication.hpp42
-rw-r--r--slox/slox/SloxRawEventHandler.hpp58
-rw-r--r--slox/slox/SloxTextureFactory.hpp36
-rw-r--r--slox/slox/events/SloxFunctionQuitListener.hpp22
-rw-r--r--slox/slox/events/SloxKeyListener.hpp12
-rw-r--r--slox/slox/events/SloxMouseMotionListener.hpp16
-rw-r--r--slox/slox/events/SloxQuitListener.hpp8
-rw-r--r--slox/slox/events/SloxResizeListener.hpp6
-rw-r--r--slox/slox/loader/SloxModelObject.hpp20
-rw-r--r--slox/slox/loader/SloxObjectLoader.hpp97
-rw-r--r--slox/slox/loader/SloxObjectMaterial.hpp121
-rw-r--r--slox/slox/loader/private_db/SloxObjectLoader.cpp452
-rw-r--r--slox/slox/private_db/SloxApplication.cpp43
-rw-r--r--slox/slox/private_db/SloxRawEventHandler.cpp66
-rw-r--r--slox/slox/private_db/SloxTextureFactory.cpp314
-rw-r--r--sons_of_sol/AIShip.hpp67
-rw-r--r--sons_of_sol/ControlMotionEvent.hpp65
-rw-r--r--sons_of_sol/ControlMotionListener.hpp10
-rw-r--r--sons_of_sol/ControlMultiplexer.hpp108
-rw-r--r--sons_of_sol/PlayerShip.hpp177
-rw-r--r--sons_of_sol/Projectile.hpp41
-rw-r--r--sons_of_sol/SonsOfSolApplication.hpp272
-rw-r--r--sons_of_sol/Updaters.hpp52
-rw-r--r--sons_of_sol/private_db/AIShip.cpp196
-rw-r--r--sons_of_sol/private_db/ApplicationDisplay.cpp246
-rw-r--r--sons_of_sol/private_db/ApplicationInit.cpp449
-rw-r--r--sons_of_sol/private_db/ControlMultiplexer.cpp93
-rw-r--r--sons_of_sol/private_db/PlayerShip.cpp235
-rw-r--r--sons_of_sol/private_db/Projectile.cpp98
-rw-r--r--sons_of_sol/private_db/SonsOfSolApplication.cpp210
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
diff --git a/.gitignore b/.gitignore
index d772925..d7f1e84 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
*~
*.swp
*.swo
+
+Makefile
diff --git a/Main.cpp b/Main.cpp
index 869ac06..d6ee2fb 100644
--- a/Main.cpp
+++ b/Main.cpp
@@ -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( cons