impl_desktop.go (1163B)
1 // Copyright 2021 The Ebiten Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 //go:build !android && !ios && !js 16 // +build !android,!ios,!js 17 18 package devicescale 19 20 import ( 21 "github.com/hajimehoshi/ebiten/v2/internal/glfw" 22 ) 23 24 func monitorAt(x, y int) *glfw.Monitor { 25 // Note: this assumes that x, y are exact monitor origins. 26 // If they're not, this arbitrarily returns the first monitor. 27 monitors := glfw.GetMonitors() 28 for _, mon := range monitors { 29 mx, my := mon.GetPos() 30 if x == mx && y == my { 31 return mon 32 } 33 } 34 return monitors[0] 35 } 36 37 func impl(x, y int) float64 { 38 sx, _ := monitorAt(x, y).GetContentScale() 39 return float64(sx) 40 }