mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
Update for newer gopherjs
This commit is contained in:
parent
9bec0cf1c6
commit
265a85e922
@ -34,9 +34,6 @@ type context struct {
|
|||||||
gl *webgl.Context
|
gl *webgl.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Is there any better way to get null value?
|
|
||||||
var nullVal = js.Global.Call("eval", "null")
|
|
||||||
|
|
||||||
func NewContext(gl *webgl.Context) *Context {
|
func NewContext(gl *webgl.Context) *Context {
|
||||||
c := &Context{
|
c := &Context{
|
||||||
Nearest: FilterType(gl.NEAREST),
|
Nearest: FilterType(gl.NEAREST),
|
||||||
@ -63,7 +60,7 @@ func (c *Context) init() {
|
|||||||
func (c *Context) NewTexture(width, height int, pixels []uint8, filter FilterType) (Texture, error) {
|
func (c *Context) NewTexture(width, height int, pixels []uint8, filter FilterType) (Texture, error) {
|
||||||
gl := c.gl
|
gl := c.gl
|
||||||
t := gl.CreateTexture()
|
t := gl.CreateTexture()
|
||||||
if t.IsNull() {
|
if t == nil {
|
||||||
return nil, errors.New("glGenTexture failed")
|
return nil, errors.New("glGenTexture failed")
|
||||||
}
|
}
|
||||||
gl.PixelStorei(gl.UNPACK_ALIGNMENT, 4)
|
gl.PixelStorei(gl.UNPACK_ALIGNMENT, 4)
|
||||||
@ -137,7 +134,7 @@ func (c *Context) SetViewport(f Framebuffer, width, height int) error {
|
|||||||
if f != nil {
|
if f != nil {
|
||||||
gl.BindFramebuffer(gl.FRAMEBUFFER, f)
|
gl.BindFramebuffer(gl.FRAMEBUFFER, f)
|
||||||
} else {
|
} else {
|
||||||
gl.BindFramebuffer(gl.FRAMEBUFFER, nullVal)
|
gl.BindFramebuffer(gl.FRAMEBUFFER, nil)
|
||||||
}
|
}
|
||||||
// gl.CheckFramebufferStatus might cause a performance problem. Don't call this here.
|
// gl.CheckFramebufferStatus might cause a performance problem. Don't call this here.
|
||||||
gl.Viewport(0, 0, width, height)
|
gl.Viewport(0, 0, width, height)
|
||||||
@ -159,7 +156,7 @@ func (c *Context) DeleteFramebuffer(f Framebuffer) {
|
|||||||
func (c *Context) NewShader(shaderType ShaderType, source string) (Shader, error) {
|
func (c *Context) NewShader(shaderType ShaderType, source string) (Shader, error) {
|
||||||
gl := c.gl
|
gl := c.gl
|
||||||
s := gl.CreateShader(int(shaderType))
|
s := gl.CreateShader(int(shaderType))
|
||||||
if s.IsNull() {
|
if s == nil {
|
||||||
println(gl.GetError())
|
println(gl.GetError())
|
||||||
return nil, errors.New("glCreateShader failed")
|
return nil, errors.New("glCreateShader failed")
|
||||||
}
|
}
|
||||||
@ -182,7 +179,7 @@ func (c *Context) DeleteShader(s Shader) {
|
|||||||
func (c *Context) NewProgram(shaders []Shader) (Program, error) {
|
func (c *Context) NewProgram(shaders []Shader) (Program, error) {
|
||||||
gl := c.gl
|
gl := c.gl
|
||||||
p := gl.CreateProgram()
|
p := gl.CreateProgram()
|
||||||
if p.IsNull() {
|
if p == nil {
|
||||||
return nil, errors.New("glCreateProgram failed")
|
return nil, errors.New("glCreateProgram failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user