2
0
mirror of synced 2025-02-22 06:28:04 +00:00

app: set valid geom.Width/Height on darwin/arm

Change-Id: Id3c5c58050fa11ec57e8efd2661047dc5e0dfc2d
Reviewed-on: https://go-review.googlesource.com/7665
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
David Crawshaw 2015-03-17 12:39:21 -04:00
parent 2476462d4e
commit f28a01df97
2 changed files with 15 additions and 12 deletions

View File

@ -96,16 +96,20 @@ var machinePPI = map[string]int{
}
func ppi() int {
// TODO(crawshaw): use lookup table to get the correct PPI.
//C.uname(&C.sysInfo)
//machine := C.GoString(C.sysInfo.machine)
//return machinePPI[machine]
return 326
C.uname(&C.sysInfo)
name := C.GoString(&C.sysInfo.machine[0])
v, ok := machinePPI[name]
if !ok {
log.Fatalf("unknown machine: %s", name)
}
return v
}
//export setGeom
func setGeom(width, height int) {
geom.PixelsPerPt = float32(ppi()) / 72
if geom.PixelsPerPt == 0 {
geom.PixelsPerPt = float32(ppi()) / 72
}
geom.Width = geom.Pt(float32(width) / geom.PixelsPerPt)
geom.Height = geom.Pt(float32(height) / geom.PixelsPerPt)
}

View File

@ -43,14 +43,13 @@ struct utsname sysInfo;
GLKView *view = (GLKView *)self.view;
view.context = self.context;
view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
// TODO(crawshaw): set correct geometry.
//CGRect bounds = view.bounds;
//view.contentScaleFactor;
setGeom(300, 300);
}
- (void)update {
NSLog(@"AppController update");
GLKView *view = (GLKView *)self.view;
int w = [view drawableWidth];
int h = [view drawableHeight];
setGeom(w, h);
drawgl((GoUintptr)self.context);
}
@end