tofu

Making something with OpenGL in Go
Log | Files | Refs

commit 594a1db68f9a11df3a3a9b037f8a91e84474761c
parent 3f5554a7e0ecb3e1ed6a892bcae80cf65f621e17
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Fri,  1 Nov 2024 10:36:02 +0900

refactor

Diffstat:
Mcmd/sample/main.go | 14+++++++-------
Mshader.go | 3+--
2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/cmd/sample/main.go b/cmd/sample/main.go @@ -108,24 +108,24 @@ func main() { if err != nil { log.Fatalf("create shader program: %v", err) } - texture1, err := tofu.NewTexture(texpath1) if err != nil { log.Fatalf("create texture: %v", err) } - if err := program.SetTexture(texture1, "texture1"); err != nil { - log.Fatalf("set texture: %v", err) - } - texture2, err := tofu.NewTextureFlip(texpath2, true, false) if err != nil { log.Fatalf("create texture: %v", err) } + if err := program.SetTexture(texture1, "texture1"); err != nil { + log.Fatalf("set texture: %v", err) + } if err := program.SetTexture(texture2, "texture2"); err != nil { log.Fatalf("set texture: %v", err) } - -// program.Use() +// gl.ActiveTexture(gl.TEXTURE0) +// gl.BindTexture(gl.TEXTURE_2D, 1) +// gl.ActiveTexture(gl.TEXTURE1) +// gl.BindTexture(gl.TEXTURE_2D, 2) window.SetFramebufferSizeCallback(framebufferSizeCallback) diff --git a/shader.go b/shader.go @@ -101,12 +101,11 @@ func (p *Program) SetFloat32(name string, val float32) error { func (p *Program) SetTexture(t *Texture, name string) error { p.Use() gl.ActiveTexture(t.unit) -// gl.BindTexture(gl.TEXTURE_2D, t.id) + gl.BindTexture(gl.TEXTURE_2D, t.id) l := gl.GetUniformLocation(p.id, gl.Str(name + "\x00")) if l == -1 { return fmt.Errorf("no such uniform: %s", name) } - fmt.Println("texture:", t.unit, t.unit-gl.TEXTURE0) gl.Uniform1i(l, int32(t.unit - gl.TEXTURE0)) return nil } \ No newline at end of file