mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
opengl: Remove pixels argument from NewTexture
This commit is contained in:
parent
85b133dad0
commit
86671f3337
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user