mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
opengl: Define Texture/Framebuffer Equals for JS performance
This commit is contained in:
parent
3a3a4af035
commit
26a83c0e00
@ -54,7 +54,7 @@ func GetContext() *Context {
|
||||
}
|
||||
|
||||
func (c *Context) BindTexture(t Texture) error {
|
||||
if c.lastTexture == t {
|
||||
if c.lastTexture.equals(t) {
|
||||
return nil
|
||||
}
|
||||
if err := c.bindTextureImpl(t); err != nil {
|
||||
@ -65,7 +65,7 @@ func (c *Context) BindTexture(t Texture) error {
|
||||
}
|
||||
|
||||
func (c *Context) bindFramebuffer(f Framebuffer) error {
|
||||
if c.lastFramebuffer == f {
|
||||
if c.lastFramebuffer.equals(f) {
|
||||
return nil
|
||||
}
|
||||
if err := c.bindFramebufferImpl(f); err != nil {
|
||||
|
@ -32,6 +32,14 @@ type Shader uint32
|
||||
type Program uint32
|
||||
type Buffer uint32
|
||||
|
||||
func (t Texture) equals(other Texture) bool {
|
||||
return t == other
|
||||
}
|
||||
|
||||
func (f Framebuffer) equals(other Framebuffer) bool {
|
||||
return f == other
|
||||
}
|
||||
|
||||
type uniformLocation int32
|
||||
type attribLocation int32
|
||||
|
||||
|
@ -24,6 +24,9 @@ import (
|
||||
"github.com/gopherjs/webgl"
|
||||
)
|
||||
|
||||
// Note that `type Texture *js.Object` doesn't work.
|
||||
// There is no way to get the internal object in that case.
|
||||
|
||||
type Texture struct {
|
||||
*js.Object
|
||||
}
|
||||
@ -44,6 +47,14 @@ type Buffer struct {
|
||||
*js.Object
|
||||
}
|
||||
|
||||
func (t Texture) equals(other Texture) bool {
|
||||
return t.Object == other.Object
|
||||
}
|
||||
|
||||
func (f Framebuffer) equals(other Framebuffer) bool {
|
||||
return f.Object == other.Object
|
||||
}
|
||||
|
||||
type uniformLocation struct {
|
||||
*js.Object
|
||||
}
|
||||
|
@ -31,6 +31,14 @@ type Shader mgl.Shader
|
||||
type Program mgl.Program
|
||||
type Buffer mgl.Buffer
|
||||
|
||||
func (t Texture) equals(other Texture) bool {
|
||||
return t == other
|
||||
}
|
||||
|
||||
func (f Framebuffer) equals(other Framebuffer) bool {
|
||||
return f == other
|
||||
}
|
||||
|
||||
type uniformLocation mgl.Uniform
|
||||
type attribLocation mgl.Attrib
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user