mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
ui: Rename MonitorSize -> ScreenSizeInFullscreen (#708)
This commit is contained in:
parent
0a54ce48fd
commit
c758a1f8c6
@ -97,10 +97,10 @@ func update(screen *ebiten.Image) error {
|
||||
op.Filter = ebiten.FilterLinear
|
||||
screen.DrawImage(gophersImage, op)
|
||||
|
||||
mw, mh := ebiten.MonitorSize()
|
||||
fw, fh := ebiten.ScreenSizeInFullscreen()
|
||||
msgs := []string{
|
||||
"This is an example of the finest fullscreen. Press Q to quit.",
|
||||
fmt.Sprintf("Monitor size: %d, %d", mw, mh),
|
||||
fmt.Sprintf("Screen size in fullscreen: %d, %d", fw, fh),
|
||||
fmt.Sprintf("Game's screen size: %d, %d", sw, sh),
|
||||
fmt.Sprintf("Device scale factor: %0.2f", scale),
|
||||
}
|
||||
@ -118,7 +118,7 @@ func main() {
|
||||
|
||||
ebiten.SetFullscreen(true)
|
||||
|
||||
w, h := ebiten.MonitorSize()
|
||||
w, h := ebiten.ScreenSizeInFullscreen()
|
||||
// On mobiles, ebiten.MonitorSize is not available so far.
|
||||
// Use arbitrary values.
|
||||
if w == 0 || h == 0 {
|
||||
|
@ -199,8 +199,8 @@ func main() {
|
||||
flag.Parse()
|
||||
|
||||
fmt.Printf("Device scale factor: %0.2f\n", ebiten.DeviceScaleFactor())
|
||||
w, h := ebiten.MonitorSize()
|
||||
fmt.Printf("Monitor size: %d, %d\n", w, h)
|
||||
w, h := ebiten.ScreenSizeInFullscreen()
|
||||
fmt.Printf("Screen size in fullscreen: %d, %d\n", w, h)
|
||||
|
||||
// Decode image from a byte slice instead of a file so that
|
||||
// this example works in any working directory.
|
||||
|
@ -232,7 +232,7 @@ func (u *userInterface) runOnMainThread(f func() error) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func MonitorSize() (int, int) {
|
||||
func ScreenSizeInFullscreen() (int, int) {
|
||||
var v *glfw.VidMode
|
||||
if currentUI.isRunning() {
|
||||
_ = currentUI.runOnMainThread(func() error {
|
||||
|
@ -59,7 +59,7 @@ var (
|
||||
setTimeout = window.Get("setTimeout")
|
||||
)
|
||||
|
||||
func MonitorSize() (int, int) {
|
||||
func ScreenSizeInFullscreen() (int, int) {
|
||||
return window.Get("innerWidth").Int(), window.Get("innerHeight").Int()
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ func (u *userInterface) screenSize() (int, int) {
|
||||
return w, h
|
||||
}
|
||||
|
||||
func MonitorSize() (int, int) {
|
||||
func ScreenSizeInFullscreen() (int, int) {
|
||||
// TODO: This function should return fullscreenWidthPx, fullscreenHeightPx,
|
||||
// but these values are not initialized until the main loop starts.
|
||||
return 0, 0
|
||||
|
21
run.go
21
run.go
@ -315,19 +315,20 @@ func RunWithoutMainLoop(f func(*Image) error, width, height int, scale float64,
|
||||
return ch
|
||||
}
|
||||
|
||||
// MonitorSize returns the monitor size in device-independent pixels.
|
||||
// The adopted monitor is the 'current' monitor that includes the biggest area of the window.
|
||||
// ScreenSizeInFullscreen returns the size in device-independent pixels when the game is fullscreen.
|
||||
// The adopted monitor is the 'current' monitor which the window belongs to.
|
||||
// The returned value can be given to Run or SetSize function if the perfectly fit fullscreen is needed.
|
||||
//
|
||||
// On browsers, MonitorSize returns the 'window' size, not 'screen' size since an Ebiten game
|
||||
// On browsers, ScreenSizeInFullscreen returns the 'window' (global object) size, not 'screen' size since an Ebiten game
|
||||
// should not know the outside of the window object.
|
||||
// For more detials, see SetFullscreen API comment.
|
||||
//
|
||||
// On mobiles, MonitorSize returns (0, 0) so far.
|
||||
// On mobiles, ScreenSizeInFullscreen returns (0, 0) so far.
|
||||
//
|
||||
// If you use this for screen size with SetFullscreen(true), you can get the fullscreen mode
|
||||
// which size is well adjusted with the monitor.
|
||||
//
|
||||
// w, h := MonitorSize()
|
||||
// w, h := ScreenSizeInFullscreen()
|
||||
// ebiten.SetFullscreen(true)
|
||||
// ebiten.Run(update, w, h, 1, "title")
|
||||
//
|
||||
@ -335,15 +336,15 @@ func RunWithoutMainLoop(f func(*Image) error, width, height int, scale float64,
|
||||
// fullscreen mode.
|
||||
//
|
||||
// s := ebiten.DeviceScaleFactor()
|
||||
// w, h := MonitorSize()
|
||||
// w, h := ScreenSizeInFullscreen()
|
||||
// ebiten.SetFullscreen(true)
|
||||
// ebiten.Run(update, int(float64(w) * s), int(float64(h) * s), 1/s, "title")
|
||||
//
|
||||
// For actual example, see examples/fullscreen
|
||||
//
|
||||
// MonitorSize is concurrent-safe.
|
||||
func MonitorSize() (int, int) {
|
||||
return ui.MonitorSize()
|
||||
// ScreenSizeInFullscreen is concurrent-safe.
|
||||
func ScreenSizeInFullscreen() (int, int) {
|
||||
return ui.ScreenSizeInFullscreen()
|
||||
}
|
||||
|
||||
// SetScreenSize changes the (logical) size of the screen.
|
||||
@ -515,7 +516,7 @@ func SetWindowIcon(iconImages []image.Image) {
|
||||
ui.SetWindowIcon(iconImages)
|
||||
}
|
||||
|
||||
// DeviceScaleFactor returns a device scale factor value.
|
||||
// DeviceScaleFactor returns a device scale factor value of the current monitor which the window belongs to.
|
||||
//
|
||||
// DeviceScaleFactor returns a meaningful value on high-DPI display environment,
|
||||
// otherwise DeviceScaleFactor returns 1.
|
||||
|
Loading…
Reference in New Issue
Block a user