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:
parent
2476462d4e
commit
f28a01df97
@ -96,16 +96,20 @@ var machinePPI = map[string]int{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ppi() int {
|
func ppi() int {
|
||||||
// TODO(crawshaw): use lookup table to get the correct PPI.
|
C.uname(&C.sysInfo)
|
||||||
//C.uname(&C.sysInfo)
|
name := C.GoString(&C.sysInfo.machine[0])
|
||||||
//machine := C.GoString(C.sysInfo.machine)
|
v, ok := machinePPI[name]
|
||||||
//return machinePPI[machine]
|
if !ok {
|
||||||
return 326
|
log.Fatalf("unknown machine: %s", name)
|
||||||
|
}
|
||||||
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
//export setGeom
|
//export setGeom
|
||||||
func setGeom(width, height int) {
|
func setGeom(width, height int) {
|
||||||
|
if geom.PixelsPerPt == 0 {
|
||||||
geom.PixelsPerPt = float32(ppi()) / 72
|
geom.PixelsPerPt = float32(ppi()) / 72
|
||||||
|
}
|
||||||
geom.Width = geom.Pt(float32(width) / geom.PixelsPerPt)
|
geom.Width = geom.Pt(float32(width) / geom.PixelsPerPt)
|
||||||
geom.Height = geom.Pt(float32(height) / geom.PixelsPerPt)
|
geom.Height = geom.Pt(float32(height) / geom.PixelsPerPt)
|
||||||
}
|
}
|
||||||
|
@ -43,14 +43,13 @@ struct utsname sysInfo;
|
|||||||
GLKView *view = (GLKView *)self.view;
|
GLKView *view = (GLKView *)self.view;
|
||||||
view.context = self.context;
|
view.context = self.context;
|
||||||
view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
|
view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
|
||||||
|
|
||||||
// TODO(crawshaw): set correct geometry.
|
|
||||||
//CGRect bounds = view.bounds;
|
|
||||||
//view.contentScaleFactor;
|
|
||||||
setGeom(300, 300);
|
|
||||||
}
|
}
|
||||||
- (void)update {
|
- (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);
|
drawgl((GoUintptr)self.context);
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user