43 lines
1.4 KiB
C#

using LearnOpenTK.Common;
using OpenTK.Graphics.OpenGL;
using OpenTK.Mathematics;
namespace TheLabs;
public struct Lighting
{
public Vector3 position;
public Vector3 ambientColour;
public Vector3 diffuseColour;
public Vector3 specularColour;
public float constant;
public float linear;
public float quadratic;
public Lighting(Vector3 pos, Vector3 ambient, Vector3 diffuse, Vector3 specular)
{
position = pos;
ambientColour = ambient;
diffuseColour = diffuse;
specularColour = specular;
constant = 1.0f;
linear = 0.09f;
quadratic = 0.032f;
}
public void Apply(Shader shader)
{
GL.Uniform3(GL.GetUniformLocation(shader.Handle, "uPointLight.position"), ref position);
GL.Uniform3(GL.GetUniformLocation(shader.Handle, "uPointLight.ambientColour"), ref ambientColour);
GL.Uniform3(GL.GetUniformLocation(shader.Handle, "uPointLight.diffuseColour"), ref diffuseColour);
GL.Uniform3(GL.GetUniformLocation(shader.Handle, "uPointLight.specularColour"), ref specularColour);
GL.Uniform1(GL.GetUniformLocation(shader.Handle, "uPointLight.constant"), constant);
GL.Uniform1(GL.GetUniformLocation(shader.Handle, "uPointLight.linear"), linear);
GL.Uniform1(GL.GetUniformLocation(shader.Handle, "uPointLight.quadratic"), quadratic);
}
}