Bladeren bron

Perform housekeeping on header includes/forward declaration lists.

Sam Jaffe 6 jaren geleden
bovenliggende
commit
ad1cd0a5fb

+ 2 - 2
engine/include/game/engine/engine_fwd.hpp

@@ -19,6 +19,8 @@ namespace engine {
 
   using key_binding = std::unordered_map<raw_key_t, key_enum_t>;
 
+  class entity;
+  class fps_counter;
   class game_dispatch;
   class scene;
 
@@ -26,6 +28,4 @@ namespace engine {
     struct key_event;
     struct mouse_event;
   }
-
-  struct tick;
 }

+ 1 - 5
engine/include/game/engine/entity.hpp

@@ -11,15 +11,11 @@
 #include <json/forwards.h>
 
 #include "game/engine/engine_fwd.hpp"
+#include "game/graphics/graphics_fwd.h"
 #include "game/graphics/object.hpp"
 #include "game/util/identity.hpp"
 
-namespace graphics {
-  class manager;
-}
-
 namespace engine {
-  class scene;
   class entity : identity<entity> {
   public:
     // TODO: Extract this out?

+ 1 - 5
engine/include/game/engine/fps_counter.hpp

@@ -10,13 +10,9 @@
 
 #include <vector>
 
+#include "game/graphics/graphics_fwd.h"
 #include "game/util/time.hpp"
 
-namespace graphics {
-  class object;
-  class manager;
-}
-
 namespace engine {
   class fps_counter {
   public:

+ 1 - 7
engine/include/game/engine/game_dispatch.hpp

@@ -16,15 +16,10 @@
 
 #include "engine_fwd.hpp"
 #include "events.hpp"
+#include "game/graphics/graphics_fwd.h"
 #include "game/util/time.hpp"
 
-namespace graphics {
-  class renderer;
-}
-
 namespace engine {
-  class fps_counter;
-
   class game_dispatch {
   public:
     game_dispatch(std::shared_ptr<graphics::renderer> renderer);
@@ -41,7 +36,6 @@ namespace engine {
 
   private:
     env::clock::tick next_frame();
-    tick get_tick();
 
   private:
     std::shared_ptr<graphics::renderer> renderer;

+ 1 - 6
engine/include/game/engine/scene.hpp

@@ -11,19 +11,14 @@
 #include <unordered_map>
 #include <vector>
 
+#include "game/graphics/graphics_fwd.h"
 #include "game/math/math_fwd.hpp"
 #include "game/util/identity.hpp"
 #include "vector/vector.hpp"
 
 #include "engine_fwd.hpp"
 
-namespace graphics {
-  class renderer;
-}
-
 namespace engine {
-  class entity;
-
   class scene : public identity<scene, std::string> {
   public:
     using identity<scene, std::string>::identity;

+ 1 - 5
engine/include/game/engine/serial.hpp

@@ -10,13 +10,9 @@
 
 #include <json/forwards.h>
 
+#include "game/graphics/graphics_fwd.h"
 #include "game/math/math_fwd.hpp"
 
-namespace graphics {
-  struct object;
-  class manager;
-}
-
 namespace engine {
   math::vec2 to_vec2(Json::Value const & json);
   math::vec2 to_vec2(Json::Value const & json, math::vec2 const & backup);

+ 28 - 0
graphics/include/game/graphics/graphics_fwd.h

@@ -0,0 +1,28 @@
+//
+//  graphics_fwd.h
+//  graphics
+//
+//  Created by Sam Jaffe on 5/25/19.
+//  Copyright © 2019 Sam Jaffe. All rights reserved.
+//
+
+#pragma once
+
+#include "game/util/identity.hpp"
+
+namespace graphics {
+  // API classes
+  class manager;
+  struct object;
+  class renderer;
+  struct vertex;
+
+  // Implementation classes
+  struct material;
+  struct shader;
+  struct shader_program;
+  class texture;
+  namespace shaders {
+    enum class type : unsigned int;
+  }
+}

+ 1 - 10
graphics/include/game/graphics/manager.hpp

@@ -11,19 +11,10 @@
 #include <memory>
 #include <unordered_map>
 
+#include "game/graphics/graphics_fwd.h"
 #include "game/math/math_fwd.hpp"
-#include "game/util/identity.hpp"
 
 namespace graphics {
-  namespace shaders {
-    enum class type : unsigned int;
-  }
-  class material;
-  class object;
-  class shader;
-  class shader_program;
-  class texture;
-
   class manager {
   public:
     manager();

+ 1 - 4
graphics/include/game/graphics/material.hpp

@@ -9,14 +9,11 @@
 
 #include <vector>
 
+#include "game/graphics/graphics_fwd.h"
 #include "game/math/math_fwd.hpp"
-#include "game/util/identity.hpp"
 #include "vector/vector.hpp"
 
 namespace graphics {
-  class texture;
-  struct shader_program;
-
   struct uniform {
     identity<texture> texture;
     int uniform_id; // TODO (sjaffe): use an enum and hide remapping?

+ 1 - 4
graphics/include/game/graphics/object.hpp

@@ -9,15 +9,12 @@
 
 #include <vector>
 
+#include "game/graphics/graphics_fwd.h"
 #include "game/math/math_fwd.hpp"
 #include "game/math/shape.hpp"
-#include "game/util/identity.hpp"
 #include "vector/vector.hpp"
 
 namespace graphics {
-  class material;
-  struct vertex;
-
   struct object {
     math::dim2::rectangle location;
     math::dim2::quad points;

+ 2 - 8
graphics/include/game/graphics/renderer.hpp

@@ -10,18 +10,12 @@
 
 #include <unordered_map>
 
+#include "game/graphics/graphics_fwd.h"
 #include "game/math/math_fwd.hpp"
 #include "game/util/hash.hpp"
-#include "game/util/identity.hpp"
 #include "vector/vector.hpp"
 
 namespace graphics {
-  class manager;
-  class material;
-  struct object;
-  struct renderer_impl;
-  struct vertex;
-
   struct renderer {
     virtual ~renderer() {}
     virtual std::shared_ptr<manager const> manager() const = 0;
@@ -45,7 +39,7 @@ namespace graphics {
     void flush() override;
 
   private:
-    renderer_impl * pimpl;
+    struct renderer_impl * pimpl;
   };
 
   class batch_renderer : public renderer {

+ 1 - 4
graphics/include/game/graphics/shader.hpp

@@ -9,12 +9,9 @@
 
 #include <string>
 
-#include "game/util/identity.hpp"
+#include "game/graphics/graphics_fwd.h"
 
 namespace graphics {
-  namespace shaders {
-    enum class type : unsigned int;
-  }
   struct shader : public identity<shader> {
     shader(shaders::type, std::string const &);
 

+ 1 - 2
graphics/include/game/graphics/shader_program.hpp

@@ -9,10 +9,9 @@
 
 #include <string>
 
-#include "game/util/identity.hpp"
+#include "game/graphics/graphics_fwd.h"
 
 namespace graphics {
-  struct shader;
   struct shader_program : public identity<shader_program> {
     shader_program(identity<shader>, identity<shader>);
 

+ 1 - 3
graphics/src/helper.hpp

@@ -11,12 +11,10 @@
 #include <string>
 #include <utility>
 
+#include "game/graphics/graphics_fwd.h"
 #include "game/math/math_fwd.hpp"
-#include "game/util/identity.hpp"
 
 namespace graphics {
-  class shader;
-  class shader_program;
   struct uniform;
   namespace textures {
     enum class format { RGB, RGBA };

+ 1 - 5
graphics/src/renderer_impl.hpp

@@ -8,17 +8,13 @@
 
 #pragma once
 
+#include "game/graphics/graphics_fwd.h"
 #include "game/graphics/renderer.hpp"
 #include "game/math/math_fwd.hpp"
-#include "game/util/identity.hpp"
 
 namespace graphics {
   template <driver> renderer_impl * get_renderer_impl();
 
-  class manager;
-  class material;
-  struct vertex;
-
   struct renderer_impl {
     virtual ~renderer_impl() {}
     virtual std::shared_ptr<manager const> manager() const = 0;