From 85d6acad114e3a752da9f4b9bc25a0d27bc11f75 Mon Sep 17 00:00:00 2001 From: rexy712 Date: Thu, 10 Feb 2022 16:56:01 -0800 Subject: [PATCH] Restructure directories --- include/basic_framebuffer.hpp | 20 ++-- include/{engine => egn}/base_types.hpp | 0 include/{engine => egn}/camera.hpp | 41 ++++--- include/{engine => egn}/collision.hpp | 0 include/{engine => egn}/font.hpp | 24 ++-- include/{engine => egn}/game.hpp | 4 +- include/{engine => egn}/game_state.hpp | 0 include/{engine => egn}/image.hpp | 0 include/{engine => egn}/input.hpp | 0 include/{engine => egn}/object.hpp | 2 +- include/{engine => egn}/observable.hpp | 0 include/{engine => egn}/observable.tpp | 0 include/{engine => egn}/stb_alloc.hpp | 0 include/{engine => egn}/stb_include.hpp | 0 include/{graphics => gfx}/backend_check.hpp | 0 include/{graphics => gfx}/init.hpp | 0 include/{graphics => gfx}/light.hpp | 0 include/{graphics => gfx}/lightable.hpp | 25 ++-- include/{graphics => gfx}/material.hpp | 10 +- include/{graphics => gfx}/mesh.hpp | 22 ++-- include/{graphics => gfx}/model.hpp | 4 +- include/{graphics => gfx/ogl}/buffer_map.hpp | 6 +- include/{graphics => gfx/ogl}/buffer_map.tpp | 6 +- include/{graphics => gfx/ogl}/fbo.hpp | 6 +- include/{graphics => gfx/ogl}/gl_include.hpp | 4 +- include/{graphics => gfx/ogl}/rbo.hpp | 6 +- include/{graphics => gfx/ogl}/shader.hpp | 6 +- .../{graphics => gfx/ogl}/shader_program.hpp | 6 +- include/{graphics => gfx/ogl}/texture.hpp | 8 +- include/{graphics => gfx/ogl}/ubo.hpp | 6 +- include/{graphics => gfx/ogl}/ubo.tpp | 6 +- include/{graphics => gfx/ogl}/vao.hpp | 6 +- include/{graphics => gfx/ogl}/vbo.hpp | 6 +- include/{graphics => gfx/ogl}/window.hpp | 10 +- include/gfx/resource_container.hpp | 90 +++++++++++++++ .../{graphics => gfx}/resource_manager.hpp | 86 ++------------ include/renderable.hpp | 6 +- include/scene.hpp | 6 +- include/ttt/board.hpp | 107 +++++++++++++++++- include/ttt/board_gfx.hpp | 20 ++-- include/ttt/main_renderer.hpp | 24 ++-- include/ttt/pause_state.hpp | 6 +- include/ttt/play_state.hpp | 4 +- include/ttt/screen_renderer.hpp | 26 ++--- include/ttt/tic_tac_toe.hpp | 4 +- include/wip/renderer.hpp | 80 +++++++++++++ include/wip/resource_manager.hpp | 50 ++++++++ include/wip_renderer.hpp | 89 --------------- makefile | 2 +- src/basic_framebuffer.cpp | 10 +- src/{engine => egn}/base_types.cpp | 2 +- src/{engine => egn}/camera.cpp | 32 +++--- src/{engine => egn}/collision.cpp | 4 +- src/{engine => egn}/font.cpp | 10 +- src/{engine => egn}/game.cpp | 4 +- src/{engine => egn}/game_state.cpp | 4 +- src/{engine => egn}/image.cpp | 4 +- src/{engine => egn}/object.cpp | 2 +- src/{engine => egn}/stb.cpp | 2 +- src/{engine => egn}/stb_alloc.cpp | 2 +- src/{graphics => gfx}/backend_check.cpp | 0 src/{graphics => gfx}/init.cpp | 4 +- src/{graphics => gfx}/lightable.cpp | 18 +-- src/{graphics => gfx}/material.cpp | 2 +- src/{graphics => gfx}/mesh.cpp | 14 +-- src/{graphics => gfx}/model.cpp | 4 +- src/{graphics => gfx/ogl}/buffer_map.cpp | 4 +- src/{graphics => gfx/ogl}/fbo.cpp | 4 +- src/{graphics => gfx/ogl}/rbo.cpp | 4 +- src/{graphics => gfx/ogl}/shader.cpp | 4 +- src/{graphics => gfx/ogl}/shader_program.cpp | 4 +- src/{graphics => gfx/ogl}/texture.cpp | 4 +- src/{graphics => gfx/ogl}/vao.cpp | 4 +- src/{graphics => gfx/ogl}/vbo.cpp | 4 +- src/{graphics => gfx/ogl}/window.cpp | 8 +- src/{graphics => gfx}/resource_manager.cpp | 8 +- src/main.cpp | 4 +- src/ttt/board.cpp | 14 +-- src/ttt/board_gfx.cpp | 6 +- src/ttt/main_renderer.cpp | 18 +-- src/ttt/pause_state.cpp | 4 +- src/ttt/play_state.cpp | 6 +- src/ttt/screen_renderer.cpp | 12 +- src/ttt/tic_tac_toe.cpp | 2 +- src/wip_renderer.cpp | 59 ---------- 85 files changed, 614 insertions(+), 511 deletions(-) rename include/{engine => egn}/base_types.hpp (100%) rename include/{engine => egn}/camera.hpp (72%) rename include/{engine => egn}/collision.hpp (100%) rename include/{engine => egn}/font.hpp (83%) rename include/{engine => egn}/game.hpp (96%) rename include/{engine => egn}/game_state.hpp (100%) rename include/{engine => egn}/image.hpp (100%) rename include/{engine => egn}/input.hpp (100%) rename include/{engine => egn}/object.hpp (98%) rename include/{engine => egn}/observable.hpp (100%) rename include/{engine => egn}/observable.tpp (100%) rename include/{engine => egn}/stb_alloc.hpp (100%) rename include/{engine => egn}/stb_include.hpp (100%) rename include/{graphics => gfx}/backend_check.hpp (100%) rename include/{graphics => gfx}/init.hpp (100%) rename include/{graphics => gfx}/light.hpp (100%) rename include/{graphics => gfx}/lightable.hpp (63%) rename include/{graphics => gfx}/material.hpp (83%) rename include/{graphics => gfx}/mesh.hpp (88%) rename include/{graphics => gfx}/model.hpp (96%) rename include/{graphics => gfx/ogl}/buffer_map.hpp (97%) rename include/{graphics => gfx/ogl}/buffer_map.tpp (95%) rename include/{graphics => gfx/ogl}/fbo.hpp (96%) rename include/{graphics => gfx/ogl}/gl_include.hpp (90%) rename include/{graphics => gfx/ogl}/rbo.hpp (93%) rename include/{graphics => gfx/ogl}/shader.hpp (95%) rename include/{graphics => gfx/ogl}/shader_program.hpp (98%) rename include/{graphics => gfx/ogl}/texture.hpp (98%) rename include/{graphics => gfx/ogl}/ubo.hpp (97%) rename include/{graphics => gfx/ogl}/ubo.tpp (98%) rename include/{graphics => gfx/ogl}/vao.hpp (97%) rename include/{graphics => gfx/ogl}/vbo.hpp (95%) rename include/{graphics => gfx/ogl}/window.hpp (95%) create mode 100644 include/gfx/resource_container.hpp rename include/{graphics => gfx}/resource_manager.hpp (53%) create mode 100644 include/wip/renderer.hpp create mode 100644 include/wip/resource_manager.hpp delete mode 100644 include/wip_renderer.hpp rename src/{engine => egn}/base_types.cpp (96%) rename src/{engine => egn}/camera.cpp (70%) rename src/{engine => egn}/collision.cpp (99%) rename src/{engine => egn}/font.cpp (91%) rename src/{engine => egn}/game.cpp (98%) rename src/{engine => egn}/game_state.cpp (97%) rename src/{engine => egn}/image.cpp (97%) rename src/{engine => egn}/object.cpp (99%) rename src/{engine => egn}/stb.cpp (96%) rename src/{engine => egn}/stb_alloc.cpp (97%) rename src/{graphics => gfx}/backend_check.cpp (100%) rename src/{graphics => gfx}/init.cpp (95%) rename src/{graphics => gfx}/lightable.cpp (65%) rename src/{graphics => gfx}/material.cpp (96%) rename src/{graphics => gfx}/mesh.cpp (89%) rename src/{graphics => gfx}/model.cpp (95%) rename src/{graphics => gfx/ogl}/buffer_map.cpp (97%) rename src/{graphics => gfx/ogl}/fbo.cpp (98%) rename src/{graphics => gfx/ogl}/rbo.cpp (98%) rename src/{graphics => gfx/ogl}/shader.cpp (98%) rename src/{graphics => gfx/ogl}/shader_program.cpp (99%) rename src/{graphics => gfx/ogl}/texture.cpp (99%) rename src/{graphics => gfx/ogl}/vao.cpp (98%) rename src/{graphics => gfx/ogl}/vbo.cpp (98%) rename src/{graphics => gfx/ogl}/window.cpp (99%) rename src/{graphics => gfx}/resource_manager.cpp (93%) delete mode 100644 src/wip_renderer.cpp diff --git a/include/basic_framebuffer.hpp b/include/basic_framebuffer.hpp index 9f903c9..0e04186 100644 --- a/include/basic_framebuffer.hpp +++ b/include/basic_framebuffer.hpp @@ -19,15 +19,15 @@ #ifndef OUR_DICK_BASIC_FRAMEBUFFER_HPP #define OUR_DICK_BASIC_FRAMEBUFFER_HPP -#include "graphics/texture.hpp" -#include "graphics/rbo.hpp" -#include "graphics/fbo.hpp" +#include "gfx/ogl/texture.hpp" +#include "gfx/ogl/rbo.hpp" +#include "gfx/ogl/fbo.hpp" -class basic_framebuffer : public gfx::fbo +class basic_framebuffer : public gfx::ogl::fbo { private: - gfx::texture m_colorbuffer; - gfx::rbo m_depthbuffer; + gfx::ogl::texture m_colorbuffer; + gfx::ogl::rbo m_depthbuffer; public: basic_framebuffer(int width, int height); @@ -36,11 +36,11 @@ public: basic_framebuffer& operator=(basic_framebuffer&&) = default; - gfx::texture& colorbuffer(void); - const gfx::texture& colorbuffer(void)const; + gfx::ogl::texture& colorbuffer(void); + const gfx::ogl::texture& colorbuffer(void)const; - gfx::rbo& depthbuffer(void); - const gfx::rbo& depthbuffer(void)const; + gfx::ogl::rbo& depthbuffer(void); + const gfx::ogl::rbo& depthbuffer(void)const; }; #endif diff --git a/include/engine/base_types.hpp b/include/egn/base_types.hpp similarity index 100% rename from include/engine/base_types.hpp rename to include/egn/base_types.hpp diff --git a/include/engine/camera.hpp b/include/egn/camera.hpp similarity index 72% rename from include/engine/camera.hpp rename to include/egn/camera.hpp index 7db0ab0..54d0908 100644 --- a/include/engine/camera.hpp +++ b/include/egn/camera.hpp @@ -19,7 +19,6 @@ #ifndef OUR_DICK_ENGINE_CAMERA_HPP #define OUR_DICK_ENGINE_CAMERA_HPP -#include "graphics/gl_include.hpp" //GLfloat #include "math/math.hpp" #include "object.hpp" @@ -38,15 +37,15 @@ namespace egn{ protected: //mutable because they're only really a cached value representation of the data //in position, orientation, near, far, etc - mutable math::mat4 m_projection_matrix; //camera-to-sceen matrix - mutable math::mat4 m_view_matrix; //world-to-camera matrix - GLfloat m_near = 1; //near clipping plane in camera space - GLfloat m_far = 100; //far clipping plane in camera space + mutable math::mat4f m_projection_matrix; //camera-to-sceen matrix + mutable math::mat4f m_view_matrix; //world-to-camera matrix + float m_near = 1; //near clipping plane in camera space + float m_far = 100; //far clipping plane in camera space public: camera_iface(void) = default; //Initialize with given projection matrix and clipping planes - camera_iface(const math::mat4& proj, GLfloat n, GLfloat f); + camera_iface(const math::mat4f& proj, float n, float f); camera_iface(const camera_iface&) = default; camera_iface(camera_iface&&) = default; virtual ~camera_iface(void) = default; @@ -55,19 +54,19 @@ namespace egn{ camera_iface& operator=(camera_iface&&) = default; //Set the camera's location and update relevant data structures - void set_position(const math::vec3& pos)override; + void set_position(const math::vec3f& pos)override; //Set the camera's facing angle and update relevant data structures - void set_orientation(const math::quaternion& distance)override; + void set_orientation(const math::quat_f& distance)override; //getters - const math::mat4& get_projection_matrix()const; - const math::mat4& get_view_matrix()const; - GLfloat get_near_plane()const; - GLfloat get_far_plane()const; + const math::mat4f& get_projection_matrix()const; + const math::mat4f& get_view_matrix()const; + float get_near_plane()const; + float get_far_plane()const; //setters - void set_near_plane(GLfloat n); - void set_far_plane(GLfloat f); + void set_near_plane(float n); + void set_far_plane(float f); //No control over matrices directly is done purposefully protected: @@ -79,11 +78,11 @@ namespace egn{ class ortho_camera : public camera_iface { protected: - GLfloat m_width, m_height; //width and height of the camera space box + float m_width, m_height; //width and height of the camera space box public: //Build camera with width, height, near, and far planes - ortho_camera(GLfloat w, GLfloat h, GLfloat n, GLfloat f); + ortho_camera(float w, float h, float n, float f); ortho_camera(const ortho_camera&) = default; ortho_camera(ortho_camera&&) = default; ~ortho_camera() = default; @@ -92,13 +91,13 @@ namespace egn{ ortho_camera& operator=(ortho_camera&&) = default; //Getters - GLfloat get_projection_width()const; - GLfloat get_projection_height()const; + float get_projection_width()const; + float get_projection_height()const; //Setters - void set_projection_width(GLfloat w); - void set_projection_height(GLfloat h); - void set_projection_box(GLfloat w, GLfloat h); + void set_projection_width(float w); + void set_projection_height(float h); + void set_projection_box(float w, float h); protected: void recalc_projection_matrix()const override; }; diff --git a/include/engine/collision.hpp b/include/egn/collision.hpp similarity index 100% rename from include/engine/collision.hpp rename to include/egn/collision.hpp diff --git a/include/engine/font.hpp b/include/egn/font.hpp similarity index 83% rename from include/engine/font.hpp rename to include/egn/font.hpp index f4e7b4f..1197b5c 100644 --- a/include/engine/font.hpp +++ b/include/egn/font.hpp @@ -27,23 +27,23 @@ #include #include //min, max -#include "graphics/texture.hpp" +#include "gfx/ogl/texture.hpp" #include "config.hpp" namespace egn{ struct font_character{ math::vec2 atlas_offset; - math::vec2 size; - math::vec2 bearing; - math::vec2 advance; - math::vec2 texture_coords[4]; + math::vec2i size; + math::vec2i bearing; + math::vec2i advance; + math::vec2f texture_coords[4]; public: float aspect_ratio(void)const; }; - class font_atlas : public gfx::texture + class font_atlas : public gfx::ogl::texture { public: using map_type = std::map; @@ -53,7 +53,7 @@ namespace egn{ size_t m_requested_width, m_requested_height; public: - font_atlas(gfx::texture&& t, map_type&& map, size_t w, size_t h); + font_atlas(gfx::ogl::texture&& t, map_type&& map, size_t w, size_t h); font_atlas(const font_atlas&) = default; font_atlas(font_atlas&&) = default; ~font_atlas(void) = default; @@ -87,13 +87,13 @@ namespace egn{ template font_atlas generate_atlas(size_t glyph_w, size_t glyph_h, Ts&&... ranges); - std::optional generate_glyph(char character, int width, int height); + std::optional generate_glyph(char character, int width, int height); private: using atlas_meta = std::tuple; template - void generate_atlas_piece_(gfx::texture& atlas, font_atlas::map_type& metadata, math::vec2& target_pos, const atlas_meta& info, unsigned char* data_buffer, const std::pair& range, Ts&&... ranges); - void generate_atlas_piece_impl_(gfx::texture& atlas, font_atlas::map_type& metadata, math::vec2& target_pos, const atlas_meta& info, unsigned char* data_buffer, const std::pair& range); + void generate_atlas_piece_(gfx::ogl::texture& atlas, font_atlas::map_type& metadata, math::vec2& target_pos, const atlas_meta& info, unsigned char* data_buffer, const std::pair& range, Ts&&... ranges); + void generate_atlas_piece_impl_(gfx::ogl::texture& atlas, font_atlas::map_type& metadata, math::vec2& target_pos, const atlas_meta& info, unsigned char* data_buffer, const std::pair& range); template atlas_meta get_atlas_size_ranges_(Ts&&... ranges); template @@ -108,7 +108,7 @@ namespace egn{ template - void font::generate_atlas_piece_(gfx::texture& atlas, font_atlas::map_type& metadata, math::vec2& target_pos, const atlas_meta& info, unsigned char* data_buffer, const std::pair& range, Ts&&... ranges){ + void font::generate_atlas_piece_(gfx::ogl::texture& atlas, font_atlas::map_type& metadata, math::vec2& target_pos, const atlas_meta& info, unsigned char* data_buffer, const std::pair& range, Ts&&... ranges){ generate_atlas_piece_impl_(atlas, metadata, target_pos, info, data_buffer, range); if constexpr(sizeof...(ranges) > 0){ @@ -123,7 +123,7 @@ namespace egn{ const auto format = (m_depth == 3) ? GL_RGB : GL_RED; - gfx::texture atlas(format, atlas_width, atlas_height, GL_UNSIGNED_BYTE, false); + gfx::ogl::texture atlas(format, atlas_width, atlas_height, GL_UNSIGNED_BYTE, false); font_atlas::map_type atlas_metadata; math::vec2 target_position = {0, 0}; std::unique_ptr dest_data(new unsigned char[max_glyph_height * max_glyph_width * m_depth]); diff --git a/include/engine/game.hpp b/include/egn/game.hpp similarity index 96% rename from include/engine/game.hpp rename to include/egn/game.hpp index f7383fb..fb98d3d 100644 --- a/include/engine/game.hpp +++ b/include/egn/game.hpp @@ -21,7 +21,7 @@ #include "observable.hpp" #include "game_state.hpp" -#include "graphics/window.hpp" +#include "gfx/ogl/window.hpp" #include "input.hpp" #include "math/vec.hpp" @@ -32,7 +32,7 @@ namespace egn{ class game : public observer { protected: - gfx::window m_window; + gfx::ogl::window m_window; game_state_manager m_states_manager; std::queue m_event_queue; double m_last_time; diff --git a/include/engine/game_state.hpp b/include/egn/game_state.hpp similarity index 100% rename from include/engine/game_state.hpp rename to include/egn/game_state.hpp diff --git a/include/engine/image.hpp b/include/egn/image.hpp similarity index 100% rename from include/engine/image.hpp rename to include/egn/image.hpp diff --git a/include/engine/input.hpp b/include/egn/input.hpp similarity index 100% rename from include/engine/input.hpp rename to include/egn/input.hpp diff --git a/include/engine/object.hpp b/include/egn/object.hpp similarity index 98% rename from include/engine/object.hpp rename to include/egn/object.hpp index 3db753f..9862966 100644 --- a/include/engine/object.hpp +++ b/include/egn/object.hpp @@ -19,7 +19,7 @@ #ifndef OUR_DICK_ENGINE_OBJECT_HPP #define OUR_DICK_ENGINE_OBJECT_HPP -#include "graphics/gl_include.hpp" //GLfloat +#include "gfx/ogl/gl_include.hpp" //GLfloat #include "math/math.hpp" #include "base_types.hpp" diff --git a/include/engine/observable.hpp b/include/egn/observable.hpp similarity index 100% rename from include/engine/observable.hpp rename to include/egn/observable.hpp diff --git a/include/engine/observable.tpp b/include/egn/observable.tpp similarity index 100% rename from include/engine/observable.tpp rename to include/egn/observable.tpp diff --git a/include/engine/stb_alloc.hpp b/include/egn/stb_alloc.hpp similarity index 100% rename from include/engine/stb_alloc.hpp rename to include/egn/stb_alloc.hpp diff --git a/include/engine/stb_include.hpp b/include/egn/stb_include.hpp similarity index 100% rename from include/engine/stb_include.hpp rename to include/egn/stb_include.hpp diff --git a/include/graphics/backend_check.hpp b/include/gfx/backend_check.hpp similarity index 100% rename from include/graphics/backend_check.hpp rename to include/gfx/backend_check.hpp diff --git a/include/graphics/init.hpp b/include/gfx/init.hpp similarity index 100% rename from include/graphics/init.hpp rename to include/gfx/init.hpp diff --git a/include/graphics/light.hpp b/include/gfx/light.hpp similarity index 100% rename from include/graphics/light.hpp rename to include/gfx/light.hpp diff --git a/include/graphics/lightable.hpp b/include/gfx/lightable.hpp similarity index 63% rename from include/graphics/lightable.hpp rename to include/gfx/lightable.hpp index 2dd7406..888124a 100644 --- a/include/graphics/lightable.hpp +++ b/include/gfx/lightable.hpp @@ -20,28 +20,27 @@ #define OUR_DICK_GRAPHICS_LIGHTABLE_HPP #include "math/vec.hpp" -#include "gl_include.hpp" namespace gfx{ class lightable { protected: - math::vec3 m_ambient; - math::vec3 m_diffuse; - math::vec3 m_specular; - GLfloat m_shininess; + math::vec3f m_ambient; + math::vec3f m_diffuse; + math::vec3f m_specular; + float m_shininess; public: - void set_ambient(const math::vec3& a); - void set_diffuse(const math::vec3& d); - void set_specular(const math::vec3& s); - void set_shininess(GLfloat s); + void set_ambient(const math::vec3f& a); + void set_diffuse(const math::vec3f& d); + void set_specular(const math::vec3f& s); + void set_shininess(float s); - const math::vec3& get_ambient()const; - const math::vec3& get_diffuse()const; - const math::vec3& get_specular()const; - GLfloat get_shininess()const; + const math::vec3f& get_ambient()const; + const math::vec3f& get_diffuse()const; + const math::vec3f& get_specular()const; + float get_shininess()const; }; } diff --git a/include/graphics/material.hpp b/include/gfx/material.hpp similarity index 83% rename from include/graphics/material.hpp rename to include/gfx/material.hpp index 0129bff..1d6bab9 100644 --- a/include/graphics/material.hpp +++ b/include/gfx/material.hpp @@ -20,18 +20,18 @@ #define OUR_DICK_GRAPHICS_MATERIAL_HPP #include "lightable.hpp" -#include "texture.hpp" +#include "ogl/texture.hpp" namespace gfx{ - class material : public lightable, public texture + class material : public lightable, public ogl::texture { public: - using texture::texture; - using texture::operator=; + using ogl::texture::texture; + using ogl::texture::operator=; //tmp - material(texture&&); + material(ogl::texture&&); }; } diff --git a/include/graphics/mesh.hpp b/include/gfx/mesh.hpp similarity index 88% rename from include/graphics/mesh.hpp rename to include/gfx/mesh.hpp index 79401db..ac3cc2a 100644 --- a/include/graphics/mesh.hpp +++ b/include/gfx/mesh.hpp @@ -20,9 +20,9 @@ #define OUR_DICK_GRAPHICS_MESH_HPP #include "math/vec.hpp" -#include "vao.hpp" -#include "vbo.hpp" -#include "shader_program.hpp" +#include "ogl/vao.hpp" +#include "ogl/vbo.hpp" +#include "ogl/shader_program.hpp" #include "material.hpp" #include @@ -31,9 +31,9 @@ namespace gfx{ struct vertex { - math::vec3 position; - math::vec3 normal; - math::vec2 tex_coords; + math::vec3f position; + math::vec3f normal; + math::vec2f tex_coords; }; class vertex_mesh @@ -41,8 +41,8 @@ namespace gfx{ protected: std::vector m_vertices; - gfx::vao m_vao; - gfx::vbo m_vbo; + gfx::ogl::vao m_vao; + gfx::ogl::vbo m_vbo; public: vertex_mesh(const std::vector& verts); @@ -61,7 +61,7 @@ namespace gfx{ const vertex& get_vertex(size_t index)const; void set_vertex(size_t index, const vertex& v); - void render(shader_program& shader); + void render(ogl::shader_program& shader); }; class material_mesh @@ -78,7 +78,7 @@ namespace gfx{ void set_material(size_t index, const material& new_texture); void set_material(size_t index, const material* new_texture); - void render(shader_program& shader); + void render(ogl::shader_program& shader); }; class unified_mesh @@ -105,7 +105,7 @@ namespace gfx{ void configure(); - void render(shader_program& shader); + void render(ogl::shader_program& shader); }; } diff --git a/include/graphics/model.hpp b/include/gfx/model.hpp similarity index 96% rename from include/graphics/model.hpp rename to include/gfx/model.hpp index 82c3783..4bd93ef 100644 --- a/include/graphics/model.hpp +++ b/include/gfx/model.hpp @@ -20,7 +20,7 @@ #define OUR_DICK_GRAPHICS_MODEL_HPP #include "mesh.hpp" -#include "shader_program.hpp" +#include "ogl/shader_program.hpp" #include #include //enable_if, decay, is_same @@ -56,7 +56,7 @@ namespace gfx{ unified_mesh& mesh(size_t index); const unified_mesh& mesh(size_t index)const; - void render(shader_program& s); + void render(ogl::shader_program& s); }; template,::gfx::unified_mesh> && ...),int>> diff --git a/include/graphics/buffer_map.hpp b/include/gfx/ogl/buffer_map.hpp similarity index 97% rename from include/graphics/buffer_map.hpp rename to include/gfx/ogl/buffer_map.hpp index 2636314..fb955a5 100644 --- a/include/graphics/buffer_map.hpp +++ b/include/gfx/ogl/buffer_map.hpp @@ -16,14 +16,14 @@ along with this program. If not, see . */ -#ifndef OUR_DICK_GRAPHICS_BUFFER_MAP_HPP -#define OUR_DICK_GRAPHICS_BUFFER_MAP_HPP +#ifndef OUR_DICK_GRAPHICS_OGL_BUFFER_MAP_HPP +#define OUR_DICK_GRAPHICS_OGL_BUFFER_MAP_HPP #include "gl_include.hpp" #include //size_t, ptrdiff_t -namespace gfx{ +namespace gfx::ogl{ namespace buffer{ //strongly typed enum for different mapping styles diff --git a/include/graphics/buffer_map.tpp b/include/gfx/ogl/buffer_map.tpp similarity index 95% rename from include/graphics/buffer_map.tpp rename to include/gfx/ogl/buffer_map.tpp index 674d42a..473307c 100644 --- a/include/graphics/buffer_map.tpp +++ b/include/gfx/ogl/buffer_map.tpp @@ -16,13 +16,13 @@ along with this program. If not, see . */ -#ifndef OUR_DICK_GRAPHICS_BUFFER_MAP_TPP -#define OUR_DICK_GRAPHICS_BUFFER_MAP_TPP +#ifndef OUR_DICK_GRAPHICS_OGL_BUFFER_MAP_TPP +#define OUR_DICK_GRAPHICS_OGL_BUFFER_MAP_TPP #include //exchange, swap #include "gl_include.hpp" -namespace gfx{ +namespace gfx::ogl{ template scoped_buffer_map::scoped_buffer_map(GLuint bid, buffer::maptype m): diff --git a/include/graphics/fbo.hpp b/include/gfx/ogl/fbo.hpp similarity index 96% rename from include/graphics/fbo.hpp rename to include/gfx/ogl/fbo.hpp index 3115502..fb90d9c 100644 --- a/include/graphics/fbo.hpp +++ b/include/gfx/ogl/fbo.hpp @@ -16,8 +16,8 @@ along with this program. If not, see . */ -#ifndef OUR_DICK_GRAPHICS_FBO_HPP -#define OUR_DICK_GRAPHICS_FBO_HPP +#ifndef OUR_DICK_GRAPHICS_OGL_FBO_HPP +#define OUR_DICK_GRAPHICS_OGL_FBO_HPP #include "gl_include.hpp" #include "texture.hpp" @@ -25,7 +25,7 @@ #include "math/vec.hpp" #include "util/init_constants.hpp" -namespace gfx{ +namespace gfx::ogl{ class fbo { diff --git a/include/graphics/gl_include.hpp b/include/gfx/ogl/gl_include.hpp similarity index 90% rename from include/graphics/gl_include.hpp rename to include/gfx/ogl/gl_include.hpp index 8a60224..52d2842 100644 --- a/include/graphics/gl_include.hpp +++ b/include/gfx/ogl/gl_include.hpp @@ -17,8 +17,8 @@ */ //ensure proper inclusion order at all times -#ifndef OUR_DICK_GRAPHICS_GL_INCLUDE_HPP -#define OUR_DICK_GRAPHICS_GL_INCLUDE_HPP +#ifndef OUR_DICK_GRAPHICS_OGL_GL_INCLUDE_HPP +#define OUR_DICK_GRAPHICS_OGL_GL_INCLUDE_HPP #include #include diff --git a/include/graphics/rbo.hpp b/include/gfx/ogl/rbo.hpp similarity index 93% rename from include/graphics/rbo.hpp rename to include/gfx/ogl/rbo.hpp index 46736ae..8f21540 100644 --- a/include/graphics/rbo.hpp +++ b/include/gfx/ogl/rbo.hpp @@ -16,12 +16,12 @@ along with this program. If not, see . */ -#ifndef OUR_DICK_GRAPHICS_RBO_HPP -#define OUR_DICK_GRAPHICS_RBO_HPP +#ifndef OUR_DICK_GRAPHICS_OGL_RBO_HPP +#define OUR_DICK_GRAPHICS_OGL_RBO_HPP #include "gl_include.hpp" -namespace gfx{ +namespace gfx::ogl{ class rbo { diff --git a/include/graphics/shader.hpp b/include/gfx/ogl/shader.hpp similarity index 95% rename from include/graphics/shader.hpp rename to include/gfx/ogl/shader.hpp index 6d3ac7b..9e3f1ed 100644 --- a/include/graphics/shader.hpp +++ b/include/gfx/ogl/shader.hpp @@ -16,13 +16,13 @@ along with this program. If not, see . */ -#ifndef OUR_DICK_GRAPHICS_SHADER_HPP -#define OUR_DICK_GRAPHICS_SHADER_HPP +#ifndef OUR_DICK_GRAPHICS_OGL_SHADER_HPP +#define OUR_DICK_GRAPHICS_OGL_SHADER_HPP #include "gl_include.hpp" #include -namespace gfx{ +namespace gfx::ogl{ //class representing an opengl shader (NOT an opengl program) class shader diff --git a/include/graphics/shader_program.hpp b/include/gfx/ogl/shader_program.hpp similarity index 98% rename from include/graphics/shader_program.hpp rename to include/gfx/ogl/shader_program.hpp index 2c1acac..6f2562c 100644 --- a/include/graphics/shader_program.hpp +++ b/include/gfx/ogl/shader_program.hpp @@ -16,8 +16,8 @@ along with this program. If not, see . */ -#ifndef OUR_DICK_GRAPHICS_SHADER_PROGRAM_HPP -#define OUR_DICK_GRAPHICS_SHADER_PROGRAM_HPP +#ifndef OUR_DICK_GRAPHICS_OGL_SHADER_PROGRAM_HPP +#define OUR_DICK_GRAPHICS_OGL_SHADER_PROGRAM_HPP #include "gl_include.hpp" #include "shader.hpp" @@ -29,7 +29,7 @@ #include "math/math.hpp" -namespace gfx{ +namespace gfx::ogl{ using namespace math; diff --git a/include/graphics/texture.hpp b/include/gfx/ogl/texture.hpp similarity index 98% rename from include/graphics/texture.hpp rename to include/gfx/ogl/texture.hpp index 9686168..88b25aa 100644 --- a/include/graphics/texture.hpp +++ b/include/gfx/ogl/texture.hpp @@ -16,14 +16,14 @@ along with this program. If not, see . */ -#ifndef OUR_DICK_GRAPHICS_TEXTURE_HPP -#define OUR_DICK_GRAPHICS_TEXTURE_HPP +#ifndef OUR_DICK_GRAPHICS_OGL_TEXTURE_HPP +#define OUR_DICK_GRAPHICS_OGL_TEXTURE_HPP -#include "engine/image.hpp" +#include "egn/image.hpp" #include "gl_include.hpp" #include "math/vec.hpp" -namespace gfx{ +namespace gfx::ogl{ class texture; diff --git a/include/graphics/ubo.hpp b/include/gfx/ogl/ubo.hpp similarity index 97% rename from include/graphics/ubo.hpp rename to include/gfx/ogl/ubo.hpp index 366d001..e0569a5 100644 --- a/include/graphics/ubo.hpp +++ b/include/gfx/ogl/ubo.hpp @@ -16,8 +16,8 @@ along with this program. If not, see . */ -#ifndef OUR_DICK_GRAPHICS_UBO_HPP -#define OUR_DICK_GRAPHICS_UBO_HPP +#ifndef OUR_DICK_GRAPHICS_OGL_UBO_HPP +#define OUR_DICK_GRAPHICS_OGL_UBO_HPP #include "gl_include.hpp" @@ -28,7 +28,7 @@ #include "buffer_map.hpp" -namespace gfx{ +namespace gfx::ogl{ namespace detail{ template diff --git a/include/graphics/ubo.tpp b/include/gfx/ogl/ubo.tpp similarity index 98% rename from include/graphics/ubo.tpp rename to include/gfx/ogl/ubo.tpp index 5105c51..aa0a4d1 100644 --- a/include/graphics/ubo.tpp +++ b/include/gfx/ogl/ubo.tpp @@ -16,8 +16,8 @@ along with this program. If not, see . */ -#ifndef OUR_DICK_GRAPHICS_UBO_TPP -#define OUR_DICK_GRAPHICS_UBO_TPP +#ifndef OUR_DICK_GRAPHICS_OGL_UBO_TPP +#define OUR_DICK_GRAPHICS_OGL_UBO_TPP #include //swap, exchange #include //a lot of stuff @@ -25,7 +25,7 @@ #include #include //memcpy, memset -namespace gfx{ +namespace gfx::ogl{ template ubo::ubo(buffer::usage usage){ diff --git a/include/graphics/vao.hpp b/include/gfx/ogl/vao.hpp similarity index 97% rename from include/graphics/vao.hpp rename to include/gfx/ogl/vao.hpp index 10db874..1f475a4 100644 --- a/include/graphics/vao.hpp +++ b/include/gfx/ogl/vao.hpp @@ -16,14 +16,14 @@ along with this program. If not, see . */ -#ifndef OUR_DICK_GRAPHICS_VAO_HPP -#define OUR_DICK_GRAPHICS_VAO_HPP +#ifndef OUR_DICK_GRAPHICS_OGL_VAO_HPP +#define OUR_DICK_GRAPHICS_OGL_VAO_HPP #include "gl_include.hpp" #include "math/math.hpp" #include "vbo.hpp" -namespace gfx{ +namespace gfx::ogl{ using namespace math; class vertex_attribute; diff --git a/include/graphics/vbo.hpp b/include/gfx/ogl/vbo.hpp similarity index 95% rename from include/graphics/vbo.hpp rename to include/gfx/ogl/vbo.hpp index a0b4b30..7835c5b 100644 --- a/include/graphics/vbo.hpp +++ b/include/gfx/ogl/vbo.hpp @@ -16,15 +16,15 @@ along with this program. If not, see . */ -#ifndef OUR_DICK_GRAPHICS_VBO_HPP -#define OUR_DICK_GRAPHICS_VBO_HPP +#ifndef OUR_DICK_GRAPHICS_OGL_VBO_HPP +#define OUR_DICK_GRAPHICS_OGL_VBO_HPP #include "gl_include.hpp" #include //size_t #include "buffer_map.hpp" -namespace gfx{ +namespace gfx::ogl{ //class representing a vertex buffer object class vbo diff --git a/include/graphics/window.hpp b/include/gfx/ogl/window.hpp similarity index 95% rename from include/graphics/window.hpp rename to include/gfx/ogl/window.hpp index c9507f0..3ada797 100644 --- a/include/graphics/window.hpp +++ b/include/gfx/ogl/window.hpp @@ -16,17 +16,17 @@ along with this program. If not, see . */ -#ifndef OUR_DICK_GRAPHICS_WINDOW_HPP -#define OUR_DICK_GRAPHICS_WINDOW_HPP +#ifndef OUR_DICK_GRAPHICS_OGL_WINDOW_HPP +#define OUR_DICK_GRAPHICS_OGL_WINDOW_HPP #include "gl_include.hpp" -#include "init.hpp" +#include "../init.hpp" #include "math/math.hpp" #include "util/init_constants.hpp" #include "fbo.hpp" -#include "resource_manager.hpp" +#include "../resource_manager.hpp" -namespace gfx{ +namespace gfx::ogl{ using namespace math; diff --git a/include/gfx/resource_container.hpp b/include/gfx/resource_container.hpp new file mode 100644 index 0000000..52054af --- /dev/null +++ b/include/gfx/resource_container.hpp @@ -0,0 +1,90 @@ +/** + This file is a part of our_dick + Copyright (C) 2022 rexy712 + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +#ifndef OUR_DICK_GRAPHICS_RESOURCE_CONTAINER_HPP +#define OUR_DICK_GRAPHICS_RESOURCE_CONTAINER_HPP + +#include +#include +#include //pair, forward +#include +#include //shared_ptr + +#include "util/deferred.hpp" + +namespace gfx{ + + template + class resource_container + { + public: + using value_type = T; + using key_type = std::string; + using reference = T&; + using const_reference = const T&; + using pointer = T*; + using const_pointer = const T*; + using node = std::shared_ptr; + using const_node = std::shared_ptr; + + private: + std::map> m_map; + + public: + resource_container(void) = default; + resource_container(const resource_container&) = default; + resource_container(resource_container&&) = default; + + ~resource_container(void) = default; + + resource_container& operator=(const resource_container&) = default; + resource_container& operator=(resource_container&&) = default; + + bool has_value(const char* key)const; + template + std::pair emplace_value(const char* key, Args&&... args); + node get_value(const char* file); + bool erase_value(const char* key); + }; + + template + bool resource_container::has_value(const char* key)const{ + if(auto it = m_map.find(key);it != m_map.end()) + return true; + return false; + } + template + template + auto resource_container::emplace_value(const char* key, Args&&... args) -> std::pair{ + auto p = m_map.try_emplace(key, util::deferred_function(std::make_shared, std::forward(args)...)); + return {(*p.first).second, p.second}; + } + template + auto resource_container::get_value(const char* key) -> node{ + if(auto it = m_map.find(key);it != m_map.end()) + return (*it).second; + return nullptr; + } + template + bool resource_container::erase_value(const char* key){ + return m_map.erase(key) == 1; + } + +} + +#endif diff --git a/include/graphics/resource_manager.hpp b/include/gfx/resource_manager.hpp similarity index 53% rename from include/graphics/resource_manager.hpp rename to include/gfx/resource_manager.hpp index c83bb86..89ac809 100644 --- a/include/graphics/resource_manager.hpp +++ b/include/gfx/resource_manager.hpp @@ -19,63 +19,26 @@ #ifndef OUR_DICK_GRAPHICS_RESOURCE_MANAGER_HPP #define OUR_DICK_GRAPHICS_RESOURCE_MANAGER_HPP -#include -#include -#include //pair, forward -#include +#include "resource_container.hpp" +#include "ogl/texture.hpp" +#include "ogl/shader_program.hpp" -#include "graphics/texture.hpp" -#include "graphics/shader_program.hpp" +#include "egn/font.hpp" -#include "engine/font.hpp" -#include "util/deferred.hpp" +#include //forward namespace gfx{ - namespace detail{ - template - class resource_manager - { - public: - using value_type = T; - using key_type = std::string; - using reference = T&; - using const_reference = const T&; - using pointer = T*; - using const_pointer = const T*; - using node = std::shared_ptr; - using const_node = std::shared_ptr; - - private: - std::map> m_map; - - public: - resource_manager(void) = default; - resource_manager(const resource_manager&) = default; - resource_manager(resource_manager&&) = default; - - ~resource_manager(void) = default; - - resource_manager& operator=(const resource_manager&) = default; - resource_manager& operator=(resource_manager&&) = default; - - bool has_value(const char* key)const; - template - std::pair emplace_value(const char* key, Args&&... args); - node get_value(const char* file); - bool erase_value(const char* key); - }; - } class resource_manager { public: template - using container_type = detail::resource_manager; + using container_type = resource_container; private: - container_type m_textures; + container_type m_textures; container_type m_fonts; - container_type m_texture_arrays; - container_type m_shaders; + container_type m_texture_arrays; + container_type m_shaders; public: resource_manager(void) = default; @@ -90,13 +53,13 @@ namespace gfx{ bool has_texture_array(const char* key)const; template auto emplace_texture_array(const char* key, Args&&... args); - container_type::node get_texture_array(const char* file); + container_type::node get_texture_array(const char* file); bool erase_texture_array(const char* key); bool has_texture(const char* key)const; template auto emplace_texture(const char* key, Args&&... args); - container_type::node get_texture(const char* file); + container_type::node get_texture(const char* file); bool erase_texture(const char* key); bool has_font(const char* key)const; @@ -108,35 +71,10 @@ namespace gfx{ bool has_shader(const char* key)const; template auto emplace_shader(const char* key, Args&&... args); - container_type::node get_shader(const char* key); + container_type::node get_shader(const char* key); bool erase_shader(const char* key); }; - namespace detail{ - template - bool resource_manager::has_value(const char* key)const{ - if(auto it = m_map.find(key);it != m_map.end()) - return true; - return false; - } - template - template - auto resource_manager::emplace_value(const char* key, Args&&... args) -> std::pair{ - auto p = m_map.try_emplace(key, util::deferred_function(std::make_shared, std::forward(args)...)); - return {(*p.first).second, p.second}; - } - template - auto resource_manager::get_value(const char* key) -> node{ - if(auto it = m_map.find(key);it != m_map.end()) - return (*it).second; - return nullptr; - } - template - bool resource_manager::erase_value(const char* key){ - return m_map.erase(key) == 1; - } - } - template auto resource_manager::emplace_texture_array(const char* key, Args&&... args){ return m_texture_arrays.emplace_value(key, std::forward(args)...); diff --git a/include/renderable.hpp b/include/renderable.hpp index 191cc98..cb2c618 100644 --- a/include/renderable.hpp +++ b/include/renderable.hpp @@ -19,15 +19,15 @@ #ifndef OUR_DICK_RENDERABLE_HPP #define OUR_DICK_RENDERABLE_HPP -#include "graphics/shader_program.hpp" -#include "engine/object.hpp" +#include "gfx/ogl/shader_program.hpp" +#include "egn/object.hpp" class renderable_iface { public: virtual ~renderable_iface() = default; - virtual void render(gfx::shader_program&) = 0; + virtual void render(gfx::ogl::shader_program&) = 0; }; class renderable_object : public renderable_iface, public egn::object_base{}; diff --git a/include/scene.hpp b/include/scene.hpp index a179874..d2018ad 100644 --- a/include/scene.hpp +++ b/include/scene.hpp @@ -19,10 +19,10 @@ #ifndef OUR_DICK_SCENE_HPP #define OUR_DICK_SCENE_HPP -#include "graphics/texture.hpp" //TODO: use material interface instead of direct texture -#include "engine/camera.hpp" +#include "gfx/ogl/texture.hpp" //TODO: use material interface instead of direct texture +#include "egn/camera.hpp" #include "renderable.hpp" -#include "graphics/model.hpp" +#include "gfx/model.hpp" #include //vector #include //unique_ptr diff --git a/include/ttt/board.hpp b/include/ttt/board.hpp index 1195a3d..7f1f975 100644 --- a/include/ttt/board.hpp +++ b/include/ttt/board.hpp @@ -19,17 +19,116 @@ #ifndef OUR_DICK_BOARD_HPP #define OUR_DICK_BOARD_HPP -#include "graphics/shader_program.hpp" +#include "gfx/ogl/shader_program.hpp" #include "renderable.hpp" -#include "graphics/resource_manager.hpp" +#include "gfx/resource_manager.hpp" #include "math/vec.hpp" #include "config.hpp" -#include //unique_ptr +#include //unique_ptr, shared_ptr +#include + +#include "gfx/ogl/shader_program.hpp" +#include "gfx/ogl/vbo.hpp" +#include "gfx/ogl/vao.hpp" +#include "gfx/ogl/texture.hpp" +#include "wip/renderer.hpp" class board_gfx; +struct vertex{ + math::vec3f position; + math::vec2f tex_coords; +}; + +class material +{ +public: + std::shared_ptr shader; + std::shared_ptr diffuse_texture; + math::vec3f diffuse; + math::vec3f specular; + math::vec3f ambient; + float shininess; + + material(const std::shared_ptr& sh); + material(const material&) = default; + material(material&&) = default; + ~material(void) = default; + + material& operator=(const material&) = default; + material& operator=(material&&) = default; + + void bind(void){ + shader->get_uniform("diffuse_texture").set(*diffuse_texture, 0); + //set uniforms for other lighting stuff or switch to a ubo + } +}; +class mesh +{ +private: + size_t m_num_vertices; + gfx::ogl::vbo m_buffer; + gfx::ogl::vao m_attributes; + +public: + mesh(const std::vector& vertices); + + void bind(void); + + void render(wip::gfx::renderer& r, material&){ + m_attributes.bind(); + r.draw_tris(0, m_num_vertices); + } +}; + + +class new_tile +{ +public: + enum class state{ + BLANK = 0, + X, + O + }; +private: + std::shared_ptr m_mesh; + +public: + std::shared_ptr image; + state value; + + new_tile(const std::shared_ptr& me, const std::shared_ptr& ma); + + + void render(wip::gfx::renderer& r){ + m_mesh->render(r, *image); + } +}; + +class new_board +{ +private: + std::shared_ptr m_blank; + std::shared_ptr m_x; + std::shared_ptr m_o; + std::unique_ptr m_tiles; + +public: + new_board(wip::gfx::renderer& r); + + void render(wip::gfx::renderer& r){ + for(size_t i = 0;i < 9;++i){ + auto& tile = m_tiles[i]; + tile.render(r); + } + } + void update(float /*dtime*/){ + + } +}; + class tile : public egn::object_base { public: @@ -77,7 +176,7 @@ public: void reset(void); - void render(gfx::shader_program& sh)override; + void render(gfx::ogl::shader_program& sh)override; private: tile::value check_rows_(void)const; diff --git a/include/ttt/board_gfx.hpp b/include/ttt/board_gfx.hpp index 0afb92c..4ad9dbf 100644 --- a/include/ttt/board_gfx.hpp +++ b/include/ttt/board_gfx.hpp @@ -19,11 +19,11 @@ #ifndef OUR_DICK_BOARD_GFX_HPP #define OUR_DICK_BOARD_GFX_HPP -#include "graphics/material.hpp" -#include "graphics/vbo.hpp" -#include "graphics/vao.hpp" -#include "graphics/shader_program.hpp" -#include "graphics/resource_manager.hpp" +#include "gfx/material.hpp" +#include "gfx/ogl/vbo.hpp" +#include "gfx/ogl/vao.hpp" +#include "gfx/ogl/shader_program.hpp" +#include "gfx/resource_manager.hpp" #include //pair #include //shared_ptr @@ -33,21 +33,21 @@ class tile; class board_gfx { private: - std::shared_ptr m_textures; - gfx::vao m_vao; - gfx::vbo m_vbo; + std::shared_ptr m_textures; + gfx::ogl::vao m_vao; + gfx::ogl::vbo m_vbo; public: board_gfx(gfx::resource_manager& resman); ~board_gfx(void) = default; - void set_uniforms(gfx::shader_program& sh); + void set_uniforms(gfx::ogl::shader_program& sh); void bind_buffers(void); void bind_attributes(void); void buffer_tiles(const tile* t); - void render(gfx::shader_program& shader); + void render(gfx::ogl::shader_program& shader); }; #endif diff --git a/include/ttt/main_renderer.hpp b/include/ttt/main_renderer.hpp index 557567e..c70e3d5 100644 --- a/include/ttt/main_renderer.hpp +++ b/include/ttt/main_renderer.hpp @@ -19,12 +19,12 @@ #ifndef OUR_DICK_MAIN_RENDERER_HPP #define OUR_DICK_MAIN_RENDERER_HPP -#include "graphics/shader_program.hpp" -#include "graphics/vao.hpp" -#include "graphics/vbo.hpp" +#include "gfx/ogl/shader_program.hpp" +#include "gfx/ogl/vao.hpp" +#include "gfx/ogl/vbo.hpp" #include "math/math.hpp" #include "scene.hpp" -#include "graphics/resource_manager.hpp" +#include "gfx/resource_manager.hpp" #include "basic_framebuffer.hpp" #include //shared_ptr @@ -46,20 +46,20 @@ private: }; private: basic_framebuffer m_fb; - gfx::fbo m_primary_fb; - std::shared_ptr m_square_shader; - std::shared_ptr m_screen_shader; - gfx::vbo m_vbo; - gfx::vao m_vao; - gfx::vao m_board_vao; - gfx::vbo m_board_vbo; + gfx::ogl::fbo m_primary_fb; + std::shared_ptr m_square_shader; + std::shared_ptr m_screen_shader; + gfx::ogl::vbo m_vbo; + gfx::ogl::vao m_vao; + gfx::ogl::vao m_board_vao; + gfx::ogl::vbo m_board_vbo; public: main_renderer(gfx::resource_manager& res, int width, int height); void set_vp_matrix(const math::mat4& vp); void render(scene&); - gfx::texture& color_buffer(void); + gfx::ogl::texture& color_buffer(void); void resize_viewport(int width, int height); const math::vec4& get_viewport(void)const; }; diff --git a/include/ttt/pause_state.hpp b/include/ttt/pause_state.hpp index 1fd027a..ccaa54c 100644 --- a/include/ttt/pause_state.hpp +++ b/include/ttt/pause_state.hpp @@ -19,9 +19,9 @@ #ifndef OUR_DICK_PAUSE_STATE_HPP #define OUR_DICK_PAUSE_STATE_HPP -#include "engine/game_state.hpp" -#include "engine/input.hpp" -#include "graphics/texture.hpp" +#include "egn/game_state.hpp" +#include "egn/input.hpp" +#include "gfx/ogl/texture.hpp" #include "screen_renderer.hpp" class pause_state : public egn::game_state_iface diff --git a/include/ttt/play_state.hpp b/include/ttt/play_state.hpp index a09a174..f2d2482 100644 --- a/include/ttt/play_state.hpp +++ b/include/ttt/play_state.hpp @@ -19,11 +19,11 @@ #ifndef OUR_DICK_PLAY_STATE_HPP #define OUR_DICK_PLAY_STATE_HPP -#include "engine/game_state.hpp" +#include "egn/game_state.hpp" #include "scene.hpp" #include "main_renderer.hpp" -#include "engine/camera.hpp" +#include "egn/camera.hpp" #include "math/vec.hpp" class play_state : public egn::game_state_iface diff --git a/include/ttt/screen_renderer.hpp b/include/ttt/screen_renderer.hpp index 82143f6..1f8443a 100644 --- a/include/ttt/screen_renderer.hpp +++ b/include/ttt/screen_renderer.hpp @@ -19,15 +19,15 @@ #ifndef OUR_DICK_SCREEN_RENDERER_HPP #define OUR_DICK_SCREEN_RENDERER_HPP -#include "graphics/vbo.hpp" -#include "graphics/vao.hpp" -#include "graphics/texture.hpp" +#include "gfx/ogl/vbo.hpp" +#include "gfx/ogl/vao.hpp" +#include "gfx/ogl/texture.hpp" #include "math/math.hpp" -#include "graphics/shader_program.hpp" -#include "graphics/resource_manager.hpp" +#include "gfx/ogl/shader_program.hpp" +#include "gfx/resource_manager.hpp" #include "scene.hpp" -#include "engine/font.hpp" +#include "egn/font.hpp" #include //shared_ptr @@ -35,8 +35,8 @@ class screen_renderer { private: struct vertex{ - math::vec2 pos; - math::vec2 tex_coord; + math::vec2f pos; + math::vec2f tex_coord; }; static constexpr vertex s_vertices[] = { {{-1.0f, 1.0f}, {0.0f, 1.0f}}, @@ -47,14 +47,14 @@ private: {{-1.0f, 1.0f}, {0.0f, 1.0f}} }; private: - std::shared_ptr m_screen_shader; - gfx::vbo m_vbo; - gfx::vao m_vao; - std::shared_ptr m_texture; + std::shared_ptr m_screen_shader; + gfx::ogl::vbo m_vbo; + gfx::ogl::vao m_vao; + std::shared_ptr m_texture; int m_screen_width, m_screen_height; public: - screen_renderer(gfx::resource_manager& res, int width, int height, const std::shared_ptr& base_tex); + screen_renderer(gfx::resource_manager& res, int width, int height, const std::shared_ptr& base_tex); void render(scene&); void resize_viewport(int width, int height); diff --git a/include/ttt/tic_tac_toe.hpp b/include/ttt/tic_tac_toe.hpp index dc0fb40..2a02f82 100644 --- a/include/ttt/tic_tac_toe.hpp +++ b/include/ttt/tic_tac_toe.hpp @@ -19,8 +19,8 @@ #ifndef OUR_DICK_TIC_TAC_TOE_HPP #define OUR_DICK_TIC_TAC_TOE_HPP -#include "engine/game.hpp" -#include "engine/game_state.hpp" +#include "egn/game.hpp" +#include "egn/game_state.hpp" #include "config.hpp" #include diff --git a/include/wip/renderer.hpp b/include/wip/renderer.hpp new file mode 100644 index 0000000..67da443 --- /dev/null +++ b/include/wip/renderer.hpp @@ -0,0 +1,80 @@ +/** + This file is a part of our_dick + Copyright (C) 2022 rexy712 + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +#ifndef OUR_DICK_GRAPHICS_WIP_RENDERER_HPP +#define OUR_DICK_GRAPHICS_WIP_RENDERER_HPP + +#include "gfx/resource_container.hpp" + +#include "math/vec.hpp" + +#include "gfx/ogl/shader_program.hpp" +#include "gfx/ogl/texture.hpp" +#include "gfx/ogl/ubo.hpp" + +namespace wip::gfx::ogl{ + + + class material; + class mesh; + + struct draw_command{ + const material* mat; + const mesh* m; + float distance; + }; + + class renderer + { + public: + template + using container_type = ::gfx::resource_container; + private: + container_type m_shader_programs; + container_type m_shaders; + ::gfx::ogl::ubo m_camera; //TODO + + public: + renderer(void) = default; + renderer(const renderer&) = default; + renderer(renderer&&) = default; + ~renderer(void) = default; + + renderer& operator=(const renderer&) = default; + renderer& operator=(renderer&&) = default; + + void render(void); + void set_viewport(const math::vec4f& vp); + + void draw_tris(int offset, int vertex_count); + + //Access to resources + const container_type& meshs(void)const; + container_type& meshs(void); + const container_type& materials(void)const; + container_type& materials(void); + }; + +} +namespace wip::gfx{ + class renderer : public wip::gfx::ogl::renderer{}; +} + + + +#endif diff --git a/include/wip/resource_manager.hpp b/include/wip/resource_manager.hpp new file mode 100644 index 0000000..3342ffd --- /dev/null +++ b/include/wip/resource_manager.hpp @@ -0,0 +1,50 @@ +/** + This file is a part of our_dick + Copyright (C) 2022 rexy712 + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +#ifndef OUR_DICK_GRAPHICS_WIP_RESOURCE_MANEGER_HPP +#define OUR_DICK_GRAPHICS_WIP_RESOURCE_MANAGER_HPP + +#include "math/vec.hpp" +#include "graphics/resource_manager_base.hpp" +#include "graphics/shader_program.hpp" +#include "graphics/texture.hpp" + +namespace wip::gfx::ogl{ + + class resource_manager + { + private: + detail::resource_manager m_shader_programs; + detail::resource_manager m_shaders; + detail::resource_manager m_textures; + detail::resource_manager m_texture_arrays; + + public: + const resource_manager& shader_programs(void)const; + resource_manager& shader_programs(void); + const resource_manager& shaders(void)const; + resource_manager& shaders(void); + const resource_manager& textures(void)const; + resource_manager& textures(void); + const resource_manager& texture_arrays(void)const; + resource_manager& texture_arrays(void); + }; + +} + +#endif diff --git a/include/wip_renderer.hpp b/include/wip_renderer.hpp deleted file mode 100644 index b804558..0000000 --- a/include/wip_renderer.hpp +++ /dev/null @@ -1,89 +0,0 @@ -/** - This file is a part of our_dick - Copyright (C) 2022 rexy712 - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -#ifndef OUR_DICK_RENDERER_HPP -#define OUR_DICK_RENDERER_HPP - -#include -#include -#include //pair, forward -#include - -#include "math/vec.hpp" - -#include "graphics/gl_include.hpp" - -struct draw_command{ -private: - using uniform_variant = std::variant; - -public: - using framebuffer_type = GLuint; - using shader_type = GLuint; - using vao_type = GLuint; - using uniform_type = GLint; - using uniform_block_type = GLuint; - using binding_type = GLuint; - using shape_type = GLenum; - using texture_type = GLuint; - -public: - framebuffer_type framebuffer; - math::vec4f viewport; - - shader_type shader; - vao_type vertex_arrays; - - shape_type shape; - size_t shape_count; - - std::vector> uniforms; - std::vector> uniform_blocks; - std::vector> texture_binds; - - GLuint clear = 0; -}; - -class wip_renderer -{ -private: - std::queue m_draws; - -public: - wip_renderer(void) = default; - wip_renderer(const wip_renderer&) = default; - wip_renderer(wip_renderer&&) = default; - ~wip_renderer(void) = default; - - wip_renderer& operator=(const wip_renderer&) = default; - wip_renderer& operator=(wip_renderer&&) = default; - - void add_command(const draw_command&); - void add_command(draw_command&&); - template - void emplace_command(Args&&... args); - - void render(void); -}; - -template -void wip_renderer::emplace_command(Args&&... args){ - m_draws.emplace(std::forward(args)...); -} - -#endif diff --git a/makefile b/makefile index fde7775..579af9b 100644 --- a/makefile +++ b/makefile @@ -19,7 +19,7 @@ ifeq ($(OS),Windows_NT) WINDOWS::=1 endif -SOURCE_DIRS::=src src/audio src/audio/impl src/graphics src/engine src/ttt +SOURCE_DIRS::=src src/audio src/audio/impl src/gfx src/gfx/ogl src/egn src/ttt SOURCES::= OBJDIR::=obj DEPDIR::=$(OBJDIR)/dep diff --git a/src/basic_framebuffer.cpp b/src/basic_framebuffer.cpp index a7d51d7..b5bffe3 100644 --- a/src/basic_framebuffer.cpp +++ b/src/basic_framebuffer.cpp @@ -19,24 +19,24 @@ #include "basic_framebuffer.hpp" basic_framebuffer::basic_framebuffer(int width, int height): - gfx::fbo(), + gfx::ogl::fbo(), m_colorbuffer(GL_RGBA, width, height, GL_UNSIGNED_BYTE), m_depthbuffer(width, height, GL_DEPTH24_STENCIL8) { attach(m_colorbuffer, GL_COLOR_ATTACHMENT0); attach(m_depthbuffer, GL_DEPTH_STENCIL_ATTACHMENT); } -gfx::texture& basic_framebuffer::colorbuffer(void){ +gfx::ogl::texture& basic_framebuffer::colorbuffer(void){ return m_colorbuffer; } -const gfx::texture& basic_framebuffer::colorbuffer(void)const{ +const gfx::ogl::texture& basic_framebuffer::colorbuffer(void)const{ return m_colorbuffer; } -gfx::rbo& basic_framebuffer::depthbuffer(void){ +gfx::ogl::rbo& basic_framebuffer::depthbuffer(void){ return m_depthbuffer; } -const gfx::rbo& basic_framebuffer::depthbuffer(void)const{ +const gfx::ogl::rbo& basic_framebuffer::depthbuffer(void)const{ return m_depthbuffer; } diff --git a/src/engine/base_types.cpp b/src/egn/base_types.cpp similarity index 96% rename from src/engine/base_types.cpp rename to src/egn/base_types.cpp index ccaf062..4a36e42 100644 --- a/src/engine/base_types.cpp +++ b/src/egn/base_types.cpp @@ -16,7 +16,7 @@ along with this program. If not, see . */ -#include "engine/base_types.hpp" +#include "egn/base_types.hpp" namespace egn{ diff --git a/src/engine/camera.cpp b/src/egn/camera.cpp similarity index 70% rename from src/engine/camera.cpp rename to src/egn/camera.cpp index 4c123d9..7ebda0f 100644 --- a/src/engine/camera.cpp +++ b/src/egn/camera.cpp @@ -16,32 +16,32 @@ along with this program. If not, see . */ -#include "engine/camera.hpp" +#include "egn/camera.hpp" #include "config.hpp" #include "math/projection.hpp" namespace egn{ - camera_iface::camera_iface(const math::mat4& proj, GLfloat n, GLfloat f): + camera_iface::camera_iface(const math::mat4f& proj, float n, float f): m_projection_matrix(proj), m_near(n), m_far(f){} - void camera_iface::set_position(const math::vec3& pos){ + void camera_iface::set_position(const math::vec3f& pos){ object_base::set_position(pos); m_update_flag |= VIEW_UPDATE; } - void camera_iface::set_orientation(const math::quaternion& orient){ + void camera_iface::set_orientation(const math::quat_f& orient){ object_base::set_orientation(orient); m_update_flag |= VIEW_UPDATE; } - const math::mat4& camera_iface::get_projection_matrix()const{ + const math::mat4f& camera_iface::get_projection_matrix()const{ if(m_update_flag & PROJ_UPDATE){ recalc_projection_matrix(); m_update_flag ^= PROJ_UPDATE; } return m_projection_matrix; } - const math::mat4& camera_iface::get_view_matrix()const{ + const math::mat4f& camera_iface::get_view_matrix()const{ if(m_update_flag & VIEW_UPDATE){ recalc_view_matrix(); m_update_flag ^= VIEW_UPDATE; @@ -49,17 +49,17 @@ namespace egn{ return m_view_matrix; } - GLfloat camera_iface::get_near_plane()const{ + float camera_iface::get_near_plane()const{ return m_near; } - GLfloat camera_iface::get_far_plane()const{ + float camera_iface::get_far_plane()const{ return m_far; } - void camera_iface::set_near_plane(GLfloat n){ + void camera_iface::set_near_plane(float n){ m_update_flag |= PROJ_UPDATE; m_near = n; } - void camera_iface::set_far_plane(GLfloat f){ + void camera_iface::set_far_plane(float f){ m_update_flag |= PROJ_UPDATE; m_far = f; } @@ -73,26 +73,26 @@ namespace egn{ } - ortho_camera::ortho_camera(GLfloat w, GLfloat h, GLfloat n, GLfloat f): + ortho_camera::ortho_camera(float w, float h, float n, float f): camera_iface(math::ortho_projection(w, h, n, f), n, f), m_width(w), m_height(h){} - GLfloat ortho_camera::get_projection_width()const{ + float ortho_camera::get_projection_width()const{ return m_width; } - GLfloat ortho_camera::get_projection_height()const{ + float ortho_camera::get_projection_height()const{ return m_height; } - void ortho_camera::set_projection_width(GLfloat w){ + void ortho_camera::set_projection_width(float w){ m_update_flag |= PROJ_UPDATE; m_width = w; } - void ortho_camera::set_projection_height(GLfloat h){ + void ortho_camera::set_projection_height(float h){ m_update_flag |= PROJ_UPDATE; m_height = h; } - void ortho_camera::set_projection_box(GLfloat w, GLfloat h){ + void ortho_camera::set_projection_box(float w, float h){ m_update_flag |= PROJ_UPDATE; m_width = w; m_height = h; diff --git a/src/engine/collision.cpp b/src/egn/collision.cpp similarity index 99% rename from src/engine/collision.cpp rename to src/egn/collision.cpp index 2af71e9..b27c70e 100644 --- a/src/engine/collision.cpp +++ b/src/egn/collision.cpp @@ -16,8 +16,8 @@ along with this program. If not, see . */ -#include "engine/collision.hpp" -#include "engine/base_types.hpp" +#include "egn/collision.hpp" +#include "egn/base_types.hpp" namespace egn{ diff --git a/src/engine/font.cpp b/src/egn/font.cpp similarity index 91% rename from src/engine/font.cpp rename to src/egn/font.cpp index 8fe1d9d..055675c 100644 --- a/src/engine/font.cpp +++ b/src/egn/font.cpp @@ -16,7 +16,7 @@ along with this program. If not, see . */ -#include "engine/font.hpp" +#include "egn/font.hpp" #include "math/vec.hpp" #include //sqrt, round #include //move @@ -28,7 +28,7 @@ namespace egn{ return ((float)size.x()) / size.y(); } - font_atlas::font_atlas(gfx::texture&& t, map_type&& map, size_t w, size_t h): + font_atlas::font_atlas(gfx::ogl::texture&& t, map_type&& map, size_t w, size_t h): texture(std::move(t)), m_atlas_data(std::move(map)), m_requested_width(w), @@ -105,7 +105,7 @@ namespace egn{ src += pitch; } } - void font::generate_atlas_piece_impl_(gfx::texture& atlas, font_atlas::map_type& metadata, math::vec2& target_pos, const atlas_meta& info, unsigned char* data_buffer, const std::pair& range){ + void font::generate_atlas_piece_impl_(gfx::ogl::texture& atlas, font_atlas::map_type& metadata, math::vec2& target_pos, const atlas_meta& info, unsigned char* data_buffer, const std::pair& range){ const auto& [atlas_width, atlas_height, max_glyph_width, max_glyph_height] = info; const auto format = (m_depth == 3) ? GL_RGB : GL_RED; const int freetype_load_flags = FT_LOAD_RENDER | ((m_depth == 3) ? FT_LOAD_TARGET_LCD : 0); @@ -132,14 +132,14 @@ namespace egn{ } } - std::optional font::generate_glyph(char character, int width, int height){ + std::optional font::generate_glyph(char character, int width, int height){ FT_Set_Pixel_Sizes(m_face, width, height); if(FT_Load_Char(m_face, character, FT_LOAD_RENDER | FT_LOAD_TARGET_LCD)){ debug_print_error("Failed to load character '%c', from font '%s'\n", character, m_face->family_name); return {}; } auto& bitmap = m_face->glyph->bitmap; - return {gfx::texture(bitmap.buffer, GL_RED, bitmap.width, bitmap.rows, GL_UNSIGNED_BYTE)}; + return {gfx::ogl::texture(bitmap.buffer, GL_RED, bitmap.width, bitmap.rows, GL_UNSIGNED_BYTE)}; } diff --git a/src/engine/game.cpp b/src/egn/game.cpp similarity index 98% rename from src/engine/game.cpp rename to src/egn/game.cpp index 2c69efd..f1ee639 100644 --- a/src/engine/game.cpp +++ b/src/egn/game.cpp @@ -16,8 +16,8 @@ along with this program. If not, see . */ -#include "engine/game.hpp" -#include "graphics/gl_include.hpp" //TODO +#include "egn/game.hpp" +#include "gfx/ogl/gl_include.hpp" //TODO #include "config.hpp" namespace egn{ diff --git a/src/engine/game_state.cpp b/src/egn/game_state.cpp similarity index 97% rename from src/engine/game_state.cpp rename to src/egn/game_state.cpp index 76f79ab..caf743f 100644 --- a/src/engine/game_state.cpp +++ b/src/egn/game_state.cpp @@ -16,8 +16,8 @@ along with this program. If not, see . */ -#include "engine/game_state.hpp" -#include "engine/input.hpp" +#include "egn/game_state.hpp" +#include "egn/input.hpp" #include "config.hpp" #include //queue diff --git a/src/engine/image.cpp b/src/egn/image.cpp similarity index 97% rename from src/engine/image.cpp rename to src/egn/image.cpp index 1b2c421..74bf02f 100644 --- a/src/engine/image.cpp +++ b/src/egn/image.cpp @@ -16,8 +16,8 @@ along with this program. If not, see . */ -#include "engine/image.hpp" -#include "engine/stb_include.hpp" +#include "egn/image.hpp" +#include "egn/stb_include.hpp" #include "config.hpp" #include //memcpy #include //exchange diff --git a/src/engine/object.cpp b/src/egn/object.cpp similarity index 99% rename from src/engine/object.cpp rename to src/egn/object.cpp index f9fa053..26cb90c 100644 --- a/src/engine/object.cpp +++ b/src/egn/object.cpp @@ -16,7 +16,7 @@ along with this program. If not, see . */ -#include "engine/object.hpp" +#include "egn/object.hpp" #include "config.hpp" namespace egn{ diff --git a/src/engine/stb.cpp b/src/egn/stb.cpp similarity index 96% rename from src/engine/stb.cpp rename to src/egn/stb.cpp index 7c402c6..2f3d659 100644 --- a/src/engine/stb.cpp +++ b/src/egn/stb.cpp @@ -18,7 +18,7 @@ #define STB_IMAGE_IMPLEMENTATION -#include "engine/stb_alloc.hpp" +#include "egn/stb_alloc.hpp" #define STBI_MALLOC(size) our_dick_stb_malloc(size) #define STBI_FREE(data) our_dick_stb_free(data) diff --git a/src/engine/stb_alloc.cpp b/src/egn/stb_alloc.cpp similarity index 97% rename from src/engine/stb_alloc.cpp rename to src/egn/stb_alloc.cpp index 551140c..dd80c8c 100644 --- a/src/engine/stb_alloc.cpp +++ b/src/egn/stb_alloc.cpp @@ -16,7 +16,7 @@ along with this program. If not, see . */ -#include "engine/stb_alloc.hpp" +#include "egn/stb_alloc.hpp" #include //size_t #include //new, delete diff --git a/src/graphics/backend_check.cpp b/src/gfx/backend_check.cpp similarity index 100% rename from src/graphics/backend_check.cpp rename to src/gfx/backend_check.cpp diff --git a/src/graphics/init.cpp b/src/gfx/init.cpp similarity index 95% rename from src/graphics/init.cpp rename to src/gfx/init.cpp index 7895d87..d1819a9 100644 --- a/src/graphics/init.cpp +++ b/src/gfx/init.cpp @@ -16,10 +16,10 @@ along with this program. If not, see . */ -#include "graphics/init.hpp" +#include "gfx/init.hpp" #include "config.hpp" -#include "graphics/gl_include.hpp" +#include "gfx/ogl/gl_include.hpp" #include //lock_guard, mutex diff --git a/src/graphics/lightable.cpp b/src/gfx/lightable.cpp similarity index 65% rename from src/graphics/lightable.cpp rename to src/gfx/lightable.cpp index 348c401..2ff3c45 100644 --- a/src/graphics/lightable.cpp +++ b/src/gfx/lightable.cpp @@ -16,33 +16,33 @@ along with this program. If not, see . */ -#include "graphics/lightable.hpp" +#include "gfx/lightable.hpp" namespace gfx{ - void lightable::set_ambient(const math::vec3& a){ + void lightable::set_ambient(const math::vec3f& a){ m_ambient = a; } - void lightable::set_diffuse(const math::vec3& d){ + void lightable::set_diffuse(const math::vec3f& d){ m_diffuse = d; } - void lightable::set_specular(const math::vec3& s){ + void lightable::set_specular(const math::vec3f& s){ m_specular = s; } - void lightable::set_shininess(GLfloat s){ + void lightable::set_shininess(float s){ m_shininess = s; } - const math::vec3& lightable::get_ambient()const{ + const math::vec3f& lightable::get_ambient()const{ return m_ambient; } - const math::vec3& lightable::get_diffuse()const{ + const math::vec3f& lightable::get_diffuse()const{ return m_diffuse; } - const math::vec3& lightable::get_specular()const{ + const math::vec3f& lightable::get_specular()const{ return m_specular; } - GLfloat lightable::get_shininess()const{ + float lightable::get_shininess()const{ return m_shininess; } diff --git a/src/graphics/material.cpp b/src/gfx/material.cpp similarity index 96% rename from src/graphics/material.cpp rename to src/gfx/material.cpp index 0916f33..200b0b0 100644 --- a/src/graphics/material.cpp +++ b/src/gfx/material.cpp @@ -16,7 +16,7 @@ along with this program. If not, see . */ -#include "graphics/material.hpp" +#include "gfx/material.hpp" #include //move diff --git a/src/graphics/mesh.cpp b/src/gfx/mesh.cpp similarity index 89% rename from src/graphics/mesh.cpp rename to src/gfx/mesh.cpp index 4eca46c..9044d31 100644 --- a/src/graphics/mesh.cpp +++ b/src/gfx/mesh.cpp @@ -16,7 +16,7 @@ along with this program. If not, see . */ -#include "graphics/mesh.hpp" +#include "gfx/mesh.hpp" #include "config.hpp" #include //offsetof @@ -26,20 +26,20 @@ namespace gfx{ vertex_mesh::vertex_mesh(const std::vector& verts): m_vertices(verts), - m_vbo(&verts[0], sizeof(vertex) * verts.size(), buffer::usage::STATIC_DRAW) + m_vbo(&verts[0], sizeof(vertex) * verts.size(), ogl::buffer::usage::STATIC_DRAW) { m_vao.bind_buffer(m_vbo, 0, 0, sizeof(vertex)); configure(); } vertex_mesh::vertex_mesh(std::vector&& verts): m_vertices(std::move(verts)), - m_vbo(&verts[0], sizeof(vertex) * verts.size(), buffer::usage::STATIC_DRAW) + m_vbo(&verts[0], sizeof(vertex) * verts.size(), ogl::buffer::usage::STATIC_DRAW) { m_vao.bind_buffer(m_vbo, 0, 0, sizeof(vertex)); configure(); } vertex_mesh::vertex_mesh(const vertex* verts, size_t nverts): - m_vbo(verts, sizeof(vertex) * nverts, buffer::usage::STATIC_DRAW) + m_vbo(verts, sizeof(vertex) * nverts, ogl::buffer::usage::STATIC_DRAW) { m_vertices.reserve(nverts); for(size_t i = 0;i < nverts;++i) @@ -70,7 +70,7 @@ namespace gfx{ void vertex_mesh::set_vertex(size_t index, const vertex& v){ m_vertices[index] = v; } - void vertex_mesh::render(shader_program&){ + void vertex_mesh::render(ogl::shader_program&){ m_vao.bind(); glDrawArrays(GL_TRIANGLES, 0, m_vertices.size()); } @@ -95,7 +95,7 @@ namespace gfx{ void material_mesh::set_material(size_t index, const material* new_texture){ m_materials[index] = new_texture; } - void material_mesh::render(shader_program& shader){ + void material_mesh::render(ogl::shader_program& shader){ size_t tex1_loc = shader.get_uniform_loc("texture1"); for(size_t i = 0;i < m_materials.size();++i){ m_materials[i]->bind_unit(i); @@ -125,7 +125,7 @@ namespace gfx{ void unified_mesh::configure(){ m_v_mesh.configure(); } - void unified_mesh::render(shader_program& shader){ + void unified_mesh::render(ogl::shader_program& shader){ m_m_mesh.render(shader); m_v_mesh.render(shader); } diff --git a/src/graphics/model.cpp b/src/gfx/model.cpp similarity index 95% rename from src/graphics/model.cpp rename to src/gfx/model.cpp index 9be7004..4bfef43 100644 --- a/src/graphics/model.cpp +++ b/src/gfx/model.cpp @@ -16,7 +16,7 @@ along with this program. If not, see . */ -#include "graphics/model.hpp" +#include "gfx/model.hpp" #include //move @@ -44,7 +44,7 @@ namespace gfx{ const unified_mesh& model::mesh(size_t index)const{ return m_meshes[index]; } - void model::render(shader_program& s){ + void model::render(ogl::shader_program& s){ for(size_t i = 0;i < m_meshes.size();++i){ m_meshes[i].render(s); } diff --git a/src/graphics/buffer_map.cpp b/src/gfx/ogl/buffer_map.cpp similarity index 97% rename from src/graphics/buffer_map.cpp rename to src/gfx/ogl/buffer_map.cpp index 3e72406..7cca8e5 100644 --- a/src/graphics/buffer_map.cpp +++ b/src/gfx/ogl/buffer_map.cpp @@ -16,13 +16,13 @@ along with this program. If not, see . */ -#include "graphics/buffer_map.hpp" +#include "gfx/ogl/buffer_map.hpp" #include "config.hpp" #include //exchange, swap -namespace gfx{ +namespace gfx::ogl{ scoped_buffer_map::scoped_buffer_map(GLuint bid, buffer::maptype m): m_buffer(bid) diff --git a/src/graphics/fbo.cpp b/src/gfx/ogl/fbo.cpp similarity index 98% rename from src/graphics/fbo.cpp rename to src/gfx/ogl/fbo.cpp index b6f1aff..49c4998 100644 --- a/src/graphics/fbo.cpp +++ b/src/gfx/ogl/fbo.cpp @@ -16,11 +16,11 @@ along with this program. If not, see . */ -#include "graphics/fbo.hpp" +#include "gfx/ogl/fbo.hpp" #include //swap, exchange #include "config.hpp" -namespace gfx{ +namespace gfx::ogl{ fbo::fbo(){ glCreateFramebuffers(1, &m_buffer); diff --git a/src/graphics/rbo.cpp b/src/gfx/ogl/rbo.cpp similarity index 98% rename from src/graphics/rbo.cpp rename to src/gfx/ogl/rbo.cpp index 7bd343e..09a44ad 100644 --- a/src/graphics/rbo.cpp +++ b/src/gfx/ogl/rbo.cpp @@ -16,10 +16,10 @@ along with this program. If not, see . */ -#include "graphics/rbo.hpp" +#include "gfx/ogl/rbo.hpp" #include //swap, exchange -namespace gfx{ +namespace gfx::ogl{ rbo::rbo(GLsizei width, GLsizei height, GLenum format, GLsizei samples): m_format(format), diff --git a/src/graphics/shader.cpp b/src/gfx/ogl/shader.cpp similarity index 98% rename from src/graphics/shader.cpp rename to src/gfx/ogl/shader.cpp index cff439a..58a2725 100644 --- a/src/graphics/shader.cpp +++ b/src/gfx/ogl/shader.cpp @@ -16,13 +16,13 @@ along with this program. If not, see . */ -#include "graphics/shader.hpp" +#include "gfx/ogl/shader.hpp" #include "config.hpp" #include //exchange, swap #include -namespace gfx{ +namespace gfx::ogl{ shader::shader(type t): m_shader_id(glCreateShader(static_cast(t))){} diff --git a/src/graphics/shader_program.cpp b/src/gfx/ogl/shader_program.cpp similarity index 99% rename from src/graphics/shader_program.cpp rename to src/gfx/ogl/shader_program.cpp index 87ab413..2b19159 100644 --- a/src/graphics/shader_program.cpp +++ b/src/gfx/ogl/shader_program.cpp @@ -16,14 +16,14 @@ along with this program. If not, see . */ -#include "graphics/shader_program.hpp" +#include "gfx/ogl/shader_program.hpp" #include "config.hpp" #include //exchange, swap #include #include //unique_ptr -namespace gfx{ +namespace gfx::ogl{ shader_program::shader_program(void): m_shader_id(glCreateProgram()){} diff --git a/src/graphics/texture.cpp b/src/gfx/ogl/texture.cpp similarity index 99% rename from src/graphics/texture.cpp rename to src/gfx/ogl/texture.cpp index a87fa24..a40d074 100644 --- a/src/graphics/texture.cpp +++ b/src/gfx/ogl/texture.cpp @@ -16,13 +16,13 @@ along with this program. If not, see . */ -#include "graphics/texture.hpp" +#include "gfx/ogl/texture.hpp" #include "config.hpp" #include //exchange, swap #include -namespace gfx{ +namespace gfx::ogl{ [[maybe_unused]] static constexpr bool is_format_compatible(GLenum format, int channel_count){ diff --git a/src/graphics/vao.cpp b/src/gfx/ogl/vao.cpp similarity index 98% rename from src/graphics/vao.cpp rename to src/gfx/ogl/vao.cpp index 81c06ad..5778722 100644 --- a/src/graphics/vao.cpp +++ b/src/gfx/ogl/vao.cpp @@ -16,10 +16,10 @@ along with this program. If not, see . */ -#include "graphics/vao.hpp" +#include "gfx/ogl/vao.hpp" #include //exchange, swap -namespace gfx{ +namespace gfx::ogl{ void vertex_attribute::enable(){ glEnableVertexArrayAttrib(m_vao, m_index); diff --git a/src/graphics/vbo.cpp b/src/gfx/ogl/vbo.cpp similarity index 98% rename from src/graphics/vbo.cpp rename to src/gfx/ogl/vbo.cpp index ece1d2a..ef33c47 100644 --- a/src/graphics/vbo.cpp +++ b/src/gfx/ogl/vbo.cpp @@ -16,7 +16,7 @@ along with this program. If not, see . */ -#include "graphics/vbo.hpp" +#include "gfx/ogl/vbo.hpp" #include "config.hpp" #include @@ -24,7 +24,7 @@ #include //memset -namespace gfx{ +namespace gfx::ogl{ vbo::vbo(size_t size, buffer::usage t): m_buffer_size(0) diff --git a/src/graphics/window.cpp b/src/gfx/ogl/window.cpp similarity index 99% rename from src/graphics/window.cpp rename to src/gfx/ogl/window.cpp index 5367a79..8b81c40 100644 --- a/src/graphics/window.cpp +++ b/src/gfx/ogl/window.cpp @@ -16,15 +16,15 @@ along with this program. If not, see . */ -#include "graphics/window.hpp" -#include "graphics/init.hpp" -#include "graphics/backend_check.hpp" +#include "gfx/ogl/window.hpp" +#include "gfx/init.hpp" +#include "gfx/backend_check.hpp" #include //exchange, swap, pair #include //strlen, strncpy #include "config.hpp" -namespace gfx{ +namespace gfx::ogl{ #ifdef OUR_DICK_ENABLE_DEBUG_CONTEXT static void APIENTRY our_dick_gl_debug_output(GLenum source, GLenum type, unsigned int /*id*/, GLenum severity, diff --git a/src/graphics/resource_manager.cpp b/src/gfx/resource_manager.cpp similarity index 93% rename from src/graphics/resource_manager.cpp rename to src/gfx/resource_manager.cpp index 8c09d6e..325a962 100644 --- a/src/graphics/resource_manager.cpp +++ b/src/gfx/resource_manager.cpp @@ -16,14 +16,14 @@ along with this program. If not, see . */ -#include "graphics/resource_manager.hpp" +#include "gfx/resource_manager.hpp" namespace gfx{ bool resource_manager::has_texture_array(const char* key)const{ return m_texture_arrays.has_value(key); } - auto resource_manager::get_texture_array(const char* file) -> container_type::node{ + auto resource_manager::get_texture_array(const char* file) -> container_type::node{ return m_texture_arrays.get_value(file); } bool resource_manager::erase_texture_array(const char* key){ @@ -33,7 +33,7 @@ namespace gfx{ bool resource_manager::has_texture(const char* key)const{ return m_textures.has_value(key); } - auto resource_manager::get_texture(const char* file) -> container_type::node{ + auto resource_manager::get_texture(const char* file) -> container_type::node{ return m_textures.get_value(file); } bool resource_manager::erase_texture(const char* key){ @@ -53,7 +53,7 @@ namespace gfx{ bool resource_manager::has_shader(const char* key)const{ return m_shaders.has_value(key); } - auto resource_manager::get_shader(const char* key) -> container_type::node{ + auto resource_manager::get_shader(const char* key) -> container_type::node{ return m_shaders.get_value(key); } bool resource_manager::erase_shader(const char* key){ diff --git a/src/main.cpp b/src/main.cpp index bf74780..b302c6f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,9 +25,7 @@ #include "config.hpp" #include "ttt/tic_tac_toe.hpp" -#include "engine/font.hpp" - -#include "graphics/ubo.hpp" +#include "egn/font.hpp" #include "math/debug.hpp" diff --git a/src/ttt/board.cpp b/src/ttt/board.cpp index 2fd42fe..45d0eef 100644 --- a/src/ttt/board.cpp +++ b/src/ttt/board.cpp @@ -19,8 +19,6 @@ #include "ttt/board.hpp" #include "ttt/board_gfx.hpp" -#include "graphics/gl_include.hpp" //GLfloat - void tile::set_value(value t){ m_active_value = t; } @@ -49,7 +47,7 @@ board::board(gfx::resource_manager& resman): m_tiles[8].set_position({ 2.125, -2.125, -1}); } -void board::render(gfx::shader_program& sh){ +void board::render(gfx::ogl::shader_program& sh){ m_gfx->buffer_tiles(m_tiles.get()); m_gfx->render(sh); } @@ -62,15 +60,15 @@ bool board::is_full(void)const{ return true; } -int board::click_collision_cheat(const math::vec3& unproj_3)const{ - math::vec4 unproj_4 = {unproj_3[0], unproj_3[1], unproj_3[2], 1}; - math::vec4 mod_coord = model_matrix().inverse() * unproj_4; +int board::click_collision_cheat(const math::vec3f& unproj_3)const{ + math::vec4f unproj_4 = {unproj_3[0], unproj_3[1], unproj_3[2], 1}; + math::vec4f mod_coord = model_matrix().inverse() * unproj_4; mod_coord /= mod_coord[3]; - math::vec3 projected1 = {mod_coord[0], mod_coord[1], mod_coord[2]}; + math::vec3f projected1 = {mod_coord[0], mod_coord[1], mod_coord[2]}; for(size_t i = 0;i < 9;++i){ const tile& sq = m_tiles[i]; - const math::vec3& sq_pos = sq.position(); + const math::vec3f& sq_pos = sq.position(); if((projected1.x() > (sq_pos.x() - 1.0f) && projected1.x() < (sq_pos.x() + 1.0f)) && (projected1.y() > (sq_pos.y() - 1.0f) && projected1.y() < (sq_pos.y() + 1.0f))) { diff --git a/src/ttt/board_gfx.cpp b/src/ttt/board_gfx.cpp index fb92de9..b2cae39 100644 --- a/src/ttt/board_gfx.cpp +++ b/src/ttt/board_gfx.cpp @@ -20,7 +20,7 @@ #include "ttt/board.hpp" board_gfx::board_gfx(gfx::resource_manager& resman): - m_vbo((16 * sizeof(GLfloat) + 4 * sizeof(GLfloat) + 1 * sizeof(GLint)) * 9, gfx::buffer::usage::DYNAMIC_DRAW) + m_vbo((16 * sizeof(GLfloat) + 4 * sizeof(GLfloat) + 1 * sizeof(GLint)) * 9, gfx::ogl::buffer::usage::DYNAMIC_DRAW) { auto result = resman.emplace_texture_array("board_textures", 3); m_textures = std::move(result.first); @@ -63,7 +63,7 @@ board_gfx::board_gfx(gfx::resource_manager& resman): attrib.enable(); } -void board_gfx::set_uniforms(gfx::shader_program& sh){ +void board_gfx::set_uniforms(gfx::ogl::shader_program& sh){ sh.get_uniform("textures").set(*m_textures, 0); } void board_gfx::bind_buffers(void){ @@ -80,7 +80,7 @@ void board_gfx::buffer_tiles(const tile* t){ } } -void board_gfx::render(gfx::shader_program& shader){ +void board_gfx::render(gfx::ogl::shader_program& shader){ set_uniforms(shader); bind_buffers(); glDrawArrays(GL_POINTS, 0, 9); diff --git a/src/ttt/main_renderer.cpp b/src/ttt/main_renderer.cpp index b7474f2..da88687 100644 --- a/src/ttt/main_renderer.cpp +++ b/src/ttt/main_renderer.cpp @@ -17,7 +17,7 @@ */ #include "ttt/main_renderer.hpp" -#include "graphics/shader.hpp" +#include "gfx/ogl/shader.hpp" #include "ttt/square_shader.hpp" #include "ttt/screen_shader.hpp" #include "util/deferred.hpp" @@ -31,20 +31,20 @@ main_renderer::main_renderer(gfx::resource_manager& res, int width, int height): m_fb(MAX_WIDTH, MAX_HEIGHT), m_primary_fb(util::no_initialize), - m_vbo(s_vertices, sizeof(s_vertices), gfx::buffer::usage::DYNAMIC_DRAW), - m_board_vbo((16*sizeof(GLfloat)+sizeof(GLint)+4*sizeof(GLfloat)) * 9, gfx::buffer::usage::DYNAMIC_DRAW) + m_vbo(s_vertices, sizeof(s_vertices), gfx::ogl::buffer::usage::DYNAMIC_DRAW), + m_board_vbo((16*sizeof(GLfloat)+sizeof(GLint)+4*sizeof(GLfloat)) * 9, gfx::ogl::buffer::usage::DYNAMIC_DRAW) { - m_square_shader = res.emplace_shader("square_shader", util::make_deferred(square_shader::fragment_shader_text, gfx::shader::type::FRAGMENT), - util::make_deferred(square_shader::geometry_shader_text, gfx::shader::type::GEOMETRY), - util::make_deferred(square_shader::vertex_shader_text, gfx::shader::type::VERTEX)).first; + m_square_shader = res.emplace_shader("square_shader", util::make_deferred(square_shader::fragment_shader_text, gfx::ogl::shader::type::FRAGMENT), + util::make_deferred(square_shader::geometry_shader_text, gfx::ogl::shader::type::GEOMETRY), + util::make_deferred(square_shader::vertex_shader_text, gfx::ogl::shader::type::VERTEX)).first; if(m_square_shader->has_link_error()){ debug_print_error("%s\n", m_square_shader->get_error().c_str()); } m_square_shader->get_uniform("vp_mat").set(math::mat4{}); - m_screen_shader = res.emplace_shader("screen_shader", util::make_deferred(screen_shader::fragment_shader_text, gfx::shader::type::FRAGMENT), - util::make_deferred(screen_shader::vertex_shader_text, gfx::shader::type::VERTEX)).first; + m_screen_shader = res.emplace_shader("screen_shader", util::make_deferred(screen_shader::fragment_shader_text, gfx::ogl::shader::type::FRAGMENT), + util::make_deferred(screen_shader::vertex_shader_text, gfx::ogl::shader::type::VERTEX)).first; m_screen_shader->get_uniform("vp_mat").set(math::mat4{}); m_vao.bind_buffer(m_vbo, 0, 0, sizeof(vertex)); @@ -87,7 +87,7 @@ void main_renderer::render(scene& s){ void main_renderer::resize_viewport(int width, int height){ m_fb.set_viewport(0, 0, width, height); - auto map = m_vbo.map(gfx::buffer::maptype::WRITE); + auto map = m_vbo.map(gfx::ogl::buffer::maptype::WRITE); vertex* data = reinterpret_cast(map.raw()); GLfloat x1 = 0, y1 = 0; GLfloat x2 = (GLfloat)width / m_fb.colorbuffer().get_width(); diff --git a/src/ttt/pause_state.cpp b/src/ttt/pause_state.cpp index 205e6ab..1231439 100644 --- a/src/ttt/pause_state.cpp +++ b/src/ttt/pause_state.cpp @@ -17,10 +17,10 @@ */ #include "ttt/pause_state.hpp" -#include "engine/game.hpp" +#include "egn/game.hpp" #include "util/deferred.hpp" -#include "graphics/gl_include.hpp" //TODO +#include "gfx/ogl/gl_include.hpp" //TODO #include "config.hpp" diff --git a/src/ttt/play_state.cpp b/src/ttt/play_state.cpp index 1b55225..970c70e 100644 --- a/src/ttt/play_state.cpp +++ b/src/ttt/play_state.cpp @@ -19,11 +19,11 @@ #include "ttt/play_state.hpp" #include "ttt/pause_state.hpp" -#include "graphics/gl_include.hpp" //TODO: separate key definitions from GLFW -#include "engine/image.hpp" //TODO: move image to engine namespace +#include "gfx/ogl/gl_include.hpp" //TODO: separate key definitions from GLFW +#include "egn/image.hpp" //TODO: move image to engine namespace #include "math/math.hpp" #include "config.hpp" -#include "engine/game.hpp" +#include "egn/game.hpp" #include "ttt/board.hpp" play_state::play_state(egn::game& owner, int width, int height): diff --git a/src/ttt/screen_renderer.cpp b/src/ttt/screen_renderer.cpp index f8c1048..935eede 100644 --- a/src/ttt/screen_renderer.cpp +++ b/src/ttt/screen_renderer.cpp @@ -18,24 +18,24 @@ #include "ttt/screen_renderer.hpp" -#include "graphics/shader.hpp" +#include "gfx/ogl/shader.hpp" #include "ttt/screen_shader.hpp" #include "util/deferred.hpp" #include #include //piecewise_construct -#include "engine/font.hpp" +#include "egn/font.hpp" #include "ttt/font_shader.hpp" #include "math/debug.hpp" -screen_renderer::screen_renderer(gfx::resource_manager& res, int width, int height, const std::shared_ptr& base_tex): - m_vbo(s_vertices, sizeof(s_vertices), gfx::buffer::usage::DYNAMIC_DRAW), +screen_renderer::screen_renderer(gfx::resource_manager& res, int width, int height, const std::shared_ptr& base_tex): + m_vbo(s_vertices, sizeof(s_vertices), gfx::ogl::buffer::usage::DYNAMIC_DRAW), m_texture(base_tex), m_screen_width(width), m_screen_height(height) { - m_screen_shader = res.emplace_shader("screen_shader", util::make_deferred(screen_shader::vertex_shader_text, gfx::shader::type::VERTEX), - util::make_deferred(screen_shader::fragment_shader_text, gfx::shader::type::FRAGMENT)).first; + m_screen_shader = res.emplace_shader("screen_shader", util::make_deferred(screen_shader::vertex_shader_text, gfx::ogl::shader::type::VERTEX), + util::make_deferred(screen_shader::fragment_shader_text, gfx::ogl::shader::type::FRAGMENT)).first; if(m_screen_shader->has_link_error()){ debug_print_error("%s\n", m_screen_shader->get_error().c_str()); } diff --git a/src/ttt/tic_tac_toe.cpp b/src/ttt/tic_tac_toe.cpp index 46aca46..0d777cc 100644 --- a/src/ttt/tic_tac_toe.cpp +++ b/src/ttt/tic_tac_toe.cpp @@ -17,7 +17,7 @@ */ #include "ttt/tic_tac_toe.hpp" -#include "engine/game_state.hpp" +#include "egn/game_state.hpp" #include "ttt/play_state.hpp" #include "config.hpp" diff --git a/src/wip_renderer.cpp b/src/wip_renderer.cpp deleted file mode 100644 index 7071e2b..0000000 --- a/src/wip_renderer.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/** - This file is a part of our_dick - Copyright (C) 2022 rexy712 - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -#include "wip_renderer.hpp" - -#include "graphics/shader_program.hpp" -#include "graphics/gl_include.hpp" - -void wip_renderer::add_command(const draw_command& c){ - m_draws.push(c); -} -void wip_renderer::add_command(draw_command&& c){ - m_draws.push(std::move(c)); -} - -void wip_renderer::render(void){ - while(!m_draws.empty()){ - auto& command = m_draws.front(); - - glBindFramebuffer(GL_FRAMEBUFFER, command.framebuffer); - glViewport(command.viewport[0], command.viewport[1], - command.viewport[2], command.viewport[3]); - if(command.clear) - glClear(command.clear); - - glUseProgram(command.shader); - glBindVertexArray(command.vertex_arrays); - for(auto& uniform_pair : command.uniforms){ - gfx::uniform tmp{command.shader, uniform_pair.first}; - std::visit([&](const auto& i){tmp.set(i);}, uniform_pair.second); - } - for(auto& uniform_block_pair : command.uniform_blocks){ - gfx::uniform_block tmp{command.shader, uniform_block_pair.first}; - tmp.set_binding(uniform_block_pair.second); - } - for(auto& texture_bind_pair : command.texture_binds){ - glBindTextureUnit(texture_bind_pair.second, texture_bind_pair.first); - } - glDrawArrays(command.shape, 0, command.shape_count); - - m_draws.pop(); - } -} -