diff --git a/CMakeLists.txt b/CMakeLists.txt index bc40e61..d4aa351 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/src/application.cpp b/src/application.cpp index 5e2d55a..c269d2e 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -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 #include @@ -203,7 +202,7 @@ application::application(): */ // Setup rasterizer - rasterizer = new ::rasterizer(); + rasterizer = new gl::rasterizer(); // Setup events event_dispatcher = new ::event_dispatcher(); diff --git a/src/application.hpp b/src/application.hpp index cff6175..ebbbcd9 100644 --- a/src/application.hpp +++ b/src/application.hpp @@ -25,6 +25,7 @@ #include #include #include +#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; } diff --git a/src/ecs/systems/painting-system.cpp b/src/ecs/systems/painting-system.cpp index 885ed85..924cea0 100644 --- a/src/ecs/systems/painting-system.cpp +++ b/src/ecs/systems/painting-system.cpp @@ -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 @@ -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(); diff --git a/src/ecs/systems/painting-system.hpp b/src/ecs/systems/painting-system.hpp index bb2d76c..e2ccae9 100644 --- a/src/ecs/systems/painting-system.hpp +++ b/src/ecs/systems/painting-system.hpp @@ -27,6 +27,7 @@ #include "utility/fundamental-types.hpp" #include "scene/collection.hpp" #include "scene/model-instance.hpp" +#include "gl/vertex-buffer.hpp" #include #include @@ -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; diff --git a/src/ecs/systems/subterrain-system.cpp b/src/ecs/systems/subterrain-system.cpp index c67a3a8..e641bb6 100644 --- a/src/ecs/systems/subterrain-system.cpp +++ b/src/ecs/systems/subterrain-system.cpp @@ -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("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("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 diff --git a/src/ecs/systems/terrain-system.cpp b/src/ecs/systems/terrain-system.cpp index 716834e..ceb610c 100644 --- a/src/ecs/systems/terrain-system.cpp +++ b/src/ecs/systems/terrain-system.cpp @@ -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("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); diff --git a/src/ecs/systems/ui-system.cpp b/src/ecs/systems/ui-system.cpp index c001224..33aa09b 100644 --- a/src/ecs/systems/ui-system.cpp +++ b/src/ecs/systems/ui-system.cpp @@ -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("ui-element-untextured.glsl")); + modal_bg_material.set_shader_program(resource_manager->load("ui-element-untextured.glsl")); modal_bg_material.set_flags(1); modal_bg_material.add_property("tint")->set_value({0, 0, 0, 0.25f}); modal_bg.set_material(&modal_bg_material); diff --git a/src/game/bootloader.cpp b/src/game/bootloader.cpp index 7a7a2af..95b3aef 100644 --- a/src/game/bootloader.cpp +++ b/src/game/bootloader.cpp @@ -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("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("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("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("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(ctx->underworld_material_pass); - shader_program* underworld_final_shader = ctx->resource_manager->load("underground-final.glsl"); + gl::shader_program* underworld_final_shader = ctx->resource_manager->load("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("color_texture"); + ctx->underground_color_texture_property = ctx->underworld_final_pass->get_material()->add_property("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("marker-clear-albedo.png"); - ctx->marker_albedo_textures[1] = ctx->resource_manager->load("marker-yellow-albedo.png"); - ctx->marker_albedo_textures[2] = ctx->resource_manager->load("marker-green-albedo.png"); - ctx->marker_albedo_textures[3] = ctx->resource_manager->load("marker-blue-albedo.png"); - ctx->marker_albedo_textures[4] = ctx->resource_manager->load("marker-purple-albedo.png"); - ctx->marker_albedo_textures[5] = ctx->resource_manager->load("marker-pink-albedo.png"); - ctx->marker_albedo_textures[6] = ctx->resource_manager->load("marker-red-albedo.png"); - ctx->marker_albedo_textures[7] = ctx->resource_manager->load("marker-orange-albedo.png"); + ctx->marker_albedo_textures = new gl::texture_2d*[8]; + ctx->marker_albedo_textures[0] = ctx->resource_manager->load("marker-clear-albedo.png"); + ctx->marker_albedo_textures[1] = ctx->resource_manager->load("marker-yellow-albedo.png"); + ctx->marker_albedo_textures[2] = ctx->resource_manager->load("marker-green-albedo.png"); + ctx->marker_albedo_textures[3] = ctx->resource_manager->load("marker-blue-albedo.png"); + ctx->marker_albedo_textures[4] = ctx->resource_manager->load("marker-purple-albedo.png"); + ctx->marker_albedo_textures[5] = ctx->resource_manager->load("marker-pink-albedo.png"); + ctx->marker_albedo_textures[6] = ctx->resource_manager->load("marker-red-albedo.png"); + ctx->marker_albedo_textures[7] = ctx->resource_manager->load("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("splash.png"); + const gl::texture_2d* splash_texture = ctx->resource_manager->load("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("ui-element-textured.glsl")); - ctx->splash_billboard_material->add_property("background")->set_value(splash_texture); + ctx->splash_billboard_material->set_shader_program(ctx->resource_manager->load("ui-element-textured.glsl")); + ctx->splash_billboard_material->add_property("background")->set_value(splash_texture); ctx->splash_billboard_material->add_property("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("ui-element-textured.glsl")); - depth_debug_material->add_property("background")->set_value(shadow_map_depth_texture); + depth_debug_material->set_shader_program(ctx->resource_manager->load("ui-element-textured.glsl")); + depth_debug_material->add_property("background")->set_value(shadow_map_depth_texture); depth_debug_material->add_property("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("fade-transition.glsl")); + ctx->fade_transition->get_material()->set_shader_program(ctx->resource_manager->load("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("radial-transition-inner.glsl")); + ctx->radial_transition_inner->get_material()->set_shader_program(ctx->resource_manager->load("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("radial-transition-outer.glsl")); + ctx->radial_transition_outer->get_material()->set_shader_program(ctx->resource_manager->load("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(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*>(albedo_property)->set_value(marker_albedo_texture); + static_cast*>(albedo_property)->set_value(marker_albedo_texture); } } } @@ -1173,7 +1173,7 @@ void setup_controls(game_context* ctx) { auto& marker_component = ctx->ecs_registry->get(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*>(albedo_property)->set_value(marker_albedo_texture); + static_cast*>(albedo_property)->set_value(marker_albedo_texture); } } } diff --git a/src/game/game-context.hpp b/src/game/game-context.hpp index c9733b4..567898b 100644 --- a/src/game/game-context.hpp +++ b/src/game/game-context.hpp @@ -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 #include #include @@ -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* 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* underground_color_texture_property; + material_property* underground_color_texture_property; compositor* overworld_compositor; compositor* underworld_compositor; compositor* ui_compositor; diff --git a/src/game/states/map-state.cpp b/src/game/states/map-state.cpp index 71726ed..c411ca0 100644 --- a/src/game/states/map-state.cpp +++ b/src/game/states/map-state.cpp @@ -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" diff --git a/src/game/states/play-state.cpp b/src/game/states/play-state.cpp index fd30565..f723cc1 100644 --- a/src/game/states/play-state.cpp +++ b/src/game/states/play-state.cpp @@ -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" diff --git a/src/game/states/splash-state.cpp b/src/game/states/splash-state.cpp index 45e790b..019c1cb 100644 --- a/src/game/states/splash-state.cpp +++ b/src/game/states/splash-state.cpp @@ -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" diff --git a/src/rasterizer/buffer-usage.hpp b/src/gl/buffer-usage.hpp similarity index 86% rename from src/rasterizer/buffer-usage.hpp rename to src/gl/buffer-usage.hpp index 5d86ff7..9b0a266 100644 --- a/src/rasterizer/buffer-usage.hpp +++ b/src/gl/buffer-usage.hpp @@ -17,8 +17,10 @@ * along with Antkeeper source code. If not, see . */ -#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 diff --git a/src/rasterizer/color-space.hpp b/src/gl/color-space.hpp similarity index 85% rename from src/rasterizer/color-space.hpp rename to src/gl/color-space.hpp index c6f14de..b6aa806 100644 --- a/src/rasterizer/color-space.hpp +++ b/src/gl/color-space.hpp @@ -17,8 +17,10 @@ * along with Antkeeper source code. If not, see . */ -#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 diff --git a/src/rasterizer/drawing-mode.hpp b/src/gl/drawing-mode.hpp similarity index 86% rename from src/rasterizer/drawing-mode.hpp rename to src/gl/drawing-mode.hpp index ca7f358..5be33bc 100644 --- a/src/rasterizer/drawing-mode.hpp +++ b/src/gl/drawing-mode.hpp @@ -17,8 +17,10 @@ * along with Antkeeper source code. If not, see . */ -#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 diff --git a/src/rasterizer/element-array-type.hpp b/src/gl/element-array-type.hpp similarity index 83% rename from src/rasterizer/element-array-type.hpp rename to src/gl/element-array-type.hpp index dbe5c2e..a086826 100644 --- a/src/rasterizer/element-array-type.hpp +++ b/src/gl/element-array-type.hpp @@ -17,8 +17,10 @@ * along with Antkeeper source code. If not, see . */ -#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 diff --git a/src/rasterizer/framebuffer.cpp b/src/gl/framebuffer.cpp similarity index 96% rename from src/rasterizer/framebuffer.cpp rename to src/gl/framebuffer.cpp index 56cb4a2..6265795 100644 --- a/src/rasterizer/framebuffer.cpp +++ b/src/gl/framebuffer.cpp @@ -17,10 +17,12 @@ * along with Antkeeper source code. If not, see . */ -#include "rasterizer/framebuffer.hpp" -#include "rasterizer/texture-2d.hpp" +#include "gl/framebuffer.hpp" +#include "gl/texture-2d.hpp" #include +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 diff --git a/src/rasterizer/framebuffer.hpp b/src/gl/framebuffer.hpp similarity index 94% rename from src/rasterizer/framebuffer.hpp rename to src/gl/framebuffer.hpp index f983dd3..f404928 100644 --- a/src/rasterizer/framebuffer.hpp +++ b/src/gl/framebuffer.hpp @@ -17,11 +17,13 @@ * along with Antkeeper source code. If not, see . */ -#ifndef ANTKEEPER_FRAMEBUFFER_HPP -#define ANTKEEPER_FRAMEBUFFER_HPP +#ifndef ANTKEEPER_GL_FRAMEBUFFER_HPP +#define ANTKEEPER_GL_FRAMEBUFFER_HPP #include +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 diff --git a/src/rasterizer/gl.hpp b/src/gl/gl.hpp similarity index 57% rename from src/rasterizer/gl.hpp rename to src/gl/gl.hpp index b7670e2..aeec32b 100644 --- a/src/rasterizer/gl.hpp +++ b/src/gl/gl.hpp @@ -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 diff --git a/src/rasterizer/pixel-format.hpp b/src/gl/pixel-format.hpp similarity index 87% rename from src/rasterizer/pixel-format.hpp rename to src/gl/pixel-format.hpp index 2b6de2e..b9d38aa 100644 --- a/src/rasterizer/pixel-format.hpp +++ b/src/gl/pixel-format.hpp @@ -17,8 +17,10 @@ * along with Antkeeper source code. If not, see . */ -#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 diff --git a/src/rasterizer/pixel-type.hpp b/src/gl/pixel-type.hpp similarity index 85% rename from src/rasterizer/pixel-type.hpp rename to src/gl/pixel-type.hpp index f85d82c..727c8ad 100644 --- a/src/rasterizer/pixel-type.hpp +++ b/src/gl/pixel-type.hpp @@ -17,8 +17,10 @@ * along with Antkeeper source code. If not, see . */ -#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 diff --git a/src/rasterizer/rasterizer.cpp b/src/gl/rasterizer.cpp similarity index 94% rename from src/rasterizer/rasterizer.cpp rename to src/gl/rasterizer.cpp index 378de2b..b1cb71f 100644 --- a/src/rasterizer/rasterizer.cpp +++ b/src/gl/rasterizer.cpp @@ -17,12 +17,14 @@ * along with Antkeeper source code. If not, see . */ -#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 +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(count), gl_type, (const GLvoid*)offset); } +} // namespace gl diff --git a/src/rasterizer/rasterizer.hpp b/src/gl/rasterizer.hpp similarity index 94% rename from src/rasterizer/rasterizer.hpp rename to src/gl/rasterizer.hpp index 1383adf..b5a7206 100644 --- a/src/rasterizer/rasterizer.hpp +++ b/src/gl/rasterizer.hpp @@ -17,11 +17,13 @@ * along with Antkeeper source code. If not, see . */ -#ifndef ANTKEEPER_RASTERIZER_HPP -#define ANTKEEPER_RASTERIZER_HPP +#ifndef ANTKEEPER_GL_RASTERIZER_HPP +#define ANTKEEPER_GL_RASTERIZER_HPP #include +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 diff --git a/src/rasterizer/shader-input.cpp b/src/gl/shader-input.cpp similarity index 99% rename from src/rasterizer/shader-input.cpp rename to src/gl/shader-input.cpp index 9127704..35e4d34 100644 --- a/src/rasterizer/shader-input.cpp +++ b/src/gl/shader-input.cpp @@ -17,11 +17,13 @@ * along with Antkeeper source code. If not, see . */ -#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 +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 diff --git a/src/rasterizer/shader-input.hpp b/src/gl/shader-input.hpp similarity index 97% rename from src/rasterizer/shader-input.hpp rename to src/gl/shader-input.hpp index d60ccdd..2cfd7de 100644 --- a/src/rasterizer/shader-input.hpp +++ b/src/gl/shader-input.hpp @@ -17,12 +17,14 @@ * along with Antkeeper source code. If not, see . */ -#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 +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 diff --git a/src/rasterizer/shader-program.cpp b/src/gl/shader-program.cpp similarity index 97% rename from src/rasterizer/shader-program.cpp rename to src/gl/shader-program.cpp index cbd75ce..f053594 100644 --- a/src/rasterizer/shader-program.cpp +++ b/src/gl/shader-program.cpp @@ -17,13 +17,15 @@ * along with Antkeeper source code. If not, see . */ -#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 #include +namespace gl { + shader_program::shader_program(const std::list& shaders): gl_program_id(0) { @@ -221,3 +223,4 @@ std::string shader_program::get_info_log() const return std::string(); } +} // namespace gl diff --git a/src/rasterizer/shader-program.hpp b/src/gl/shader-program.hpp similarity index 92% rename from src/rasterizer/shader-program.hpp rename to src/gl/shader-program.hpp index ba770c8..61b593e 100644 --- a/src/rasterizer/shader-program.hpp +++ b/src/gl/shader-program.hpp @@ -17,14 +17,16 @@ * along with Antkeeper source code. If not, see . */ -#ifndef ANTKEEPER_SHADER_PROGRAM_HPP -#define ANTKEEPER_SHADER_PROGRAM_HPP +#ifndef ANTKEEPER_GL_SHADER_PROGRAM_HPP +#define ANTKEEPER_GL_SHADER_PROGRAM_HPP #include #include #include #include +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 diff --git a/src/rasterizer/shader-type.hpp b/src/gl/shader-type.hpp similarity index 85% rename from src/rasterizer/shader-type.hpp rename to src/gl/shader-type.hpp index 7441594..648c0b7 100644 --- a/src/rasterizer/shader-type.hpp +++ b/src/gl/shader-type.hpp @@ -17,8 +17,10 @@ * along with Antkeeper source code. If not, see . */ -#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 diff --git a/src/rasterizer/shader-variable-type.hpp b/src/gl/shader-variable-type.hpp similarity index 85% rename from src/rasterizer/shader-variable-type.hpp rename to src/gl/shader-variable-type.hpp index 654ecf6..2aa3a58 100644 --- a/src/rasterizer/shader-variable-type.hpp +++ b/src/gl/shader-variable-type.hpp @@ -17,8 +17,10 @@ * along with Antkeeper source code. If not, see . */ -#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 diff --git a/src/rasterizer/shader.cpp b/src/gl/shader.cpp similarity index 96% rename from src/rasterizer/shader.cpp rename to src/gl/shader.cpp index ae4d111..91a9ec5 100644 --- a/src/rasterizer/shader.cpp +++ b/src/gl/shader.cpp @@ -17,10 +17,12 @@ * along with Antkeeper source code. If not, see . */ -#include "rasterizer/shader.hpp" +#include "gl/shader.hpp" #include #include +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 diff --git a/src/rasterizer/shader.hpp b/src/gl/shader.hpp similarity index 90% rename from src/rasterizer/shader.hpp rename to src/gl/shader.hpp index 7281463..2eeadd8 100644 --- a/src/rasterizer/shader.hpp +++ b/src/gl/shader.hpp @@ -17,12 +17,14 @@ * along with Antkeeper source code. If not, see . */ -#ifndef ANTKEEPER_SHADER_HPP -#define ANTKEEPER_SHADER_HPP +#ifndef ANTKEEPER_GL_SHADER_HPP +#define ANTKEEPER_GL_SHADER_HPP #include #include +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 diff --git a/src/rasterizer/texture-2d.cpp b/src/gl/texture-2d.cpp similarity index 92% rename from src/rasterizer/texture-2d.cpp rename to src/gl/texture-2d.cpp index e287d01..2979c69 100644 --- a/src/rasterizer/texture-2d.cpp +++ b/src/gl/texture-2d.cpp @@ -17,12 +17,14 @@ * along with Antkeeper source code. If not, see . */ -#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 #include +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(format)][static_cast(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 diff --git a/src/rasterizer/texture-2d.hpp b/src/gl/texture-2d.hpp similarity index 83% rename from src/rasterizer/texture-2d.hpp rename to src/gl/texture-2d.hpp index 01a06e7..e3d3dd1 100644 --- a/src/rasterizer/texture-2d.hpp +++ b/src/gl/texture-2d.hpp @@ -17,14 +17,16 @@ * along with Antkeeper source code. If not, see . */ -#ifndef ANTKEEPER_TEXTURE_2D_HPP -#define ANTKEEPER_TEXTURE_2D_HPP +#ifndef ANTKEEPER_GL_TEXTURE_2D_HPP +#define ANTKEEPER_GL_TEXTURE_2D_HPP #include #include -#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 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 wrapping; std::tuple 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 diff --git a/src/rasterizer/texture-cube.cpp b/src/gl/texture-cube.cpp similarity index 93% rename from src/rasterizer/texture-cube.cpp rename to src/gl/texture-cube.cpp index e32e3bd..e6656fe 100644 --- a/src/rasterizer/texture-cube.cpp +++ b/src/gl/texture-cube.cpp @@ -17,9 +17,11 @@ * along with Antkeeper source code. If not, see . */ -#include "rasterizer/texture-cube.hpp" +#include "gl/texture-cube.hpp" #include +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 \ No newline at end of file diff --git a/src/rasterizer/texture-cube.hpp b/src/gl/texture-cube.hpp similarity index 89% rename from src/rasterizer/texture-cube.hpp rename to src/gl/texture-cube.hpp index ccf288f..009d012 100644 --- a/src/rasterizer/texture-cube.hpp +++ b/src/gl/texture-cube.hpp @@ -17,8 +17,10 @@ * along with Antkeeper source code. If not, see . */ -#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 diff --git a/src/rasterizer/texture-filter.hpp b/src/gl/texture-filter.hpp similarity index 86% rename from src/rasterizer/texture-filter.hpp rename to src/gl/texture-filter.hpp index e5e611b..d65a48c 100644 --- a/src/rasterizer/texture-filter.hpp +++ b/src/gl/texture-filter.hpp @@ -17,8 +17,10 @@ * along with Antkeeper source code. If not, see . */ -#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 diff --git a/src/rasterizer/texture-wrapping.hpp b/src/gl/texture-wrapping.hpp similarity index 83% rename from src/rasterizer/texture-wrapping.hpp rename to src/gl/texture-wrapping.hpp index bd20716..f1e6e79 100644 --- a/src/rasterizer/texture-wrapping.hpp +++ b/src/gl/texture-wrapping.hpp @@ -17,8 +17,10 @@ * along with Antkeeper source code. If not, see . */ -#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 diff --git a/src/rasterizer/vertex-array.cpp b/src/gl/vertex-array.cpp similarity index 94% rename from src/rasterizer/vertex-array.cpp rename to src/gl/vertex-array.cpp index 0cccf9a..2960591 100644 --- a/src/rasterizer/vertex-array.cpp +++ b/src/gl/vertex-array.cpp @@ -17,10 +17,12 @@ * along with Antkeeper source code. If not, see . */ -#include "rasterizer/vertex-array.hpp" -#include "rasterizer/vertex-buffer.hpp" +#include "gl/vertex-array.hpp" +#include "gl/vertex-buffer.hpp" #include +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 diff --git a/src/rasterizer/vertex-array.hpp b/src/gl/vertex-array.hpp similarity index 89% rename from src/rasterizer/vertex-array.hpp rename to src/gl/vertex-array.hpp index e1adecd..c886ae1 100644 --- a/src/rasterizer/vertex-array.hpp +++ b/src/gl/vertex-array.hpp @@ -17,11 +17,13 @@ * along with Antkeeper source code. If not, see . */ -#ifndef ANTKEEPER_VERTEX_ARRAY_HPP -#define ANTKEEPER_VERTEX_ARRAY_HPP +#ifndef ANTKEEPER_GL_VERTEX_ARRAY_HPP +#define ANTKEEPER_GL_VERTEX_ARRAY_HPP #include +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 diff --git a/src/rasterizer/vertex-attribute-type.hpp b/src/gl/vertex-attribute-type.hpp similarity index 83% rename from src/rasterizer/vertex-attribute-type.hpp rename to src/gl/vertex-attribute-type.hpp index 8785545..4e934f7 100644 --- a/src/rasterizer/vertex-attribute-type.hpp +++ b/src/gl/vertex-attribute-type.hpp @@ -17,8 +17,10 @@ * along with Antkeeper source code. If not, see . */ -#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 diff --git a/src/rasterizer/vertex-buffer.cpp b/src/gl/vertex-buffer.cpp similarity index 96% rename from src/rasterizer/vertex-buffer.cpp rename to src/gl/vertex-buffer.cpp index d4dec4a..b397b98 100644 --- a/src/rasterizer/vertex-buffer.cpp +++ b/src/gl/vertex-buffer.cpp @@ -17,9 +17,11 @@ * along with Antkeeper source code. If not, see . */ -#include "rasterizer/vertex-buffer.hpp" +#include "gl/vertex-buffer.hpp" #include +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 diff --git a/src/rasterizer/vertex-buffer.hpp b/src/gl/vertex-buffer.hpp similarity index 90% rename from src/rasterizer/vertex-buffer.hpp rename to src/gl/vertex-buffer.hpp index 987e706..c2113c5 100644 --- a/src/rasterizer/vertex-buffer.hpp +++ b/src/gl/vertex-buffer.hpp @@ -17,11 +17,13 @@ * along with Antkeeper source code. If not, see . */ -#ifndef ANTKEEPER_VERTEX_BUFFER_HPP -#define ANTKEEPER_VERTEX_BUFFER_HPP +#ifndef ANTKEEPER_GL_VERTEX_BUFFER_HPP +#define ANTKEEPER_GL_VERTEX_BUFFER_HPP #include -#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 diff --git a/src/rasterizer/buffer-usage.cpp b/src/rasterizer/buffer-usage.cpp deleted file mode 100644 index 5d86ff7..0000000 --- a/src/rasterizer/buffer-usage.cpp +++ /dev/null @@ -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 . - */ - -#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 - diff --git a/src/renderer/material-property.cpp b/src/renderer/material-property.cpp index 1b28d44..692d812 100644 --- a/src/renderer/material-property.cpp +++ b/src/renderer/material-property.cpp @@ -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()) { diff --git a/src/renderer/material-property.hpp b/src/renderer/material-property.hpp index da9b815..5677778 100644 --- a/src/renderer/material-property.hpp +++ b/src/renderer/material-property.hpp @@ -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 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::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::bool1; + return gl::shader_variable_type::bool1; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::bool2; + return gl::shader_variable_type::bool2; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::bool3; + return gl::shader_variable_type::bool3; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::bool4; + return gl::shader_variable_type::bool4; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::int1; + return gl::shader_variable_type::int1; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::int2; + return gl::shader_variable_type::int2; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::int3; + return gl::shader_variable_type::int3; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::int4; + return gl::shader_variable_type::int4; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::uint1; + return gl::shader_variable_type::uint1; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::uint2; + return gl::shader_variable_type::uint2; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::uint3; + return gl::shader_variable_type::uint3; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::uint4; + return gl::shader_variable_type::uint4; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::float1; + return gl::shader_variable_type::float1; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::float2; + return gl::shader_variable_type::float2; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::float3; + return gl::shader_variable_type::float3; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::float4; + return gl::shader_variable_type::float4; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::float2x2; + return gl::shader_variable_type::float2x2; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::float3x3; + return gl::shader_variable_type::float3x3; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::float4x4; + return gl::shader_variable_type::float4x4; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::texture_2d; + return gl::shader_variable_type::texture_2d; } template <> -inline shader_variable_type material_property::get_data_type() const +inline gl::shader_variable_type material_property::get_data_type() const { - return shader_variable_type::texture_cube; + return gl::shader_variable_type::texture_cube; } template diff --git a/src/renderer/material.cpp b/src/renderer/material.cpp index f4fb398..a4426df 100644 --- a/src/renderer/material.cpp +++ b/src/renderer/material.cpp @@ -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(); diff --git a/src/renderer/material.hpp b/src/renderer/material.hpp index 30f7b9f..2d4d33e 100644 --- a/src/renderer/material.hpp +++ b/src/renderer/material.hpp @@ -21,7 +21,7 @@ #define ANTKEEPER_MATERIAL_HPP #include "renderer/material-property.hpp" -#include "rasterizer/shader-program.hpp" +#include "gl/shader-program.hpp" #include #include #include @@ -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 properties; std::map 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; } diff --git a/src/renderer/model.cpp b/src/renderer/model.cpp index 23a907a..998cd54 100644 --- a/src/renderer/model.cpp +++ b/src/renderer/model.cpp @@ -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; diff --git a/src/renderer/model.hpp b/src/renderer/model.hpp index e77ca7f..ae509a9 100644 --- a/src/renderer/model.hpp +++ b/src/renderer/model.hpp @@ -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 #include @@ -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* 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 groups; std::map 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; } diff --git a/src/renderer/passes/bloom-pass.cpp b/src/renderer/passes/bloom-pass.cpp index ae0f867..2504574 100644 --- a/src/renderer/passes/bloom-pass.cpp +++ b/src/renderer/passes/bloom-pass.cpp @@ -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 #include -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("brightness-threshold.glsl"); + threshold_shader = resource_manager->load("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("blur.glsl"); + blur_shader = resource_manager->load("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; } diff --git a/src/renderer/passes/bloom-pass.hpp b/src/renderer/passes/bloom-pass.hpp index 50a06a7..f6b68c7 100644 --- a/src/renderer/passes/bloom-pass.hpp +++ b/src/renderer/passes/bloom-pass.hpp @@ -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; }; diff --git a/src/renderer/passes/clear-pass.cpp b/src/renderer/passes/clear-pass.cpp index 62eb447..563a8ce 100644 --- a/src/renderer/passes/clear-pass.cpp +++ b/src/renderer/passes/clear-pass.cpp @@ -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 -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), diff --git a/src/renderer/passes/clear-pass.hpp b/src/renderer/passes/clear-pass.hpp index 223f6fb..f9ffe29 100644 --- a/src/renderer/passes/clear-pass.hpp +++ b/src/renderer/passes/clear-pass.hpp @@ -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; diff --git a/src/renderer/passes/final-pass.cpp b/src/renderer/passes/final-pass.cpp index 320ae4d..4444829 100644 --- a/src/renderer/passes/final-pass.cpp +++ b/src/renderer/passes/final-pass.cpp @@ -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 #include -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("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; } diff --git a/src/renderer/passes/final-pass.hpp b/src/renderer/passes/final-pass.hpp index 1f2e58a..fecccf9 100644 --- a/src/renderer/passes/final-pass.hpp +++ b/src/renderer/passes/final-pass.hpp @@ -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 diff --git a/src/renderer/passes/material-pass.cpp b/src/renderer/passes/material-pass.cpp index 42b651f..5509dac 100644 --- a/src/renderer/passes/material-pass.cpp +++ b/src/renderer/passes/material-pass.cpp @@ -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("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("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(); diff --git a/src/renderer/passes/material-pass.hpp b/src/renderer/passes/material-pass.hpp index a3f5e07..91899a6 100644 --- a/src/renderer/passes/material-pass.hpp +++ b/src/renderer/passes/material-pass.hpp @@ -27,12 +27,12 @@ #include "event/event-handler.hpp" #include "event/input-events.hpp" #include +#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 { 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* 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 parameter_sets; + mutable std::unordered_map parameter_sets; const material* fallback_material; const tween* time_tween; float2 mouse_position; const tween* focal_point_tween; - texture_2d* soft_shadows_texture; + gl::texture_2d* soft_shadows_texture; float shadow_strength; int max_ambient_light_count; diff --git a/src/renderer/passes/outline-pass.cpp b/src/renderer/passes/outline-pass.cpp index 997a14d..1edd48d 100644 --- a/src/renderer/passes/outline-pass.cpp +++ b/src/renderer/passes/outline-pass.cpp @@ -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 #include -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("outline-fill-unskinned.glsl"); + fill_shader = resource_manager->load("outline-fill-unskinned.glsl"); fill_model_view_projection_input = fill_shader->get_input("model_view_projection"); // Load stroke shader - stroke_shader = resource_manager->load("outline-stroke-unskinned.glsl"); + stroke_shader = resource_manager->load("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"); diff --git a/src/renderer/passes/outline-pass.hpp b/src/renderer/passes/outline-pass.hpp index 67f4d39..149092f 100644 --- a/src/renderer/passes/outline-pass.hpp +++ b/src/renderer/passes/outline-pass.hpp @@ -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; diff --git a/src/renderer/passes/shadow-map-pass.cpp b/src/renderer/passes/shadow-map-pass.cpp index bc03721..e745c76 100644 --- a/src/renderer/passes/shadow-map-pass.cpp +++ b/src/renderer/passes/shadow-map-pass.cpp @@ -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("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("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; diff --git a/src/renderer/passes/shadow-map-pass.hpp b/src/renderer/passes/shadow-map-pass.hpp index 0f908ca..3167d3c 100644 --- a/src/renderer/passes/shadow-map-pass.hpp +++ b/src/renderer/passes/shadow-map-pass.hpp @@ -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]; diff --git a/src/renderer/passes/sky-pass.cpp b/src/renderer/passes/sky-pass.cpp index 67322fe..c14d707 100644 --- a/src/renderer/passes/sky-pass.cpp +++ b/src/renderer/passes/sky-pass.cpp @@ -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 #include -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; } diff --git a/src/renderer/passes/sky-pass.hpp b/src/renderer/passes/sky-pass.hpp index 16e02df..11f88f0 100644 --- a/src/renderer/passes/sky-pass.hpp +++ b/src/renderer/passes/sky-pass.hpp @@ -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 { 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* 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* time_tween; diff --git a/src/renderer/passes/ui-pass.cpp b/src/renderer/passes/ui-pass.cpp index 19db104..f8c598f 100644 --- a/src/renderer/passes/ui-pass.cpp +++ b/src/renderer/passes/ui-pass.cpp @@ -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 #include -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(); diff --git a/src/renderer/passes/ui-pass.hpp b/src/renderer/passes/ui-pass.hpp index 081fc15..6ef682b 100644 --- a/src/renderer/passes/ui-pass.hpp +++ b/src/renderer/passes/ui-pass.hpp @@ -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 -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 parameter_sets; + mutable std::unordered_map parameter_sets; float time; }; diff --git a/src/renderer/render-operation.hpp b/src/renderer/render-operation.hpp index 4893c64..4cd07ba 100644 --- a/src/renderer/render-operation.hpp +++ b/src/renderer/render-operation.hpp @@ -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 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; diff --git a/src/renderer/render-pass.cpp b/src/renderer/render-pass.cpp index 7b0f267..1020649 100644 --- a/src/renderer/render-pass.cpp +++ b/src/renderer/render-pass.cpp @@ -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) diff --git a/src/renderer/render-pass.hpp b/src/renderer/render-pass.hpp index a41fafc..69412aa 100644 --- a/src/renderer/render-pass.hpp +++ b/src/renderer/render-pass.hpp @@ -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; diff --git a/src/renderer/renderer.cpp b/src/renderer/renderer.cpp index 1da1031..87f87be 100644 --- a/src/renderer/renderer.cpp +++ b/src/renderer/renderer.cpp @@ -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; } diff --git a/src/renderer/renderer.hpp b/src/renderer/renderer.hpp index 4247aeb..0d7536b 100644 --- a/src/renderer/renderer.hpp +++ b/src/renderer/renderer.hpp @@ -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; diff --git a/src/renderer/simple-render-pass.cpp b/src/renderer/simple-render-pass.cpp index 919f2ee..4ee257b 100644 --- a/src/renderer/simple-render-pass.cpp +++ b/src/renderer/simple-render-pass.cpp @@ -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 -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* time) diff --git a/src/renderer/simple-render-pass.hpp b/src/renderer/simple-render-pass.hpp index 0f56e09..bbc38db 100644 --- a/src/renderer/simple-render-pass.hpp +++ b/src/renderer/simple-render-pass.hpp @@ -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 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* time_property; material_property* resolution_property; const tween* 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 diff --git a/src/resources/material-loader.cpp b/src/resources/material-loader.cpp index 63c5641..da68acf 100644 --- a/src/resources/material-loader.cpp +++ b/src/resources/material-loader.cpp @@ -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 #include #include -static const std::map texture_wrapping_map = +static const std::map 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 texture_min_filter_map = +static const std::map 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 texture_mag_filter_map = +static const std::map 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(std::stod(row[offset + 5])); - texture_2d* texture = resource_manager->load(row[4 + i]); + gl::texture_2d* texture = resource_manager->load(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* property = material->add_property(row[1], array_size); + material_property* property = material->add_property(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(row[1]); + gl::shader_program* program = resource_manager->load(row[1]); material->set_shader_program(program); } else if (row[0] == "flags" && row.size() == 2) diff --git a/src/resources/model-loader.cpp b/src/resources/model-loader.cpp index 097a914..e6a4635 100644 --- a/src/resources/model-loader.cpp +++ b/src/resources/model-loader.cpp @@ -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 #include @@ -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(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); diff --git a/src/resources/shader-program-loader.cpp b/src/resources/shader-program-loader.cpp index 59c2e96..cc86484 100644 --- a/src/resources/shader-program-loader.cpp +++ b/src/resources/shader-program-loader.cpp @@ -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 #include @@ -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 detect_shader_types(text_file* source) +static std::list detect_shader_types(text_file* source) { - std::list types; + std::list 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::load(resource_manager* resource_manager, PHYSFS_File* file) +gl::shader_program* resource_loader::load(resource_manager* resource_manager, PHYSFS_File* file) { // Load shader source text_file* source = resource_loader::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_types = detect_shader_types(source); + std::list shader_types = detect_shader_types(source); // Load detected shaders - std::list shaders; - for (shader_type type: shader_types) + std::list 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; } diff --git a/src/resources/texture-2d-loader.cpp b/src/resources/texture-2d-loader.cpp index cdbc130..b331a7d 100644 --- a/src/resources/texture-2d-loader.cpp +++ b/src/resources/texture-2d-loader.cpp @@ -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 template <> -texture_2d* resource_loader::load(resource_manager* resource_manager, PHYSFS_File* file) +gl::texture_2d* resource_loader::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;