diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-01-17 19:36:30 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-01-17 22:16:48 +0000 |
commit | 0bf4ad9e4a9e1c97e92aa23a365405dfef89bd7c (patch) | |
tree | 68a80976a247836bbb1eecc835af437e3489fbb7 | |
parent | First cut modernizing and sanitizing (diff) | |
download | ilt-0bf4ad9e4a9e1c97e92aa23a365405dfef89bd7c.tar.bz2 ilt-0bf4ad9e4a9e1c97e92aa23a365405dfef89bd7c.tar.xz ilt-0bf4ad9e4a9e1c97e92aa23a365405dfef89bd7c.zip |
Big reshuffle
Fixes code quality warnings now picked up.
-rw-r--r-- | Jamroot.jam | 6 | ||||
-rw-r--r-- | application/display.cpp (renamed from display.cpp) | 0 | ||||
-rw-r--r-- | application/display.h (renamed from display.h) | 8 | ||||
-rw-r--r-- | application/main.cpp (renamed from main.cpp) | 10 | ||||
-rw-r--r-- | gfx/gl/camera.cpp (renamed from camera.cpp) | 0 | ||||
-rw-r--r-- | gfx/gl/camera.h (renamed from camera.h) | 2 | ||||
-rw-r--r-- | gfx/gl/shader.cpp (renamed from shader.cpp) | 4 | ||||
-rw-r--r-- | gfx/gl/shader.h (renamed from shader.h) | 6 | ||||
-rw-r--r-- | gfx/gl/shaders/basicShader.fs (renamed from res/basicShader.fs) | 0 | ||||
-rw-r--r-- | gfx/gl/shaders/basicShader.vs (renamed from res/basicShader.vs) | 0 | ||||
-rw-r--r-- | gfx/gl/transform.cpp (renamed from transform.cpp) | 0 | ||||
-rw-r--r-- | gfx/gl/transform.h (renamed from transform.h) | 19 | ||||
-rw-r--r-- | gfx/models/mesh.cpp (renamed from mesh.cpp) | 0 | ||||
-rw-r--r-- | gfx/models/mesh.h (renamed from mesh.h) | 7 | ||||
-rw-r--r-- | gfx/models/obj_loader.cpp (renamed from obj_loader.cpp) | 0 | ||||
-rw-r--r-- | gfx/models/obj_loader.h (renamed from obj_loader.h) | 0 | ||||
-rw-r--r-- | gfx/models/stb_image.c (renamed from stb_image.c) | 0 | ||||
-rw-r--r-- | gfx/models/texture.cpp (renamed from texture.cpp) | 0 | ||||
-rw-r--r-- | gfx/models/texture.h (renamed from texture.h) | 8 | ||||
-rw-r--r-- | gfx/models/vertex.hpp (renamed from vertex.hpp) | 1 | ||||
-rw-r--r-- | util.h | 34 | ||||
-rw-r--r-- | utility/ptr.hpp (renamed from ptr.hpp) | 0 | ||||
-rw-r--r-- | utility/special_members.hpp | 12 |
23 files changed, 50 insertions, 67 deletions
diff --git a/Jamroot.jam b/Jamroot.jam index 5058f6a..e67a00c 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -13,8 +13,8 @@ project : requirements <variant>debug:<warnings>extra <variant>debug:<warnings-as-errors>on <variant>release:<lto>on - <toolset>tidy:<exclude>bin/res/fs-basicShader.h - <toolset>tidy:<exclude>bin/res/vs-basicShader.h + <toolset>tidy:<exclude>bin/gfx/gl/shaders/fs-basicShader.h + <toolset>tidy:<exclude>bin/gfx/gl/shaders/vs-basicShader.h <toolset>tidy:<checkxx>boost-* <toolset>tidy:<checkxx>bugprone-* <toolset>tidy:<checkxx>clang-* @@ -45,6 +45,8 @@ IMPORT $(__name__) : xxd.i : : xxd.i ; exe test : [ glob-tree *.cpp *.c *.vs *.fs : bin ] : + <include>. + <include>utility <library>sdl2 <library>glew <use>stb diff --git a/display.cpp b/application/display.cpp index b4a42d7..b4a42d7 100644 --- a/display.cpp +++ b/application/display.cpp diff --git a/display.h b/application/display.h index e5fcc73..b561d77 100644 --- a/display.h +++ b/application/display.h @@ -3,18 +3,18 @@ #include "ptr.hpp"
#include <SDL2/SDL.h>
+#include <special_members.hpp>
#include <string>
#include <type_traits>
class Display {
public:
Display(int width, int height, const std::string & title);
-
- Display(const Display &) = delete;
- void operator=(const Display &) = delete;
-
virtual ~Display();
+ NO_COPY(Display);
+ NO_MOVE(Display);
+
void Clear(float r, float g, float b, float a) const;
void SwapBuffers() const;
diff --git a/main.cpp b/application/main.cpp index 7f67ad4..a5a09e5 100644 --- a/main.cpp +++ b/application/main.cpp @@ -1,11 +1,11 @@ -#include "camera.h" #include "display.h" -#include "mesh.h" -#include "shader.h" -#include "texture.h" -#include "transform.h" #include <SDL2/SDL.h> #include <cmath> +#include <gfx/gl/camera.h> +#include <gfx/gl/shader.h> +#include <gfx/gl/transform.h> +#include <gfx/models/mesh.h> +#include <gfx/models/texture.h> #include <glm/glm.hpp> #include <memory> #include <numbers> diff --git a/camera.cpp b/gfx/gl/camera.cpp index b4a76d0..b4a76d0 100644 --- a/camera.cpp +++ b/gfx/gl/camera.cpp diff --git a/camera.h b/gfx/gl/camera.h index 3c1e40c..fa4296d 100644 --- a/camera.h +++ b/gfx/gl/camera.h @@ -7,7 +7,7 @@ class Camera { public:
Camera(glm::vec3 pos, float fov, float aspect, float zNear, float zFar);
- glm::mat4 GetViewProjection() const;
+ [[nodiscard]] glm::mat4 GetViewProjection() const;
void MoveForward(float amt);
void MoveRight(float amt);
diff --git a/shader.cpp b/gfx/gl/shader.cpp index 4d9f43b..33fdf61 100644 --- a/shader.cpp +++ b/gfx/gl/shader.cpp @@ -1,8 +1,8 @@ #include "shader.h"
#include "transform.h"
+#include <gfx/gl/shaders/fs-basicShader.h>
+#include <gfx/gl/shaders/vs-basicShader.h>
#include <glm/glm.hpp>
-#include <res/fs-basicShader.h>
-#include <res/vs-basicShader.h>
#include <stdexcept>
Shader::Shader(const std::string &) :
diff --git a/shader.h b/gfx/gl/shader.h index 85a7d58..2072199 100644 --- a/shader.h +++ b/gfx/gl/shader.h @@ -3,6 +3,7 @@ #include <GL/glew.h>
#include <array>
+#include <special_members.hpp>
#include <string>
class Camera;
@@ -12,8 +13,9 @@ class Shader { public:
explicit Shader(const std::string & fileName);
virtual ~Shader();
- void operator=(const Shader &) = delete;
- Shader(const Shader &) = delete;
+
+ NO_COPY(Shader);
+ NO_MOVE(Shader);
void Bind() const;
void Update(const Transform & transform, const Camera & camera) const;
diff --git a/res/basicShader.fs b/gfx/gl/shaders/basicShader.fs index 3aa974f..3aa974f 100644 --- a/res/basicShader.fs +++ b/gfx/gl/shaders/basicShader.fs diff --git a/res/basicShader.vs b/gfx/gl/shaders/basicShader.vs index e673548..e673548 100644 --- a/res/basicShader.vs +++ b/gfx/gl/shaders/basicShader.vs diff --git a/transform.cpp b/gfx/gl/transform.cpp index 7b256af..7b256af 100644 --- a/transform.cpp +++ b/gfx/gl/transform.cpp diff --git a/transform.h b/gfx/gl/transform.h index 783ef31..07040ae 100644 --- a/transform.h +++ b/gfx/gl/transform.h @@ -2,31 +2,30 @@ #define TRANSFORM_INCLUDED_H
#include <glm/glm.hpp>
-#include <utility>
class Camera;
class Transform {
public:
- Transform(glm::vec3 pos = {}, glm::vec3 rot = {}, glm::vec3 scale = {1.0f, 1.0f, 1.0f});
+ explicit Transform(glm::vec3 pos = {}, glm::vec3 rot = {}, glm::vec3 scale = {1.0F, 1.0F, 1.0F});
- glm::mat4 GetModel() const;
+ [[nodiscard]] glm::mat4 GetModel() const;
- glm::mat4 GetMVP(const Camera & camera) const;
+ [[nodiscard]] glm::mat4 GetMVP(const Camera & camera) const;
- inline glm::vec3 &
+ [[nodiscard]] inline glm::vec3 &
GetPos()
{
return pos;
}
- inline glm::vec3 &
+ [[nodiscard]] inline glm::vec3 &
GetRot()
{
return rot;
}
- inline glm::vec3 &
+ [[nodiscard]] inline glm::vec3 &
GetScale()
{
return scale;
@@ -35,19 +34,19 @@ public: inline void
SetPos(glm::vec3 && pos)
{
- this->pos = std::move(pos);
+ this->pos = pos;
}
inline void
SetRot(glm::vec3 && rot)
{
- this->rot = std::move(rot);
+ this->rot = rot;
}
inline void
SetScale(glm::vec3 && scale)
{
- this->scale = std::move(scale);
+ this->scale = scale;
}
private:
diff --git a/mesh.cpp b/gfx/models/mesh.cpp index 8c304b3..8c304b3 100644 --- a/mesh.cpp +++ b/gfx/models/mesh.cpp diff --git a/mesh.h b/gfx/models/mesh.h index 69f41b9..453e54a 100644 --- a/mesh.h +++ b/gfx/models/mesh.h @@ -4,6 +4,7 @@ #include <GL/glew.h>
#include <array>
#include <cstddef>
+#include <special_members.hpp>
#include <string>
class IndexedModel;
@@ -16,11 +17,11 @@ public: explicit Mesh(const std::string & fileName);
explicit Mesh(const IndexedModel & model);
Mesh(Vertex * vertices, unsigned int numVertices, unsigned int * indices, unsigned int numIndices);
- Mesh(const Mesh &) = delete;
- void operator=(const Mesh &) = delete;
-
virtual ~Mesh();
+ NO_COPY(Mesh);
+ NO_MOVE(Mesh);
+
void Draw();
private:
diff --git a/obj_loader.cpp b/gfx/models/obj_loader.cpp index 7611a2c..7611a2c 100644 --- a/obj_loader.cpp +++ b/gfx/models/obj_loader.cpp diff --git a/obj_loader.h b/gfx/models/obj_loader.h index 11c6b38..11c6b38 100644 --- a/obj_loader.h +++ b/gfx/models/obj_loader.h diff --git a/stb_image.c b/gfx/models/stb_image.c index a839b61..a839b61 100644 --- a/stb_image.c +++ b/gfx/models/stb_image.c diff --git a/texture.cpp b/gfx/models/texture.cpp index a388b32..a388b32 100644 --- a/texture.cpp +++ b/gfx/models/texture.cpp diff --git a/texture.h b/gfx/models/texture.h index 9955f01..6ebf88d 100644 --- a/texture.h +++ b/gfx/models/texture.h @@ -2,20 +2,20 @@ #define TEXTURE_H
#include <GL/glew.h>
+#include <special_members.hpp>
#include <string>
class Texture {
public:
explicit Texture(const std::string & fileName);
- Texture(const Texture &) = delete;
- void operator=(const Texture &) = delete;
-
virtual ~Texture();
+ NO_COPY(Texture);
+ NO_MOVE(Texture);
+
void Bind() const;
-protected:
private:
GLuint m_texture;
};
diff --git a/vertex.hpp b/gfx/models/vertex.hpp index 3f6514b..4ab6024 100644 --- a/vertex.hpp +++ b/gfx/models/vertex.hpp @@ -33,4 +33,5 @@ private: glm::vec2 texCoord; glm::vec3 normal; }; + #endif @@ -1,34 +0,0 @@ -#ifndef UTIL_H_INCLUDED -#define UTIL_H_INCLUDED - -#include <sstream> -#include <vector> - -namespace Util { - std::vector<std::string> - Split(const std::string & s, char delim) - { - std::vector<std::string> elems; - - const char * cstr = s.c_str(); - unsigned int strLength = s.length(); - unsigned int start = 0; - unsigned int end = 0; - - while (end <= strLength) { - while (end <= strLength) { - if (cstr[end] == delim) - break; - end++; - } - - elems.push_back(s.substr(start, end - start)); - start = end + 1; - end = start; - } - - return elems; - } -}; - -#endif // UTIL_H_INCLUDED diff --git a/ptr.hpp b/utility/ptr.hpp index b92b63e..b92b63e 100644 --- a/ptr.hpp +++ b/utility/ptr.hpp diff --git a/utility/special_members.hpp b/utility/special_members.hpp new file mode 100644 index 0000000..f396813 --- /dev/null +++ b/utility/special_members.hpp @@ -0,0 +1,12 @@ +#ifndef SPECIAL_MEMBERS_H +#define SPECIAL_MEMBERS_H + +#define NO_COPY(TYPE) \ + TYPE(const TYPE &) = delete; \ + void operator=(const TYPE &) = delete + +#define NO_MOVE(TYPE) \ + TYPE(TYPE &&) = delete; \ + void operator=(TYPE &&) = delete + +#endif |