mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
Bug fix: glfw's framebuffer might be lately changed after consuming some events
This commit is contained in:
parent
ce81251730
commit
48f639db02
@ -66,10 +66,10 @@ func (c *graphicsContext) postUpdate() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
scale := float64(c.screenScale)
|
scale := float64(c.screenScale)
|
||||||
option := &DrawImageOptions{
|
options := &DrawImageOptions{
|
||||||
GeometryMatrix: ScaleGeometry(scale, scale),
|
GeometryMatrix: ScaleGeometry(scale, scale),
|
||||||
}
|
}
|
||||||
if err := c.defaultR.drawImage(c.screen, option); err != nil {
|
if err := c.defaultR.drawImage(c.screen, options); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ type Matrix interface {
|
|||||||
var initialized = false
|
var initialized = false
|
||||||
|
|
||||||
const size = 10000
|
const size = 10000
|
||||||
|
|
||||||
// TODO: Use unsafe.SizeOf?
|
// TODO: Use unsafe.SizeOf?
|
||||||
const uint16Size = 2
|
const uint16Size = 2
|
||||||
const short32Size = 4
|
const short32Size = 4
|
||||||
@ -48,8 +49,8 @@ func DrawTexture(native gl.Texture, projectionMatrix [4][4]float64, quads []Text
|
|||||||
|
|
||||||
vertexBuffer := gl.GenBuffer()
|
vertexBuffer := gl.GenBuffer()
|
||||||
vertexBuffer.Bind(gl.ARRAY_BUFFER)
|
vertexBuffer.Bind(gl.ARRAY_BUFFER)
|
||||||
vertices := make([]float32, stride*size)
|
s := short32Size * stride * size
|
||||||
gl.BufferData(gl.ARRAY_BUFFER, short32Size*len(vertices), vertices, gl.DYNAMIC_DRAW)
|
gl.BufferData(gl.ARRAY_BUFFER, s, nil, gl.DYNAMIC_DRAW)
|
||||||
|
|
||||||
indexBuffer := gl.GenBuffer()
|
indexBuffer := gl.GenBuffer()
|
||||||
indexBuffer.Bind(gl.ELEMENT_ARRAY_BUFFER)
|
indexBuffer.Bind(gl.ELEMENT_ARRAY_BUFFER)
|
||||||
|
17
ui.go
17
ui.go
@ -78,6 +78,23 @@ func startUI(width, height, scale int, title string) error {
|
|||||||
window.SetPosition(x, y)
|
window.SetPosition(x, y)
|
||||||
window.Show()
|
window.Show()
|
||||||
|
|
||||||
|
ch := make(chan struct{})
|
||||||
|
window.SetFramebufferSizeCallback(func(w *glfw.Window, width, height int) {
|
||||||
|
close(ch)
|
||||||
|
})
|
||||||
|
for {
|
||||||
|
done := false
|
||||||
|
glfw.PollEvents()
|
||||||
|
select {
|
||||||
|
case <-ch:
|
||||||
|
done = true
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
if done {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ui := currentUI
|
ui := currentUI
|
||||||
ui.scale = scale
|
ui.scale = scale
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user