Fixed colors in shaders.

This commit is contained in:
2023-04-02 17:45:46 -07:00
parent b3f58ed0ec
commit b20c099fc0
3 changed files with 13 additions and 6 deletions

View File

@ -97,7 +97,8 @@ void ShaderProgram::setBoolean(shaderparameter_t uni, bool value) {
} }
void ShaderProgram::setColor(shaderparameter_t uniform, struct Color color) { 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) { void ShaderProgram::setVector3(shaderparameter_t uniform, glm::vec3 vector) {

View File

@ -43,8 +43,8 @@ namespace Dawn {
camera = Camera::create(this); camera = Camera::create(this);
camera->fov = 0.436332f; camera->fov = 0.436332f;
camera->transform->lookAt(glm::vec3(10, 10, 10), glm::vec3(0, 0, 0)); camera->transform->lookAt(glm::vec3(10, 10, 10), glm::vec3(0, 0, 0));
// auto gameCamera = camera->item->addComponent<GameCamera>(); auto gameCamera = camera->item->addComponent<GameCamera>();
// gameCamera->player = player->player; gameCamera->player = player->player;
} }
std::vector<Asset*> getRequiredAssets() override { std::vector<Asset*> getRequiredAssets() override {

View File

@ -21,8 +21,8 @@ int32_t TextureTool::start() {
if(!in.open(FILE_MODE_READ)) return 1; if(!in.open(FILE_MODE_READ)) return 1;
int w, h, channels; int w, h, channels;
auto dataImage = stbi_load_from_file(in.file, &w, &h, &channels, STBI_rgb_alpha); auto imageRaw = stbi_load_from_file(in.file, &w, &h, &channels, STBI_rgb_alpha);
if(dataImage == NULL) { if(imageRaw == NULL) {
std::cout << "Failed to load input texture!" << std::endl; std::cout << "Failed to load input texture!" << std::endl;
return 1; return 1;
} }
@ -30,6 +30,12 @@ int32_t TextureTool::start() {
// Convert to floating points // Convert to floating points
size_t len = STBI_rgb_alpha * w * h; 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 // Open and create output
File out(flags["output"] + ".texture"); 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; std::cout << "Failed to write texture data for " << out.filename << std::endl;
return 1; return 1;
} }
stbi_image_free(dataImage); free(dataImage);
return 0; return 0;
} }