From b20c099fc0ba7edfe95ee54bf1919c31b24dc099 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Sun, 2 Apr 2023 17:45:46 -0700 Subject: [PATCH] Fixed colors in shaders. --- src/dawnopengl/display/shader/ShaderProgram.cpp | 3 ++- src/dawnrose/scenes/HelloWorldScene.hpp | 4 ++-- src/dawntools/texturetool/TextureTool.cpp | 12 +++++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/dawnopengl/display/shader/ShaderProgram.cpp b/src/dawnopengl/display/shader/ShaderProgram.cpp index 58b5e52e..b649ecec 100644 --- a/src/dawnopengl/display/shader/ShaderProgram.cpp +++ b/src/dawnopengl/display/shader/ShaderProgram.cpp @@ -97,7 +97,8 @@ void ShaderProgram::setBoolean(shaderparameter_t uni, bool value) { } void ShaderProgram::setColor(shaderparameter_t uniform, struct Color color) { - glUniform4f(uniform, color.r, color.g, color.b, color.a); + auto precise = color.precision(); + glUniform4f(uniform, precise.r, precise.g, precise.b, precise.a); } void ShaderProgram::setVector3(shaderparameter_t uniform, glm::vec3 vector) { diff --git a/src/dawnrose/scenes/HelloWorldScene.hpp b/src/dawnrose/scenes/HelloWorldScene.hpp index 81c4ab1a..a3d3e819 100644 --- a/src/dawnrose/scenes/HelloWorldScene.hpp +++ b/src/dawnrose/scenes/HelloWorldScene.hpp @@ -43,8 +43,8 @@ namespace Dawn { camera = Camera::create(this); camera->fov = 0.436332f; camera->transform->lookAt(glm::vec3(10, 10, 10), glm::vec3(0, 0, 0)); - // auto gameCamera = camera->item->addComponent(); - // gameCamera->player = player->player; + auto gameCamera = camera->item->addComponent(); + gameCamera->player = player->player; } std::vector getRequiredAssets() override { diff --git a/src/dawntools/texturetool/TextureTool.cpp b/src/dawntools/texturetool/TextureTool.cpp index c472029a..adafb4dd 100644 --- a/src/dawntools/texturetool/TextureTool.cpp +++ b/src/dawntools/texturetool/TextureTool.cpp @@ -21,8 +21,8 @@ int32_t TextureTool::start() { if(!in.open(FILE_MODE_READ)) return 1; int w, h, channels; - auto dataImage = stbi_load_from_file(in.file, &w, &h, &channels, STBI_rgb_alpha); - if(dataImage == NULL) { + auto imageRaw = stbi_load_from_file(in.file, &w, &h, &channels, STBI_rgb_alpha); + if(imageRaw == NULL) { std::cout << "Failed to load input texture!" << std::endl; return 1; } @@ -30,6 +30,12 @@ int32_t TextureTool::start() { // Convert to floating points size_t len = STBI_rgb_alpha * w * h; + uint8_t *dataImage = (uint8_t*)malloc(sizeof(uint8_t) * len); + for(size_t i = 0; i < len; i++) { + auto dataIn = imageRaw[i]; + dataImage[i] = dataIn; + } + stbi_image_free(imageRaw); // Open and create output File out(flags["output"] + ".texture"); @@ -55,7 +61,7 @@ int32_t TextureTool::start() { std::cout << "Failed to write texture data for " << out.filename << std::endl; return 1; } - stbi_image_free(dataImage); + free(dataImage); return 0; } \ No newline at end of file