graphics: Bug fix: Need to reset viewport size after resizing (#232)

This commit is contained in:
Hajime Hoshi 2016-06-18 06:25:40 +09:00
parent 5eb77d2fb5
commit 98fccb563e
6 changed files with 36 additions and 12 deletions

View File

@ -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
}

View File

@ -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 {

View File

@ -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
}

View File

@ -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) {

View File

@ -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) {

View File

@ -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() {