1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 08:47:34 +00:00

LibGL: Flesh out glMaterialf{v}

These two functions have been turned from stubs into actually doing
something. They now set the correspondingmaterial data member based on
the value passed into the `pname`argument.

Co-authored-by: Stephan Unverwerth <s.unverwerth@serenityos.org>
This commit is contained in:
Jesse Buhagiar 2022-01-08 17:46:58 +11:00 committed by Linus Groh
parent 9118b0d164
commit 92373ab0b6
7 changed files with 138 additions and 48 deletions

View file

@ -1009,4 +1009,9 @@ void Device::set_light_state(unsigned int light_id, Light const& light)
m_lights.at(light_id) = light;
}
void Device::set_material_state(unsigned int material_id, Material const& material)
{
m_materials.at(material_id) = material;
}
}

View file

@ -23,6 +23,7 @@
#include <LibSoftGPU/Image.h>
#include <LibSoftGPU/ImageFormat.h>
#include <LibSoftGPU/Light/Light.h>
#include <LibSoftGPU/Light/Material.h>
#include <LibSoftGPU/Sampler.h>
#include <LibSoftGPU/Triangle.h>
#include <LibSoftGPU/Vertex.h>
@ -94,6 +95,7 @@ public:
void set_sampler_config(unsigned, SamplerConfig const&);
void set_light_state(unsigned, Light const&);
void set_material_state(unsigned, Material const&);
private:
void draw_statistics_overlay(Gfx::Bitmap&);
@ -115,6 +117,7 @@ private:
Vector<size_t> m_enabled_texture_units;
AlphaBlendFactors m_alpha_blend_factors;
Array<Light, NUM_LIGHTS> m_lights;
Array<Material, 2u> m_materials;
};
}

View file

@ -0,0 +1,25 @@
/*
* Copyright (c) 2022, Jesse Buhagiar <jooster669@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGfx/Vector4.h>
namespace SoftGPU {
struct Material {
Vector4<float> ambient { 0.2f, 0.2f, 0.2f, 1.0f };
Vector4<float> diffuse { 0.8f, 0.8f, 0.8f, 1.0f };
Vector4<float> specular { 0.0f, 0.0f, 0.0f, 1.0f };
Vector4<float> emissive { 0.0f, 0.0f, 0.0f, 1.0f };
float shininess { 0.0f };
float specular_exponent { 0.0f };
float ambient_color_index { 0.0f };
float diffuse_color_index = { 1.0f };
float specular_color_index = { 1.0f };
};
}