Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
target_link_libraries(EX32_TEXTURED_MATERIAL glfw)
4 changes: 2 additions & 2 deletions source/examples/ex02_shader_introduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions source/examples/ex03_uniforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions source/examples/ex04_varyings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions source/examples/ex05_attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions source/examples/ex06_multiple_attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions source/examples/ex07_interleaved_attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions source/examples/ex08_elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions source/examples/ex09_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions source/examples/ex10_model_loading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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");

}

Expand Down
4 changes: 2 additions & 2 deletions source/examples/ex11_transformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<our::ColoredVertex>});
Expand Down
4 changes: 2 additions & 2 deletions source/examples/ex12_composition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<our::ColoredVertex>});
Expand Down
4 changes: 2 additions & 2 deletions source/examples/ex13_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<our::ColoredVertex>});
Expand Down
4 changes: 2 additions & 2 deletions source/examples/ex14_projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions source/examples/ex15_depth_testing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions source/examples/ex16_face_culling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<our::ColoredVertex>});
Expand Down
4 changes: 2 additions & 2 deletions source/examples/ex17_viewports_and_scissors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions source/examples/ex18_camera_stacking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions source/examples/ex19_ray_casting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions source/examples/ex20_scene_graphs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<our::Mesh>();
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions source/examples/ex21_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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";
Expand Down
10 changes: 5 additions & 5 deletions source/examples/ex22_texture_sampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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";
Expand Down
12 changes: 6 additions & 6 deletions source/examples/ex23_sampler_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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>();
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>();
our::mesh_utils::Plane(*(meshes["plane"]), {1, 1}, false, {0, 0, 0}, {1, 1}, {0, 0}, {100, 100});
meshes["sphere"] = std::make_unique<our::Mesh>();
Expand All @@ -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();
Expand Down
Loading