From 13e6b34243edf479ae9eab1ad0c0ded573348a7d Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Tue, 7 Dec 2021 20:49:25 -0500 Subject: [PATCH] Pass around a gfx::Shader instead of a shared_ptr --- examples/dev_testing/src/main.cpp | 15 +++++++-------- src/objects/3d/obj_model.cpp | 3 --- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/examples/dev_testing/src/main.cpp b/examples/dev_testing/src/main.cpp index 27415fa..5be195e 100644 --- a/examples/dev_testing/src/main.cpp +++ b/examples/dev_testing/src/main.cpp @@ -35,20 +35,19 @@ int main(int argc, char *argv[]) { std::string vertex_core = read_resource_shader("shaders/vertex_core.glsl"); std::string fragment_core = read_resource_shader("shaders/fragment_core.glsl"); - // Create shader program + // Compile shader program simpleengine::ShaderProgram shader_prog; shader_prog.add_shader_from_source(simpleengine::gfx::ShaderType::ST_Vertex, vertex_core); shader_prog.add_shader_from_source(simpleengine::gfx::ShaderType::ST_Fragment, fragment_core); shader_prog.link(); - std::shared_ptr base_shader_program = shader_prog.program; + simpleengine::gfx::Shader core_shader = shader_prog.shaders.front(); /* simpleengine::gfx::Texture wall_texture("resources/wall.jpg"); simpleengine::gfx::Texture crate_texture("resources/container.jpg", true, true); */ simpleengine::gfx::Texture stall_texture("resources/stallTexture.png"); - auto stall = std::make_shared(game.get_window(), simpleengine::gfx::Shader(base_shader_program), - stall_texture, "resources/stall.obj"); + auto stall = std::make_shared(game.get_window(), core_shader, stall_texture, "resources/stall.obj"); stall->translate(0.f, -4.f, -18.f); game.add_event(stall); @@ -64,7 +63,7 @@ int main(int argc, char *argv[]) { 1, 2, 3 }; - auto square = std::make_shared(game.get_window(), base_shader_program, square_vertices, indicies); + auto square = std::make_shared(game.get_window(), core_shader, square_vertices, indicies); square->translate(1.25f, 0.f, -1.f); square->scale(.75f); game.add_event(square); @@ -75,7 +74,7 @@ int main(int argc, char *argv[]) { { simpleengine::Vectorf(0.f, 0.5f, -1.f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.5f, 1.0f) }, // bottom left }; - auto tri = std::make_shared(game.get_window(), base_shader_program, tri_vertices); + auto tri = std::make_shared(game.get_window(), core_shader, tri_vertices); tri->translate(-1.25f, 0.f, -1.f); tri->scale(.75f); game.add_event(tri); */ @@ -127,10 +126,10 @@ int main(int argc, char *argv[]) { 23,21,22 }; - auto cube = std::make_shared(game.get_window(), base_shader_program, cube_vertices, cube_indicies); + auto cube = std::make_shared(game.get_window(), core_shader, cube_vertices, cube_indicies); game.add_event(cube); */ - auto camera = std::make_shared(game.get_window(), base_shader_program); + auto camera = std::make_shared(game.get_window(), core_shader); game.add_event(camera); return game.run(); diff --git a/src/objects/3d/obj_model.cpp b/src/objects/3d/obj_model.cpp index 0d7946f..770a414 100644 --- a/src/objects/3d/obj_model.cpp +++ b/src/objects/3d/obj_model.cpp @@ -68,9 +68,6 @@ namespace simpleengine::objects_3d { auto size = obj_vertices.size(); textures.resize(size); normals.resize(size); - - std::cout << "Textures should be size of " << size << " but is a size of " << textures.size() << std::endl; - std::cout << "Normals should be size of " << size << " but is a size of " << normals.size() << std::endl; break; } }