Hey all,
I've got a simple chunk of code that uses a simple texture program to draw a texture full screen. However, I'm running into some really weird behaviour with the OpenGL from
github.com/go-gl/gl. If I call program.Use() once on init, everything works fine. However, I'm designing this to switch between multiple shaders, and so I thought I'd add program.Use() to the top of this specific drawing function, which gets called on every frame. If I do that, and nothing else, my app only draws a big white square instead of the texture / color stuff it's supposed to.
Here's my function:
func DrawTexture(t *glh.Texture, correctaspect bool) error {
// prg.Use()
gl.ActiveTexture(gl.TEXTURE0)
t.Bind(gl.TEXTURE_2D)
// draw!
gl.DrawArrays(gl.TRIANGLE_STRIP, 0, 4)
if err := GLErrors(); err != nil {
// return errors.New("Error drawing texture: " + err.Error())
}
return GLErrors()
}
This gets called from the main app like so:
for glfw.WindowParam(glfw.Opened) == 1 {
if err = v.DrawTexture(tex, false); err != nil {
Logger.Fatalln(err)
}
glfw.SwapBuffers()
}
prg is the global variable for the shader program I'm using. So, prg.Use() once, works great, prg.Use() on every draw, just draws white.
Any ideas on how to debug this would be exceedingly welcome. ;)
Thanks,
Graeme H