diff --git a/internal/graphics/command.go b/internal/graphics/command.go index 73cadcd9d..047a459b5 100644 --- a/internal/graphics/command.go +++ b/internal/graphics/command.go @@ -329,7 +329,7 @@ func (c *newImageCommand) Exec(indexOffsetInBytes int) error { if h < 1 { return errors.New("graphics: height must be equal or more than 1.") } - native, err := opengl.GetContext().NewTexture(w, h, nil) + native, err := opengl.GetContext().NewTexture(w, h) if err != nil { return err } diff --git a/internal/opengl/context_desktop.go b/internal/opengl/context_desktop.go index 32b3138a2..97ea90a39 100644 --- a/internal/opengl/context_desktop.go +++ b/internal/opengl/context_desktop.go @@ -133,7 +133,7 @@ func (c *Context) BlendFunc(mode CompositeMode) { }) } -func (c *Context) NewTexture(width, height int, pixels []uint8) (Texture, error) { +func (c *Context) NewTexture(width, height int) (Texture, error) { var texture Texture if err := c.runOnContextThread(func() error { var t uint32 @@ -152,12 +152,7 @@ func (c *Context) NewTexture(width, height int, pixels []uint8) (Texture, error) _ = c.runOnContextThread(func() error { gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST) gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST) - - var p interface{} - if pixels != nil { - p = pixels - } - gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, int32(width), int32(height), 0, gl.RGBA, gl.UNSIGNED_BYTE, gl.Ptr(p)) + gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, int32(width), int32(height), 0, gl.RGBA, gl.UNSIGNED_BYTE, nil) return nil }) return texture, nil diff --git a/internal/opengl/context_js.go b/internal/opengl/context_js.go index 51f2b1105..ecaa03eb8 100644 --- a/internal/opengl/context_js.go +++ b/internal/opengl/context_js.go @@ -131,7 +131,7 @@ func (c *Context) BlendFunc(mode CompositeMode) { gl.BlendFunc(int(s), int(d)) } -func (c *Context) NewTexture(width, height int, pixels []uint8) (Texture, error) { +func (c *Context) NewTexture(width, height int) (Texture, error) { gl := c.gl t := gl.CreateTexture() if t == nil { @@ -148,11 +148,7 @@ func (c *Context) NewTexture(width, height int, pixels []uint8) (Texture, error) // void texImage2D(GLenum target, GLint level, GLenum internalformat, // GLsizei width, GLsizei height, GLint border, GLenum format, // GLenum type, ArrayBufferView? pixels); - var p interface{} - if pixels != nil { - p = pixels - } - gl.Call("texImage2D", gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, p) + gl.Call("texImage2D", gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, nil) return t, nil } diff --git a/internal/opengl/context_mobile.go b/internal/opengl/context_mobile.go index ad7e07c87..4745f9757 100644 --- a/internal/opengl/context_mobile.go +++ b/internal/opengl/context_mobile.go @@ -123,7 +123,7 @@ func (c *Context) BlendFunc(mode CompositeMode) { gl.BlendFunc(mgl.Enum(s), mgl.Enum(d)) } -func (c *Context) NewTexture(width, height int, pixels []uint8) (Texture, error) { +func (c *Context) NewTexture(width, height int) (Texture, error) { gl := c.gl t := gl.CreateTexture() if t.Value <= 0 { @@ -134,12 +134,7 @@ func (c *Context) NewTexture(width, height int, pixels []uint8) (Texture, error) gl.TexParameteri(mgl.TEXTURE_2D, mgl.TEXTURE_MAG_FILTER, mgl.NEAREST) gl.TexParameteri(mgl.TEXTURE_2D, mgl.TEXTURE_MIN_FILTER, mgl.NEAREST) - - var p []uint8 - if pixels != nil { - p = pixels - } - gl.TexImage2D(mgl.TEXTURE_2D, 0, width, height, mgl.RGBA, mgl.UNSIGNED_BYTE, p) + gl.TexImage2D(mgl.TEXTURE_2D, 0, width, height, mgl.RGBA, mgl.UNSIGNED_BYTE, nil) return Texture(t), nil }