carpy-breakout/pkg/gl_objects/point_light.go

33 lines
860 B
Go

package gl_objects
import (
"github.com/go-gl/mathgl/mgl32"
"gitea.wisellama.rocks/Wisellama/carpy-breakout/pkg/gl_helpers"
)
// Point Light
type PointLight struct {
Position mgl32.Vec3
AmbientColor mgl32.Vec4
DiffuseColor mgl32.Vec4
SpecularColor mgl32.Vec4
}
func NewPointLight(position mgl32.Vec3) *PointLight {
d := PointLight{
Position: position,
AmbientColor: mgl32.Vec4{0.2, 0.2, 0.2, 1},
DiffuseColor: mgl32.Vec4{1, 1, 1, 1},
SpecularColor: mgl32.Vec4{1, 1, 1, 1},
}
return &d
}
func (l *PointLight) GLInit(glProgram uint32) {
gl_helpers.SetUniformVec3f(glProgram, "light.position", l.Position)
gl_helpers.SetUniformVec4f(glProgram, "light.ambient", l.AmbientColor)
gl_helpers.SetUniformVec4f(glProgram, "light.diffuse", l.DiffuseColor)
gl_helpers.SetUniformVec4f(glProgram, "light.specular", l.SpecularColor)
}