Correct loading of png textures to match opengl coords

This commit is contained in:
bloeys
2022-02-23 07:28:12 +04:00
parent 592208d5c9
commit f16407629a
2 changed files with 6 additions and 3 deletions

View File

@ -50,7 +50,7 @@ func LoadPNGTexture(file string) (Texture, error) {
//NOTE: We only support 8-bit channels (32-bit colors) for now
i := 0
for y := 0; y < img.Bounds().Dy(); y++ {
for y := img.Bounds().Dy() - 1; y >= 0; y-- {
for x := 0; x < img.Bounds().Dx(); x++ {
c := color.NRGBAModel.Convert(img.At(x, y)).(color.NRGBA)

View File

@ -26,6 +26,7 @@ import (
//Flesh out the material system
//Low Priority:
// Abstract keys enum away from sdl
// Abstract UI
// Proper Asset loading
@ -137,8 +138,10 @@ func (g *OurGame) Update() {
}
//Rotating cubes
modelMat.Rotate(10*timing.DT()*gglm.Deg2Rad, gglm.NewVec3(1, 1, 1).Normalize())
simpleMat.SetUnifMat4("modelMat", &modelMat.Mat4)
if input.KeyDown(sdl.K_SPACE) {
modelMat.Rotate(10*timing.DT()*gglm.Deg2Rad, gglm.NewVec3(1, 1, 1).Normalize())
simpleMat.SetUnifMat4("modelMat", &modelMat.Mat4)
}
imgui.DragFloat3("Cam Pos", &camPos.Data)
}