From 317d4809ee4abde6433dcacc80c291c4f32ac85c Mon Sep 17 00:00:00 2001 From: 3a2l Date: Wed, 4 Nov 2020 11:19:03 +0000 Subject: [PATCH] Define the base assets path using CMake. --- CMakeLists.txt | 4 +- source/examples/ex02_shader_introduction.cpp | 4 +- source/examples/ex03_uniforms.cpp | 4 +- source/examples/ex04_varyings.cpp | 4 +- source/examples/ex05_attributes.cpp | 4 +- source/examples/ex06_multiple_attributes.cpp | 4 +- .../examples/ex07_interleaved_attributes.cpp | 4 +- source/examples/ex08_elements.cpp | 4 +- source/examples/ex09_stream.cpp | 4 +- source/examples/ex10_model_loading.cpp | 6 +-- source/examples/ex11_transformation.cpp | 4 +- source/examples/ex12_composition.cpp | 4 +- source/examples/ex13_camera.cpp | 4 +- source/examples/ex14_projection.cpp | 4 +- source/examples/ex15_depth_testing.cpp | 4 +- source/examples/ex16_face_culling.cpp | 4 +- .../examples/ex17_viewports_and_scissors.cpp | 4 +- source/examples/ex18_camera_stacking.cpp | 4 +- source/examples/ex19_ray_casting.cpp | 4 +- source/examples/ex20_scene_graphs.cpp | 10 ++--- source/examples/ex21_texture.cpp | 8 ++-- source/examples/ex22_texture_sampling.cpp | 10 ++--- source/examples/ex23_sampler_objects.cpp | 12 +++--- source/examples/ex24_displacement.cpp | 20 ++++----- source/examples/ex25_blending.cpp | 20 ++++----- source/examples/ex26_frame_buffer.cpp | 14 +++---- source/examples/ex27_postprocessing.cpp | 26 ++++++------ .../examples/ex28_multiple_render_targets.cpp | 18 ++++---- source/examples/ex29_light.cpp | 16 +++---- source/examples/ex30_light_array.cpp | 8 ++-- source/examples/ex31_light_multipass.cpp | 16 +++---- source/examples/ex32_textured_material.cpp | 42 +++++++++---------- 32 files changed, 150 insertions(+), 148 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94e720b..4453b66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,8 @@ include_directories( vendor/utils ) +add_definitions(-DASSETS_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/assets\") + # For each example, we add an executable target # Each target compiles one example source file and the common & vendor source files # Then we link GLFW with each target @@ -144,4 +146,4 @@ add_executable(EX31_LIGHT_MULTIPASS source/examples/ex31_light_multipass.cpp ${C target_link_libraries(EX31_LIGHT_MULTIPASS glfw) add_executable(EX32_TEXTURED_MATERIAL source/examples/ex32_textured_material.cpp ${COMMON_SOURCES} ${VENDOR_SOURCES}) -target_link_libraries(EX32_TEXTURED_MATERIAL glfw) \ No newline at end of file +target_link_libraries(EX32_TEXTURED_MATERIAL glfw) diff --git a/source/examples/ex02_shader_introduction.cpp b/source/examples/ex02_shader_introduction.cpp index 02d1a30..1ba5045 100644 --- a/source/examples/ex02_shader_introduction.cpp +++ b/source/examples/ex02_shader_introduction.cpp @@ -94,8 +94,8 @@ class ShaderIntroductionApplication : public our::Application { program = glCreateProgram(); // We ask GL to create a program for us and return a uint that we will use it by. // (act as a pointer to the created program). - attachShader(program, "assets/shaders/ex02_shader_introduction/triangle.vert", GL_VERTEX_SHADER); // read the vertex shader and attach it to the program. - attachShader(program, "assets/shaders/ex02_shader_introduction/red.frag", GL_FRAGMENT_SHADER); // read the fragment shader and attach it to the program. + attachShader(program, ASSETS_DIR "/shaders/ex02_shader_introduction/triangle.vert", GL_VERTEX_SHADER); // read the vertex shader and attach it to the program. + attachShader(program, ASSETS_DIR "/shaders/ex02_shader_introduction/red.frag", GL_FRAGMENT_SHADER); // read the fragment shader and attach it to the program. glLinkProgram(program); // Link the vertex and fragment shader together. checkProgramLinkingErrors(program); // Check if there is any link errors between the fragment shader and vertex shader. diff --git a/source/examples/ex03_uniforms.cpp b/source/examples/ex03_uniforms.cpp index c75e79e..70aa652 100644 --- a/source/examples/ex03_uniforms.cpp +++ b/source/examples/ex03_uniforms.cpp @@ -18,8 +18,8 @@ class UniformsApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex03_uniforms/quad.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex03_uniforms/uniform_color.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex03_uniforms/quad.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex03_uniforms/uniform_color.frag", GL_FRAGMENT_SHADER); program.link(); glGenVertexArrays(1, &vertex_array); diff --git a/source/examples/ex04_varyings.cpp b/source/examples/ex04_varyings.cpp index f9cddb5..5574dd1 100644 --- a/source/examples/ex04_varyings.cpp +++ b/source/examples/ex04_varyings.cpp @@ -13,8 +13,8 @@ class VaryingsApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex04_varyings/colored_triangle.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex04_varyings/varying_color.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex04_varyings/colored_triangle.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex04_varyings/varying_color.frag", GL_FRAGMENT_SHADER); program.link(); glGenVertexArrays(1, &vertex_array); diff --git a/source/examples/ex05_attributes.cpp b/source/examples/ex05_attributes.cpp index 914f52c..3df7d64 100644 --- a/source/examples/ex05_attributes.cpp +++ b/source/examples/ex05_attributes.cpp @@ -14,8 +14,8 @@ class AttributesApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex05_attributes/attribute_position.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex02_shader_introduction/red.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex05_attributes/attribute_position.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex02_shader_introduction/red.frag", GL_FRAGMENT_SHADER); program.link(); glGenVertexArrays(1, &vertex_array); diff --git a/source/examples/ex06_multiple_attributes.cpp b/source/examples/ex06_multiple_attributes.cpp index 6eff35d..19f828f 100644 --- a/source/examples/ex06_multiple_attributes.cpp +++ b/source/examples/ex06_multiple_attributes.cpp @@ -14,8 +14,8 @@ class AttributesApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex06_multiple_attributes/multiple_attributes.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex04_varyings/varying_color.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex06_multiple_attributes/multiple_attributes.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex04_varyings/varying_color.frag", GL_FRAGMENT_SHADER); program.link(); glGenVertexArrays(1, &vertex_array); diff --git a/source/examples/ex07_interleaved_attributes.cpp b/source/examples/ex07_interleaved_attributes.cpp index bebf063..d597003 100644 --- a/source/examples/ex07_interleaved_attributes.cpp +++ b/source/examples/ex07_interleaved_attributes.cpp @@ -13,8 +13,8 @@ class AttributesApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex06_multiple_attributes/multiple_attributes.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex04_varyings/varying_color.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex06_multiple_attributes/multiple_attributes.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex04_varyings/varying_color.frag", GL_FRAGMENT_SHADER); program.link(); glGenVertexArrays(1, &vertex_array); diff --git a/source/examples/ex08_elements.cpp b/source/examples/ex08_elements.cpp index 7750681..435e47a 100644 --- a/source/examples/ex08_elements.cpp +++ b/source/examples/ex08_elements.cpp @@ -14,8 +14,8 @@ class ElementsApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex06_multiple_attributes/multiple_attributes.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex04_varyings/varying_color.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex06_multiple_attributes/multiple_attributes.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex04_varyings/varying_color.frag", GL_FRAGMENT_SHADER); program.link(); glGenVertexArrays(1, &vertex_array); diff --git a/source/examples/ex09_stream.cpp b/source/examples/ex09_stream.cpp index 0980796..4df83db 100644 --- a/source/examples/ex09_stream.cpp +++ b/source/examples/ex09_stream.cpp @@ -31,8 +31,8 @@ class ElementsApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex06_multiple_attributes/multiple_attributes.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex04_varyings/varying_color.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex06_multiple_attributes/multiple_attributes.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex04_varyings/varying_color.frag", GL_FRAGMENT_SHADER); program.link(); glGenVertexArrays(1, &vertex_array); diff --git a/source/examples/ex10_model_loading.cpp b/source/examples/ex10_model_loading.cpp index c13aa4a..29b4556 100644 --- a/source/examples/ex10_model_loading.cpp +++ b/source/examples/ex10_model_loading.cpp @@ -25,8 +25,8 @@ class MeshApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex06_multiple_attributes/multiple_attributes.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex04_varyings/varying_color.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex06_multiple_attributes/multiple_attributes.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex04_varyings/varying_color.frag", GL_FRAGMENT_SHADER); program.link(); quad.create({ @@ -48,7 +48,7 @@ class MeshApplication : public our::Application { 2, 3, 0 },GL_STATIC_DRAW); - our::mesh_utils::loadOBJ(model, "assets/models/Suzanne/Suzanne.obj"); + our::mesh_utils::loadOBJ(model, ASSETS_DIR "/models/Suzanne/Suzanne.obj"); } diff --git a/source/examples/ex11_transformation.cpp b/source/examples/ex11_transformation.cpp index 458d559..041bc9c 100644 --- a/source/examples/ex11_transformation.cpp +++ b/source/examples/ex11_transformation.cpp @@ -19,8 +19,8 @@ class TransformationApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); program.link(); quad.create({our::setup_buffer_accessors}); diff --git a/source/examples/ex12_composition.cpp b/source/examples/ex12_composition.cpp index 3dcae86..500c48d 100644 --- a/source/examples/ex12_composition.cpp +++ b/source/examples/ex12_composition.cpp @@ -32,8 +32,8 @@ class CompositionApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); program.link(); quad.create({our::setup_buffer_accessors}); diff --git a/source/examples/ex13_camera.cpp b/source/examples/ex13_camera.cpp index 65a004e..a0e1be4 100644 --- a/source/examples/ex13_camera.cpp +++ b/source/examples/ex13_camera.cpp @@ -38,8 +38,8 @@ class CameraApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); program.link(); quad.create({our::setup_buffer_accessors}); diff --git a/source/examples/ex14_projection.cpp b/source/examples/ex14_projection.cpp index fdceeb7..27f12d8 100644 --- a/source/examples/ex14_projection.cpp +++ b/source/examples/ex14_projection.cpp @@ -52,8 +52,8 @@ class CameraProjectionApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); program.link(); our::mesh_utils::Cuboid(model, true); diff --git a/source/examples/ex15_depth_testing.cpp b/source/examples/ex15_depth_testing.cpp index a6dbe29..41601fc 100644 --- a/source/examples/ex15_depth_testing.cpp +++ b/source/examples/ex15_depth_testing.cpp @@ -47,8 +47,8 @@ class DepthTestingApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); program.link(); our::mesh_utils::Cuboid(model, true); diff --git a/source/examples/ex16_face_culling.cpp b/source/examples/ex16_face_culling.cpp index e629844..a89cc58 100644 --- a/source/examples/ex16_face_culling.cpp +++ b/source/examples/ex16_face_culling.cpp @@ -51,8 +51,8 @@ class DepthTestingAndFaceCullingApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); program.link(); triangle.create({our::setup_buffer_accessors}); diff --git a/source/examples/ex17_viewports_and_scissors.cpp b/source/examples/ex17_viewports_and_scissors.cpp index 249b9f6..d07dae0 100644 --- a/source/examples/ex17_viewports_and_scissors.cpp +++ b/source/examples/ex17_viewports_and_scissors.cpp @@ -52,8 +52,8 @@ class ViewportsApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); program.link(); our::mesh_utils::Cuboid(model, true); diff --git a/source/examples/ex18_camera_stacking.cpp b/source/examples/ex18_camera_stacking.cpp index 41dc7b1..f2879d6 100644 --- a/source/examples/ex18_camera_stacking.cpp +++ b/source/examples/ex18_camera_stacking.cpp @@ -45,8 +45,8 @@ class CameraStackApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); program.link(); our::mesh_utils::Cuboid(model, true); diff --git a/source/examples/ex19_ray_casting.cpp b/source/examples/ex19_ray_casting.cpp index 93b3bb4..b9ceff4 100644 --- a/source/examples/ex19_ray_casting.cpp +++ b/source/examples/ex19_ray_casting.cpp @@ -50,8 +50,8 @@ class RayCastingApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); program.link(); our::mesh_utils::Cuboid(model, true); diff --git a/source/examples/ex20_scene_graphs.cpp b/source/examples/ex20_scene_graphs.cpp index 228c325..aa57aaf 100644 --- a/source/examples/ex20_scene_graphs.cpp +++ b/source/examples/ex20_scene_graphs.cpp @@ -63,8 +63,8 @@ class SceneGraphApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/transform.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex11_transformation/tint.frag", GL_FRAGMENT_SHADER); program.link(); meshes["cube"] = std::make_unique(); @@ -84,9 +84,9 @@ class SceneGraphApplication : public our::Application { controller.initialize(this, &camera); - roots["simple"] = loadSceneGraph("assets/data/ex20_scene_graphs/simple.json"); - roots["solar-system"] = loadSceneGraph("assets/data/ex20_scene_graphs/solar-system.json"); - roots["human"] = loadSceneGraph("assets/data/ex20_scene_graphs/human.json"); + roots["simple"] = loadSceneGraph(ASSETS_DIR "/data/ex20_scene_graphs/simple.json"); + roots["solar-system"] = loadSceneGraph(ASSETS_DIR "/data/ex20_scene_graphs/solar-system.json"); + roots["human"] = loadSceneGraph(ASSETS_DIR "/data/ex20_scene_graphs/human.json"); current_root_name = "simple"; glEnable(GL_DEPTH_TEST); diff --git a/source/examples/ex21_texture.cpp b/source/examples/ex21_texture.cpp index bc2ea39..9c52e9e 100644 --- a/source/examples/ex21_texture.cpp +++ b/source/examples/ex21_texture.cpp @@ -22,8 +22,8 @@ class TextureApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex21_texture/fullscreen_triangle.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex21_texture/texel_fetch.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex21_texture/fullscreen_triangle.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex21_texture/texel_fetch.frag", GL_FRAGMENT_SHADER); program.link(); glGenVertexArrays(1, &vertex_array); @@ -93,11 +93,11 @@ class TextureApplication : public our::Application { textures["bubbles"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/color-grid.png"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/color-grid.png"); textures["color-grid"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/moon.jpg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/moon.jpg"); textures["moon"] = texture; current_texture_name = "color-grid"; diff --git a/source/examples/ex22_texture_sampling.cpp b/source/examples/ex22_texture_sampling.cpp index ae13242..316b3b9 100644 --- a/source/examples/ex22_texture_sampling.cpp +++ b/source/examples/ex22_texture_sampling.cpp @@ -45,8 +45,8 @@ class TextureSamplingApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex22_texture_sampling/transform.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex22_texture_sampling/texture.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex22_texture_sampling/transform.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex22_texture_sampling/texture.frag", GL_FRAGMENT_SHADER); program.link(); model.create({ @@ -67,15 +67,15 @@ class TextureSamplingApplication : public our::Application { textures["checkerboard"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/color-grid.png"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/color-grid.png"); textures["color-grid"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/moon.jpg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/moon.jpg"); textures["moon"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/monarch.png"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/monarch.png"); textures["monarch"] = texture; current_texture_name = "color-grid"; diff --git a/source/examples/ex23_sampler_objects.cpp b/source/examples/ex23_sampler_objects.cpp index 5dfef99..0d30ff3 100644 --- a/source/examples/ex23_sampler_objects.cpp +++ b/source/examples/ex23_sampler_objects.cpp @@ -76,8 +76,8 @@ class SamplerObjectsApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex22_texture_sampling/transform.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex22_texture_sampling/texture.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex22_texture_sampling/transform.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex22_texture_sampling/texture.frag", GL_FRAGMENT_SHADER); program.link(); GLuint texture; @@ -87,15 +87,15 @@ class SamplerObjectsApplication : public our::Application { textures["checkerboard"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/models/House/House.jpeg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/models/House/House.jpeg"); textures["house"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/moon.jpg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/moon.jpg"); textures["moon"] = texture; meshes["house"] = std::make_unique(); - our::mesh_utils::loadOBJ(*(meshes["house"]), "assets/models/House/House.obj"); + our::mesh_utils::loadOBJ(*(meshes["house"]), ASSETS_DIR "/models/House/House.obj"); meshes["plane"] = std::make_unique(); our::mesh_utils::Plane(*(meshes["plane"]), {1, 1}, false, {0, 0, 0}, {1, 1}, {0, 0}, {100, 100}); meshes["sphere"] = std::make_unique(); @@ -114,7 +114,7 @@ class SamplerObjectsApplication : public our::Application { camera_controller.initialize(this, &camera); camera_controller.setFieldOfViewSensitivity(0.05f ); - std::ifstream file_in("assets/data/ex23_sampler_objects/scene.json"); + std::ifstream file_in(ASSETS_DIR "/data/ex23_sampler_objects/scene.json"); nlohmann::json json; file_in >> json; file_in.close(); diff --git a/source/examples/ex24_displacement.cpp b/source/examples/ex24_displacement.cpp index 3351606..9a74dfe 100644 --- a/source/examples/ex24_displacement.cpp +++ b/source/examples/ex24_displacement.cpp @@ -56,36 +56,36 @@ class DisplacementApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex24_displacement/terrain.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex24_displacement/terrain.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex24_displacement/terrain.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex24_displacement/terrain.frag", GL_FRAGMENT_SHADER); program.link(); GLuint texture; glGenTextures(1, &texture); - our::texture_utils::loadImageGrayscale(texture, "assets/images/ex24_displacement/Heightmap_Default.png"); + our::texture_utils::loadImageGrayscale(texture, ASSETS_DIR "/images/ex24_displacement/Heightmap_Default.png"); height_textures["default"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImageGrayscale(texture, "assets/images/ex24_displacement/Heightmap_Billow.png"); + our::texture_utils::loadImageGrayscale(texture, ASSETS_DIR "/images/ex24_displacement/Heightmap_Billow.png"); height_textures["billow"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImageGrayscale(texture, "assets/images/ex24_displacement/Heightmap_Island.png"); + our::texture_utils::loadImageGrayscale(texture, ASSETS_DIR "/images/ex24_displacement/Heightmap_Island.png"); height_textures["island"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImageGrayscale(texture, "assets/images/ex24_displacement/Heightmap_Mountain.png"); + our::texture_utils::loadImageGrayscale(texture, ASSETS_DIR "/images/ex24_displacement/Heightmap_Mountain.png"); height_textures["mountain"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImageGrayscale(texture, "assets/images/ex24_displacement/Heightmap_Plateau.png"); + our::texture_utils::loadImageGrayscale(texture, ASSETS_DIR "/images/ex24_displacement/Heightmap_Plateau.png"); height_textures["plateau"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImageGrayscale(texture, "assets/images/ex24_displacement/Heightmap_Rocky.png"); + our::texture_utils::loadImageGrayscale(texture, ASSETS_DIR "/images/ex24_displacement/Heightmap_Rocky.png"); height_textures["rocky"] = texture; current_height_texture_name = "default"; glGenTextures(1, &top_texture); - our::texture_utils::loadImage(top_texture, "assets/images/ex24_displacement/mntn_white_d.jpg"); + our::texture_utils::loadImage(top_texture, ASSETS_DIR "/images/ex24_displacement/mntn_white_d.jpg"); glGenTextures(1, &bottom_texture); - our::texture_utils::loadImage(bottom_texture, "assets/images/ex24_displacement/grass_ground_d.jpg"); + our::texture_utils::loadImage(bottom_texture, ASSETS_DIR "/images/ex24_displacement/grass_ground_d.jpg"); our::mesh_utils::Plane(plane, {512, 512}, false); diff --git a/source/examples/ex25_blending.cpp b/source/examples/ex25_blending.cpp index da161ad..c3db59d 100644 --- a/source/examples/ex25_blending.cpp +++ b/source/examples/ex25_blending.cpp @@ -110,12 +110,12 @@ class BlendingApplication : public our::Application { void onInitialize() override { default_program.create(); - default_program.attach("assets/shaders/ex22_texture_sampling/transform.vert", GL_VERTEX_SHADER); - default_program.attach("assets/shaders/ex22_texture_sampling/texture.frag", GL_FRAGMENT_SHADER); + default_program.attach(ASSETS_DIR "/shaders/ex22_texture_sampling/transform.vert", GL_VERTEX_SHADER); + default_program.attach(ASSETS_DIR "/shaders/ex22_texture_sampling/texture.frag", GL_FRAGMENT_SHADER); default_program.link(); alpha_test_program.create(); - alpha_test_program.attach("assets/shaders/ex22_texture_sampling/transform.vert", GL_VERTEX_SHADER); - alpha_test_program.attach("assets/shaders/ex25_blending/alpha_test.frag", GL_FRAGMENT_SHADER); + alpha_test_program.attach(ASSETS_DIR "/shaders/ex22_texture_sampling/transform.vert", GL_VERTEX_SHADER); + alpha_test_program.attach(ASSETS_DIR "/shaders/ex25_blending/alpha_test.frag", GL_FRAGMENT_SHADER); alpha_test_program.link(); @@ -127,19 +127,19 @@ class BlendingApplication : public our::Application { our::texture_utils::checkerBoard(texture, {256,256}, {128,128}, {255, 255, 255, 255}, {16, 16, 16, 255}); textures["checkerboard"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/color-grid.png"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/color-grid.png"); textures["color-grid"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/moon.jpg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/moon.jpg"); textures["moon"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/ex25_blending/glass-panels.png"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/ex25_blending/glass-panels.png"); textures["glass-panels"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/ex25_blending/metal.png"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/ex25_blending/metal.png"); textures["metal"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/ex25_blending/fog.png"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/ex25_blending/fog.png"); textures["fog"] = texture; meshes["cube"] = std::make_shared(); @@ -166,7 +166,7 @@ class BlendingApplication : public our::Application { camera_controller.initialize(this, &camera); camera_controller.setFieldOfViewSensitivity(0.05f ); - std::ifstream file_in("assets/data/ex25_blending/scene.json"); + std::ifstream file_in(ASSETS_DIR "/data/ex25_blending/scene.json"); nlohmann::json json; file_in >> json; file_in.close(); diff --git a/source/examples/ex26_frame_buffer.cpp b/source/examples/ex26_frame_buffer.cpp index 4c41562..f9d3170 100644 --- a/source/examples/ex26_frame_buffer.cpp +++ b/source/examples/ex26_frame_buffer.cpp @@ -75,8 +75,8 @@ class FrameBufferApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex22_texture_sampling/transform.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex22_texture_sampling/texture.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex22_texture_sampling/transform.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex22_texture_sampling/texture.frag", GL_FRAGMENT_SHADER); program.link(); GLuint texture; @@ -85,10 +85,10 @@ class FrameBufferApplication : public our::Application { our::texture_utils::checkerBoard(texture, {256, 256}, {128, 128}, {255, 255, 255, 255}, {16, 16, 16, 255}); textures["checkerboard"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/models/House/House.jpeg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/models/House/House.jpeg"); textures["house"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/moon.jpg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/moon.jpg"); textures["moon"] = texture; GLuint rt_levels = glm::floor(glm::log2(glm::max(rt_size.x, rt_size.y))) + 1; @@ -102,7 +102,7 @@ class FrameBufferApplication : public our::Application { textures["depth_rt"] = texture; meshes["house"] = std::make_unique(); - our::mesh_utils::loadOBJ(*(meshes["house"]), "assets/models/House/House.obj"); + our::mesh_utils::loadOBJ(*(meshes["house"]), ASSETS_DIR "/models/House/House.obj"); meshes["plane"] = std::make_unique(); our::mesh_utils::Plane(*(meshes["plane"]), {1, 1}, false, {0, 0, 0}, {1, 1}, {0, 0}, {100, 100}); meshes["sphere"] = std::make_unique(); @@ -134,8 +134,8 @@ class FrameBufferApplication : public our::Application { internal_camera_controller.initialize(this, &internal_camera); - root = loadSceneGraph("assets/data/ex26_frame_buffer/external.json"); - internal_root = loadSceneGraph("assets/data/ex23_sampler_objects/scene.json"); + root = loadSceneGraph(ASSETS_DIR "/data/ex26_frame_buffer/external.json"); + internal_root = loadSceneGraph(ASSETS_DIR "/data/ex23_sampler_objects/scene.json"); glGenFramebuffers(1, &frame_buffer); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frame_buffer); diff --git a/source/examples/ex27_postprocessing.cpp b/source/examples/ex27_postprocessing.cpp index 0143d27..6f929cf 100644 --- a/source/examples/ex27_postprocessing.cpp +++ b/source/examples/ex27_postprocessing.cpp @@ -100,20 +100,20 @@ class PostProcessingApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex22_texture_sampling/transform.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex22_texture_sampling/texture.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex22_texture_sampling/transform.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex22_texture_sampling/texture.frag", GL_FRAGMENT_SHADER); program.link(); blit.effect_program.create(); - blit.effect_program.attach("assets/shaders/ex27_postprocessing/fullscreen_triangle.vert", GL_VERTEX_SHADER); - blit.effect_program.attach("assets/shaders/ex27_postprocessing/blit.frag", GL_FRAGMENT_SHADER); + blit.effect_program.attach(ASSETS_DIR "/shaders/ex27_postprocessing/fullscreen_triangle.vert", GL_VERTEX_SHADER); + blit.effect_program.attach(ASSETS_DIR "/shaders/ex27_postprocessing/blit.frag", GL_FRAGMENT_SHADER); blit.effect_program.link(); distortion.effect_program.create(); - distortion.effect_program.attach("assets/shaders/ex27_postprocessing/fullscreen_triangle.vert", GL_VERTEX_SHADER); - distortion.effect_program.attach("assets/shaders/ex27_postprocessing/distortion.frag", GL_FRAGMENT_SHADER); + distortion.effect_program.attach(ASSETS_DIR "/shaders/ex27_postprocessing/fullscreen_triangle.vert", GL_VERTEX_SHADER); + distortion.effect_program.attach(ASSETS_DIR "/shaders/ex27_postprocessing/distortion.frag", GL_FRAGMENT_SHADER); distortion.effect_program.link(); fog.effect_program.create(); - fog.effect_program.attach("assets/shaders/ex27_postprocessing/fullscreen_triangle.vert", GL_VERTEX_SHADER); - fog.effect_program.attach("assets/shaders/ex27_postprocessing/fog.frag", GL_FRAGMENT_SHADER); + fog.effect_program.attach(ASSETS_DIR "/shaders/ex27_postprocessing/fullscreen_triangle.vert", GL_VERTEX_SHADER); + fog.effect_program.attach(ASSETS_DIR "/shaders/ex27_postprocessing/fog.frag", GL_FRAGMENT_SHADER); fog.effect_program.link(); GLuint texture; @@ -122,13 +122,13 @@ class PostProcessingApplication : public our::Application { our::texture_utils::checkerBoard(texture, {256, 256}, {128, 128}, {255, 255, 255, 255}, {16, 16, 16, 255}); textures["checkerboard"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/models/House/House.jpeg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/models/House/House.jpeg"); textures["house"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/moon.jpg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/moon.jpg"); textures["moon"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/ex27_postprocessing/water-normal.png"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/ex27_postprocessing/water-normal.png"); textures["water-normal"] = texture; int width, height; @@ -145,7 +145,7 @@ class PostProcessingApplication : public our::Application { textures["depth_rt"] = texture; meshes["house"] = std::make_unique(); - our::mesh_utils::loadOBJ(*(meshes["house"]), "assets/models/House/House.obj"); + our::mesh_utils::loadOBJ(*(meshes["house"]), ASSETS_DIR "/models/House/House.obj"); meshes["plane"] = std::make_unique(); our::mesh_utils::Plane(*(meshes["plane"]), {1, 1}, false, {0, 0, 0}, {1, 1}, {0, 0}, {100, 100}); meshes["sphere"] = std::make_unique(); @@ -172,7 +172,7 @@ class PostProcessingApplication : public our::Application { camera_controller.initialize(this, &camera); - root = loadSceneGraph("assets/data/ex23_sampler_objects/scene.json"); + root = loadSceneGraph(ASSETS_DIR "/data/ex23_sampler_objects/scene.json"); glGenFramebuffers(1, &frame_buffer); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frame_buffer); diff --git a/source/examples/ex28_multiple_render_targets.cpp b/source/examples/ex28_multiple_render_targets.cpp index c396b60..d17daeb 100644 --- a/source/examples/ex28_multiple_render_targets.cpp +++ b/source/examples/ex28_multiple_render_targets.cpp @@ -73,12 +73,12 @@ class MultipleRenderTargetsApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex22_texture_sampling/transform.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex28_multiple_render_targets/mrt.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex22_texture_sampling/transform.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex28_multiple_render_targets/mrt.frag", GL_FRAGMENT_SHADER); program.link(); blit_program.create(); - blit_program.attach("assets/shaders/ex27_postprocessing/fullscreen_triangle.vert", GL_VERTEX_SHADER); - blit_program.attach("assets/shaders/ex27_postprocessing/blit.frag", GL_FRAGMENT_SHADER); + blit_program.attach(ASSETS_DIR "/shaders/ex27_postprocessing/fullscreen_triangle.vert", GL_VERTEX_SHADER); + blit_program.attach(ASSETS_DIR "/shaders/ex27_postprocessing/blit.frag", GL_FRAGMENT_SHADER); blit_program.link(); GLuint texture; @@ -87,13 +87,13 @@ class MultipleRenderTargetsApplication : public our::Application { our::texture_utils::checkerBoard(texture, {256, 256}, {128, 128}, {255, 255, 255, 255}, {16, 16, 16, 255}); textures["checkerboard"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/models/House/House.jpeg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/models/House/House.jpeg"); textures["house"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/moon.jpg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/moon.jpg"); textures["moon"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/ex27_postprocessing/water-normal.png"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/ex27_postprocessing/water-normal.png"); textures["water-normal"] = texture; int width, height; @@ -118,7 +118,7 @@ class MultipleRenderTargetsApplication : public our::Application { textures["tex_coord_derivative_rt"] = texture; meshes["house"] = std::make_unique(); - our::mesh_utils::loadOBJ(*(meshes["house"]), "assets/models/House/House.obj"); + our::mesh_utils::loadOBJ(*(meshes["house"]), ASSETS_DIR "/models/House/House.obj"); meshes["plane"] = std::make_unique(); our::mesh_utils::Plane(*(meshes["plane"]), {1, 1}, false, {0, 0, 0}, {1, 1}, {0, 0}, {100, 100}); meshes["sphere"] = std::make_unique(); @@ -145,7 +145,7 @@ class MultipleRenderTargetsApplication : public our::Application { camera_controller.initialize(this, &camera); - root = loadSceneGraph("assets/data/ex23_sampler_objects/scene.json"); + root = loadSceneGraph(ASSETS_DIR "/data/ex23_sampler_objects/scene.json"); glGenFramebuffers(1, &frame_buffer); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frame_buffer); diff --git a/source/examples/ex29_light.cpp b/source/examples/ex29_light.cpp index 3f15263..bf5b1ae 100644 --- a/source/examples/ex29_light.cpp +++ b/source/examples/ex29_light.cpp @@ -102,20 +102,20 @@ class LightApplication : public our::Application { void onInitialize() override { programs[LightType::DIRECTIONAL].create(); - programs[LightType::DIRECTIONAL].attach("assets/shaders/ex29_light/light_transform.vert", GL_VERTEX_SHADER); - programs[LightType::DIRECTIONAL].attach("assets/shaders/ex29_light/directional_light.frag", GL_FRAGMENT_SHADER); + programs[LightType::DIRECTIONAL].attach(ASSETS_DIR "/shaders/ex29_light/light_transform.vert", GL_VERTEX_SHADER); + programs[LightType::DIRECTIONAL].attach(ASSETS_DIR "/shaders/ex29_light/directional_light.frag", GL_FRAGMENT_SHADER); programs[LightType::DIRECTIONAL].link(); programs[LightType::POINT].create(); - programs[LightType::POINT].attach("assets/shaders/ex29_light/light_transform.vert", GL_VERTEX_SHADER); - programs[LightType::POINT].attach("assets/shaders/ex29_light/point_light.frag", GL_FRAGMENT_SHADER); + programs[LightType::POINT].attach(ASSETS_DIR "/shaders/ex29_light/light_transform.vert", GL_VERTEX_SHADER); + programs[LightType::POINT].attach(ASSETS_DIR "/shaders/ex29_light/point_light.frag", GL_FRAGMENT_SHADER); programs[LightType::POINT].link(); programs[LightType::SPOT].create(); - programs[LightType::SPOT].attach("assets/shaders/ex29_light/light_transform.vert", GL_VERTEX_SHADER); - programs[LightType::SPOT].attach("assets/shaders/ex29_light/spot_light.frag", GL_FRAGMENT_SHADER); + programs[LightType::SPOT].attach(ASSETS_DIR "/shaders/ex29_light/light_transform.vert", GL_VERTEX_SHADER); + programs[LightType::SPOT].attach(ASSETS_DIR "/shaders/ex29_light/spot_light.frag", GL_FRAGMENT_SHADER); programs[LightType::SPOT].link(); meshes["suzanne"] = std::make_unique(); - our::mesh_utils::loadOBJ(*(meshes["suzanne"]), "assets/models/Suzanne/Suzanne.obj"); + our::mesh_utils::loadOBJ(*(meshes["suzanne"]), ASSETS_DIR "/models/Suzanne/Suzanne.obj"); meshes["plane"] = std::make_unique(); our::mesh_utils::Plane(*(meshes["plane"]), {1, 1}, false, {0, 0, 0}, {1, 1}, {0, 0}, {100, 100}); meshes["sphere"] = std::make_unique(); @@ -133,7 +133,7 @@ class LightApplication : public our::Application { camera_controller.initialize(this, &camera); camera_controller.setFieldOfViewSensitivity(0.05f ); - std::ifstream file_in("assets/data/ex29_light/scene.json"); + std::ifstream file_in(ASSETS_DIR "/data/ex29_light/scene.json"); nlohmann::json json; file_in >> json; file_in.close(); diff --git a/source/examples/ex30_light_array.cpp b/source/examples/ex30_light_array.cpp index 440da4d..b915e4a 100644 --- a/source/examples/ex30_light_array.cpp +++ b/source/examples/ex30_light_array.cpp @@ -103,13 +103,13 @@ class LightArrayApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex29_light/light_transform.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex30_light_array/light_array.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex29_light/light_transform.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex30_light_array/light_array.frag", GL_FRAGMENT_SHADER); program.link(); meshes["suzanne"] = std::make_unique(); - our::mesh_utils::loadOBJ(*(meshes["suzanne"]), "assets/models/Suzanne/Suzanne.obj"); + our::mesh_utils::loadOBJ(*(meshes["suzanne"]), ASSETS_DIR "/models/Suzanne/Suzanne.obj"); meshes["plane"] = std::make_unique(); our::mesh_utils::Plane(*(meshes["plane"]), {1, 1}, false, {0, 0, 0}, {1, 1}, {0, 0}, {100, 100}); meshes["sphere"] = std::make_unique(); @@ -127,7 +127,7 @@ class LightArrayApplication : public our::Application { camera_controller.initialize(this, &camera); camera_controller.setFieldOfViewSensitivity(0.05f ); - std::ifstream file_in("assets/data/ex29_light/scene.json"); + std::ifstream file_in(ASSETS_DIR "/data/ex29_light/scene.json"); nlohmann::json json; file_in >> json; file_in.close(); diff --git a/source/examples/ex31_light_multipass.cpp b/source/examples/ex31_light_multipass.cpp index 6a94683..7fda50d 100644 --- a/source/examples/ex31_light_multipass.cpp +++ b/source/examples/ex31_light_multipass.cpp @@ -103,20 +103,20 @@ class LightMultipassApplication : public our::Application { void onInitialize() override { programs[LightType::DIRECTIONAL].create(); - programs[LightType::DIRECTIONAL].attach("assets/shaders/ex29_light/light_transform.vert", GL_VERTEX_SHADER); - programs[LightType::DIRECTIONAL].attach("assets/shaders/ex29_light/directional_light.frag", GL_FRAGMENT_SHADER); + programs[LightType::DIRECTIONAL].attach(ASSETS_DIR "/shaders/ex29_light/light_transform.vert", GL_VERTEX_SHADER); + programs[LightType::DIRECTIONAL].attach(ASSETS_DIR "/shaders/ex29_light/directional_light.frag", GL_FRAGMENT_SHADER); programs[LightType::DIRECTIONAL].link(); programs[LightType::POINT].create(); - programs[LightType::POINT].attach("assets/shaders/ex29_light/light_transform.vert", GL_VERTEX_SHADER); - programs[LightType::POINT].attach("assets/shaders/ex29_light/point_light.frag", GL_FRAGMENT_SHADER); + programs[LightType::POINT].attach(ASSETS_DIR "/shaders/ex29_light/light_transform.vert", GL_VERTEX_SHADER); + programs[LightType::POINT].attach(ASSETS_DIR "/shaders/ex29_light/point_light.frag", GL_FRAGMENT_SHADER); programs[LightType::POINT].link(); programs[LightType::SPOT].create(); - programs[LightType::SPOT].attach("assets/shaders/ex29_light/light_transform.vert", GL_VERTEX_SHADER); - programs[LightType::SPOT].attach("assets/shaders/ex29_light/spot_light.frag", GL_FRAGMENT_SHADER); + programs[LightType::SPOT].attach(ASSETS_DIR "/shaders/ex29_light/light_transform.vert", GL_VERTEX_SHADER); + programs[LightType::SPOT].attach(ASSETS_DIR "/shaders/ex29_light/spot_light.frag", GL_FRAGMENT_SHADER); programs[LightType::SPOT].link(); meshes["suzanne"] = std::make_unique(); - our::mesh_utils::loadOBJ(*(meshes["suzanne"]), "assets/models/Suzanne/Suzanne.obj"); + our::mesh_utils::loadOBJ(*(meshes["suzanne"]), ASSETS_DIR "/models/Suzanne/Suzanne.obj"); meshes["plane"] = std::make_unique(); our::mesh_utils::Plane(*(meshes["plane"]), {1, 1}, false, {0, 0, 0}, {1, 1}, {0, 0}, {100, 100}); meshes["sphere"] = std::make_unique(); @@ -134,7 +134,7 @@ class LightMultipassApplication : public our::Application { camera_controller.initialize(this, &camera); camera_controller.setFieldOfViewSensitivity(0.05f ); - std::ifstream file_in("assets/data/ex29_light/scene.json"); + std::ifstream file_in(ASSETS_DIR "/data/ex29_light/scene.json"); nlohmann::json json; file_in >> json; file_in.close(); diff --git a/source/examples/ex32_textured_material.cpp b/source/examples/ex32_textured_material.cpp index cd8414f..88512bb 100644 --- a/source/examples/ex32_textured_material.cpp +++ b/source/examples/ex32_textured_material.cpp @@ -149,18 +149,18 @@ class TexturedMaterialApplication : public our::Application { void onInitialize() override { program.create(); - program.attach("assets/shaders/ex29_light/light_transform.vert", GL_VERTEX_SHADER); - program.attach("assets/shaders/ex32_textured_material/light_array.frag", GL_FRAGMENT_SHADER); + program.attach(ASSETS_DIR "/shaders/ex29_light/light_transform.vert", GL_VERTEX_SHADER); + program.attach(ASSETS_DIR "/shaders/ex32_textured_material/light_array.frag", GL_FRAGMENT_SHADER); program.link(); sky_program.create(); - sky_program.attach("assets/shaders/ex32_textured_material/sky_transform.vert", GL_VERTEX_SHADER); - sky_program.attach("assets/shaders/ex32_textured_material/sky.frag", GL_FRAGMENT_SHADER); + sky_program.attach(ASSETS_DIR "/shaders/ex32_textured_material/sky_transform.vert", GL_VERTEX_SHADER); + sky_program.attach(ASSETS_DIR "/shaders/ex32_textured_material/sky.frag", GL_FRAGMENT_SHADER); sky_program.link(); meshes["suzanne"] = std::make_unique(); - our::mesh_utils::loadOBJ(*(meshes["suzanne"]), "assets/models/Suzanne/Suzanne.obj"); + our::mesh_utils::loadOBJ(*(meshes["suzanne"]), ASSETS_DIR "/models/Suzanne/Suzanne.obj"); meshes["house"] = std::make_unique(); - our::mesh_utils::loadOBJ(*(meshes["house"]), "assets/models/House/House.obj"); + our::mesh_utils::loadOBJ(*(meshes["house"]), ASSETS_DIR "/models/House/House.obj"); meshes["plane"] = std::make_unique(); our::mesh_utils::Plane(*(meshes["plane"]), {1, 1}, false, {0, 0, 0}, {1, 1}, {0, 0}, {100, 100}); meshes["sphere"] = std::make_unique(); @@ -188,48 +188,48 @@ class TexturedMaterialApplication : public our::Application { textures["checkerboard_roughness"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/materials/asphalt/albedo.jpg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/materials/asphalt/albedo.jpg"); textures["asphalt_albedo"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/materials/asphalt/specular.jpg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/materials/asphalt/specular.jpg"); textures["asphalt_specular"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImageGrayscale(texture, "assets/images/common/materials/asphalt/roughness.jpg"); + our::texture_utils::loadImageGrayscale(texture, ASSETS_DIR "/images/common/materials/asphalt/roughness.jpg"); textures["asphalt_roughness"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/materials/asphalt/emissive.jpg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/materials/asphalt/emissive.jpg"); textures["asphalt_emissive"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/materials/metal/albedo.jpg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/materials/metal/albedo.jpg"); textures["metal_albedo"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/materials/metal/specular.jpg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/materials/metal/specular.jpg"); textures["metal_specular"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImageGrayscale(texture, "assets/images/common/materials/metal/roughness.jpg"); + our::texture_utils::loadImageGrayscale(texture, ASSETS_DIR "/images/common/materials/metal/roughness.jpg"); textures["metal_roughness"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/materials/wood/albedo.jpg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/materials/wood/albedo.jpg"); textures["wood_albedo"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/materials/wood/specular.jpg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/materials/wood/specular.jpg"); textures["wood_specular"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImageGrayscale(texture, "assets/images/common/materials/wood/roughness.jpg"); + our::texture_utils::loadImageGrayscale(texture, ASSETS_DIR "/images/common/materials/wood/roughness.jpg"); textures["wood_roughness"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImageGrayscale(texture, "assets/images/common/materials/suzanne/ambient_occlusion.jpg"); + our::texture_utils::loadImageGrayscale(texture, ASSETS_DIR "/images/common/materials/suzanne/ambient_occlusion.jpg"); textures["suzanne_ambient_occlusion"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/models/House/House.jpeg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/models/House/House.jpeg"); textures["house"] = texture; glGenTextures(1, &texture); - our::texture_utils::loadImage(texture, "assets/images/common/moon.jpg"); + our::texture_utils::loadImage(texture, ASSETS_DIR "/images/common/moon.jpg"); textures["moon"] = texture; glGenSamplers(1, &sampler); @@ -253,13 +253,13 @@ class TexturedMaterialApplication : public our::Application { camera_controller.initialize(this, &camera); camera_controller.setFieldOfViewSensitivity(0.05f ); - std::ifstream file_in("assets/data/ex32_textured_material/scene.json"); + std::ifstream file_in(ASSETS_DIR "/data/ex32_textured_material/scene.json"); nlohmann::json json; file_in >> json; file_in.close(); root = loadNode(json); - file_in.open("assets/data/ex32_textured_material/lights.json"); + file_in.open(ASSETS_DIR "/data/ex32_textured_material/lights.json"); file_in >> json; file_in.close(); sky_light = json.value("sky", SkyLight());