zorldo

Goofing around with Ebiten
git clone git://bsandro.tech/zorldo
Log | Files | Refs

impl_mac.go (1345B)


      1 // Copyright 2018 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 // +build darwin
     16 // +build !ios
     17 
     18 package devicescale
     19 
     20 // #cgo CFLAGS: -x objective-c
     21 // #cgo LDFLAGS: -framework AppKit
     22 //
     23 // #import <AppKit/AppKit.h>
     24 //
     25 // static float scaleAt(int x, int y) {
     26 //   // On macOS, the direction of Y axis is inverted from GLFW monitors (#807).
     27 //   // This is an inverse function of _glfwTransformYNS in GLFW (#1113).
     28 //   y = CGDisplayBounds(CGMainDisplayID()).size.height - y - 1;
     29 //
     30 //   NSArray<NSScreen*>* screens = [NSScreen screens];
     31 //   for (NSScreen* screen in screens) {
     32 //     if (NSPointInRect(NSMakePoint(x, y), [screen frame])) {
     33 //       return [screen backingScaleFactor];
     34 //     }
     35 //   }
     36 //   return 0;
     37 // }
     38 import "C"
     39 
     40 func impl(x, y int) float64 {
     41 	return float64(C.scaleAt(C.int(x), C.int(y)))
     42 }