add more logging, use autolayout constraints to pin metal view to superview to support orientation changes easier
This commit is contained in:
parent
82d6d8e876
commit
897aee0bcf
|
@ -500,6 +500,12 @@
|
||||||
|
|
||||||
- (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size
|
- (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size
|
||||||
{
|
{
|
||||||
|
NSLog(@"mtkView drawableSizeWillChange to: %f x %f",size.width,size.height);
|
||||||
|
// due to autolayout constraints?
|
||||||
|
if (size.width == INFINITY || size.height == INFINITY) {
|
||||||
|
NSLog(@"mtkView drawableSizeWillChange width or height is inifinity, skipping...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
[self setViewportWidth:(unsigned int)size.width height:(unsigned int)size.height forceFull:NO allowRotate:YES];
|
[self setViewportWidth:(unsigned int)size.width height:(unsigned int)size.height forceFull:NO allowRotate:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31196,7 +31196,8 @@ bool video_driver_translate_coord_viewport(
|
||||||
int norm_vp_height = (int)vp->height;
|
int norm_vp_height = (int)vp->height;
|
||||||
int norm_full_vp_width = (int)vp->full_width;
|
int norm_full_vp_width = (int)vp->full_width;
|
||||||
int norm_full_vp_height = (int)vp->full_height;
|
int norm_full_vp_height = (int)vp->full_height;
|
||||||
|
printf("yoshi debug: video size: %i, %i full size: %i, %i \n",norm_vp_width,norm_vp_height,norm_full_vp_width,norm_full_vp_height);
|
||||||
|
printf("yoshi debug: video_driver_translate_coord_viewport: incoming mouse coord: %i,%i \n",mouse_x,mouse_y);
|
||||||
if (norm_vp_width <= 0 ||
|
if (norm_vp_width <= 0 ||
|
||||||
norm_vp_height <= 0 ||
|
norm_vp_height <= 0 ||
|
||||||
norm_full_vp_width <= 0 ||
|
norm_full_vp_width <= 0 ||
|
||||||
|
@ -31234,7 +31235,7 @@ bool video_driver_translate_coord_viewport(
|
||||||
*res_y = scaled_y;
|
*res_y = scaled_y;
|
||||||
*res_screen_x = scaled_screen_x;
|
*res_screen_x = scaled_screen_x;
|
||||||
*res_screen_y = scaled_screen_y;
|
*res_screen_y = scaled_screen_y;
|
||||||
|
printf("yoshi debug: translated coordinates: res: (%i,%i) res_screen:(%i,%i) \n",scaled_x,scaled_y,scaled_screen_x,scaled_screen_y);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,10 +125,11 @@ static void handle_touch_event(NSArray* touches)
|
||||||
CGPoint coord;
|
CGPoint coord;
|
||||||
UITouch *touch = [touches objectAtIndex:i];
|
UITouch *touch = [touches objectAtIndex:i];
|
||||||
|
|
||||||
if (touch.view != [CocoaView get].view)
|
// if (touch.view != [CocoaView get].view)
|
||||||
continue;
|
// continue;
|
||||||
|
|
||||||
coord = [touch locationInView:[touch view]];
|
coord = [touch locationInView:[touch view]];
|
||||||
|
NSLog(@"yoshi debug: handle_touch_event: coord = %f,%f , scaled = %f,%f",coord.x,coord.y,coord.x*scale,coord.y*scale);
|
||||||
|
|
||||||
if (touch.phase != UITouchPhaseEnded && touch.phase != UITouchPhaseCancelled)
|
if (touch.phase != UITouchPhaseEnded && touch.phase != UITouchPhaseCancelled)
|
||||||
{
|
{
|
||||||
|
@ -365,8 +366,15 @@ enum
|
||||||
}
|
}
|
||||||
|
|
||||||
// _renderView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
// _renderView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
||||||
[_renderView setFrame:self.window.bounds];
|
// [_renderView setFrame:self.window.bounds];
|
||||||
[[CocoaView get].view addSubview:_renderView];
|
_renderView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||||
|
UIView *rootView = [CocoaView get].view;
|
||||||
|
[rootView addSubview:_renderView];
|
||||||
|
[[_renderView.topAnchor constraintEqualToAnchor:rootView.topAnchor] setActive:YES];
|
||||||
|
[[_renderView.bottomAnchor constraintEqualToAnchor:rootView.bottomAnchor] setActive:YES];
|
||||||
|
[[_renderView.leadingAnchor constraintEqualToAnchor:rootView.leadingAnchor] setActive:YES];
|
||||||
|
[[_renderView.trailingAnchor constraintEqualToAnchor:rootView.trailingAnchor] setActive:YES];
|
||||||
|
|
||||||
|
|
||||||
// [self.window addSubview:_renderView];
|
// [self.window addSubview:_renderView];
|
||||||
// self.window.contentView.nextResponder = _listener;
|
// self.window.contentView.nextResponder = _listener;
|
||||||
|
@ -377,7 +385,10 @@ enum
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setVideoMode:(gfx_ctx_mode_t)mode {
|
- (void)setVideoMode:(gfx_ctx_mode_t)mode {
|
||||||
// no-op for iOS?
|
// hmm might need some scaling factor...
|
||||||
|
MetalView *metalView = (MetalView*) _renderView;
|
||||||
|
[metalView setDrawableSize:CGSizeMake(mode.width, mode.height)];
|
||||||
|
NSLog(@"setVideoMode set drawable size to %i x %i",mode.width,mode.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setCursorVisible:(bool)v {
|
- (void)setCursorVisible:(bool)v {
|
||||||
|
|
Loading…
Reference in New Issue