mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphics: Bug fix: Need to reset viewport size after resizing (#232)
This commit is contained in:
parent
5eb77d2fb5
commit
98fccb563e
@ -52,6 +52,7 @@ func (c *graphicsContext) SetSize(screenWidth, screenHeight, screenScale int) er
|
||||
c.screen.Clear()
|
||||
c.offscreen = offscreen
|
||||
c.screenScale = screenScale
|
||||
ui.GLContext().ResetViewportSize()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -54,10 +54,10 @@ func newFramebufferFromTexture(context *opengl.Context, texture *texture) (*fram
|
||||
|
||||
const viewportSize = 4096
|
||||
|
||||
func (f *framebuffer) setAsViewport(c *opengl.Context) error {
|
||||
func (f *framebuffer) setAsViewport(context *opengl.Context) error {
|
||||
width := viewportSize
|
||||
height := viewportSize
|
||||
return c.SetViewport(f.native, width, height)
|
||||
return context.SetViewport(f.native, width, height)
|
||||
}
|
||||
|
||||
func (f *framebuffer) projectionMatrix() *[4][4]float64 {
|
||||
|
@ -51,3 +51,8 @@ func (c *Context) bindFramebuffer(f Framebuffer) {
|
||||
func (c *Context) ScreenFramebuffer() Framebuffer {
|
||||
return c.screenFramebuffer
|
||||
}
|
||||
|
||||
func (c *Context) ResetViewportSize() {
|
||||
c.lastViewportWidth = 0
|
||||
c.lastViewportHeight = 0
|
||||
}
|
||||
|
@ -104,23 +104,39 @@ func (c *Context) Init() error {
|
||||
return err
|
||||
}
|
||||
c.BlendFunc(CompositeModeSourceOver)
|
||||
f := int32(0)
|
||||
gl.GetIntegerv(gl.FRAMEBUFFER_BINDING, &f)
|
||||
c.screenFramebuffer = Framebuffer(f)
|
||||
if err := c.RunOnContextThread(func() error {
|
||||
f := int32(0)
|
||||
gl.GetIntegerv(gl.FRAMEBUFFER_BINDING, &f)
|
||||
c.screenFramebuffer = Framebuffer(f)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Context) Resume() {
|
||||
func (c *Context) Resume() error {
|
||||
c.locationCache = newLocationCache()
|
||||
c.lastFramebuffer = invalidFramebuffer
|
||||
c.lastViewportWidth = 0
|
||||
c.lastViewportHeight = 0
|
||||
c.lastCompositeMode = CompositeModeUnknown
|
||||
gl.Enable(gl.BLEND)
|
||||
if err := c.RunOnContextThread(func() error {
|
||||
gl.Enable(gl.BLEND)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
c.BlendFunc(CompositeModeSourceOver)
|
||||
f := int32(0)
|
||||
gl.GetIntegerv(gl.FRAMEBUFFER_BINDING, &f)
|
||||
c.screenFramebuffer = Framebuffer(f)
|
||||
if err := c.RunOnContextThread(func() error {
|
||||
f := int32(0)
|
||||
gl.GetIntegerv(gl.FRAMEBUFFER_BINDING, &f)
|
||||
c.screenFramebuffer = Framebuffer(f)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Context) BlendFunc(mode CompositeMode) {
|
||||
|
@ -122,7 +122,7 @@ func (c *Context) init() {
|
||||
c.screenFramebuffer = Framebuffer{f}
|
||||
}
|
||||
|
||||
func (c *Context) Resume() {
|
||||
func (c *Context) Resume() error {
|
||||
c.locationCache = newLocationCache()
|
||||
c.lastFramebuffer = invalidFramebuffer
|
||||
c.lastViewportWidth = 0
|
||||
@ -133,6 +133,7 @@ func (c *Context) Resume() {
|
||||
c.BlendFunc(CompositeModeSourceOver)
|
||||
f := gl.GetParameter(gl.FRAMEBUFFER_BINDING)
|
||||
c.screenFramebuffer = Framebuffer{f}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Context) BlendFunc(mode CompositeMode) {
|
||||
|
@ -84,7 +84,7 @@ func NewContext() (*Context, error) {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (c *Context) Resume() {
|
||||
func (c *Context) Resume() error {
|
||||
c.locationCache = newLocationCache()
|
||||
c.lastFramebuffer = invalidFramebuffer
|
||||
c.lastViewportWidth = 0
|
||||
@ -94,6 +94,7 @@ func (c *Context) Resume() {
|
||||
c.BlendFunc(CompositeModeSourceOver)
|
||||
f := c.gl.GetInteger(mgl.FRAMEBUFFER_BINDING)
|
||||
c.screenFramebuffer = Framebuffer(mgl.Framebuffer{uint32(f)})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Context) WaitUntilInitializingDone() {
|
||||
|
Loading…
Reference in New Issue
Block a user