mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +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
|
<-ch
|
||||||
}
|
}
|
||||||
|
|
||||||
func ActualScale() int {
|
|
||||||
return current.actualScale
|
|
||||||
}
|
|
||||||
|
|
||||||
func DoEvents() {
|
func DoEvents() {
|
||||||
current.doEvents()
|
current.doEvents()
|
||||||
}
|
}
|
||||||
@ -88,20 +84,19 @@ func init() {
|
|||||||
type ui struct {
|
type ui struct {
|
||||||
window *glfw.Window
|
window *glfw.Window
|
||||||
scale int
|
scale int
|
||||||
actualScale int
|
|
||||||
glContext *opengl.Context
|
glContext *opengl.Context
|
||||||
input input
|
input input
|
||||||
funcs chan func()
|
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()
|
monitor, err := glfw.GetPrimaryMonitor()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return 0, err
|
||||||
}
|
}
|
||||||
videoMode, err := monitor.GetVideoMode()
|
videoMode, err := monitor.GetVideoMode()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return 0, err
|
||||||
}
|
}
|
||||||
x := (videoMode.Width - width*scale) / 2
|
x := (videoMode.Width - width*scale) / 2
|
||||||
y := (videoMode.Height - height*scale) / 3
|
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.
|
// For retina displays, recalculate the scale with the framebuffer size.
|
||||||
windowWidth, _ := window.GetFramebufferSize()
|
windowWidth, _ := window.GetFramebufferSize()
|
||||||
ui.actualScale = windowWidth / width
|
actualScale = windowWidth / width
|
||||||
|
|
||||||
return err
|
return actualScale, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *ui) doEvents() {
|
func (u *ui) doEvents() {
|
||||||
|
6
run.go
6
run.go
@ -30,15 +30,15 @@ import (
|
|||||||
// but this is not strictly guaranteed.
|
// but this is not strictly guaranteed.
|
||||||
// If you need to care about time, you need to check current time every time f is called.
|
// 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 {
|
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
|
return err
|
||||||
}
|
}
|
||||||
defer ui.Terminate()
|
defer ui.Terminate()
|
||||||
|
|
||||||
var graphicsContext *graphicsContext
|
var graphicsContext *graphicsContext
|
||||||
var err error
|
|
||||||
ui.Use(func(c *opengl.Context) {
|
ui.Use(func(c *opengl.Context) {
|
||||||
graphicsContext, err = newGraphicsContext(c, width, height, ui.ActualScale())
|
graphicsContext, err = newGraphicsContext(c, width, height, actualScale)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user