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 1b84cd36d1
commit da14685fb0
3 changed files with 16 additions and 4 deletions

View File

@ -67,7 +67,7 @@ func initialize(c *opengl.Context) error {
var lastProgram opengl.Program
func useProgramColorMatrix(c *opengl.Context, projectionMatrix []float32, geo Matrix, color Matrix) opengl.Program {
if lastProgram != programColorMatrix {
if !lastProgram.Equals(programColorMatrix) {
c.UseProgram(programColorMatrix)
lastProgram = programColorMatrix
}

View File

@ -26,8 +26,14 @@ type Texture int
type Framebuffer int
type Shader int
type Program int
type UniformLocation int
type AttribLocation 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
type context struct{}

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
}
@ -141,7 +146,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
}