carpy-breakout/pkg/globject/material.go

40 lines
897 B
Go

package globject
import (
"git.wisellama.rocks/Wisellama/carpy-breakout/pkg/glshader"
"github.com/go-gl/mathgl/mgl32"
)
type Material struct {
TextureDiffuse int32
TextureSpecular int32
Shininess float32
Color mgl32.Vec4
TextureOn bool
TextureID uint32
}
func NewMaterial() *Material {
m := Material{
Shininess: 128.0,
Color: mgl32.Vec4{1, 1, 1, 1},
TextureOn: false,
}
return &m
}
func (m *Material) GLDraw(glProgram uint32) {
glshader.SetUniformInt(glProgram, "material.textureDiffuse", m.TextureDiffuse)
glshader.SetUniformInt(glProgram, "material.textureSpecular", m.TextureSpecular)
glshader.SetUniformFloat(glProgram, "material.shininess", m.Shininess)
glshader.SetUniformVec4f(glProgram, "material.color", m.Color)
var tOn int32 = 0
if m.TextureOn {
tOn = 1
}
glshader.SetUniformInt(glProgram, "material.textureOn", tOn)
}