From fd1f745ff0f89b8b44977382c41629299d52773c Mon Sep 17 00:00:00 2001 From: Vanessa Karolek <vaka1997@uni-koblenz.de> Date: Tue, 31 Aug 2021 14:36:56 +0200 Subject: [PATCH] [#94] replace vkcv::sfrScene::TextureData by vkcv::asset::Texture --- projects/saf_r/src/main.cpp | 2 +- projects/saf_r/src/safrScene.cpp | 9 +++++---- projects/saf_r/src/safrScene.hpp | 12 +----------- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/projects/saf_r/src/main.cpp b/projects/saf_r/src/main.cpp index a39ad8e8..e1b87366 100644 --- a/projects/saf_r/src/main.cpp +++ b/projects/saf_r/src/main.cpp @@ -101,7 +101,7 @@ int main(int argc, const char** argv) { lights.push_back(safrScene::Light(glm::vec3(30, 20, 30), 1.7)); //create the raytracer image for rendering safrScene scene; - safrScene::TextureData texData = scene.render(spheres, lights); + vkcv::asset::Texture texData = scene.render(spheres, lights); vkcv::Image texture = core.createImage(vk::Format::eR8G8B8A8Unorm, texData.width, texData.height); texture.fill(texData.data.data()); diff --git a/projects/saf_r/src/safrScene.cpp b/projects/saf_r/src/safrScene.cpp index aacf879a..38a40605 100644 --- a/projects/saf_r/src/safrScene.cpp +++ b/projects/saf_r/src/safrScene.cpp @@ -56,7 +56,7 @@ glm::vec3 safrScene::castRay(const glm::vec3& orig, const glm::vec3& dir, const glm::vec3(1., 1., 1.) * specular_light_intensity * material.albedo[1] + reflect_color * material.albedo[2]; } -safrScene::TextureData safrScene::render(const std::vector<safrScene::Sphere>& spheres, const std::vector<safrScene::Light>& lights) { +vkcv::asset::Texture safrScene::render(const std::vector<safrScene::Sphere>& spheres, const std::vector<safrScene::Light>& lights) { //constants for the image data const int width = 800; const int height = 600; @@ -86,12 +86,13 @@ safrScene::TextureData safrScene::render(const std::vector<safrScene::Sphere>& s data.push_back(static_cast<uint8_t>(255.f)); } - safrScene::TextureData textureData; + vkcv::asset::Texture textureData; + textureData.width = width; textureData.height = height; - textureData.componentCount = 4; + textureData.channels = 4; - textureData.data.resize(textureData.width * textureData.height * textureData.componentCount); + textureData.data.resize(textureData.width * textureData.height * textureData.channels); memcpy(textureData.data.data(), data.data(), textureData.data.size()); return textureData; } \ No newline at end of file diff --git a/projects/saf_r/src/safrScene.hpp b/projects/saf_r/src/safrScene.hpp index a3396afe..09fdf5e5 100644 --- a/projects/saf_r/src/safrScene.hpp +++ b/projects/saf_r/src/safrScene.hpp @@ -14,16 +14,6 @@ class safrScene { public: - /** - * WORKAROUND - * moved the texture data struct from the old asset loader version, because it is necessary for our rendering for now - */ - struct TextureData { - int width; - int height; - int componentCount; - std::vector<char*> data; - }; /* * Light struct with a position and intensity of the light source */ @@ -79,7 +69,7 @@ public: * @param vector: all light sources in the scene * @return TextureData: texture data for the buffers */ - TextureData render(const std::vector<Sphere>& spheres, const std::vector<Light>& lights); + vkcv::asset::Texture render(const std::vector<Sphere>& spheres, const std::vector<Light>& lights); private: /* -- GitLab