Browse Source

Rename rasterizer folder to gl and put all files in the gl folder into the gl namespace

master
C. J. Howard 3 years ago
parent
commit
ccbbd08b32
77 changed files with 791 additions and 704 deletions
  1. +0
    -1
      CMakeLists.txt
  2. +1
    -2
      src/application.cpp
  3. +4
    -4
      src/application.hpp
  4. +7
    -7
      src/ecs/systems/painting-system.cpp
  5. +2
    -2
      src/ecs/systems/painting-system.hpp
  6. +11
    -11
      src/ecs/systems/subterrain-system.cpp
  7. +11
    -11
      src/ecs/systems/terrain-system.cpp
  8. +1
    -1
      src/ecs/systems/ui-system.cpp
  9. +67
    -67
      src/game/bootloader.cpp
  10. +17
    -17
      src/game/game-context.hpp
  11. +1
    -1
      src/game/states/map-state.cpp
  12. +3
    -3
      src/game/states/play-state.cpp
  13. +1
    -1
      src/game/states/splash-state.cpp
  14. +7
    -3
      src/gl/buffer-usage.hpp
  15. +7
    -3
      src/gl/color-space.hpp
  16. +7
    -3
      src/gl/drawing-mode.hpp
  17. +7
    -3
      src/gl/element-array-type.hpp
  18. +6
    -2
      src/gl/framebuffer.cpp
  19. +6
    -3
      src/gl/framebuffer.hpp
  20. +22
    -1
      src/gl/gl.hpp
  21. +7
    -3
      src/gl/pixel-format.hpp
  22. +7
    -3
      src/gl/pixel-type.hpp
  23. +8
    -5
      src/gl/rasterizer.cpp
  24. +8
    -4
      src/gl/rasterizer.hpp
  25. +6
    -3
      src/gl/shader-input.cpp
  26. +7
    -3
      src/gl/shader-input.hpp
  27. +7
    -4
      src/gl/shader-program.cpp
  28. +7
    -3
      src/gl/shader-program.hpp
  29. +7
    -3
      src/gl/shader-type.hpp
  30. +7
    -3
      src/gl/shader-variable-type.hpp
  31. +4
    -1
      src/gl/shader.cpp
  32. +7
    -3
      src/gl/shader.hpp
  33. +10
    -7
      src/gl/texture-2d.cpp
  34. +16
    -12
      src/gl/texture-2d.hpp
  35. +4
    -1
      src/gl/texture-cube.cpp
  36. +7
    -3
      src/gl/texture-cube.hpp
  37. +7
    -3
      src/gl/texture-filter.hpp
  38. +7
    -3
      src/gl/texture-wrapping.hpp
  39. +5
    -2
      src/gl/vertex-array.cpp
  40. +7
    -3
      src/gl/vertex-array.hpp
  41. +7
    -3
      src/gl/vertex-attribute-type.hpp
  42. +4
    -1
      src/gl/vertex-buffer.cpp
  43. +8
    -4
      src/gl/vertex-buffer.hpp
  44. +0
    -37
      src/rasterizer/buffer-usage.cpp
  45. +2
    -2
      src/renderer/material-property.cpp
  46. +51
    -51
      src/renderer/material-property.hpp
  47. +3
    -3
      src/renderer/material.cpp
  48. +6
    -6
      src/renderer/material.hpp
  49. +1
    -2
      src/renderer/model.cpp
  50. +18
    -20
      src/renderer/model.hpp
  51. +25
    -25
      src/renderer/passes/bloom-pass.cpp
  52. +22
    -22
      src/renderer/passes/bloom-pass.hpp
  53. +3
    -3
      src/renderer/passes/clear-pass.cpp
  54. +1
    -1
      src/renderer/passes/clear-pass.hpp
  55. +19
    -19
      src/renderer/passes/final-pass.cpp
  56. +16
    -16
      src/renderer/passes/final-pass.hpp
  57. +20
    -20
      src/renderer/passes/material-pass.cpp
  58. +41
    -41
      src/renderer/passes/material-pass.hpp
  59. +11
    -11
      src/renderer/passes/outline-pass.cpp
  60. +9
    -9
      src/renderer/passes/outline-pass.hpp
  61. +10
    -10
      src/renderer/passes/shadow-map-pass.cpp
  62. +7
    -7
      src/renderer/passes/shadow-map-pass.hpp
  63. +13
    -13
      src/renderer/passes/sky-pass.cpp
  64. +35
    -35
      src/renderer/passes/sky-pass.hpp
  65. +15
    -15
      src/renderer/passes/ui-pass.cpp
  66. +8
    -8
      src/renderer/passes/ui-pass.hpp
  67. +4
    -4
      src/renderer/render-operation.hpp
  68. +1
    -1
      src/renderer/render-pass.cpp
  69. +6
    -5
      src/renderer/render-pass.hpp
  70. +3
    -3
      src/renderer/renderer.cpp
  71. +2
    -2
      src/renderer/renderer.hpp
  72. +16
    -16
      src/renderer/simple-render-pass.cpp
  73. +8
    -8
      src/renderer/simple-render-pass.hpp
  74. +26
    -26
      src/resources/material-loader.cpp
  75. +6
    -6
      src/resources/model-loader.cpp
  76. +19
    -19
      src/resources/shader-program-loader.cpp
  77. +12
    -12
      src/resources/texture-2d-loader.cpp

+ 0
- 1
CMakeLists.txt View File

@ -14,7 +14,6 @@ find_package(SDL2 REQUIRED COMPONENTS SDL2::SDL2-static SDL2::SDL2main CONFIG)
find_package(OpenAL REQUIRED CONFIG)
find_library(physfs REQUIRED NAMES physfs-static PATHS "${CMAKE_PREFIX_PATH}/lib")
# Determine dependencies
set(STATIC_LIBS
dr_wav

+ 1
- 2
src/application.cpp View File

@ -29,7 +29,6 @@
#include "input/keyboard.hpp"
#include "input/mouse.hpp"
#include "input/game-controller.hpp"
#include "rasterizer/rasterizer.hpp"
#include "resources/image.hpp"
#include <SDL2/SDL.h>
#include <glad/glad.h>
@ -203,7 +202,7 @@ application::application():
*/
// Setup rasterizer
rasterizer = new ::rasterizer();
rasterizer = new gl::rasterizer();
// Setup events
event_dispatcher = new ::event_dispatcher();

+ 4
- 4
src/application.hpp View File

@ -25,6 +25,7 @@
#include <list>
#include <memory>
#include <unordered_map>
#include "gl/rasterizer.hpp"
// Forward declarations
typedef struct SDL_Window SDL_Window;
@ -34,7 +35,6 @@ class frame_scheduler;
class game_controller;
class keyboard;
class mouse;
class rasterizer;
class image;
namespace debug
@ -180,7 +180,7 @@ public:
bool is_fullscreen() const;
/// Returns the rasterizer for the window.
::rasterizer* get_rasterizer();
gl::rasterizer* get_rasterizer();
/// Returns the application logger.
debug::logger* get_logger();
@ -222,7 +222,7 @@ private:
SDL_Window* sdl_window;
SDL_GLContext sdl_gl_context;
rasterizer* rasterizer;
gl::rasterizer* rasterizer;
// Frame timing
frame_scheduler* frame_scheduler;
@ -263,7 +263,7 @@ inline bool application::is_fullscreen() const
return fullscreen;
}
inline rasterizer* application::get_rasterizer()
inline gl::rasterizer* application::get_rasterizer()
{
return rasterizer;
}

+ 7
- 7
src/ecs/systems/painting-system.cpp View File

@ -30,8 +30,8 @@
#include "ecs/commands.hpp"
#include "ecs/components/collision-component.hpp"
#include "ecs/components/transform-component.hpp"
#include "rasterizer/vertex-buffer.hpp"
#include "rasterizer/vertex-attribute-type.hpp"
#include "gl/vertex-buffer.hpp"
#include "gl/vertex-attribute-type.hpp"
#include "renderer/vertex-attributes.hpp"
#include "geom/mesh-functions.hpp"
#include <limits>
@ -66,11 +66,11 @@ painting_system::painting_system(ecs::registry& registry, ::event_dispatcher* ev
// Setup stroke vbo and vao
stroke_vbo = stroke_model->get_vertex_buffer();
stroke_vbo->repurpose(sizeof(float) * vertex_size * vertex_count, nullptr, buffer_usage::dynamic_draw);
stroke_model->get_vertex_array()->bind_attribute(VERTEX_POSITION_LOCATION, *stroke_vbo, 4, vertex_attribute_type::float_32, vertex_stride, 0);
stroke_model->get_vertex_array()->bind_attribute(VERTEX_NORMAL_LOCATION, *stroke_vbo, 3, vertex_attribute_type::float_32, vertex_stride, sizeof(float) * 4);
stroke_model->get_vertex_array()->bind_attribute(VERTEX_TEXCOORD_LOCATION, *stroke_vbo, 2, vertex_attribute_type::float_32, vertex_stride, sizeof(float) * 7);
stroke_model->get_vertex_array()->bind_attribute(VERTEX_TANGENT_LOCATION, *stroke_vbo, 4, vertex_attribute_type::float_32, vertex_stride, sizeof(float) * 9);
stroke_vbo->repurpose(sizeof(float) * vertex_size * vertex_count, nullptr, gl::buffer_usage::dynamic_draw);
stroke_model->get_vertex_array()->bind_attribute(VERTEX_POSITION_LOCATION, *stroke_vbo, 4, gl::vertex_attribute_type::float_32, vertex_stride, 0);
stroke_model->get_vertex_array()->bind_attribute(VERTEX_NORMAL_LOCATION, *stroke_vbo, 3, gl::vertex_attribute_type::float_32, vertex_stride, sizeof(float) * 4);
stroke_model->get_vertex_array()->bind_attribute(VERTEX_TEXCOORD_LOCATION, *stroke_vbo, 2, gl::vertex_attribute_type::float_32, vertex_stride, sizeof(float) * 7);
stroke_model->get_vertex_array()->bind_attribute(VERTEX_TANGENT_LOCATION, *stroke_vbo, 4, gl::vertex_attribute_type::float_32, vertex_stride, sizeof(float) * 9);
// Create stroke model instance
stroke_model_instance = new scene::model_instance();

+ 2
- 2
src/ecs/systems/painting-system.hpp View File

@ -27,6 +27,7 @@
#include "utility/fundamental-types.hpp"
#include "scene/collection.hpp"
#include "scene/model-instance.hpp"
#include "gl/vertex-buffer.hpp"
#include <vector>
#include <optional>
@ -35,7 +36,6 @@ class event_dispatcher;
class resource_manager;
class model;
class model_group;
class vertex_buffer;
namespace ecs {
@ -83,7 +83,7 @@ private:
model* stroke_model;
model_group* stroke_model_group;
vertex_buffer* stroke_vbo;
gl::vertex_buffer* stroke_vbo;
bool midstroke;
scene::model_instance* stroke_model_instance;

+ 11
- 11
src/ecs/systems/subterrain-system.cpp View File

@ -25,9 +25,9 @@
#include "renderer/material.hpp"
#include "geom/mesh-functions.hpp"
#include "renderer/vertex-attributes.hpp"
#include "rasterizer/vertex-attribute-type.hpp"
#include "rasterizer/drawing-mode.hpp"
#include "rasterizer/vertex-buffer.hpp"
#include "gl/vertex-attribute-type.hpp"
#include "gl/drawing-mode.hpp"
#include "gl/vertex-buffer.hpp"
#include "resources/resource-manager.hpp"
#include "geom/marching-cubes.hpp"
#include "geom/intersection.hpp"
@ -203,14 +203,14 @@ subterrain_system::subterrain_system(ecs::registry& registry, ::resource_manager
// Create inside model group
subterrain_inside_group = subterrain_model->add_group("inside");
subterrain_inside_group->set_material(resource_manager->load<material>("subterrain-inside.mtl"));
subterrain_inside_group->set_drawing_mode(drawing_mode::triangles);
subterrain_inside_group->set_drawing_mode(gl::drawing_mode::triangles);
subterrain_inside_group->set_start_index(0);
subterrain_inside_group->set_index_count(0);
// Create outside model group
subterrain_outside_group = subterrain_model->add_group("outside");
subterrain_outside_group->set_material(resource_manager->load<material>("subterrain-outside.mtl"));
subterrain_outside_group->set_drawing_mode(drawing_mode::triangles);
subterrain_outside_group->set_drawing_mode(gl::drawing_mode::triangles);
subterrain_outside_group->set_start_index(0);
subterrain_outside_group->set_index_count(0);
@ -219,14 +219,14 @@ subterrain_system::subterrain_system(ecs::registry& registry, ::resource_manager
subterrain_model_vertex_stride = subterrain_model_vertex_size * sizeof(float);
// Bind vertex attributes
vertex_buffer* vbo = subterrain_model->get_vertex_buffer();
vertex_array* vao = subterrain_model->get_vertex_array();
gl::vertex_buffer* vbo = subterrain_model->get_vertex_buffer();
gl::vertex_array* vao = subterrain_model->get_vertex_array();
std::size_t offset = 0;
vao->bind_attribute(VERTEX_POSITION_LOCATION, *vbo, 3, vertex_attribute_type::float_32, subterrain_model_vertex_stride, 0);
vao->bind_attribute(VERTEX_POSITION_LOCATION, *vbo, 3, gl::vertex_attribute_type::float_32, subterrain_model_vertex_stride, 0);
offset += 3;
vao->bind_attribute(VERTEX_NORMAL_LOCATION, *vbo, 3, vertex_attribute_type::float_32, subterrain_model_vertex_stride, sizeof(float) * offset);
vao->bind_attribute(VERTEX_NORMAL_LOCATION, *vbo, 3, gl::vertex_attribute_type::float_32, subterrain_model_vertex_stride, sizeof(float) * offset);
offset += 3;
vao->bind_attribute(VERTEX_BARYCENTRIC_LOCATION, *vbo, 3, vertex_attribute_type::float_32, subterrain_model_vertex_stride, sizeof(float) * offset);
vao->bind_attribute(VERTEX_BARYCENTRIC_LOCATION, *vbo, 3, gl::vertex_attribute_type::float_32, subterrain_model_vertex_stride, sizeof(float) * offset);
offset += 3;
// Calculate adjusted bounds to fit isosurface resolution
@ -438,7 +438,7 @@ void subterrain_system::regenerate_subterrain_model()
}
// Resized VBO and upload vertex data
vertex_buffer* vbo = subterrain_model->get_vertex_buffer();
gl::vertex_buffer* vbo = subterrain_model->get_vertex_buffer();
vbo->resize(subterrain_mesh->get_faces().size() * 3 * subterrain_model_vertex_stride, vertex_data);
// Deallocate vertex data

+ 11
- 11
src/ecs/systems/terrain-system.cpp View File

@ -26,9 +26,9 @@
#include "geom/mesh.hpp"
#include "geom/mesh-functions.hpp"
#include "renderer/vertex-attributes.hpp"
#include "rasterizer/vertex-attribute-type.hpp"
#include "rasterizer/drawing-mode.hpp"
#include "rasterizer/vertex-buffer.hpp"
#include "gl/vertex-attribute-type.hpp"
#include "gl/drawing-mode.hpp"
#include "gl/vertex-buffer.hpp"
#include "resources/resource-manager.hpp"
#include "resources/image.hpp"
#include "utility/fundamental-types.hpp"
@ -82,8 +82,8 @@ model* terrain_system::generate_terrain_model(geom::mesh* terrain_mesh)
model* terrain_model = new model();
// Get model's VAO and VBO
vertex_buffer* vbo = terrain_model->get_vertex_buffer();
vertex_array* vao = terrain_model->get_vertex_array();
gl::vertex_buffer* vbo = terrain_model->get_vertex_buffer();
gl::vertex_array* vao = terrain_model->get_vertex_array();
// Resize VBO
int vertex_size = 3 + 2 + 3 + 4 + 3;
@ -92,21 +92,21 @@ model* terrain_system::generate_terrain_model(geom::mesh* terrain_mesh)
// Bind vertex attributes
std::size_t offset = 0;
vao->bind_attribute(VERTEX_POSITION_LOCATION, *vbo, 3, vertex_attribute_type::float_32, vertex_stride, 0);
vao->bind_attribute(VERTEX_POSITION_LOCATION, *vbo, 3, gl::vertex_attribute_type::float_32, vertex_stride, 0);
offset += 3;
vao->bind_attribute(VERTEX_TEXCOORD_LOCATION, *vbo, 2, vertex_attribute_type::float_32, vertex_stride, sizeof(float) * offset);
vao->bind_attribute(VERTEX_TEXCOORD_LOCATION, *vbo, 2, gl::vertex_attribute_type::float_32, vertex_stride, sizeof(float) * offset);
offset += 2;
vao->bind_attribute(VERTEX_NORMAL_LOCATION, *vbo, 3, vertex_attribute_type::float_32, vertex_stride, sizeof(float) * offset);
vao->bind_attribute(VERTEX_NORMAL_LOCATION, *vbo, 3, gl::vertex_attribute_type::float_32, vertex_stride, sizeof(float) * offset);
offset += 3;
vao->bind_attribute(VERTEX_TANGENT_LOCATION, *vbo, 4, vertex_attribute_type::float_32, vertex_stride, sizeof(float) * offset);
vao->bind_attribute(VERTEX_TANGENT_LOCATION, *vbo, 4, gl::vertex_attribute_type::float_32, vertex_stride, sizeof(float) * offset);
offset += 4;
vao->bind_attribute(VERTEX_BARYCENTRIC_LOCATION, *vbo, 3, vertex_attribute_type::float_32, vertex_stride, sizeof(float) * offset);
vao->bind_attribute(VERTEX_BARYCENTRIC_LOCATION, *vbo, 3, gl::vertex_attribute_type::float_32, vertex_stride, sizeof(float) * offset);
offset += 3;
// Create model group
model_group* model_group = terrain_model->add_group("terrain");
model_group->set_material(resource_manager->load<material>("grassland-terrain.mtl"));
model_group->set_drawing_mode(drawing_mode::triangles);
model_group->set_drawing_mode(gl::drawing_mode::triangles);
model_group->set_start_index(0);
model_group->set_index_count(terrain_mesh->get_faces().size() * 3);

+ 1
- 1
src/ecs/systems/ui-system.cpp View File

@ -37,7 +37,7 @@ ui_system::ui_system(::resource_manager* resource_manager):
direct_light.update_tweens();
// Setup modal background
modal_bg_material.set_shader_program(resource_manager->load<shader_program>("ui-element-untextured.glsl"));
modal_bg_material.set_shader_program(resource_manager->load<gl::shader_program>("ui-element-untextured.glsl"));
modal_bg_material.set_flags(1);
modal_bg_material.add_property<float4>("tint")->set_value({0, 0, 0, 0.25f});
modal_bg.set_material(&modal_bg_material);

+ 67
- 67
src/game/bootloader.cpp View File

@ -27,16 +27,16 @@
#include "debug/console-commands.hpp"
#include "debug/logger.hpp"
#include "game/game-context.hpp"
#include "rasterizer/framebuffer.hpp"
#include "rasterizer/pixel-format.hpp"
#include "rasterizer/pixel-type.hpp"
#include "rasterizer/rasterizer.hpp"
#include "rasterizer/texture-2d.hpp"
#include "rasterizer/texture-filter.hpp"
#include "rasterizer/texture-wrapping.hpp"
#include "rasterizer/vertex-array.hpp"
#include "rasterizer/vertex-attribute-type.hpp"
#include "rasterizer/vertex-buffer.hpp"
#include "gl/framebuffer.hpp"
#include "gl/pixel-format.hpp"
#include "gl/pixel-type.hpp"
#include "gl/rasterizer.hpp"
#include "gl/texture-2d.hpp"
#include "gl/texture-filter.hpp"
#include "gl/texture-wrapping.hpp"
#include "gl/vertex-array.hpp"
#include "gl/vertex-attribute-type.hpp"
#include "gl/vertex-buffer.hpp"
#include "renderer/material-flags.hpp"
#include "renderer/material-property.hpp"
#include "renderer/passes/bloom-pass.hpp"
@ -443,22 +443,22 @@ void setup_rendering(game_context* ctx)
ctx->rasterizer = ctx->app->get_rasterizer();
// Get default framebuffer
const framebuffer& default_framebuffer = ctx->rasterizer->get_default_framebuffer();
const gl::framebuffer& default_framebuffer = ctx->rasterizer->get_default_framebuffer();
const auto& viewport_dimensions = default_framebuffer.get_dimensions();
// Create HDR framebuffer (32F color, 32F depth)
ctx->framebuffer_hdr_color = new texture_2d(viewport_dimensions[0], viewport_dimensions[1], pixel_type::float_32, pixel_format::rgb);
ctx->framebuffer_hdr_color->set_wrapping(texture_wrapping::clamp, texture_wrapping::clamp);
ctx->framebuffer_hdr_color->set_filters(texture_min_filter::linear, texture_mag_filter::linear);
ctx->framebuffer_hdr_color = new gl::texture_2d(viewport_dimensions[0], viewport_dimensions[1], gl::pixel_type::float_32, gl::pixel_format::rgb);
ctx->framebuffer_hdr_color->set_wrapping(gl::texture_wrapping::clamp, gl::texture_wrapping::clamp);
ctx->framebuffer_hdr_color->set_filters(gl::texture_min_filter::linear, gl::texture_mag_filter::linear);
ctx->framebuffer_hdr_color->set_max_anisotropy(0.0f);
ctx->framebuffer_hdr_depth = new texture_2d(viewport_dimensions[0], viewport_dimensions[1], pixel_type::float_32, pixel_format::ds);
ctx->framebuffer_hdr_depth->set_wrapping(texture_wrapping::clamp, texture_wrapping::clamp);
ctx->framebuffer_hdr_depth->set_filters(texture_min_filter::linear, texture_mag_filter::linear);
ctx->framebuffer_hdr_depth = new gl::texture_2d(viewport_dimensions[0], viewport_dimensions[1], gl::pixel_type::float_32, gl::pixel_format::ds);
ctx->framebuffer_hdr_depth->set_wrapping(gl::texture_wrapping::clamp, gl::texture_wrapping::clamp);
ctx->framebuffer_hdr_depth->set_filters(gl::texture_min_filter::linear, gl::texture_mag_filter::linear);
ctx->framebuffer_hdr_depth->set_max_anisotropy(0.0f);
ctx->framebuffer_hdr = new framebuffer(viewport_dimensions[0], viewport_dimensions[1]);
ctx->framebuffer_hdr->attach(framebuffer_attachment_type::color, ctx->framebuffer_hdr_color);
ctx->framebuffer_hdr->attach(framebuffer_attachment_type::depth, ctx->framebuffer_hdr_depth);
ctx->framebuffer_hdr->attach(framebuffer_attachment_type::stencil, ctx->framebuffer_hdr_depth);
ctx->framebuffer_hdr = new gl::framebuffer(viewport_dimensions[0], viewport_dimensions[1]);
ctx->framebuffer_hdr->attach(gl::framebuffer_attachment_type::color, ctx->framebuffer_hdr_color);
ctx->framebuffer_hdr->attach(gl::framebuffer_attachment_type::depth, ctx->framebuffer_hdr_depth);
ctx->framebuffer_hdr->attach(gl::framebuffer_attachment_type::stencil, ctx->framebuffer_hdr_depth);
// Create shadow map framebuffer
int shadow_map_resolution = 4096;
@ -466,29 +466,29 @@ void setup_rendering(game_context* ctx)
{
shadow_map_resolution = ctx->config->get<int>("shadow_map_resolution");
}
ctx->shadow_map_depth_texture = new texture_2d(shadow_map_resolution, shadow_map_resolution, pixel_type::float_32, pixel_format::d);
ctx->shadow_map_depth_texture->set_wrapping(texture_wrapping::clamp, texture_wrapping::clamp);
ctx->shadow_map_depth_texture->set_filters(texture_min_filter::linear, texture_mag_filter::linear);
ctx->shadow_map_depth_texture = new gl::texture_2d(shadow_map_resolution, shadow_map_resolution, gl::pixel_type::float_32, gl::pixel_format::d);
ctx->shadow_map_depth_texture->set_wrapping(gl::texture_wrapping::clamp, gl::texture_wrapping::clamp);
ctx->shadow_map_depth_texture->set_filters(gl::texture_min_filter::linear, gl::texture_mag_filter::linear);
ctx->shadow_map_depth_texture->set_max_anisotropy(0.0f);
ctx->shadow_map_framebuffer = new framebuffer(shadow_map_resolution, shadow_map_resolution);
ctx->shadow_map_framebuffer->attach(framebuffer_attachment_type::depth, ctx->shadow_map_depth_texture);
ctx->shadow_map_framebuffer = new gl::framebuffer(shadow_map_resolution, shadow_map_resolution);
ctx->shadow_map_framebuffer->attach(gl::framebuffer_attachment_type::depth, ctx->shadow_map_depth_texture);
// Create bloom pingpong framebuffers (16F color, no depth)
int bloom_width = viewport_dimensions[0] >> 1;
int bloom_height = viewport_dimensions[1] >> 1;
ctx->bloom_texture = new texture_2d(bloom_width, bloom_height, pixel_type::float_16, pixel_format::rgb);
ctx->bloom_texture->set_wrapping(texture_wrapping::clamp, texture_wrapping::clamp);
ctx->bloom_texture->set_filters(texture_min_filter::linear, texture_mag_filter::linear);
ctx->bloom_texture = new gl::texture_2d(bloom_width, bloom_height, gl::pixel_type::float_16, gl::pixel_format::rgb);
ctx->bloom_texture->set_wrapping(gl::texture_wrapping::clamp, gl::texture_wrapping::clamp);
ctx->bloom_texture->set_filters(gl::texture_min_filter::linear, gl::texture_mag_filter::linear);
ctx->bloom_texture->set_max_anisotropy(0.0f);
ctx->framebuffer_bloom = new framebuffer(bloom_width, bloom_height);
ctx->framebuffer_bloom->attach(framebuffer_attachment_type::color, ctx->bloom_texture);
ctx->framebuffer_bloom = new gl::framebuffer(bloom_width, bloom_height);
ctx->framebuffer_bloom->attach(gl::framebuffer_attachment_type::color, ctx->bloom_texture);
// Load blue noise texture
texture_2d* blue_noise_map = ctx->resource_manager->load<texture_2d>("blue-noise.png");
blue_noise_map->set_wrapping(texture_wrapping::repeat, texture_wrapping::repeat);
blue_noise_map->set_wrapping(texture_wrapping::repeat, texture_wrapping::repeat);
blue_noise_map->set_filters(texture_min_filter::nearest, texture_mag_filter::nearest);
blue_noise_map->set_filters(texture_min_filter::nearest, texture_mag_filter::nearest);
gl::texture_2d* blue_noise_map = ctx->resource_manager->load<gl::texture_2d>("blue-noise.png");
blue_noise_map->set_wrapping(gl::texture_wrapping::repeat, gl::texture_wrapping::repeat);
blue_noise_map->set_wrapping(gl::texture_wrapping::repeat, gl::texture_wrapping::repeat);
blue_noise_map->set_filters(gl::texture_min_filter::nearest, gl::texture_mag_filter::nearest);
blue_noise_map->set_filters(gl::texture_min_filter::nearest, gl::texture_mag_filter::nearest);
// Load fallback material
ctx->fallback_material = ctx->resource_manager->load<material>("fallback.mtl");
@ -538,9 +538,9 @@ void setup_rendering(game_context* ctx)
ctx->underworld_material_pass = new material_pass(ctx->rasterizer, ctx->framebuffer_hdr, ctx->resource_manager);
ctx->underworld_material_pass->set_fallback_material(ctx->fallback_material);
ctx->app->get_event_dispatcher()->subscribe<mouse_moved_event>(ctx->underworld_material_pass);
shader_program* underworld_final_shader = ctx->resource_manager->load<shader_program>("underground-final.glsl");
gl::shader_program* underworld_final_shader = ctx->resource_manager->load<gl::shader_program>("underground-final.glsl");
ctx->underworld_final_pass = new simple_render_pass(ctx->rasterizer, &ctx->rasterizer->get_default_framebuffer(), underworld_final_shader);
ctx->underground_color_texture_property = ctx->underworld_final_pass->get_material()->add_property<const texture_2d*>("color_texture");
ctx->underground_color_texture_property = ctx->underworld_final_pass->get_material()->add_property<const gl::texture_2d*>("color_texture");
ctx->underground_color_texture_property->set_value(ctx->framebuffer_hdr_color);
ctx->underworld_final_pass->get_material()->update_tweens();
ctx->underworld_compositor = new compositor();
@ -574,28 +574,28 @@ void setup_rendering(game_context* ctx)
std::size_t billboard_vertex_stride = sizeof(float) * billboard_vertex_size;
std::size_t billboard_vertex_count = 6;
ctx->billboard_vbo = new vertex_buffer(sizeof(float) * billboard_vertex_size * billboard_vertex_count, billboard_vertex_data);
ctx->billboard_vao = new vertex_array();
ctx->billboard_vao->bind_attribute(VERTEX_POSITION_LOCATION, *ctx->billboard_vbo, 3, vertex_attribute_type::float_32, billboard_vertex_stride, 0);
ctx->billboard_vao->bind_attribute(VERTEX_TEXCOORD_LOCATION, *ctx->billboard_vbo, 2, vertex_attribute_type::float_32, billboard_vertex_stride, sizeof(float) * 3);
ctx->billboard_vao->bind_attribute(VERTEX_BARYCENTRIC_LOCATION, *ctx->billboard_vbo, 3, vertex_attribute_type::float_32, billboard_vertex_stride, sizeof(float) * 5);
ctx->billboard_vbo = new gl::vertex_buffer(sizeof(float) * billboard_vertex_size * billboard_vertex_count, billboard_vertex_data);
ctx->billboard_vao = new gl::vertex_array();
ctx->billboard_vao->bind_attribute(VERTEX_POSITION_LOCATION, *ctx->billboard_vbo, 3, gl::vertex_attribute_type::float_32, billboard_vertex_stride, 0);
ctx->billboard_vao->bind_attribute(VERTEX_TEXCOORD_LOCATION, *ctx->billboard_vbo, 2, gl::vertex_attribute_type::float_32, billboard_vertex_stride, sizeof(float) * 3);
ctx->billboard_vao->bind_attribute(VERTEX_BARYCENTRIC_LOCATION, *ctx->billboard_vbo, 3, gl::vertex_attribute_type::float_32, billboard_vertex_stride, sizeof(float) * 5);
}
// Load marker albedo textures
ctx->marker_albedo_textures = new texture_2d*[8];
ctx->marker_albedo_textures[0] = ctx->resource_manager->load<texture_2d>("marker-clear-albedo.png");
ctx->marker_albedo_textures[1] = ctx->resource_manager->load<texture_2d>("marker-yellow-albedo.png");
ctx->marker_albedo_textures[2] = ctx->resource_manager->load<texture_2d>("marker-green-albedo.png");
ctx->marker_albedo_textures[3] = ctx->resource_manager->load<texture_2d>("marker-blue-albedo.png");
ctx->marker_albedo_textures[4] = ctx->resource_manager->load<texture_2d>("marker-purple-albedo.png");
ctx->marker_albedo_textures[5] = ctx->resource_manager->load<texture_2d>("marker-pink-albedo.png");
ctx->marker_albedo_textures[6] = ctx->resource_manager->load<texture_2d>("marker-red-albedo.png");
ctx->marker_albedo_textures[7] = ctx->resource_manager->load<texture_2d>("marker-orange-albedo.png");
ctx->marker_albedo_textures = new gl::texture_2d*[8];
ctx->marker_albedo_textures[0] = ctx->resource_manager->load<gl::texture_2d>("marker-clear-albedo.png");
ctx->marker_albedo_textures[1] = ctx->resource_manager->load<gl::texture_2d>("marker-yellow-albedo.png");
ctx->marker_albedo_textures[2] = ctx->resource_manager->load<gl::texture_2d>("marker-green-albedo.png");
ctx->marker_albedo_textures[3] = ctx->resource_manager->load<gl::texture_2d>("marker-blue-albedo.png");
ctx->marker_albedo_textures[4] = ctx->resource_manager->load<gl::texture_2d>("marker-purple-albedo.png");
ctx->marker_albedo_textures[5] = ctx->resource_manager->load<gl::texture_2d>("marker-pink-albedo.png");
ctx->marker_albedo_textures[6] = ctx->resource_manager->load<gl::texture_2d>("marker-red-albedo.png");
ctx->marker_albedo_textures[7] = ctx->resource_manager->load<gl::texture_2d>("marker-orange-albedo.png");
for (int i = 0; i < 8; ++i)
{
texture_2d* texture = ctx->marker_albedo_textures[i];
texture->set_wrapping(texture_wrapping::clamp, texture_wrapping::clamp);
texture->set_filters(texture_min_filter::nearest, texture_mag_filter::nearest);
gl::texture_2d* texture = ctx->marker_albedo_textures[i];
texture->set_wrapping(gl::texture_wrapping::clamp, gl::texture_wrapping::clamp);
texture->set_filters(gl::texture_min_filter::nearest, gl::texture_mag_filter::nearest);
texture->set_max_anisotropy(0.0f);
}
@ -676,11 +676,11 @@ void setup_scenes(game_context* ctx)
const texture_2d* splash_texture = ctx->resource_manager->load<texture_2d>("splash.png");
const gl::texture_2d* splash_texture = ctx->resource_manager->load<gl::texture_2d>("splash.png");
auto splash_dimensions = splash_texture->get_dimensions();
ctx->splash_billboard_material = new material();
ctx->splash_billboard_material->set_shader_program(ctx->resource_manager->load<shader_program>("ui-element-textured.glsl"));
ctx->splash_billboard_material->add_property<const texture_2d*>("background")->set_value(splash_texture);
ctx->splash_billboard_material->set_shader_program(ctx->resource_manager->load<gl::shader_program>("ui-element-textured.glsl"));
ctx->splash_billboard_material->add_property<const gl::texture_2d*>("background")->set_value(splash_texture);
ctx->splash_billboard_material->add_property<float4>("tint")->set_value(float4{1, 1, 1, 1});
ctx->splash_billboard_material->update_tweens();
ctx->splash_billboard = new scene::billboard();
@ -693,8 +693,8 @@ void setup_scenes(game_context* ctx)
// Create depth debug billboard
/*
material* depth_debug_material = new material();
depth_debug_material->set_shader_program(ctx->resource_manager->load<shader_program>("ui-element-textured.glsl"));
depth_debug_material->add_property<const texture_2d*>("background")->set_value(shadow_map_depth_texture);
depth_debug_material->set_shader_program(ctx->resource_manager->load<gl::shader_program>("ui-element-textured.glsl"));
depth_debug_material->add_property<const gl::texture_2d*>("background")->set_value(shadow_map_depth_texture);
depth_debug_material->add_property<float4>("tint")->set_value(float4{1, 1, 1, 1});
billboard* depth_debug_billboard = new billboard();
depth_debug_billboard->set_material(depth_debug_material);
@ -750,19 +750,19 @@ void setup_animation(game_context* ctx)
// Create fade transition
ctx->fade_transition = new screen_transition();
ctx->fade_transition->get_material()->set_shader_program(ctx->resource_manager->load<shader_program>("fade-transition.glsl"));
ctx->fade_transition->get_material()->set_shader_program(ctx->resource_manager->load<gl::shader_program>("fade-transition.glsl"));
ctx->ui_scene->add_object(ctx->fade_transition->get_billboard());
ctx->animator->add_animation(ctx->fade_transition->get_animation());
// Create inner radial transition
ctx->radial_transition_inner = new screen_transition();
ctx->radial_transition_inner->get_material()->set_shader_program(ctx->resource_manager->load<shader_program>("radial-transition-inner.glsl"));
ctx->radial_transition_inner->get_material()->set_shader_program(ctx->resource_manager->load<gl::shader_program>("radial-transition-inner.glsl"));
ctx->ui_scene->add_object(ctx->radial_transition_inner->get_billboard());
ctx->animator->add_animation(ctx->radial_transition_inner->get_animation());
// Create outer radial transition
ctx->radial_transition_outer = new screen_transition();
ctx->radial_transition_outer->get_material()->set_shader_program(ctx->resource_manager->load<shader_program>("radial-transition-outer.glsl"));
ctx->radial_transition_outer->get_material()->set_shader_program(ctx->resource_manager->load<gl::shader_program>("radial-transition-outer.glsl"));
ctx->ui_scene->add_object(ctx->radial_transition_outer->get_billboard());
ctx->animator->add_animation(ctx->radial_transition_outer->get_animation());
@ -1153,7 +1153,7 @@ void setup_controls(game_context* ctx)
{
auto& marker_component = ctx->ecs_registry->get<ecs::marker_component>(ctx->marker_entity);
marker_component.color = (marker_component.color + 1) % 8;
const texture_2d* marker_albedo_texture = ctx->marker_albedo_textures[marker_component.color];
const gl::texture_2d* marker_albedo_texture = ctx->marker_albedo_textures[marker_component.color];
model* marker_model = ctx->render_system->get_model_instance(ctx->marker_entity)->get_model();
for (::model_group* group: *marker_model->get_groups())
@ -1161,7 +1161,7 @@ void setup_controls(game_context* ctx)
material_property_base* albedo_property = group->get_material()->get_property("albedo_texture");
if (albedo_property)
{
static_cast<material_property<const texture_2d*>*>(albedo_property)->set_value(marker_albedo_texture);
static_cast<material_property<const gl::texture_2d*>*>(albedo_property)->set_value(marker_albedo_texture);
}
}
}
@ -1173,7 +1173,7 @@ void setup_controls(game_context* ctx)
{
auto& marker_component = ctx->ecs_registry->get<ecs::marker_component>(ctx->marker_entity);
marker_component.color = (marker_component.color + 7) % 8;
const texture_2d* marker_albedo_texture = ctx->marker_albedo_textures[marker_component.color];
const gl::texture_2d* marker_albedo_texture = ctx->marker_albedo_textures[marker_component.color];
model* marker_model = ctx->render_system->get_model_instance(ctx->marker_entity)->get_model();
for (::model_group* group: *marker_model->get_groups())
@ -1181,7 +1181,7 @@ void setup_controls(game_context* ctx)
material_property_base* albedo_property = group->get_material()->get_property("albedo_texture");
if (albedo_property)
{
static_cast<material_property<const texture_2d*>*>(albedo_property)->set_value(marker_albedo_texture);
static_cast<material_property<const gl::texture_2d*>*>(albedo_property)->set_value(marker_albedo_texture);
}
}
}

+ 17
- 17
src/game/game-context.hpp View File

@ -25,6 +25,11 @@
#include "ecs/entity.hpp"
#include "ecs/registry.hpp"
#include "geom/aabb.hpp"
#include "gl/vertex-array.hpp"
#include "gl/vertex-buffer.hpp"
#include "gl/texture-2d.hpp"
#include "gl/rasterizer.hpp"
#include "gl/framebuffer.hpp"
#include <optional>
#include <entt/entt.hpp>
#include <fstream>
@ -40,22 +45,17 @@ class config_file;
class control;
class control_set;
class final_pass;
class framebuffer;
class material;
class input_listener;
class material_pass;
class orbit_cam;
class pheromone_matrix;
class rasterizer;
class resource_manager;
class screen_transition;
class shadow_map_pass;
class simple_render_pass;
class sky_pass;
class texture_2d;
class timeline;
class vertex_array;
class vertex_buffer;
class renderer;
class input_event_router;
class input_mapper;
@ -141,22 +141,22 @@ struct game_context
std::unordered_map<std::string, std::string>* strings;
// Framebuffers
framebuffer* shadow_map_framebuffer;
texture_2d* shadow_map_depth_texture;
framebuffer* framebuffer_hdr;
texture_2d* framebuffer_hdr_color;
texture_2d* framebuffer_hdr_depth;
framebuffer* framebuffer_bloom; // General purpose framebuffer A
texture_2d* bloom_texture;
gl::framebuffer* shadow_map_framebuffer;
gl::texture_2d* shadow_map_depth_texture;
gl::framebuffer* framebuffer_hdr;
gl::texture_2d* framebuffer_hdr_color;
gl::texture_2d* framebuffer_hdr_depth;
gl::framebuffer* framebuffer_bloom; // General purpose framebuffer A
gl::texture_2d* bloom_texture;
// Rendering
rasterizer* rasterizer;
gl::rasterizer* rasterizer;
renderer* renderer;
vertex_buffer* billboard_vbo;
vertex_array* billboard_vao;
gl::vertex_buffer* billboard_vbo;
gl::vertex_array* billboard_vao;
material* fallback_material;
material* splash_billboard_material;
texture_2d** marker_albedo_textures;
gl::texture_2d** marker_albedo_textures;
// Compositing
bloom_pass* overworld_bloom_pass;
@ -172,7 +172,7 @@ struct game_context
shadow_map_pass* overworld_shadow_map_pass;
simple_render_pass* underworld_final_pass;
sky_pass* overworld_sky_pass;
material_property<const texture_2d*>* underground_color_texture_property;
material_property<const gl::texture_2d*>* underground_color_texture_property;
compositor* overworld_compositor;
compositor* underworld_compositor;
compositor* ui_compositor;

+ 1
- 1
src/game/states/map-state.cpp View File

@ -25,7 +25,7 @@
#include "game/game-context.hpp"
#include "input/input-listener.hpp"
#include "event/input-events.hpp"
#include "rasterizer/rasterizer.hpp"
#include "gl/rasterizer.hpp"
#include "game/states/game-states.hpp"
#include "renderer/passes/sky-pass.hpp"
#include "scene/billboard.hpp"

+ 3
- 3
src/game/states/play-state.cpp View File

@ -39,9 +39,9 @@
#include "math/math.hpp"
#include "nest.hpp"
#include "renderer/material.hpp"
#include "rasterizer/texture-2d.hpp"
#include "rasterizer/texture-filter.hpp"
#include "rasterizer/texture-wrapping.hpp"
#include "gl/texture-2d.hpp"
#include "gl/texture-filter.hpp"
#include "gl/texture-wrapping.hpp"
#include "renderer/model.hpp"
#include "renderer/passes/sky-pass.hpp"
#include "resources/resource-manager.hpp"

+ 1
- 1
src/game/states/splash-state.cpp View File

@ -25,7 +25,7 @@
#include "game/game-context.hpp"
#include "input/input-listener.hpp"
#include "event/input-events.hpp"
#include "rasterizer/rasterizer.hpp"
#include "gl/rasterizer.hpp"
#include "game/states/game-states.hpp"
#include "renderer/passes/sky-pass.hpp"
#include "scene/billboard.hpp"

src/rasterizer/buffer-usage.hpp → src/gl/buffer-usage.hpp View File

@ -17,8 +17,10 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_BUFFER_USAGE_HPP
#define ANTKEEPER_BUFFER_USAGE_HPP
#ifndef ANTKEEPER_GL_BUFFER_USAGE_HPP
#define ANTKEEPER_GL_BUFFER_USAGE_HPP
namespace gl {
enum class buffer_usage
{
@ -33,5 +35,7 @@ enum class buffer_usage
dynamic_copy
};
#endif // ANTKEEPER_BUFFER_USAGE_HPP
} // namespace gl
#endif // ANTKEEPER_GL_BUFFER_USAGE_HPP

src/rasterizer/color-space.hpp → src/gl/color-space.hpp View File

@ -17,8 +17,10 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_COLOR_SPACE_HPP
#define ANTKEEPER_COLOR_SPACE_HPP
#ifndef ANTKEEPER_GL_COLOR_SPACE_HPP
#define ANTKEEPER_GL_COLOR_SPACE_HPP
namespace gl {
enum class color_space
{
@ -26,5 +28,7 @@ enum class color_space
srgb ///< sRGB color space
};
#endif // ANTKEEPER_COLOR_SPACE_HPP
} // namespace gl
#endif // ANTKEEPER_GL_COLOR_SPACE_HPP

src/rasterizer/drawing-mode.hpp → src/gl/drawing-mode.hpp View File

@ -17,8 +17,10 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_DRAWING_MODE_HPP
#define ANTKEEPER_DRAWING_MODE_HPP
#ifndef ANTKEEPER_GL_DRAWING_MODE_HPP
#define ANTKEEPER_GL_DRAWING_MODE_HPP
namespace gl {
enum class drawing_mode
{
@ -35,5 +37,7 @@ enum class drawing_mode
triangles_adjacency
};
#endif // ANTKEEPER_DRAWING_MODE_HPP
} // namespace gl
#endif // ANTKEEPER_GL_DRAWING_MODE_HPP

src/rasterizer/element-array-type.hpp → src/gl/element-array-type.hpp View File

@ -17,8 +17,10 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_ELEMENT_ARRAY_TYPE_HPP
#define ANTKEEPER_ELEMENT_ARRAY_TYPE_HPP
#ifndef ANTKEEPER_GL_ELEMENT_ARRAY_TYPE_HPP
#define ANTKEEPER_GL_ELEMENT_ARRAY_TYPE_HPP
namespace gl {
enum class element_array_type
{
@ -27,5 +29,7 @@ enum class element_array_type
uint_32
};
#endif // ANTKEEPER_ELEMENT_ARRAY_TYPE_HPP
} // namespace gl
#endif // ANTKEEPER_GL_ELEMENT_ARRAY_TYPE_HPP

src/rasterizer/framebuffer.cpp → src/gl/framebuffer.cpp View File

@ -17,10 +17,12 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rasterizer/framebuffer.hpp"
#include "rasterizer/texture-2d.hpp"
#include "gl/framebuffer.hpp"
#include "gl/texture-2d.hpp"
#include <glad/glad.h>
namespace gl {
static constexpr GLenum attachment_lut[] =
{
GL_COLOR_ATTACHMENT0,
@ -86,3 +88,5 @@ void framebuffer::attach(framebuffer_attachment_type attachment_type, texture_2d
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
} // namespace gl

src/rasterizer/framebuffer.hpp → src/gl/framebuffer.hpp View File

@ -17,11 +17,13 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_FRAMEBUFFER_HPP
#define ANTKEEPER_FRAMEBUFFER_HPP
#ifndef ANTKEEPER_GL_FRAMEBUFFER_HPP
#define ANTKEEPER_GL_FRAMEBUFFER_HPP
#include <array>
namespace gl {
class rasterizer;
class texture_2d;
@ -115,6 +117,7 @@ inline texture_2d* framebuffer::get_stencil_attachment()
return stencil_attachment;
}
} // namespace gl
#endif // ANTKEEPER_FRAMEBUFFER_HPP
#endif // ANTKEEPER_GL_FRAMEBUFFER_HPP

src/rasterizer/gl.hpp → src/gl/gl.hpp View File

@ -20,7 +20,28 @@
#ifndef ANTKEEPER_GL_HPP
#define ANTKEEPER_GL_HPP
/// Graphics library (GL) provides a cross-platform GPU interface.
/// Graphics library (GL) is a cross-platform GPU interface.
namespace gl {}
#include "buffer-usage.hpp"
#include "color-space.hpp"
#include "drawing-mode.hpp"
#include "element-array-type.hpp"
#include "framebuffer.hpp"
#include "pixel-format.hpp"
#include "pixel-type.hpp"
#include "rasterizer.hpp"
#include "shader.hpp"
#include "shader-input.hpp"
#include "shader-program.hpp"
#include "shader-type.hpp"
#include "shader-variable-type.hpp"
#include "texture-2d.hpp"
#include "texture-cube.hpp"
#include "texture-filter.hpp"
#include "texture-wrapping.hpp"
#include "vertex-array.hpp"
#include "vertex-attribute-type.hpp"
#include "vertex-buffer.hpp"
#endif // ANTKEEPER_GL_HPP

src/rasterizer/pixel-format.hpp → src/gl/pixel-format.hpp View File

@ -17,8 +17,10 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_PIXEL_FORMAT_HPP
#define ANTKEEPER_PIXEL_FORMAT_HPP
#ifndef ANTKEEPER_GL_PIXEL_FORMAT_HPP
#define ANTKEEPER_GL_PIXEL_FORMAT_HPP
namespace gl {
enum class pixel_format
{
@ -32,5 +34,7 @@ enum class pixel_format
bgra ///< Blue, green, red, alpha
};
#endif // ANTKEEPER_PIXEL_FORMAT_HPP
} // namespace gl
#endif // ANTKEEPER_GL_PIXEL_FORMAT_HPP

src/rasterizer/pixel-type.hpp → src/gl/pixel-type.hpp View File

@ -17,8 +17,10 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_PIXEL_TYPE_HPP
#define ANTKEEPER_PIXEL_TYPE_HPP
#ifndef ANTKEEPER_GL_PIXEL_TYPE_HPP
#define ANTKEEPER_GL_PIXEL_TYPE_HPP
namespace gl {
enum class pixel_type
{
@ -32,5 +34,7 @@ enum class pixel_type
float_32
};
#endif // ANTKEEPER_PIXEL_TYPE_HPP
} // namespace gl
#endif // ANTKEEPER_GL_PIXEL_TYPE_HPP

src/rasterizer/rasterizer.cpp → src/gl/rasterizer.cpp View File

@ -17,12 +17,14 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rasterizer/rasterizer.hpp"
#include "rasterizer/framebuffer.hpp"
#include "rasterizer/shader-program.hpp"
#include "rasterizer/vertex-array.hpp"
#include "gl/rasterizer.hpp"
#include "gl/framebuffer.hpp"
#include "gl/shader-program.hpp"
#include "gl/vertex-array.hpp"
#include <glad/glad.h>
namespace gl {
static constexpr GLenum drawing_mode_lut[] =
{
GL_POINTS,
@ -72,7 +74,7 @@ void rasterizer::context_resized(int width, int height)
default_framebuffer->dimensions = {width, height};
}
void rasterizer::use_framebuffer(const ::framebuffer& framebuffer)
void rasterizer::use_framebuffer(const gl::framebuffer& framebuffer)
{
if (bound_framebuffer != &framebuffer)
{
@ -161,3 +163,4 @@ void rasterizer::draw_elements(const vertex_array& vao, drawing_mode mode, std::
glDrawElements(gl_mode, static_cast<GLsizei>(count), gl_type, (const GLvoid*)offset);
}
} // namespace gl

src/rasterizer/rasterizer.hpp → src/gl/rasterizer.hpp View File

@ -17,11 +17,13 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_RASTERIZER_HPP
#define ANTKEEPER_RASTERIZER_HPP
#ifndef ANTKEEPER_GL_RASTERIZER_HPP
#define ANTKEEPER_GL_RASTERIZER_HPP
#include <cstdlib>
namespace gl {
class framebuffer;
class vertex_array;
class shader_program;
@ -52,7 +54,7 @@ public:
*
* @param framebuffer Framebuffer to use.
*/
void use_framebuffer(const ::framebuffer& framebuffer);
void use_framebuffer(const framebuffer& framebuffer);
/**
* Sets the color to be used when the color buffer of a framebuffer is cleared.
@ -133,5 +135,7 @@ inline const framebuffer& rasterizer::get_default_framebuffer() const
return *default_framebuffer;
}
#endif // ANTKEEPER_RASTERIZER_HPP
} // namespace gl
#endif // ANTKEEPER_GL_RASTERIZER_HPP

src/rasterizer/shader-input.cpp → src/gl/shader-input.cpp View File

@ -17,11 +17,13 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rasterizer/shader-input.hpp"
#include "rasterizer/texture-2d.hpp"
#include "rasterizer/texture-cube.hpp"
#include "gl/shader-input.hpp"
#include "gl/texture-2d.hpp"
#include "gl/texture-cube.hpp"
#include <glad/glad.h>
namespace gl {
shader_input::shader_input(shader_program* program, std::size_t input_index, int gl_uniform_location, const std::string& name, shader_variable_type data_type, std::size_t element_count, int texture_unit):
program(program),
input_index(input_index),
@ -670,3 +672,4 @@ bool shader_input::upload(std::size_t index, const texture_cube** values, std::s
return true;
}
} // namespace gl

src/rasterizer/shader-input.hpp → src/gl/shader-input.hpp View File

@ -17,12 +17,14 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_SHADER_INPUT_HPP
#define ANTKEEPER_SHADER_INPUT_HPP
#ifndef ANTKEEPER_GL_SHADER_INPUT_HPP
#define ANTKEEPER_GL_SHADER_INPUT_HPP
#include "utility/fundamental-types.hpp"
#include <string>
namespace gl {
class shader_program;
class texture_2d;
class texture_cube;
@ -186,5 +188,7 @@ inline std::size_t shader_input::get_element_count() const
return element_count;
}
#endif // ANTKEEPER_SHADER_INPUT_HPP
} // namespace gl
#endif // ANTKEEPER_GL_SHADER_INPUT_HPP

src/rasterizer/shader-program.cpp → src/gl/shader-program.cpp View File

@ -17,13 +17,15 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rasterizer/shader-program.hpp"
#include "rasterizer/shader.hpp"
#include "rasterizer/shader-variable-type.hpp"
#include "rasterizer/shader-input.hpp"
#include "gl/shader-program.hpp"
#include "gl/shader.hpp"
#include "gl/shader-variable-type.hpp"
#include "gl/shader-input.hpp"
#include <glad/glad.h>
#include <stdexcept>
namespace gl {
shader_program::shader_program(const std::list<shader*>& shaders):
gl_program_id(0)
{
@ -221,3 +223,4 @@ std::string shader_program::get_info_log() const
return std::string();
}
} // namespace gl

src/rasterizer/shader-program.hpp → src/gl/shader-program.hpp View File

@ -17,14 +17,16 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_SHADER_PROGRAM_HPP
#define ANTKEEPER_SHADER_PROGRAM_HPP
#ifndef ANTKEEPER_GL_SHADER_PROGRAM_HPP
#define ANTKEEPER_GL_SHADER_PROGRAM_HPP
#include <cstdlib>
#include <list>
#include <map>
#include <string>
namespace gl {
class shader;
class rasterizer;
class shader_input;
@ -73,5 +75,7 @@ inline const shader_input* shader_program::get_input(const std::string& name) co
return it->second;
}
#endif // ANTKEEPER_SHADER_PROGRAM_HPP
} // namespace gl
#endif // ANTKEEPER_GL_SHADER_PROGRAM_HPP

src/rasterizer/shader-type.hpp → src/gl/shader-type.hpp View File

@ -17,8 +17,10 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_SHADER_TYPE_HPP
#define ANTKEEPER_SHADER_TYPE_HPP
#ifndef ANTKEEPER_GL_SHADER_TYPE_HPP
#define ANTKEEPER_GL_SHADER_TYPE_HPP
namespace gl {
enum class shader_type
{
@ -27,5 +29,7 @@ enum class shader_type
geometry
};
#endif // ANTKEEPER_SHADER_TYPE_HPP
} // namespace gl
#endif // ANTKEEPER_GL_SHADER_TYPE_HPP

src/rasterizer/shader-variable-type.hpp → src/gl/shader-variable-type.hpp View File

@ -17,8 +17,10 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_SHADER_VARIABLE_TYPE_HPP
#define ANTKEEPER_SHADER_VARIABLE_TYPE_HPP
#ifndef ANTKEEPER_GL_SHADER_VARIABLE_TYPE_HPP
#define ANTKEEPER_GL_SHADER_VARIABLE_TYPE_HPP
namespace gl {
enum class shader_variable_type
{
@ -45,5 +47,7 @@ enum class shader_variable_type
texture_cube
};
#endif // ANTKEEPER_SHADER_VARIABLE_TYPE_HPP
} // namespace gl
#endif // ANTKEEPER_GL_SHADER_VARIABLE_TYPE_HPP

src/rasterizer/shader.cpp → src/gl/shader.cpp View File

@ -17,10 +17,12 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rasterizer/shader.hpp"
#include "gl/shader.hpp"
#include <glad/glad.h>
#include <stdexcept>
namespace gl {
static constexpr GLenum shader_type_lut[] =
{
GL_VERTEX_SHADER,
@ -67,3 +69,4 @@ std::string shader::get_info_log() const
return std::string();
}
} // namespace gl

src/rasterizer/shader.hpp → src/gl/shader.hpp View File

@ -17,12 +17,14 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_SHADER_HPP
#define ANTKEEPER_SHADER_HPP
#ifndef ANTKEEPER_GL_SHADER_HPP
#define ANTKEEPER_GL_SHADER_HPP
#include <cstdlib>
#include <string>
namespace gl {
enum class shader_type;
class shader_program;
@ -51,5 +53,7 @@ inline shader_type shader::get_type() const
return type;
}
#endif // ANTKEEPER_SHADER_HPP
} // namespace gl
#endif // ANTKEEPER_GL_SHADER_HPP

src/rasterizer/texture-2d.cpp → src/gl/texture-2d.cpp View File

@ -17,12 +17,14 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rasterizer/texture-2d.hpp"
#include "rasterizer/texture-wrapping.hpp"
#include "rasterizer/texture-filter.hpp"
#include "gl/texture-2d.hpp"
#include "gl/texture-wrapping.hpp"
#include "gl/texture-filter.hpp"
#include <glad/glad.h>
#include <algorithm>
namespace gl {
static constexpr GLenum pixel_format_lut[] =
{
GL_DEPTH_COMPONENT,
@ -109,7 +111,7 @@ static constexpr GLenum mag_filter_lut[] =
GL_LINEAR
};
texture_2d::texture_2d(int width, int height, ::pixel_type type, ::pixel_format format, ::color_space color_space, const void* data):
texture_2d::texture_2d(int width, int height, gl::pixel_type type, gl::pixel_format format, gl::color_space color_space, const void* data):
gl_texture_id(0),
dimensions({0, 0}),
wrapping({texture_wrapping::repeat, texture_wrapping::repeat}),
@ -128,7 +130,7 @@ texture_2d::~texture_2d()
glDeleteTextures(1, &gl_texture_id);
}
void texture_2d::resize(int width, int height, ::pixel_type type, ::pixel_format format, ::color_space color_space, const void* data)
void texture_2d::resize(int width, int height, gl::pixel_type type, gl::pixel_format format, gl::color_space color_space, const void* data)
{
dimensions = {width, height};
pixel_type = type;
@ -136,7 +138,7 @@ void texture_2d::resize(int width, int height, ::pixel_type type, ::pixel_format
this->color_space = color_space;
GLenum gl_internal_format;
if (color_space == ::color_space::srgb)
if (color_space == gl::color_space::srgb)
{
gl_internal_format = srgb_internal_format_lut[static_cast<std::size_t>(format)][static_cast<std::size_t>(type)];
}
@ -172,7 +174,7 @@ void texture_2d::resize(int width, int height, ::pixel_type type, ::pixel_format
}
}
void texture_2d::set_wrapping(texture_wrapping wrap_s, texture_wrapping wrap_t)
void texture_2d::set_wrapping(gl::texture_wrapping wrap_s, texture_wrapping wrap_t)
{
wrapping = {wrap_s, wrap_t};
@ -209,3 +211,4 @@ void texture_2d::set_max_anisotropy(float anisotropy)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_max_anisotropy);
}
} // namespace gl

src/rasterizer/texture-2d.hpp → src/gl/texture-2d.hpp View File

@ -17,14 +17,16 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_TEXTURE_2D_HPP
#define ANTKEEPER_TEXTURE_2D_HPP
#ifndef ANTKEEPER_GL_TEXTURE_2D_HPP
#define ANTKEEPER_GL_TEXTURE_2D_HPP
#include <array>
#include <tuple>
#include "rasterizer/color-space.hpp"
#include "rasterizer/pixel-format.hpp"
#include "rasterizer/pixel-type.hpp"
#include "gl/color-space.hpp"
#include "gl/pixel-format.hpp"
#include "gl/pixel-type.hpp"
namespace gl {
class framebuffer;
class shader_input;
@ -45,7 +47,7 @@ public:
*
* @warning If the sRGB color space is specified, pixel data will be stored internally as 8 bits per channel, and automatically converted to linear space before reading.
*/
texture_2d(int width, int height, ::pixel_type type = ::pixel_type::uint_8, ::pixel_format format = ::pixel_format::rgba, ::color_space color_space = ::color_space::linear, const void* data = nullptr);
texture_2d(int width, int height, gl::pixel_type type = gl::pixel_type::uint_8, gl::pixel_format format = gl::pixel_format::rgba, gl::color_space color_space = gl::color_space::linear, const void* data = nullptr);
/**
* Destroys a 2D texture.
@ -57,7 +59,7 @@ public:
*
* @warning If the sRGB color space is specified, pixel data will be stored internally as 8 bits per channel, and automatically converted to linear space before reading.
*/
void resize(int width, int height, ::pixel_type type, ::pixel_format format, ::color_space color_space, const void* data);
void resize(int width, int height, gl::pixel_type type, gl::pixel_format format, gl::color_space color_space, const void* data);
/**
* Sets the texture wrapping modes.
@ -65,7 +67,7 @@ public:
* @param wrap_s Wrapping mode for s-coordinates.
* @param wrap_t Wrapping mode for t-coordinates.
*/
void set_wrapping(texture_wrapping wrap_s, texture_wrapping wrap_t);
void set_wrapping(gl::texture_wrapping wrap_s, texture_wrapping wrap_t);
/**
* Sets the texture filtering modes.
@ -109,9 +111,9 @@ private:
unsigned int gl_texture_id;
std::array<int, 2> dimensions;
::pixel_type pixel_type;
::pixel_format pixel_format;
::color_space color_space;
gl::pixel_type pixel_type;
gl::pixel_format pixel_format;
gl::color_space color_space;
std::tuple<texture_wrapping, texture_wrapping> wrapping;
std::tuple<texture_min_filter, texture_mag_filter> filters;
float max_anisotropy;
@ -152,5 +154,7 @@ inline float texture_2d::get_max_anisotropy() const
return max_anisotropy;
}
#endif // ANTKEEPER_TEXTURE_2D_HPP
} // namespace gl
#endif // ANTKEEPER_GL_TEXTURE_2D_HPP

src/rasterizer/texture-cube.cpp → src/gl/texture-cube.cpp View File

@ -17,9 +17,11 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rasterizer/texture-cube.hpp"
#include "gl/texture-cube.hpp"
#include <glad/glad.h>
namespace gl {
texture_cube::texture_cube():
gl_texture_id(0),
face_size(0)
@ -32,3 +34,4 @@ texture_cube::~texture_cube()
glDeleteTextures(1, &gl_texture_id);
}
} // namespace gl

src/rasterizer/texture-cube.hpp → src/gl/texture-cube.hpp View File

@ -17,8 +17,10 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_TEXTURE_CUBE_HPP
#define ANTKEEPER_TEXTURE_CUBE_HPP
#ifndef ANTKEEPER_GL_TEXTURE_CUBE_HPP
#define ANTKEEPER_GL_TEXTURE_CUBE_HPP
namespace gl {
class shader_input;
@ -53,5 +55,7 @@ inline int texture_cube::get_face_size() const
return face_size;
}
#endif // ANTKEEPER_TEXTURE_CUBE_HPP
} // namespace gl
#endif // ANTKEEPER_GL_TEXTURE_CUBE_HPP

src/rasterizer/texture-filter.hpp → src/gl/texture-filter.hpp View File

@ -17,8 +17,10 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_TEXTURE_FILTER_HPP
#define ANTKEEPER_TEXTURE_FILTER_HPP
#ifndef ANTKEEPER_GL_TEXTURE_FILTER_HPP
#define ANTKEEPER_GL_TEXTURE_FILTER_HPP
namespace gl {
enum class texture_min_filter
{
@ -36,5 +38,7 @@ enum class texture_mag_filter
linear
};
#endif // ANTKEEPER_TEXTURE_FILTER_HPP
} // namespace gl
#endif // ANTKEEPER_GL_TEXTURE_FILTER_HPP

src/rasterizer/texture-wrapping.hpp → src/gl/texture-wrapping.hpp View File

@ -17,8 +17,10 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_TEXTURE_WRAPPING_HPP
#define ANTKEEPER_TEXTURE_WRAPPING_HPP
#ifndef ANTKEEPER_GL_TEXTURE_WRAPPING_HPP
#define ANTKEEPER_GL_TEXTURE_WRAPPING_HPP
namespace gl {
enum class texture_wrapping
{
@ -27,5 +29,7 @@ enum class texture_wrapping
mirrored_repeat
};
#endif // ANTKEEPER_TEXTURE_WRAPPING_HPP
} // namespace gl
#endif // ANTKEEPER_GL_TEXTURE_WRAPPING_HPP

src/rasterizer/vertex-array.cpp → src/gl/vertex-array.cpp View File

@ -17,10 +17,12 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rasterizer/vertex-array.hpp"
#include "rasterizer/vertex-buffer.hpp"
#include "gl/vertex-array.hpp"
#include "gl/vertex-buffer.hpp"
#include <glad/glad.h>
namespace gl {
static constexpr GLenum vertex_attribute_type_lut[] =
{
GL_BYTE,
@ -61,3 +63,4 @@ void vertex_array::bind_elements(const vertex_buffer& buffer)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer.gl_buffer_id);
}
} // namespace gl

src/rasterizer/vertex-array.hpp → src/gl/vertex-array.hpp View File

@ -17,11 +17,13 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_VERTEX_ARRAY_HPP
#define ANTKEEPER_VERTEX_ARRAY_HPP
#ifndef ANTKEEPER_GL_VERTEX_ARRAY_HPP
#define ANTKEEPER_GL_VERTEX_ARRAY_HPP
#include <cstdlib>
namespace gl {
class rasterizer;
class vertex_buffer;
enum class vertex_attribute_type;
@ -44,5 +46,7 @@ private:
unsigned int gl_array_id;
};
#endif // ANTKEEPER_VERTEX_ARRAY_HPP
} // namespace gl
#endif // ANTKEEPER_GL_VERTEX_ARRAY_HPP

src/rasterizer/vertex-attribute-type.hpp → src/gl/vertex-attribute-type.hpp View File

@ -17,8 +17,10 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_VERTEX_ATTRIBUTE_TYPE_HPP
#define ANTKEEPER_VERTEX_ATTRIBUTE_TYPE_HPP
#ifndef ANTKEEPER_GL_VERTEX_ATTRIBUTE_TYPE_HPP
#define ANTKEEPER_GL_VERTEX_ATTRIBUTE_TYPE_HPP
namespace gl {
enum class vertex_attribute_type
{
@ -33,5 +35,7 @@ enum class vertex_attribute_type
float_64
};
#endif // ANTKEEPER_VERTEX_ATTRIBUTE_TYPE_HPP
} // namespace gl
#endif // ANTKEEPER_GL_VERTEX_ATTRIBUTE_TYPE_HPP

src/rasterizer/vertex-buffer.cpp → src/gl/vertex-buffer.cpp View File

@ -17,9 +17,11 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rasterizer/vertex-buffer.hpp"
#include "gl/vertex-buffer.hpp"
#include <glad/glad.h>
namespace gl {
static constexpr GLenum buffer_usage_lut[] =
{
GL_STREAM_DRAW,
@ -76,3 +78,4 @@ void vertex_buffer::update(int offset, std::size_t size, const void* data)
glBufferSubData(GL_ARRAY_BUFFER, offset, size, data);
}
} // namespace gl

src/rasterizer/vertex-buffer.hpp → src/gl/vertex-buffer.hpp View File

@ -17,11 +17,13 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_VERTEX_BUFFER_HPP
#define ANTKEEPER_VERTEX_BUFFER_HPP
#ifndef ANTKEEPER_GL_VERTEX_BUFFER_HPP
#define ANTKEEPER_GL_VERTEX_BUFFER_HPP
#include <cstdlib>
#include "rasterizer/buffer-usage.hpp"
#include "gl/buffer-usage.hpp"
namespace gl {
class vertex_array;
@ -61,5 +63,7 @@ inline buffer_usage vertex_buffer::get_usage() const
return usage;
}
#endif // ANTKEEPER_VERTEX_BUFFER_HPP
} // namespace gl
#endif // ANTKEEPER_GL_VERTEX_BUFFER_HPP

+ 0
- 37
src/rasterizer/buffer-usage.cpp View File

@ -1,37 +0,0 @@
/*
* Copyright (C) 2021 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_BUFFER_USAGE_HPP
#define ANTKEEPER_BUFFER_USAGE_HPP
enum class buffer_usage
{
stream_draw,
stream_read,
stream_copy,
static_draw,
static_read,
static_copy,
dynamic_draw,
dynamic_read,
dynamic_copy
};
#endif // ANTKEEPER_BUFFER_USAGE_HPP

+ 2
- 2
src/renderer/material-property.cpp View File

@ -18,13 +18,13 @@
*/
#include "renderer/material-property.hpp"
#include "rasterizer/shader-input.hpp"
#include "gl/shader-input.hpp"
material_property_base::material_property_base():
input(nullptr)
{}
bool material_property_base::connect(const shader_input* input)
bool material_property_base::connect(const gl::shader_input* input)
{
if (!input || input->get_data_type() != get_data_type())
{

+ 51
- 51
src/renderer/material-property.hpp View File

@ -21,16 +21,16 @@
#define ANTKEEPER_MATERIAL_PROPERTY_HPP
#include "animation/tween.hpp"
#include "rasterizer/shader-variable-type.hpp"
#include "rasterizer/shader-input.hpp"
#include "gl/shader-variable-type.hpp"
#include "gl/shader-input.hpp"
#include "math/interpolation.hpp"
#include "utility/fundamental-types.hpp"
#include "gl/shader-program.hpp"
#include "gl/texture-2d.hpp"
#include "gl/texture-cube.hpp"
#include <cstdlib>
class material;
class shader_program;
class texture_2d;
class texture_cube;
/**
* Abstract base class for material properties.
@ -44,7 +44,7 @@ public:
* @param input Shader input to which the material property should be connected.
* @return `true` if the property was connected to the input successfully, `false` otherwise.
*/
bool connect(const shader_input* input);
bool connect(const gl::shader_input* input);
/**
* Disconnects the material property from its shader input.
@ -67,7 +67,7 @@ public:
/**
* Returns the type of data which the property contains.
*/
virtual shader_variable_type get_data_type() const = 0;
virtual gl::shader_variable_type get_data_type() const = 0;
/**
* Returns `true` if the material property is connected to a shader input, `false` otherwise.
@ -82,7 +82,7 @@ public:
protected:
material_property_base();
const shader_input* input;
const gl::shader_input* input;
};
inline bool material_property_base::is_connected() const
@ -169,7 +169,7 @@ public:
const T& get_value(std::size_t index) const;
/// @copydoc material_property_base::get_data_type() const
virtual shader_variable_type get_data_type() const;
virtual gl::shader_variable_type get_data_type() const;
/// @copydoc material_property_base::clone() const
virtual material_property_base* clone() const;
@ -300,129 +300,129 @@ inline const T& material_property::get_value(std::size_t index) const
}
template <>
inline shader_variable_type material_property<bool>::get_data_type() const
inline gl::shader_variable_type material_property<bool>::get_data_type() const
{
return shader_variable_type::bool1;
return gl::shader_variable_type::bool1;
}
template <>
inline shader_variable_type material_property<bool2>::get_data_type() const
inline gl::shader_variable_type material_property<bool2>::get_data_type() const
{
return shader_variable_type::bool2;
return gl::shader_variable_type::bool2;
}
template <>
inline shader_variable_type material_property<bool3>::get_data_type() const
inline gl::shader_variable_type material_property<bool3>::get_data_type() const
{
return shader_variable_type::bool3;
return gl::shader_variable_type::bool3;
}
template <>
inline shader_variable_type material_property<bool4>::get_data_type() const
inline gl::shader_variable_type material_property<bool4>::get_data_type() const
{
return shader_variable_type::bool4;
return gl::shader_variable_type::bool4;
}
template <>
inline shader_variable_type material_property<int>::get_data_type() const
inline gl::shader_variable_type material_property<int>::get_data_type() const
{
return shader_variable_type::int1;
return gl::shader_variable_type::int1;
}
template <>
inline shader_variable_type material_property<int2>::get_data_type() const
inline gl::shader_variable_type material_property<int2>::get_data_type() const
{
return shader_variable_type::int2;
return gl::shader_variable_type::int2;
}
template <>
inline shader_variable_type material_property<int3>::get_data_type() const
inline gl::shader_variable_type material_property<int3>::get_data_type() const
{
return shader_variable_type::int3;
return gl::shader_variable_type::int3;
}
template <>
inline shader_variable_type material_property<int4>::get_data_type() const
inline gl::shader_variable_type material_property<int4>::get_data_type() const
{
return shader_variable_type::int4;
return gl::shader_variable_type::int4;
}
template <>
inline shader_variable_type material_property<unsigned int>::get_data_type() const
inline gl::shader_variable_type material_property<unsigned int>::get_data_type() const
{
return shader_variable_type::uint1;
return gl::shader_variable_type::uint1;
}
template <>
inline shader_variable_type material_property<uint2>::get_data_type() const
inline gl::shader_variable_type material_property<uint2>::get_data_type() const
{
return shader_variable_type::uint2;
return gl::shader_variable_type::uint2;
}
template <>
inline shader_variable_type material_property<uint3>::get_data_type() const
inline gl::shader_variable_type material_property<uint3>::get_data_type() const
{
return shader_variable_type::uint3;
return gl::shader_variable_type::uint3;
}
template <>
inline shader_variable_type material_property<uint4>::get_data_type() const
inline gl::shader_variable_type material_property<uint4>::get_data_type() const
{
return shader_variable_type::uint4;
return gl::shader_variable_type::uint4;
}
template <>
inline shader_variable_type material_property<float>::get_data_type() const
inline gl::shader_variable_type material_property<float>::get_data_type() const
{
return shader_variable_type::float1;
return gl::shader_variable_type::float1;
}
template <>
inline shader_variable_type material_property<float2>::get_data_type() const
inline gl::shader_variable_type material_property<float2>::get_data_type() const
{
return shader_variable_type::float2;
return gl::shader_variable_type::float2;
}
template <>
inline shader_variable_type material_property<float3>::get_data_type() const
inline gl::shader_variable_type material_property<float3>::get_data_type() const
{
return shader_variable_type::float3;
return gl::shader_variable_type::float3;
}
template <>
inline shader_variable_type material_property<float4>::get_data_type() const
inline gl::shader_variable_type material_property<float4>::get_data_type() const
{
return shader_variable_type::float4;
return gl::shader_variable_type::float4;
}
template <>
inline shader_variable_type material_property<float2x2>::get_data_type() const
inline gl::shader_variable_type material_property<float2x2>::get_data_type() const
{
return shader_variable_type::float2x2;
return gl::shader_variable_type::float2x2;
}
template <>
inline shader_variable_type material_property<float3x3>::get_data_type() const
inline gl::shader_variable_type material_property<float3x3>::get_data_type() const
{
return shader_variable_type::float3x3;
return gl::shader_variable_type::float3x3;
}
template <>
inline shader_variable_type material_property<float4x4>::get_data_type() const
inline gl::shader_variable_type material_property<float4x4>::get_data_type() const
{
return shader_variable_type::float4x4;
return gl::shader_variable_type::float4x4;
}
template <>
inline shader_variable_type material_property<const texture_2d*>::get_data_type() const
inline gl::shader_variable_type material_property<const gl::texture_2d*>::get_data_type() const
{
return shader_variable_type::texture_2d;
return gl::shader_variable_type::texture_2d;
}
template <>
inline shader_variable_type material_property<const texture_cube*>::get_data_type() const
inline gl::shader_variable_type material_property<const gl::texture_cube*>::get_data_type() const
{
return shader_variable_type::texture_cube;
return gl::shader_variable_type::texture_cube;
}
template <class T>

+ 3
- 3
src/renderer/material.cpp View File

@ -18,9 +18,9 @@
*/
#include "renderer/material.hpp"
#include "rasterizer/shader-program.hpp"
#include "gl/shader-program.hpp"
material::material(shader_program* program):
material::material(gl::shader_program* program):
program(program),
flags(0)
{}
@ -92,7 +92,7 @@ std::size_t material::upload(double a) const
return failed_upload_count;
}
void material::set_shader_program(shader_program* program)
void material::set_shader_program(gl::shader_program* program)
{
this->program = program;
reconnect_properties();

+ 6
- 6
src/renderer/material.hpp View File

@ -21,7 +21,7 @@
#define ANTKEEPER_MATERIAL_HPP
#include "renderer/material-property.hpp"
#include "rasterizer/shader-program.hpp"
#include "gl/shader-program.hpp"
#include <cstdint>
#include <cstdlib>
#include <list>
@ -39,7 +39,7 @@ public:
*
* @param program Shader program with which to associate this material.
*/
explicit material(shader_program* program);
explicit material(gl::shader_program* program);
/**
* Creates a material.
@ -84,7 +84,7 @@ public:
*
* @param program Shader program with which to associate the material.
*/
void set_shader_program(shader_program* program);
void set_shader_program(gl::shader_program* program);
/**
* Sets the material flags.
@ -106,7 +106,7 @@ public:
/**
* Returns the shader program with which this material is associated.
*/
shader_program* get_shader_program() const;
gl::shader_program* get_shader_program() const;
/**
* Returns the material flags.
@ -131,7 +131,7 @@ private:
*/
std::size_t reconnect_properties();
shader_program* program;
gl::shader_program* program;
std::uint32_t flags;
std::list<material_property_base*> properties;
std::map<std::string, material_property_base*> property_map;
@ -156,7 +156,7 @@ material_property* material::add_property(const std::string& name, std::size_
return property;
}
inline shader_program* material::get_shader_program() const
inline gl::shader_program* material::get_shader_program() const
{
return program;
}

+ 1
- 2
src/renderer/model.cpp View File

@ -18,7 +18,6 @@
*/
#include "renderer/model.hpp"
#include "rasterizer/drawing-mode.hpp"
model::model():
bounds({0, 0, 0}, {0, 0, 0})
@ -46,7 +45,7 @@ model_group* model::add_group(const std::string& name)
group->index = groups.size();
group->name = name;
group->material = nullptr;
group->drawing_mode = drawing_mode::triangles;
group->drawing_mode = gl::drawing_mode::triangles;
group->start_index = 0;
group->index_count = 0;

+ 18
- 20
src/renderer/model.hpp View File

@ -20,8 +20,9 @@
#ifndef ANTKEEPER_MODEL_HPP
#define ANTKEEPER_MODEL_HPP
#include "rasterizer/vertex-array.hpp"
#include "rasterizer/vertex-buffer.hpp"
#include "gl/vertex-array.hpp"
#include "gl/vertex-buffer.hpp"
#include "gl/drawing-mode.hpp"
#include "geom/aabb.hpp"
#include <map>
#include <string>
@ -29,9 +30,6 @@
class material;
class skeleton;
class vertex_array;
class vertex_buffer;
enum class drawing_mode;
/**
* Part of a model which is associated with exactly one material.
@ -40,7 +38,7 @@ class model_group
{
public:
void set_material(material* material);
void set_drawing_mode(drawing_mode mode);
void set_drawing_mode(gl::drawing_mode mode);
void set_start_index(std::size_t index);
void set_index_count(std::size_t count);
@ -48,7 +46,7 @@ public:
const std::string& get_name() const;
const material* get_material() const;
material* get_material();
drawing_mode get_drawing_mode() const;
gl::drawing_mode get_drawing_mode() const;
std::size_t get_start_index() const;
std::size_t get_index_count() const;
@ -58,7 +56,7 @@ private:
std::size_t index;
std::string name;
material* material;
drawing_mode drawing_mode;
gl::drawing_mode drawing_mode;
std::size_t start_index;
std::size_t index_count;
};
@ -68,7 +66,7 @@ inline void model_group::set_material(::material* material)
this->material = material;
}
inline void model_group::set_drawing_mode(::drawing_mode mode)
inline void model_group::set_drawing_mode(gl::drawing_mode mode)
{
this->drawing_mode = mode;
}
@ -103,7 +101,7 @@ inline material* model_group::get_material()
return material;
}
inline drawing_mode model_group::get_drawing_mode() const
inline gl::drawing_mode model_group::get_drawing_mode() const
{
return drawing_mode;
}
@ -143,18 +141,18 @@ public:
const std::vector<model_group*>* get_groups() const;
const vertex_array* get_vertex_array() const;
vertex_array* get_vertex_array();
const gl::vertex_array* get_vertex_array() const;
gl::vertex_array* get_vertex_array();
const vertex_buffer* get_vertex_buffer() const;
vertex_buffer* get_vertex_buffer();
const gl::vertex_buffer* get_vertex_buffer() const;
gl::vertex_buffer* get_vertex_buffer();
private:
aabb_type bounds;
std::vector<model_group*> groups;
std::map<std::string, model_group*> group_map;
vertex_array vao;
vertex_buffer vbo;
gl::vertex_array vao;
gl::vertex_buffer vbo;
skeleton* skeleton;
};
@ -173,22 +171,22 @@ inline const std::vector* model::get_groups() const
return &groups;
}
inline const vertex_array* model::get_vertex_array() const
inline const gl::vertex_array* model::get_vertex_array() const
{
return &vao;
}
inline vertex_array* model::get_vertex_array()
inline gl::vertex_array* model::get_vertex_array()
{
return &vao;
}
inline const vertex_buffer* model::get_vertex_buffer() const
inline const gl::vertex_buffer* model::get_vertex_buffer() const
{
return &vbo;
}
inline vertex_buffer* model::get_vertex_buffer()
inline gl::vertex_buffer* model::get_vertex_buffer()
{
return &vbo;
}

+ 25
- 25
src/renderer/passes/bloom-pass.cpp View File

@ -19,45 +19,45 @@
#include "renderer/passes/bloom-pass.hpp"
#include "resources/resource-manager.hpp"
#include "rasterizer/rasterizer.hpp"
#include "rasterizer/framebuffer.hpp"
#include "rasterizer/shader-program.hpp"
#include "rasterizer/shader-input.hpp"
#include "rasterizer/vertex-buffer.hpp"
#include "rasterizer/vertex-array.hpp"
#include "rasterizer/vertex-attribute-type.hpp"
#include "rasterizer/drawing-mode.hpp"
#include "rasterizer/texture-2d.hpp"
#include "rasterizer/texture-wrapping.hpp"
#include "rasterizer/texture-filter.hpp"
#include "gl/rasterizer.hpp"
#include "gl/framebuffer.hpp"
#include "gl/shader-program.hpp"
#include "gl/shader-input.hpp"
#include "gl/vertex-buffer.hpp"
#include "gl/vertex-array.hpp"
#include "gl/vertex-attribute-type.hpp"
#include "gl/drawing-mode.hpp"
#include "gl/texture-2d.hpp"
#include "gl/texture-wrapping.hpp"
#include "gl/texture-filter.hpp"
#include "renderer/vertex-attributes.hpp"
#include "renderer/render-context.hpp"
#include "math/math.hpp"
#include <cmath>
#include <glad/glad.h>
bloom_pass::bloom_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer, resource_manager* resource_manager):
bloom_pass::bloom_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, resource_manager* resource_manager):
render_pass(rasterizer, framebuffer),
source_texture(nullptr),
brightness_threshold(1.0f),
blur_iterations(1)
{
// Create clone of framebuffer texture
const texture_2d* framebuffer_texture = framebuffer->get_color_attachment();
const gl::texture_2d* framebuffer_texture = framebuffer->get_color_attachment();
auto dimensions = framebuffer_texture->get_dimensions();
auto pixel_type = framebuffer_texture->get_pixel_type();
auto pixel_format = framebuffer_texture->get_pixel_format();
auto wrapping = framebuffer_texture->get_wrapping();
auto filters = framebuffer_texture->get_filters();
float max_anisotropy = framebuffer_texture->get_max_anisotropy();
cloned_framebuffer_texture = new texture_2d(std::get<0>(dimensions), std::get<1>(dimensions), pixel_type, pixel_format);
cloned_framebuffer_texture = new gl::texture_2d(std::get<0>(dimensions), std::get<1>(dimensions), pixel_type, pixel_format);
cloned_framebuffer_texture->set_wrapping(std::get<0>(wrapping), std::get<1>(wrapping));
cloned_framebuffer_texture->set_filters(std::get<0>(filters), std::get<1>(filters));
cloned_framebuffer_texture->set_max_anisotropy(max_anisotropy);
// Create clone of framebuffer
cloned_framebuffer = new ::framebuffer(std::get<0>(dimensions), std::get<1>(dimensions));
cloned_framebuffer->attach(framebuffer_attachment_type::color, cloned_framebuffer_texture);
cloned_framebuffer = new gl::framebuffer(std::get<0>(dimensions), std::get<1>(dimensions));
cloned_framebuffer->attach(gl::framebuffer_attachment_type::color, cloned_framebuffer_texture);
// Setup pingponging
pingpong_textures[0] = framebuffer_texture;
@ -66,13 +66,13 @@ bloom_pass::bloom_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffe
pingpong_framebuffers[1] = cloned_framebuffer;
// Load brightness threshold shader
threshold_shader = resource_manager->load<shader_program>("brightness-threshold.glsl");
threshold_shader = resource_manager->load<gl::shader_program>("brightness-threshold.glsl");
threshold_shader_image_input = threshold_shader->get_input("image");
threshold_shader_resolution_input = threshold_shader->get_input("resolution");
threshold_shader_threshold_input = threshold_shader->get_input("threshold");
// Load blur shader
blur_shader = resource_manager->load<shader_program>("blur.glsl");
blur_shader = resource_manager->load<gl::shader_program>("blur.glsl");
blur_shader_image_input = blur_shader->get_input("image");
blur_shader_resolution_input = blur_shader->get_input("resolution");
blur_shader_direction_input = blur_shader->get_input("direction");
@ -91,9 +91,9 @@ bloom_pass::bloom_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffe
std::size_t vertex_stride = sizeof(float) * vertex_size;
std::size_t vertex_count = 6;
quad_vbo = new vertex_buffer(sizeof(float) * vertex_size * vertex_count, vertex_data);
quad_vao = new vertex_array();
quad_vao->bind_attribute(VERTEX_POSITION_LOCATION, *quad_vbo, 3, vertex_attribute_type::float_32, vertex_stride, 0);
quad_vbo = new gl::vertex_buffer(sizeof(float) * vertex_size * vertex_count, vertex_data);
quad_vao = new gl::vertex_array();
quad_vao->bind_attribute(VERTEX_POSITION_LOCATION, *quad_vbo, 3, gl::vertex_attribute_type::float_32, vertex_stride, 0);
}
bloom_pass::~bloom_pass()
@ -123,7 +123,7 @@ void bloom_pass::render(render_context* context) const
threshold_shader_image_input->upload(source_texture);
threshold_shader_resolution_input->upload(resolution);
threshold_shader_threshold_input->upload(brightness_threshold);
rasterizer->draw_arrays(*quad_vao, drawing_mode::triangles, 0, 6);
rasterizer->draw_arrays(*quad_vao, gl::drawing_mode::triangles, 0, 6);
// Perform iterative blur subpass
const float2 direction_horizontal = {1, 0};
@ -136,17 +136,17 @@ void bloom_pass::render(render_context* context) const
rasterizer->use_framebuffer(*pingpong_framebuffers[1]);
blur_shader_image_input->upload(pingpong_textures[0]);
blur_shader_direction_input->upload(direction_horizontal);
rasterizer->draw_arrays(*quad_vao, drawing_mode::triangles, 0, 6);
rasterizer->draw_arrays(*quad_vao, gl::drawing_mode::triangles, 0, 6);
// Perform vertical blur
rasterizer->use_framebuffer(*pingpong_framebuffers[0]);
blur_shader_image_input->upload(pingpong_textures[1]);
blur_shader_direction_input->upload(direction_vertical);
rasterizer->draw_arrays(*quad_vao, drawing_mode::triangles, 0, 6);
rasterizer->draw_arrays(*quad_vao, gl::drawing_mode::triangles, 0, 6);
}
}
void bloom_pass::set_source_texture(const texture_2d* texture)
void bloom_pass::set_source_texture(const gl::texture_2d* texture)
{
this->source_texture = texture;
}

+ 22
- 22
src/renderer/passes/bloom-pass.hpp View File

@ -22,12 +22,12 @@
#include "renderer/render-pass.hpp"
#include "math/math.hpp"
#include "gl/shader-program.hpp"
#include "gl/shader-input.hpp"
#include "gl/vertex-buffer.hpp"
#include "gl/vertex-array.hpp"
#include "gl/texture-2d.hpp"
class shader_program;
class shader_input;
class vertex_buffer;
class vertex_array;
class texture_2d;
class resource_manager;
/**
@ -36,34 +36,34 @@ class resource_manager;
class bloom_pass: public render_pass
{
public:
bloom_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer, resource_manager* resource_manager);
bloom_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, resource_manager* resource_manager);
virtual ~bloom_pass();
virtual void render(render_context* context) const final;
void set_source_texture(const texture_2d* texture);
void set_source_texture(const gl::texture_2d* texture);
void set_brightness_threshold(float threshold);
void set_blur_iterations(int iterations);
private:
vertex_buffer* quad_vbo;
vertex_array* quad_vao;
gl::vertex_buffer* quad_vbo;
gl::vertex_array* quad_vao;
const ::framebuffer* pingpong_framebuffers[2];
const texture_2d* pingpong_textures[2];
texture_2d* cloned_framebuffer_texture;
::framebuffer* cloned_framebuffer;
const gl::framebuffer* pingpong_framebuffers[2];
const gl::texture_2d* pingpong_textures[2];
gl::texture_2d* cloned_framebuffer_texture;
gl::framebuffer* cloned_framebuffer;
shader_program* threshold_shader;
const shader_input* threshold_shader_image_input;
const shader_input* threshold_shader_resolution_input;
const shader_input* threshold_shader_threshold_input;
gl::shader_program* threshold_shader;
const gl::shader_input* threshold_shader_image_input;
const gl::shader_input* threshold_shader_resolution_input;
const gl::shader_input* threshold_shader_threshold_input;
shader_program* blur_shader;
const shader_input* blur_shader_image_input;
const shader_input* blur_shader_resolution_input;
const shader_input* blur_shader_direction_input;
gl::shader_program* blur_shader;
const gl::shader_input* blur_shader_image_input;
const gl::shader_input* blur_shader_resolution_input;
const gl::shader_input* blur_shader_direction_input;
const texture_2d* source_texture;
const gl::texture_2d* source_texture;
float brightness_threshold;
int blur_iterations;
};

+ 3
- 3
src/renderer/passes/clear-pass.cpp View File

@ -18,11 +18,11 @@
*/
#include "renderer/passes/clear-pass.hpp"
#include "rasterizer/rasterizer.hpp"
#include "rasterizer/framebuffer.hpp"
#include "gl/rasterizer.hpp"
#include "gl/framebuffer.hpp"
#include <glad/glad.h>
clear_pass::clear_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer):
clear_pass::clear_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer):
render_pass(rasterizer, framebuffer),
clear_color_buffer(false),
clear_depth_buffer(false),

+ 1
- 1
src/renderer/passes/clear-pass.hpp View File

@ -29,7 +29,7 @@
class clear_pass: public render_pass
{
public:
clear_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer);
clear_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer);
virtual ~clear_pass();
virtual void render(render_context* context) const final;

+ 19
- 19
src/renderer/passes/final-pass.cpp View File

@ -19,29 +19,29 @@
#include "renderer/passes/final-pass.hpp"
#include "resources/resource-manager.hpp"
#include "rasterizer/rasterizer.hpp"
#include "rasterizer/framebuffer.hpp"
#include "rasterizer/shader-program.hpp"
#include "rasterizer/shader-input.hpp"
#include "rasterizer/vertex-buffer.hpp"
#include "rasterizer/vertex-array.hpp"
#include "rasterizer/vertex-attribute-type.hpp"
#include "rasterizer/drawing-mode.hpp"
#include "rasterizer/texture-2d.hpp"
#include "rasterizer/texture-wrapping.hpp"
#include "rasterizer/texture-filter.hpp"
#include "gl/rasterizer.hpp"
#include "gl/framebuffer.hpp"
#include "gl/shader-program.hpp"
#include "gl/shader-input.hpp"
#include "gl/vertex-buffer.hpp"
#include "gl/vertex-array.hpp"
#include "gl/vertex-attribute-type.hpp"
#include "gl/drawing-mode.hpp"
#include "gl/texture-2d.hpp"
#include "gl/texture-wrapping.hpp"
#include "gl/texture-filter.hpp"
#include "renderer/vertex-attributes.hpp"
#include "renderer/render-context.hpp"
#include "math/math.hpp"
#include <cmath>
#include <glad/glad.h>
final_pass::final_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer, resource_manager* resource_manager):
final_pass::final_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, resource_manager* resource_manager):
render_pass(rasterizer, framebuffer),
color_texture(nullptr),
bloom_texture(nullptr)
{
shader_program = resource_manager->load<::shader_program>("final.glsl");
shader_program = resource_manager->load<gl::shader_program>("final.glsl");
color_texture_input = shader_program->get_input("color_texture");
bloom_texture_input = shader_program->get_input("bloom_texture");
resolution_input = shader_program->get_input("resolution");
@ -60,9 +60,9 @@ final_pass::final_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffe
std::size_t vertex_stride = sizeof(float) * vertex_size;
std::size_t vertex_count = 6;
quad_vbo = new vertex_buffer(sizeof(float) * vertex_size * vertex_count, vertex_data);
quad_vao = new vertex_array();
quad_vao->bind_attribute(VERTEX_POSITION_LOCATION, *quad_vbo, 3, vertex_attribute_type::float_32, vertex_stride, 0);
quad_vbo = new gl::vertex_buffer(sizeof(float) * vertex_size * vertex_count, vertex_data);
quad_vao = new gl::vertex_array();
quad_vao->bind_attribute(VERTEX_POSITION_LOCATION, *quad_vbo, 3, gl::vertex_attribute_type::float_32, vertex_stride, 0);
}
final_pass::~final_pass()
@ -95,15 +95,15 @@ void final_pass::render(render_context* context) const
resolution_input->upload(resolution);
// Draw quad
rasterizer->draw_arrays(*quad_vao, drawing_mode::triangles, 0, 6);
rasterizer->draw_arrays(*quad_vao, gl::drawing_mode::triangles, 0, 6);
}
void final_pass::set_color_texture(const texture_2d* texture)
void final_pass::set_color_texture(const gl::texture_2d* texture)
{
this->color_texture = texture;
}
void final_pass::set_bloom_texture(const texture_2d* texture)
void final_pass::set_bloom_texture(const gl::texture_2d* texture)
{
this->bloom_texture = texture;
}

+ 16
- 16
src/renderer/passes/final-pass.hpp View File

@ -22,12 +22,12 @@
#include "renderer/render-pass.hpp"
#include "math/math.hpp"
#include "gl/shader-program.hpp"
#include "gl/shader-input.hpp"
#include "gl/vertex-buffer.hpp"
#include "gl/vertex-array.hpp"
#include "gl/texture-2d.hpp"
class shader_program;
class shader_input;
class vertex_buffer;
class vertex_array;
class texture_2d;
class resource_manager;
/**
@ -36,23 +36,23 @@ class resource_manager;
class final_pass: public render_pass
{
public:
final_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer, resource_manager* resource_manager);
final_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, resource_manager* resource_manager);
virtual ~final_pass();
virtual void render(render_context* context) const final;
void set_color_texture(const texture_2d* texture);
void set_bloom_texture(const texture_2d* texture);
void set_color_texture(const gl::texture_2d* texture);
void set_bloom_texture(const gl::texture_2d* texture);
private:
shader_program* shader_program;
const shader_input* color_texture_input;
const shader_input* bloom_texture_input;
const shader_input* resolution_input;
vertex_buffer* quad_vbo;
vertex_array* quad_vao;
gl::shader_program* shader_program;
const gl::shader_input* color_texture_input;
const gl::shader_input* bloom_texture_input;
const gl::shader_input* resolution_input;
gl::vertex_buffer* quad_vbo;
gl::vertex_array* quad_vao;
const texture_2d* color_texture;
const texture_2d* bloom_texture;
const gl::texture_2d* color_texture;
const gl::texture_2d* bloom_texture;
};
#endif // ANTKEEPER_FINAL_PASS_HPP

+ 20
- 20
src/renderer/passes/material-pass.cpp View File

@ -20,19 +20,19 @@
#include "renderer/passes/material-pass.hpp"
#include "configuration.hpp"
#include "resources/resource-manager.hpp"
#include "rasterizer/rasterizer.hpp"
#include "rasterizer/framebuffer.hpp"
#include "rasterizer/shader.hpp"
#include "rasterizer/shader-type.hpp"
#include "rasterizer/shader-program.hpp"
#include "rasterizer/shader-input.hpp"
#include "rasterizer/vertex-buffer.hpp"
#include "rasterizer/vertex-array.hpp"
#include "rasterizer/vertex-attribute-type.hpp"
#include "rasterizer/drawing-mode.hpp"
#include "rasterizer/texture-2d.hpp"
#include "rasterizer/texture-wrapping.hpp"
#include "rasterizer/texture-filter.hpp"
#include "gl/rasterizer.hpp"
#include "gl/framebuffer.hpp"
#include "gl/shader.hpp"
#include "gl/shader-type.hpp"
#include "gl/shader-program.hpp"
#include "gl/shader-input.hpp"
#include "gl/vertex-buffer.hpp"
#include "gl/vertex-array.hpp"
#include "gl/vertex-attribute-type.hpp"
#include "gl/drawing-mode.hpp"
#include "gl/texture-2d.hpp"
#include "gl/texture-wrapping.hpp"
#include "gl/texture-filter.hpp"
#include "renderer/vertex-attributes.hpp"
#include "renderer/material-flags.hpp"
#include "renderer/model.hpp"
@ -52,7 +52,7 @@
static bool operation_compare(const render_operation& a, const render_operation& b);
material_pass::material_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer, resource_manager* resource_manager):
material_pass::material_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, resource_manager* resource_manager):
render_pass(rasterizer, framebuffer),
fallback_material(nullptr),
time_tween(nullptr),
@ -62,9 +62,9 @@ material_pass::material_pass(::rasterizer* rasterizer, const ::framebuffer* fram
shadow_map(nullptr),
shadow_strength(1.0f)
{
soft_shadows_texture = resource_manager->load<texture_2d>("tree-shadow.png");
soft_shadows_texture->set_wrapping(texture_wrapping::clamp, texture_wrapping::clamp);
soft_shadows_texture->set_filters(texture_min_filter::linear_mipmap_linear, texture_mag_filter::linear);
soft_shadows_texture = resource_manager->load<gl::texture_2d>("tree-shadow.png");
soft_shadows_texture->set_wrapping(gl::texture_wrapping::clamp, gl::texture_wrapping::clamp);
soft_shadows_texture->set_filters(gl::texture_min_filter::linear_mipmap_linear, gl::texture_mag_filter::linear);
max_ambient_light_count = MATERIAL_PASS_MAX_AMBIENT_LIGHT_COUNT;
max_point_light_count = MATERIAL_PASS_MAX_POINT_LIGHT_COUNT;
@ -136,7 +136,7 @@ void material_pass::render(render_context* context) const
int active_material_flags = 0;
const ::shader_program* active_shader_program = nullptr;
const gl::shader_program* active_shader_program = nullptr;
const ::material* active_material = nullptr;
const parameter_set* parameters = nullptr;
@ -394,7 +394,7 @@ void material_pass::render(render_context* context) const
}
// Switch shaders if necessary
const ::shader_program* shader_program = active_material->get_shader_program();
const gl::shader_program* shader_program = active_material->get_shader_program();
if (active_shader_program != shader_program)
{
active_shader_program = shader_program;
@ -523,7 +523,7 @@ void material_pass::set_focal_point_tween(const tween* focal_point)
this->focal_point_tween = focal_point;
}
const material_pass::parameter_set* material_pass::load_parameter_set(const shader_program* program) const
const material_pass::parameter_set* material_pass::load_parameter_set(const gl::shader_program* program) const
{
// Allocate a new parameter set
parameter_set* parameters = new parameter_set();

+ 41
- 41
src/renderer/passes/material-pass.hpp View File

@ -27,12 +27,12 @@
#include "event/event-handler.hpp"
#include "event/input-events.hpp"
#include <unordered_map>
#include "gl/shader-program.hpp"
#include "gl/shader-input.hpp"
#include "gl/texture-2d.hpp"
class camera;
class shader_program;
class shader_input;
class resource_manager;
class texture_2d;
class shadow_map_pass;
/**
@ -42,7 +42,7 @@ class material_pass: public render_pass,
public event_handler<mouse_moved_event>
{
public:
material_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer, resource_manager* resource_manager);
material_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, resource_manager* resource_manager);
virtual ~material_pass();
virtual void render(render_context* context) const final;
@ -57,7 +57,7 @@ public:
void set_focal_point_tween(const tween<float3>* focal_point);
const ::shadow_map_pass* shadow_map_pass;
const texture_2d* shadow_map;
const gl::texture_2d* shadow_map;
private:
virtual void handle_event(const mouse_moved_event& event);
@ -67,52 +67,52 @@ private:
*/
struct parameter_set
{
const shader_input* time;
const shader_input* mouse;
const shader_input* resolution;
const shader_input* model;
const shader_input* view;
const shader_input* projection;
const shader_input* model_view;
const shader_input* view_projection;
const shader_input* model_view_projection;
const shader_input* normal_model_view;
const shader_input* clip_depth;
const shader_input* log_depth_coef;
const gl::shader_input* time;
const gl::shader_input* mouse;
const gl::shader_input* resolution;
const gl::shader_input* model;
const gl::shader_input* view;
const gl::shader_input* projection;
const gl::shader_input* model_view;
const gl::shader_input* view_projection;
const gl::shader_input* model_view_projection;
const gl::shader_input* normal_model_view;
const gl::shader_input* clip_depth;
const gl::shader_input* log_depth_coef;
const shader_input* ambient_light_count;
const shader_input* ambient_light_colors;
const shader_input* point_light_count;
const shader_input* point_light_colors;
const shader_input* point_light_positions;
const shader_input* point_light_attenuations;
const shader_input* directional_light_count;
const shader_input* directional_light_colors;
const shader_input* directional_light_directions;
const shader_input* spotlight_count;
const shader_input* spotlight_colors;
const shader_input* spotlight_positions;
const shader_input* spotlight_directions;
const shader_input* spotlight_attenuations;
const shader_input* spotlight_cutoffs;
const gl::shader_input* ambient_light_count;
const gl::shader_input* ambient_light_colors;
const gl::shader_input* point_light_count;
const gl::shader_input* point_light_colors;
const gl::shader_input* point_light_positions;
const gl::shader_input* point_light_attenuations;
const gl::shader_input* directional_light_count;
const gl::shader_input* directional_light_colors;
const gl::shader_input* directional_light_directions;
const gl::shader_input* spotlight_count;
const gl::shader_input* spotlight_colors;
const gl::shader_input* spotlight_positions;
const gl::shader_input* spotlight_directions;
const gl::shader_input* spotlight_attenuations;
const gl::shader_input* spotlight_cutoffs;
const shader_input* soft_shadows;
const shader_input* focal_point;
const gl::shader_input* soft_shadows;
const gl::shader_input* focal_point;
const shader_input* shadow_map_matrices;
const shader_input* shadow_map_split_distances;
const shader_input* shadow_map;
const shader_input* shadow_strength;
const gl::shader_input* shadow_map_matrices;
const gl::shader_input* shadow_map_split_distances;
const gl::shader_input* shadow_map;
const gl::shader_input* shadow_strength;
};
const parameter_set* load_parameter_set(const shader_program* program) const;
const parameter_set* load_parameter_set(const gl::shader_program* program) const;
mutable std::unordered_map<const shader_program*, parameter_set*> parameter_sets;
mutable std::unordered_map<const gl::shader_program*, parameter_set*> parameter_sets;
const material* fallback_material;
const tween<double>* time_tween;
float2 mouse_position;
const tween<float3>* focal_point_tween;
texture_2d* soft_shadows_texture;
gl::texture_2d* soft_shadows_texture;
float shadow_strength;
int max_ambient_light_count;

+ 11
- 11
src/renderer/passes/outline-pass.cpp View File

@ -19,14 +19,14 @@
#include "renderer/passes/outline-pass.hpp"
#include "resources/resource-manager.hpp"
#include "rasterizer/rasterizer.hpp"
#include "rasterizer/framebuffer.hpp"
#include "rasterizer/shader-program.hpp"
#include "rasterizer/shader-input.hpp"
#include "rasterizer/vertex-buffer.hpp"
#include "rasterizer/vertex-array.hpp"
#include "rasterizer/vertex-attribute-type.hpp"
#include "rasterizer/drawing-mode.hpp"
#include "gl/rasterizer.hpp"
#include "gl/framebuffer.hpp"
#include "gl/shader-program.hpp"
#include "gl/shader-input.hpp"
#include "gl/vertex-buffer.hpp"
#include "gl/vertex-array.hpp"
#include "gl/vertex-attribute-type.hpp"
#include "gl/drawing-mode.hpp"
#include "renderer/vertex-attributes.hpp"
#include "renderer/render-context.hpp"
#include "renderer/material.hpp"
@ -36,17 +36,17 @@
#include <cmath>
#include <glad/glad.h>
outline_pass::outline_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer, resource_manager* resource_manager):
outline_pass::outline_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, resource_manager* resource_manager):
render_pass(rasterizer, framebuffer),
fill_shader(nullptr),
stroke_shader(nullptr)
{
// Load fill shader
fill_shader = resource_manager->load<shader_program>("outline-fill-unskinned.glsl");
fill_shader = resource_manager->load<gl::shader_program>("outline-fill-unskinned.glsl");
fill_model_view_projection_input = fill_shader->get_input("model_view_projection");
// Load stroke shader
stroke_shader = resource_manager->load<shader_program>("outline-stroke-unskinned.glsl");
stroke_shader = resource_manager->load<gl::shader_program>("outline-stroke-unskinned.glsl");
stroke_model_view_projection_input = stroke_shader->get_input("model_view_projection");
stroke_width_input = stroke_shader->get_input("width");
stroke_color_input = stroke_shader->get_input("color");

+ 9
- 9
src/renderer/passes/outline-pass.hpp View File

@ -22,9 +22,9 @@
#include "renderer/render-pass.hpp"
#include "utility/fundamental-types.hpp"
#include "gl/shader-program.hpp"
#include "gl/shader-input.hpp"
class shader_program;
class shader_input;
class resource_manager;
/**
@ -33,7 +33,7 @@ class resource_manager;
class outline_pass: public render_pass
{
public:
outline_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer, resource_manager* resource_manager);
outline_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, resource_manager* resource_manager);
virtual ~outline_pass();
virtual void render(render_context* context) const final;
@ -41,13 +41,13 @@ public:
void set_outline_color(const float4& color);
private:
shader_program* fill_shader;
const shader_input* fill_model_view_projection_input;
gl::shader_program* fill_shader;
const gl::shader_input* fill_model_view_projection_input;
shader_program* stroke_shader;
const shader_input* stroke_model_view_projection_input;
const shader_input* stroke_width_input;
const shader_input* stroke_color_input;
gl::shader_program* stroke_shader;
const gl::shader_input* stroke_model_view_projection_input;
const gl::shader_input* stroke_width_input;
const gl::shader_input* stroke_color_input;
float outline_width;
float4 outline_color;

+ 10
- 10
src/renderer/passes/shadow-map-pass.cpp View File

@ -19,11 +19,11 @@
#include "renderer/passes/shadow-map-pass.hpp"
#include "resources/resource-manager.hpp"
#include "rasterizer/rasterizer.hpp"
#include "rasterizer/framebuffer.hpp"
#include "rasterizer/shader-program.hpp"
#include "rasterizer/shader-input.hpp"
#include "rasterizer/drawing-mode.hpp"
#include "gl/rasterizer.hpp"
#include "gl/framebuffer.hpp"
#include "gl/shader-program.hpp"
#include "gl/shader-input.hpp"
#include "gl/drawing-mode.hpp"
#include "renderer/render-context.hpp"
#include "renderer/material.hpp"
#include "renderer/material-flags.hpp"
@ -56,17 +56,17 @@ void shadow_map_pass::distribute_frustum_splits(float* split_distances, std::siz
}
}
shadow_map_pass::shadow_map_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer, resource_manager* resource_manager):
shadow_map_pass::shadow_map_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, resource_manager* resource_manager):
render_pass(rasterizer, framebuffer),
split_scheme_weight(0.5f),
light(nullptr)
{
// Load skinned shader program
unskinned_shader_program = resource_manager->load<::shader_program>("depth-unskinned.glsl");
unskinned_shader_program = resource_manager->load<gl::shader_program>("depth-unskinned.glsl");
unskinned_model_view_projection_input = unskinned_shader_program->get_input("model_view_projection");
// Load unskinned shader program
skinned_shader_program = resource_manager->load<::shader_program>("depth-skinned.glsl");
skinned_shader_program = resource_manager->load<gl::shader_program>("depth-skinned.glsl");
skinned_model_view_projection_input = skinned_shader_program->get_input("model_view_projection");
// Calculate bias-tile matrices
@ -151,7 +151,7 @@ void shadow_map_pass::render(render_context* context) const
// Sort render operations
context->operations.sort(operation_compare);
shader_program* active_shader_program = nullptr;
gl::shader_program* active_shader_program = nullptr;
for (int i = 0; i < 4; ++i)
{
@ -223,7 +223,7 @@ void shadow_map_pass::render(render_context* context) const
}
// Switch shader programs if necessary
::shader_program* shader_program = (operation.pose != nullptr) ? skinned_shader_program : unskinned_shader_program;
gl::shader_program* shader_program = (operation.pose != nullptr) ? skinned_shader_program : unskinned_shader_program;
if (active_shader_program != shader_program)
{
active_shader_program = shader_program;

+ 7
- 7
src/renderer/passes/shadow-map-pass.hpp View File

@ -23,9 +23,9 @@
#include "renderer/render-pass.hpp"
#include "utility/fundamental-types.hpp"
#include "scene/directional-light.hpp"
#include "gl/shader-program.hpp"
#include "gl/shader-input.hpp"
class shader_program;
class shader_input;
class resource_manager;
/**
@ -34,7 +34,7 @@ class resource_manager;
class shadow_map_pass: public render_pass
{
public:
shadow_map_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer, resource_manager* resource_manager);
shadow_map_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, resource_manager* resource_manager);
virtual ~shadow_map_pass();
virtual void render(render_context* context) const final;
@ -62,11 +62,11 @@ private:
*/
static void distribute_frustum_splits(float* split_distances, std::size_t split_count, float split_scheme, float near, float far);
shader_program* unskinned_shader_program;
const shader_input* unskinned_model_view_projection_input;
gl::shader_program* unskinned_shader_program;
const gl::shader_input* unskinned_model_view_projection_input;
shader_program* skinned_shader_program;
const shader_input* skinned_model_view_projection_input;
gl::shader_program* skinned_shader_program;
const gl::shader_input* skinned_model_view_projection_input;
mutable float split_distances[5];
mutable float4x4 shadow_matrices[4];

+ 13
- 13
src/renderer/passes/sky-pass.cpp View File

@ -19,17 +19,17 @@
#include "renderer/passes/sky-pass.hpp"
#include "resources/resource-manager.hpp"
#include "rasterizer/rasterizer.hpp"
#include "rasterizer/framebuffer.hpp"
#include "rasterizer/shader-program.hpp"
#include "rasterizer/shader-input.hpp"
#include "rasterizer/vertex-buffer.hpp"
#include "rasterizer/vertex-array.hpp"
#include "rasterizer/vertex-attribute-type.hpp"
#include "rasterizer/drawing-mode.hpp"
#include "rasterizer/texture-2d.hpp"
#include "rasterizer/texture-wrapping.hpp"
#include "rasterizer/texture-filter.hpp"
#include "gl/rasterizer.hpp"
#include "gl/framebuffer.hpp"
#include "gl/shader-program.hpp"
#include "gl/shader-input.hpp"
#include "gl/vertex-buffer.hpp"
#include "gl/vertex-array.hpp"
#include "gl/vertex-attribute-type.hpp"
#include "gl/drawing-mode.hpp"
#include "gl/texture-2d.hpp"
#include "gl/texture-wrapping.hpp"
#include "gl/texture-filter.hpp"
#include "renderer/vertex-attributes.hpp"
#include "renderer/render-context.hpp"
#include "renderer/model.hpp"
@ -40,7 +40,7 @@
#include <glad/glad.h>
#include <iostream>
sky_pass::sky_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer, resource_manager* resource_manager):
sky_pass::sky_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, resource_manager* resource_manager):
render_pass(rasterizer, framebuffer),
mouse_position({0.0f, 0.0f}),
sky_model(nullptr),
@ -275,7 +275,7 @@ void sky_pass::set_time_tween(const tween* time)
this->time_tween = time;
}
void sky_pass::set_blue_noise_map(const texture_2d* texture)
void sky_pass::set_blue_noise_map(const gl::texture_2d* texture)
{
blue_noise_map = texture;
}

+ 35
- 35
src/renderer/passes/sky-pass.hpp View File

@ -26,16 +26,16 @@
#include "event/input-events.hpp"
#include "animation/tween.hpp"
#include "math/quaternion-type.hpp"
#include "gl/shader-program.hpp"
#include "gl/shader-input.hpp"
#include "gl/vertex-buffer.hpp"
#include "gl/vertex-array.hpp"
#include "gl/texture-2d.hpp"
#include "gl/drawing-mode.hpp"
class shader_program;
class shader_input;
class vertex_buffer;
class vertex_array;
class texture_2d;
class resource_manager;
class model;
class material;
enum class drawing_mode;
/**
*
@ -44,7 +44,7 @@ class sky_pass: public render_pass,
public event_handler<mouse_moved_event>
{
public:
sky_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer, resource_manager* resource_manager);
sky_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, resource_manager* resource_manager);
virtual ~sky_pass();
virtual void render(render_context* context) const final;
@ -54,7 +54,7 @@ public:
void set_horizon_color(const float3& color);
void set_zenith_color(const float3& color);
void set_time_of_day(float time);
void set_blue_noise_map(const texture_2d* texture);
void set_blue_noise_map(const gl::texture_2d* texture);
void set_time_tween(const tween<double>* time);
void set_moon_model(const model* model);
@ -70,45 +70,45 @@ public:
private:
virtual void handle_event(const mouse_moved_event& event);
shader_program* sky_shader_program;
const shader_input* model_view_projection_input;
const shader_input* horizon_color_input;
const shader_input* zenith_color_input;
const shader_input* mouse_input;
const shader_input* resolution_input;
const shader_input* time_input;
const shader_input* time_of_day_input;
const shader_input* observer_location_input;
const shader_input* sun_position_input;
const shader_input* sun_az_el_input;
const shader_input* moon_position_input;
const shader_input* moon_az_el_input;
const shader_input* blue_noise_map_input;
const shader_input* julian_day_input;
const shader_input* cos_sun_angular_radius_input;
const shader_input* cos_moon_angular_radius_input;
gl::shader_program* sky_shader_program;
const gl::shader_input* model_view_projection_input;
const gl::shader_input* horizon_color_input;
const gl::shader_input* zenith_color_input;
const gl::shader_input* mouse_input;
const gl::shader_input* resolution_input;
const gl::shader_input* time_input;
const gl::shader_input* time_of_day_input;
const gl::shader_input* observer_location_input;
const gl::shader_input* sun_position_input;
const gl::shader_input* sun_az_el_input;
const gl::shader_input* moon_position_input;
const gl::shader_input* moon_az_el_input;
const gl::shader_input* blue_noise_map_input;
const gl::shader_input* julian_day_input;
const gl::shader_input* cos_sun_angular_radius_input;
const gl::shader_input* cos_moon_angular_radius_input;
::shader_program* moon_shader_program;
const shader_input* moon_model_view_projection_input;
const shader_input* moon_normal_model_input;
const shader_input* moon_moon_position_input;
const shader_input* moon_sun_position_input;
gl::shader_program* moon_shader_program;
const gl::shader_input* moon_model_view_projection_input;
const gl::shader_input* moon_normal_model_input;
const gl::shader_input* moon_moon_position_input;
const gl::shader_input* moon_sun_position_input;
const model* sky_model;
const material* sky_material;
const vertex_array* sky_model_vao;
drawing_mode sky_model_drawing_mode;
const gl::vertex_array* sky_model_vao;
gl::drawing_mode sky_model_drawing_mode;
std::size_t sky_model_start_index;
std::size_t sky_model_index_count;
const model* moon_model;
const material* moon_material;
const vertex_array* moon_model_vao;
drawing_mode moon_model_drawing_mode;
const gl::vertex_array* moon_model_vao;
gl::drawing_mode moon_model_drawing_mode;
std::size_t moon_model_start_index;
std::size_t moon_model_index_count;
const texture_2d* blue_noise_map;
const gl::texture_2d* blue_noise_map;
float2 mouse_position;
const tween<double>* time_tween;

+ 15
- 15
src/renderer/passes/ui-pass.cpp View File

@ -19,19 +19,19 @@
#include "renderer/passes/ui-pass.hpp"
#include "resources/resource-manager.hpp"
#include "rasterizer/rasterizer.hpp"
#include "rasterizer/framebuffer.hpp"
#include "rasterizer/shader.hpp"
#include "rasterizer/shader-type.hpp"
#include "rasterizer/shader-program.hpp"
#include "rasterizer/shader-input.hpp"
#include "rasterizer/vertex-buffer.hpp"
#include "rasterizer/vertex-array.hpp"
#include "rasterizer/vertex-attribute-type.hpp"
#include "rasterizer/drawing-mode.hpp"
#include "rasterizer/texture-2d.hpp"
#include "rasterizer/texture-wrapping.hpp"
#include "rasterizer/texture-filter.hpp"
#include "gl/rasterizer.hpp"
#include "gl/framebuffer.hpp"
#include "gl/shader.hpp"
#include "gl/shader-type.hpp"
#include "gl/shader-program.hpp"
#include "gl/shader-input.hpp"
#include "gl/vertex-buffer.hpp"
#include "gl/vertex-array.hpp"
#include "gl/vertex-attribute-type.hpp"
#include "gl/drawing-mode.hpp"
#include "gl/texture-2d.hpp"
#include "gl/texture-wrapping.hpp"
#include "gl/texture-filter.hpp"
#include "renderer/vertex-attributes.hpp"
#include "renderer/material-flags.hpp"
#include "renderer/render-context.hpp"
@ -44,7 +44,7 @@
#include <cmath>
#include <glad/glad.h>
ui_pass::ui_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer, resource_manager* resource_manager):
ui_pass::ui_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, resource_manager* resource_manager):
render_pass(rasterizer, framebuffer),
time(0.0f)
{}
@ -80,7 +80,7 @@ void ui_pass::set_time(float time)
this->time = time;
}
const ui_pass::parameter_set* ui_pass::load_parameter_set(const shader_program* program) const
const ui_pass::parameter_set* ui_pass::load_parameter_set(const gl::shader_program* program) const
{
// Allocate a new parameter set
parameter_set* parameters = new parameter_set();

+ 8
- 8
src/renderer/passes/ui-pass.hpp View File

@ -22,12 +22,12 @@
#include "renderer/render-pass.hpp"
#include "renderer/material.hpp"
#include "gl/shader-program.hpp"
#include "gl/shader-input.hpp"
#include "gl/texture-2d.hpp"
#include <unordered_map>
class shader_program;
class shader_input;
class resource_manager;
class texture_2d;
/**
*
@ -35,7 +35,7 @@ class texture_2d;
class ui_pass: public render_pass
{
public:
ui_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer, resource_manager* resource_manager);
ui_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, resource_manager* resource_manager);
virtual ~ui_pass();
virtual void render(render_context* context) const final;
@ -47,13 +47,13 @@ private:
*/
struct parameter_set
{
const shader_input* time;
const shader_input* model_view_projection;
const gl::shader_input* time;
const gl::shader_input* model_view_projection;
};
const parameter_set* load_parameter_set(const shader_program* program) const;
const parameter_set* load_parameter_set(const gl::shader_program* program) const;
mutable std::unordered_map<const shader_program*, parameter_set*> parameter_sets;
mutable std::unordered_map<const gl::shader_program*, parameter_set*> parameter_sets;
float time;
};

+ 4
- 4
src/renderer/render-operation.hpp View File

@ -21,12 +21,12 @@
#define ANTKEEPER_RENDER_OPERATION_HPP
#include "utility/fundamental-types.hpp"
#include "gl/vertex-array.hpp"
#include "gl/drawing-mode.hpp"
#include <cstdlib>
class pose;
class material;
class vertex_array;
enum class drawing_mode;
/**
* Describes a render operation with a single mesh and single material.
@ -35,8 +35,8 @@ struct render_operation
{
const pose* pose;
const material* material;
const vertex_array* vertex_array;
drawing_mode drawing_mode;
const gl::vertex_array* vertex_array;
gl::drawing_mode drawing_mode;
std::size_t start_index;
std::size_t index_count;
float4x4 transform;

+ 1
- 1
src/renderer/render-pass.cpp View File

@ -19,7 +19,7 @@
#include "renderer/render-pass.hpp"
render_pass::render_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer):
render_pass::render_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer):
rasterizer(rasterizer),
framebuffer(framebuffer),
enabled(true)

+ 6
- 5
src/renderer/render-pass.hpp View File

@ -20,8 +20,9 @@
#ifndef ANTKEEPER_RENDER_PASS_HPP
#define ANTKEEPER_RENDER_PASS_HPP
class rasterizer;
class framebuffer;
#include "gl/rasterizer.hpp"
#include "gl/framebuffer.hpp"
struct render_context;
/**
@ -30,7 +31,7 @@ struct render_context;
class render_pass
{
public:
render_pass(rasterizer* rasterizer, const framebuffer* framebuffer);
render_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer);
virtual ~render_pass();
virtual void render(render_context* context) const = 0;
@ -39,8 +40,8 @@ public:
bool is_enabled() const;
protected:
rasterizer* rasterizer;
const ::framebuffer* framebuffer;
gl::rasterizer* rasterizer;
const gl::framebuffer* framebuffer;
private:
bool enabled;

+ 3
- 3
src/renderer/renderer.cpp View File

@ -26,7 +26,7 @@
#include "scene/billboard.hpp"
#include "scene/lod-group.hpp"
#include "renderer/model.hpp"
#include "rasterizer/drawing-mode.hpp"
#include "gl/drawing-mode.hpp"
#include "math/math.hpp"
#include "geom/projection.hpp"
#include "configuration.hpp"
@ -37,7 +37,7 @@ renderer::renderer()
{
// Setup billboard render operation
billboard_op.pose = nullptr;
billboard_op.drawing_mode = drawing_mode::triangles;
billboard_op.drawing_mode = gl::drawing_mode::triangles;
billboard_op.vertex_array = nullptr;
billboard_op.start_index = 0;
billboard_op.index_count = 6;
@ -113,7 +113,7 @@ void renderer::render(float alpha, const scene::collection& collection) const
}
}
void renderer::set_billboard_vao(vertex_array* vao)
void renderer::set_billboard_vao(gl::vertex_array* vao)
{
billboard_op.vertex_array = vao;
}

+ 2
- 2
src/renderer/renderer.hpp View File

@ -21,9 +21,9 @@
#define ANTKEEPER_RENDERER_HPP
#include "render-operation.hpp"
#include "gl/vertex-array.hpp"
struct render_context;
class vertex_array;
namespace scene
{
@ -64,7 +64,7 @@ public:
/**
* Sets the VAO to be used when generating render operations for billboards.
*/
void set_billboard_vao(vertex_array* vao);
void set_billboard_vao(gl::vertex_array* vao);
private:
void process_object(render_context& context, const scene::object_base* object) const;

+ 16
- 16
src/renderer/simple-render-pass.cpp View File

@ -18,17 +18,17 @@
*/
#include "renderer/simple-render-pass.hpp"
#include "rasterizer/rasterizer.hpp"
#include "rasterizer/framebuffer.hpp"
#include "rasterizer/shader-program.hpp"
#include "rasterizer/shader-input.hpp"
#include "rasterizer/vertex-buffer.hpp"
#include "rasterizer/vertex-array.hpp"
#include "rasterizer/vertex-attribute-type.hpp"
#include "rasterizer/drawing-mode.hpp"
#include "rasterizer/texture-2d.hpp"
#include "rasterizer/texture-wrapping.hpp"
#include "rasterizer/texture-filter.hpp"
#include "gl/rasterizer.hpp"
#include "gl/framebuffer.hpp"
#include "gl/shader-program.hpp"
#include "gl/shader-input.hpp"
#include "gl/vertex-buffer.hpp"
#include "gl/vertex-array.hpp"
#include "gl/vertex-attribute-type.hpp"
#include "gl/drawing-mode.hpp"
#include "gl/texture-2d.hpp"
#include "gl/texture-wrapping.hpp"
#include "gl/texture-filter.hpp"
#include "renderer/vertex-attributes.hpp"
#include "renderer/render-context.hpp"
#include "renderer/material.hpp"
@ -36,7 +36,7 @@
#include "math/math.hpp"
#include <glad/glad.h>
simple_render_pass::simple_render_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer, ::shader_program* shader_program):
simple_render_pass::simple_render_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, gl::shader_program* shader_program):
render_pass(rasterizer, framebuffer),
shader_program(shader_program),
time_tween(nullptr)
@ -62,9 +62,9 @@ simple_render_pass::simple_render_pass(::rasterizer* rasterizer, const ::framebu
std::size_t vertex_stride = sizeof(float) * vertex_size;
std::size_t vertex_count = 6;
quad_vbo = new vertex_buffer(sizeof(float) * vertex_size * vertex_count, vertex_data);
quad_vao = new vertex_array();
quad_vao->bind_attribute(VERTEX_POSITION_LOCATION, *quad_vbo, 3, vertex_attribute_type::float_32, vertex_stride, 0);
quad_vbo = new gl::vertex_buffer(sizeof(float) * vertex_size * vertex_count, vertex_data);
quad_vao = new gl::vertex_array();
quad_vao->bind_attribute(VERTEX_POSITION_LOCATION, *quad_vbo, 3, gl::vertex_attribute_type::float_32, vertex_stride, 0);
}
simple_render_pass::~simple_render_pass()
@ -104,7 +104,7 @@ void simple_render_pass::render(render_context* context) const
material->upload(context->alpha);
// Draw quad
rasterizer->draw_arrays(*quad_vao, drawing_mode::triangles, 0, 6);
rasterizer->draw_arrays(*quad_vao, gl::drawing_mode::triangles, 0, 6);
}
void simple_render_pass::set_time_tween(const tween<double>* time)

+ 8
- 8
src/renderer/simple-render-pass.hpp View File

@ -23,11 +23,11 @@
#include "renderer/render-pass.hpp"
#include "animation/tween.hpp"
#include "utility/fundamental-types.hpp"
#include "gl/shader-program.hpp"
#include "gl/shader-input.hpp"
#include "gl/vertex-buffer.hpp"
#include "gl/vertex-array.hpp"
class shader_program;
class shader_input;
class vertex_buffer;
class vertex_array;
class material;
template <class T>
class material_property;
@ -38,7 +38,7 @@ class material_property;
class simple_render_pass: public render_pass
{
public:
simple_render_pass(::rasterizer* rasterizer, const ::framebuffer* framebuffer, ::shader_program* shader_program);
simple_render_pass(gl::rasterizer* rasterizer, const gl::framebuffer* framebuffer, gl::shader_program* shader_program);
virtual ~simple_render_pass();
virtual void render(render_context* context) const final;
@ -48,15 +48,15 @@ public:
::material* get_material();
private:
shader_program* shader_program;
gl::shader_program* shader_program;
material* material;
material_property<float>* time_property;
material_property<float2>* resolution_property;
const tween<double>* time_tween;
vertex_buffer* quad_vbo;
vertex_array* quad_vao;
gl::vertex_buffer* quad_vbo;
gl::vertex_array* quad_vao;
};
inline const ::material* simple_render_pass::get_material() const

+ 26
- 26
src/resources/material-loader.cpp View File

@ -20,37 +20,37 @@
#include "renderer/material.hpp"
#include "resource-loader.hpp"
#include "resource-manager.hpp"
#include "rasterizer/shader-variable-type.hpp"
#include "rasterizer/texture-wrapping.hpp"
#include "rasterizer/texture-filter.hpp"
#include "rasterizer/texture-2d.hpp"
#include "gl/shader-variable-type.hpp"
#include "gl/texture-wrapping.hpp"
#include "gl/texture-filter.hpp"
#include "gl/texture-2d.hpp"
#include "utility/fundamental-types.hpp"
#include "string-table.hpp"
#include <cctype>
#include <vector>
#include <map>
static const std::map<std::string, texture_wrapping> texture_wrapping_map =
static const std::map<std::string, gl::texture_wrapping> texture_wrapping_map =
{
{"clamp", texture_wrapping::clamp},
{"repeat", texture_wrapping::repeat},
{"mirrored_repeat", texture_wrapping::mirrored_repeat},
{"clamp", gl::texture_wrapping::clamp},
{"repeat", gl::texture_wrapping::repeat},
{"mirrored_repeat", gl::texture_wrapping::mirrored_repeat},
};
static const std::map<std::string, texture_min_filter> texture_min_filter_map =
static const std::map<std::string, gl::texture_min_filter> texture_min_filter_map =
{
{"nearest", texture_min_filter::nearest},
{"linear", texture_min_filter::linear},
{"nearest_mipmap_nearest", texture_min_filter::nearest_mipmap_nearest},
{"linear_mipmap_nearest", texture_min_filter::linear_mipmap_nearest},
{"nearest_mipmap_linear", texture_min_filter::nearest_mipmap_linear},
{"linear_mipmap_linear", texture_min_filter::linear_mipmap_linear}
{"nearest", gl::texture_min_filter::nearest},
{"linear", gl::texture_min_filter::linear},
{"nearest_mipmap_nearest", gl::texture_min_filter::nearest_mipmap_nearest},
{"linear_mipmap_nearest", gl::texture_min_filter::linear_mipmap_nearest},
{"nearest_mipmap_linear", gl::texture_min_filter::nearest_mipmap_linear},
{"linear_mipmap_linear", gl::texture_min_filter::linear_mipmap_linear}
};
static const std::map<std::string, texture_mag_filter> texture_mag_filter_map =
static const std::map<std::string, gl::texture_mag_filter> texture_mag_filter_map =
{
{"nearest", texture_mag_filter::nearest},
{"linear", texture_mag_filter::linear},
{"nearest", gl::texture_mag_filter::nearest},
{"linear", gl::texture_mag_filter::linear},
};
static bool load_bool_property(material* material, const string_table_row& row, int vector_size, int array_size)
@ -257,16 +257,16 @@ static bool load_texture_2d_property(material* material, const string_table_row&
return false;
}
const texture_2d** values = new const texture_2d*[array_size];
const gl::texture_2d** values = new const gl::texture_2d*[array_size];
for (std::size_t i = 0; i < array_size; ++i)
{
std::size_t offset = 4 + i;
const std::string& filename = row[offset];
texture_wrapping wrap_s = texture_wrapping::clamp;
texture_wrapping wrap_t = texture_wrapping::clamp;
texture_min_filter min_filter = texture_min_filter::linear_mipmap_linear;
texture_mag_filter mag_filter = texture_mag_filter::linear;
gl::texture_wrapping wrap_s = gl::texture_wrapping::clamp;
gl::texture_wrapping wrap_t = gl::texture_wrapping::clamp;
gl::texture_min_filter min_filter = gl::texture_min_filter::linear_mipmap_linear;
gl::texture_mag_filter mag_filter = gl::texture_mag_filter::linear;
if (auto it = texture_wrapping_map.find(row[offset + 1]); it != texture_wrapping_map.end())
{
wrap_s = it->second;
@ -285,7 +285,7 @@ static bool load_texture_2d_property(material* material, const string_table_row&
}
float max_anisotropy = static_cast<float>(std::stod(row[offset + 5]));
texture_2d* texture = resource_manager->load<texture_2d>(row[4 + i]);
gl::texture_2d* texture = resource_manager->load<gl::texture_2d>(row[4 + i]);
texture->set_wrapping(wrap_s, wrap_t);
texture->set_filters(min_filter, mag_filter);
texture->set_max_anisotropy(max_anisotropy);
@ -293,7 +293,7 @@ static bool load_texture_2d_property(material* material, const string_table_row&
values[i] = texture;
}
material_property<const texture_2d*>* property = material->add_property<const texture_2d*>(row[1], array_size);
material_property<const gl::texture_2d*>* property = material->add_property<const gl::texture_2d*>(row[1], array_size);
property->set_values(0, values, array_size);
delete[] values;
@ -405,7 +405,7 @@ material* resource_loader::load(resource_manager* resource_manager, PH
if (row[0] == "shader" && row.size() == 2)
{
shader_program* program = resource_manager->load<shader_program>(row[1]);
gl::shader_program* program = resource_manager->load<gl::shader_program>(row[1]);
material->set_shader_program(program);
}
else if (row[0] == "flags" && row.size() == 2)

+ 6
- 6
src/resources/model-loader.cpp View File

@ -21,8 +21,8 @@
#include "resources/resource-manager.hpp"
#include "renderer/model.hpp"
#include "renderer/vertex-attributes.hpp"
#include "rasterizer/vertex-attribute-type.hpp"
#include "rasterizer/drawing-mode.hpp"
#include "gl/vertex-attribute-type.hpp"
#include "gl/drawing-mode.hpp"
#include "utility/fundamental-types.hpp"
#include <sstream>
#include <stdexcept>
@ -462,7 +462,7 @@ model* resource_loader::load(resource_manager* resource_manager, PHYSFS_F
}
// Resize VBO and upload vertex data
vertex_buffer* vbo = model->get_vertex_buffer();
gl::vertex_buffer* vbo = model->get_vertex_buffer();
vbo->resize(sizeof(float) * vertex_size * vertex_count, vertex_data);
// Free interleaved vertex data buffer
@ -482,7 +482,7 @@ model* resource_loader::load(resource_manager* resource_manager, PHYSFS_F
};
// Bind attributes to VAO
vertex_array* vao = model->get_vertex_array();
gl::vertex_array* vao = model->get_vertex_array();
std::size_t offset = 0;
for (auto attribute_it = attributes.begin(); attribute_it != attributes.end(); ++attribute_it)
{
@ -490,7 +490,7 @@ model* resource_loader::load(resource_manager* resource_manager, PHYSFS_F
std::size_t attribute_size = std::get<0>(attribute_it->second);
if (auto location_it = attribute_location_map.find(attribute_name); location_it != attribute_location_map.end())
vao->bind_attribute(location_it->second, *vbo, attribute_size, vertex_attribute_type::float_32, vertex_stride, offset);
vao->bind_attribute(location_it->second, *vbo, attribute_size, gl::vertex_attribute_type::float_32, vertex_stride, offset);
offset += attribute_size * sizeof(float);
}
@ -515,7 +515,7 @@ model* resource_loader::load(resource_manager* resource_manager, PHYSFS_F
group_material = resource_manager->load<material>(group_name + ".mtl");
model_group* model_group = model->add_group(group_name);
model_group->set_drawing_mode(drawing_mode::triangles);
model_group->set_drawing_mode(gl::drawing_mode::triangles);
model_group->set_start_index(group_offset * 3);
model_group->set_index_count(group_size * 3);
model_group->set_material(group_material);

+ 19
- 19
src/resources/shader-program-loader.cpp View File

@ -20,9 +20,9 @@
#include "resources/resource-loader.hpp"
#include "resources/resource-manager.hpp"
#include "resources/text-file.hpp"
#include "rasterizer/shader-type.hpp"
#include "rasterizer/shader.hpp"
#include "rasterizer/shader-program.hpp"
#include "gl/shader-type.hpp"
#include "gl/shader.hpp"
#include "gl/shader-program.hpp"
#include <sstream>
#include <iterator>
@ -104,18 +104,18 @@ static void inject_debug_macro(text_file* source)
/**
* Injects a shader type macro definition after the `#version` directive.
*/
static void inject_shader_type_macro(text_file* source, shader_type type)
static void inject_shader_type_macro(text_file* source, gl::shader_type type)
{
const char* vertex_macro = "#define _VERTEX";
const char* fragment_macro = "#define _FRAGMENT";
const char* geometry_macro = "#define _GEOMETRY";
const char* macro = nullptr;
if (type == shader_type::vertex)
if (type == gl::shader_type::vertex)
macro = vertex_macro;
else if (type == shader_type::fragment)
else if (type == gl::shader_type::fragment)
macro = fragment_macro;
else if (type == shader_type::geometry)
else if (type == gl::shader_type::geometry)
macro = geometry_macro;
// For each line in the source
@ -133,9 +133,9 @@ static void inject_shader_type_macro(text_file* source, shader_type type)
}
}
static std::list<shader_type> detect_shader_types(text_file* source)
static std::list<gl::shader_type> detect_shader_types(text_file* source)
{
std::list<shader_type> types;
std::list<gl::shader_type> types;
// For each line in the source
for (std::size_t i = 0; i < source->size(); ++i)
@ -148,15 +148,15 @@ static std::list detect_shader_types(text_file* source)
{
if (tokens[1] == "vertex")
{
types.push_back(shader_type::vertex);
types.push_back(gl::shader_type::vertex);
}
else if (tokens[1] == "fragment")
{
types.push_back(shader_type::fragment);
types.push_back(gl::shader_type::fragment);
}
else if (tokens[1] == "geometry")
{
types.push_back(shader_type::geometry);
types.push_back(gl::shader_type::geometry);
}
}
}
@ -172,7 +172,7 @@ static std::string generate_source_buffer(const std::vector& source
}
template <>
shader_program* resource_loader<shader_program>::load(resource_manager* resource_manager, PHYSFS_File* file)
gl::shader_program* resource_loader<gl::shader_program>::load(resource_manager* resource_manager, PHYSFS_File* file)
{
// Load shader source
text_file* source = resource_loader<text_file>::load(resource_manager, file);
@ -184,23 +184,23 @@ shader_program* resource_loader::load(resource_manager* resource
inject_debug_macro(source);
// Detect declared shader types via the `#pragma vertex`, `#pragma fragment` and `#pragma geometry` directives
std::list<shader_type> shader_types = detect_shader_types(source);
std::list<gl::shader_type> shader_types = detect_shader_types(source);
// Load detected shaders
std::list<shader*> shaders;
for (shader_type type: shader_types)
std::list<gl::shader*> shaders;
for (gl::shader_type type: shader_types)
{
text_file type_source = *source;
inject_shader_type_macro(&type_source, type);
std::string source_buffer = generate_source_buffer(type_source);
shaders.push_back(new shader(type, source_buffer));
shaders.push_back(new gl::shader(type, source_buffer));
}
// Create shader program
shader_program* program = new shader_program(shaders);
gl::shader_program* program = new gl::shader_program(shaders);
// Delete shaders
for (shader* shader: shaders)
for (gl::shader* shader: shaders)
{
delete shader;
}

+ 12
- 12
src/resources/texture-2d-loader.cpp View File

@ -19,37 +19,37 @@
#include "resources/resource-loader.hpp"
#include "resources/image.hpp"
#include "rasterizer/pixel-type.hpp"
#include "rasterizer/pixel-format.hpp"
#include "rasterizer/texture-2d.hpp"
#include "gl/pixel-type.hpp"
#include "gl/pixel-format.hpp"
#include "gl/texture-2d.hpp"
#include <sstream>
template <>
texture_2d* resource_loader<texture_2d>::load(resource_manager* resource_manager, PHYSFS_File* file)
gl::texture_2d* resource_loader<gl::texture_2d>::load(resource_manager* resource_manager, PHYSFS_File* file)
{
// Load image
::image* image = resource_loader<::image>::load(resource_manager, file);
// Determine pixel type
pixel_type type = (image->is_hdr()) ? pixel_type::float_32 : pixel_type::uint_8;
gl::pixel_type type = (image->is_hdr()) ? gl::pixel_type::float_32 : gl::pixel_type::uint_8;
// Determine pixel format
pixel_format format;
gl::pixel_format format;
if (image->get_channels() == 1)
{
format = pixel_format::r;
format = gl::pixel_format::r;
}
else if (image->get_channels() == 2)
{
format = pixel_format::rg;
format = gl::pixel_format::rg;
}
else if (image->get_channels() == 3)
{
format = pixel_format::rgb;
format = gl::pixel_format::rgb;
}
else if (image->get_channels() == 4)
{
format = pixel_format::rgba;
format = gl::pixel_format::rgba;
}
else
{
@ -60,10 +60,10 @@ texture_2d* resource_loader::load(resource_manager* resource_manager
}
// Assume linear color space
::color_space color_space = ::color_space::linear;
gl::color_space color_space = gl::color_space::linear;
// Create texture
texture_2d* texture = new texture_2d(image->get_width(), image->get_height(), type, format, color_space, image->get_pixels());
gl::texture_2d* texture = new gl::texture_2d(image->get_width(), image->get_height(), type, format, color_space, image->get_pixels());
// Free loaded image
delete image;

Loading…
Cancel
Save