opengl: SetViewport no longer returns error

This commit is contained in:
Hajime Hoshi 2017-09-25 00:17:07 +09:00
parent b590005c7a
commit d455b9b8bb
6 changed files with 14 additions and 22 deletions

View File

@ -197,9 +197,8 @@ func (c *fillCommand) Exec(indexOffsetInBytes int) error {
if err != nil { if err != nil {
return err return err
} }
if err := f.setAsViewport(); err != nil { f.setAsViewport()
return err
}
cr, cg, cb, ca := c.color.R, c.color.G, c.color.B, c.color.A cr, cg, cb, ca := c.color.R, c.color.G, c.color.B, c.color.A
const max = math.MaxUint8 const max = math.MaxUint8
r := float64(cr) / max r := float64(cr) / max
@ -235,9 +234,8 @@ func (c *drawImageCommand) Exec(indexOffsetInBytes int) error {
if err != nil { if err != nil {
return err return err
} }
if err := f.setAsViewport(); err != nil { f.setAsViewport()
return err
}
opengl.GetContext().BlendFunc(c.mode) opengl.GetContext().BlendFunc(c.mode)
n := c.quadsNum() n := c.quadsNum()
@ -302,9 +300,8 @@ func (c *replacePixelsCommand) Exec(indexOffsetInBytes int) error {
if err != nil { if err != nil {
return err return err
} }
if err := f.setAsViewport(); err != nil { f.setAsViewport()
return err
}
// Filling with non black or white color is required here for glTexSubImage2D. // Filling with non black or white color is required here for glTexSubImage2D.
// Very mysterious but this actually works (Issue #186). // Very mysterious but this actually works (Issue #186).
// This is needed even after fixing a shader bug at f537378f2a6a8ef56e1acf1c03034967b77c7b51. // This is needed even after fixing a shader bug at f537378f2a6a8ef56e1acf1c03034967b77c7b51.

View File

@ -93,9 +93,9 @@ func (f *framebuffer) viewportSize() (int, int) {
} }
// setAsViewport sets the framebuffer as the current viewport. // setAsViewport sets the framebuffer as the current viewport.
func (f *framebuffer) setAsViewport() error { func (f *framebuffer) setAsViewport() {
w, h := f.viewportSize() w, h := f.viewportSize()
return opengl.GetContext().SetViewport(f.native, w, h) opengl.GetContext().SetViewport(f.native, w, h)
} }
// projectionMatrix returns a projection matrix of the framebuffer. // projectionMatrix returns a projection matrix of the framebuffer.

View File

@ -69,16 +69,13 @@ func (c *Context) bindFramebuffer(f Framebuffer) {
c.lastFramebuffer = f c.lastFramebuffer = f
} }
func (c *Context) SetViewport(f Framebuffer, width, height int) error { func (c *Context) SetViewport(f Framebuffer, width, height int) {
c.bindFramebuffer(f) c.bindFramebuffer(f)
if c.lastViewportWidth != width || c.lastViewportHeight != height { if c.lastViewportWidth != width || c.lastViewportHeight != height {
if err := c.setViewportImpl(width, height); err != nil { c.setViewportImpl(width, height)
return nil
}
c.lastViewportWidth = width c.lastViewportWidth = width
c.lastViewportHeight = height c.lastViewportHeight = height
} }
return nil
} }
func (c *Context) ScreenFramebuffer() Framebuffer { func (c *Context) ScreenFramebuffer() Framebuffer {

View File

@ -274,8 +274,8 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) {
return framebuffer, nil return framebuffer, nil
} }
func (c *Context) setViewportImpl(width, height int) error { func (c *Context) setViewportImpl(width, height int) {
return c.runOnContextThread(func() error { _ = c.runOnContextThread(func() error {
gl.Viewport(0, 0, int32(width), int32(height)) gl.Viewport(0, 0, int32(width), int32(height))
return nil return nil
}) })

View File

@ -254,10 +254,9 @@ func (c *Context) NewFramebuffer(t Texture) (Framebuffer, error) {
return Framebuffer{f}, nil return Framebuffer{f}, nil
} }
func (c *Context) setViewportImpl(width, height int) error { func (c *Context) setViewportImpl(width, height int) {
gl := c.gl gl := c.gl
gl.Viewport(0, 0, width, height) gl.Viewport(0, 0, width, height)
return nil
} }
func (c *Context) FillFramebuffer(r, g, b, a float64) error { func (c *Context) FillFramebuffer(r, g, b, a float64) error {

View File

@ -215,10 +215,9 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) {
return Framebuffer(f), nil return Framebuffer(f), nil
} }
func (c *Context) setViewportImpl(width, height int) error { func (c *Context) setViewportImpl(width, height int) {
gl := c.gl gl := c.gl
gl.Viewport(0, 0, width, height) gl.Viewport(0, 0, width, height)
return nil
} }
func (c *Context) FillFramebuffer(r, g, b, a float64) error { func (c *Context) FillFramebuffer(r, g, b, a float64) error {