Bug fix: Structs containing js.Object can't be compared (for now)

This commit is contained in:
Hajime Hoshi 2015-01-17 00:56:29 +09:00
parent 952f6be822
commit fe69c04f8f
3 changed files with 14 additions and 2 deletions

View File

@ -95,7 +95,7 @@ func (p programFinisher) FinishProgram() {
}
func useProgramTexture(c *opengl.Context, projectionMatrix []float32, texture opengl.Texture, geo Matrix, color Matrix) programFinisher {
if lastProgram != programTexture {
if !lastProgram.Equals(programTexture) {
c.UseProgram(programTexture)
lastProgram = programTexture
}

View File

@ -26,6 +26,12 @@ type Texture int
type Framebuffer int
type Shader int
type Program int
// TODO: Remove this after the GopherJS bug was fixed (#159)
func (p Program) Equals(other Program) bool {
return p == other
}
type UniformLocation gl.UniformLocation
type AttribLocation gl.AttribLocation

View File

@ -39,6 +39,11 @@ type Program struct {
js.Object
}
// TODO: Remove this after the GopherJS bug was fixed (#159)
func (p Program) Equals(other Program) bool {
return p.Object == other.Object
}
type UniformLocation struct {
js.Object
}
@ -151,7 +156,8 @@ var lastFramebuffer Framebuffer
func (c *Context) SetViewport(f Framebuffer, width, height int) error {
gl := c.gl
if lastFramebuffer != f {
// TODO: Fix this after the GopherJS bug was fixed (#159)
if lastFramebuffer.Object != f.Object {
gl.Flush()
lastFramebuffer = f
}