mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
opengl: SetViewport no longer returns error
This commit is contained in:
parent
b590005c7a
commit
d455b9b8bb
@ -197,9 +197,8 @@ func (c *fillCommand) Exec(indexOffsetInBytes int) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := f.setAsViewport(); err != nil {
|
||||
return err
|
||||
}
|
||||
f.setAsViewport()
|
||||
|
||||
cr, cg, cb, ca := c.color.R, c.color.G, c.color.B, c.color.A
|
||||
const max = math.MaxUint8
|
||||
r := float64(cr) / max
|
||||
@ -235,9 +234,8 @@ func (c *drawImageCommand) Exec(indexOffsetInBytes int) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := f.setAsViewport(); err != nil {
|
||||
return err
|
||||
}
|
||||
f.setAsViewport()
|
||||
|
||||
opengl.GetContext().BlendFunc(c.mode)
|
||||
|
||||
n := c.quadsNum()
|
||||
@ -302,9 +300,8 @@ func (c *replacePixelsCommand) Exec(indexOffsetInBytes int) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := f.setAsViewport(); err != nil {
|
||||
return err
|
||||
}
|
||||
f.setAsViewport()
|
||||
|
||||
// Filling with non black or white color is required here for glTexSubImage2D.
|
||||
// Very mysterious but this actually works (Issue #186).
|
||||
// This is needed even after fixing a shader bug at f537378f2a6a8ef56e1acf1c03034967b77c7b51.
|
||||
|
@ -93,9 +93,9 @@ func (f *framebuffer) viewportSize() (int, int) {
|
||||
}
|
||||
|
||||
// setAsViewport sets the framebuffer as the current viewport.
|
||||
func (f *framebuffer) setAsViewport() error {
|
||||
func (f *framebuffer) setAsViewport() {
|
||||
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.
|
||||
|
@ -69,16 +69,13 @@ func (c *Context) bindFramebuffer(f Framebuffer) {
|
||||
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)
|
||||
if c.lastViewportWidth != width || c.lastViewportHeight != height {
|
||||
if err := c.setViewportImpl(width, height); err != nil {
|
||||
return nil
|
||||
}
|
||||
c.setViewportImpl(width, height)
|
||||
c.lastViewportWidth = width
|
||||
c.lastViewportHeight = height
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Context) ScreenFramebuffer() Framebuffer {
|
||||
|
@ -274,8 +274,8 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) {
|
||||
return framebuffer, nil
|
||||
}
|
||||
|
||||
func (c *Context) setViewportImpl(width, height int) error {
|
||||
return c.runOnContextThread(func() error {
|
||||
func (c *Context) setViewportImpl(width, height int) {
|
||||
_ = c.runOnContextThread(func() error {
|
||||
gl.Viewport(0, 0, int32(width), int32(height))
|
||||
return nil
|
||||
})
|
||||
|
@ -254,10 +254,9 @@ func (c *Context) NewFramebuffer(t Texture) (Framebuffer, error) {
|
||||
return Framebuffer{f}, nil
|
||||
}
|
||||
|
||||
func (c *Context) setViewportImpl(width, height int) error {
|
||||
func (c *Context) setViewportImpl(width, height int) {
|
||||
gl := c.gl
|
||||
gl.Viewport(0, 0, width, height)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Context) FillFramebuffer(r, g, b, a float64) error {
|
||||
|
@ -215,10 +215,9 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) {
|
||||
return Framebuffer(f), nil
|
||||
}
|
||||
|
||||
func (c *Context) setViewportImpl(width, height int) error {
|
||||
func (c *Context) setViewportImpl(width, height int) {
|
||||
gl := c.gl
|
||||
gl.Viewport(0, 0, width, height)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Context) FillFramebuffer(r, g, b, a float64) error {
|
||||
|
Loading…
Reference in New Issue
Block a user