mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
Remove ui.ActualScale()
This commit is contained in:
parent
3d01084a2a
commit
c4e104a5d2
@ -32,10 +32,6 @@ func Use(f func(*opengl.Context)) {
|
||||
<-ch
|
||||
}
|
||||
|
||||
func ActualScale() int {
|
||||
return current.actualScale
|
||||
}
|
||||
|
||||
func DoEvents() {
|
||||
current.doEvents()
|
||||
}
|
||||
@ -86,22 +82,21 @@ func init() {
|
||||
}
|
||||
|
||||
type ui struct {
|
||||
window *glfw.Window
|
||||
scale int
|
||||
actualScale int
|
||||
glContext *opengl.Context
|
||||
input input
|
||||
funcs chan func()
|
||||
window *glfw.Window
|
||||
scale int
|
||||
glContext *opengl.Context
|
||||
input input
|
||||
funcs chan func()
|
||||
}
|
||||
|
||||
func Start(width, height, scale int, title string) error {
|
||||
func Start(width, height, scale int, title string) (actualScale int, err error) {
|
||||
monitor, err := glfw.GetPrimaryMonitor()
|
||||
if err != nil {
|
||||
return err
|
||||
return 0, err
|
||||
}
|
||||
videoMode, err := monitor.GetVideoMode()
|
||||
if err != nil {
|
||||
return err
|
||||
return 0, err
|
||||
}
|
||||
x := (videoMode.Width - width*scale) / 2
|
||||
y := (videoMode.Height - height*scale) / 3
|
||||
@ -134,9 +129,9 @@ func Start(width, height, scale int, title string) error {
|
||||
|
||||
// For retina displays, recalculate the scale with the framebuffer size.
|
||||
windowWidth, _ := window.GetFramebufferSize()
|
||||
ui.actualScale = windowWidth / width
|
||||
actualScale = windowWidth / width
|
||||
|
||||
return err
|
||||
return actualScale, nil
|
||||
}
|
||||
|
||||
func (u *ui) doEvents() {
|
||||
|
6
run.go
6
run.go
@ -30,15 +30,15 @@ import (
|
||||
// but this is not strictly guaranteed.
|
||||
// If you need to care about time, you need to check current time every time f is called.
|
||||
func Run(f func(*Image) error, width, height, scale int, title string) error {
|
||||
if err := ui.Start(width, height, scale, title); err != nil {
|
||||
actualScale, err := ui.Start(width, height, scale, title)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer ui.Terminate()
|
||||
|
||||
var graphicsContext *graphicsContext
|
||||
var err error
|
||||
ui.Use(func(c *opengl.Context) {
|
||||
graphicsContext, err = newGraphicsContext(c, width, height, ui.ActualScale())
|
||||
graphicsContext, err = newGraphicsContext(c, width, height, actualScale)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user