Fix Window sizing.

This commit is contained in:
Chinmay Garde
2021-05-04 15:52:46 -07:00
committed by Dan Field
parent e8a4173daf
commit e452fab337
4 changed files with 12 additions and 9 deletions

View File

@@ -14,6 +14,8 @@ executable("host") {
cflags_objc = flutter_cflags_objc_arc
cflags_objcc = flutter_cflags_objcc_arc
cflags_objcc += [ "-Wno-auto-var-id" ]
output_name = "impeller"
sources = [
@@ -31,6 +33,7 @@ executable("host") {
"AppKit.framework",
"Metal.framework",
"MetalKit.framework",
"QuartzCore.framework",
"ModelIO.framework",
]
@@ -38,6 +41,5 @@ executable("host") {
":impeller_host_shaders",
"//flutter/fml",
"//flutter/impeller/impeller",
"//third_party/glfw",
]
}

View File

@@ -12,9 +12,9 @@
}
- (void)loadView {
view_ = [[MTKView alloc] init];
view_ = [[MTKView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)];
view_.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
[self setView:view_];
self.view = view_;
}
- (void)viewDidLoad {

View File

@@ -218,7 +218,6 @@ static const size_t kAlignedUniformsSize = (sizeof(Uniforms) & ~0xFF) + 0x100;
- (void)drawInMTKView:(nonnull MTKView*)view {
/// Per frame updates here
dispatch_semaphore_wait(_inFlightSemaphore, DISPATCH_TIME_FOREVER);
id<MTLCommandBuffer> commandBuffer = [_commandQueue commandBuffer];
@@ -234,9 +233,8 @@ static const size_t kAlignedUniformsSize = (sizeof(Uniforms) & ~0xFF) + 0x100;
[self _updateGameState];
/// Delay getting the currentRenderPassDescriptor until we absolutely need it
/// to avoid
/// holding onto the drawable and blocking the display pipeline any longer
/// than necessary
/// to avoid holding onto the drawable and blocking the display pipeline any
/// longer than necessary
MTLRenderPassDescriptor* renderPassDescriptor =
view.currentRenderPassDescriptor;
@@ -293,6 +291,7 @@ static const size_t kAlignedUniformsSize = (sizeof(Uniforms) & ~0xFF) + 0x100;
}
- (void)mtkView:(nonnull MTKView*)view drawableSizeWillChange:(CGSize)size {
NSLog(@"Drawable sized did change: %@", NSStringFromSize(size));
float aspect = size.width / (float)size.height;
_projectionMatrix = matrix_perspective_right_hand(65.0f * (M_PI / 180.0f),
aspect, 0.1f, 100.0f);

View File

@@ -19,16 +19,18 @@
if (self = [super init]) {
view_controller_ = [[ImpellerHostViewController alloc] init];
window_ = [[NSWindow alloc]
initWithContentRect:NSMakeRect(0, 0, 800, 600)
initWithContentRect:NSMakeRect(200, 200, 800, 600)
styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable
backing:NSBackingStoreBuffered
defer:NO];
window_.styleMask |= NSWindowStyleMaskResizable;
[window_ setContentViewController:view_controller_];
}
return self;
}
- (void)applicationWillFinishLaunching:(NSNotification*)notification {
[window_ makeMainWindow];
[window_ setTitle:@"Impeller Host"];
[window_ makeKeyAndOrderFront:self];
}
@@ -43,7 +45,7 @@ int main(int argc, const char* argv[]) {
NSApplication* app = [NSApplication sharedApplication];
[app setActivationPolicy:NSApplicationActivationPolicyRegular];
NSMenuItem* item = [[NSMenuItem alloc] init];
NSApp.mainMenu = [[NSMenu alloc] init];
app.mainMenu = [[NSMenu alloc] init];
item.submenu = [[NSMenu alloc] init];
[app.mainMenu addItem:item];
[item.submenu