From 570c5ab6bfd67d5e83afded269f42a4dbdd006da Mon Sep 17 00:00:00 2001 From: Kearwood Gilbert Date: Thu, 11 Jul 2019 21:58:59 -0700 Subject: [PATCH] Smoke test on macos now compiles --- kraken/KRContext_osx.mm | 8 ++--- tests/smoke/hello_cube/CMakeLists.txt | 4 +-- tests/smoke/hello_cube/main_macos.mm | 33 +++++++++++++++++++ .../hello_cube/{main.cpp => main_win.cpp} | 0 4 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 tests/smoke/hello_cube/main_macos.mm rename tests/smoke/hello_cube/{main.cpp => main_win.cpp} (100%) diff --git a/kraken/KRContext_osx.mm b/kraken/KRContext_osx.mm index 94d18a6..461f4ea 100755 --- a/kraken/KRContext_osx.mm +++ b/kraken/KRContext_osx.mm @@ -20,7 +20,7 @@ void KRContext::destroyDeviceContexts() gRenderContext = nil; } -void KRContext::createDeviceContexts() +void createGLDeviceContexts() { if(gRenderContext == nil) { @@ -63,20 +63,20 @@ void KRContext::createDeviceContexts() void KRContext::activateStreamerContext() { - createDeviceContexts(); + createGLDeviceContexts(); [gStreamerContext makeCurrentContext]; } void KRContext::activateRenderContext() { - createDeviceContexts(); + createGLDeviceContexts(); [gRenderContext update]; [gRenderContext makeCurrentContext]; } void KRContext::attachToView(void *view) { - createDeviceContexts(); + createGLDeviceContexts(); NSView *v = (NSView *)view; [gRenderContext setView: v]; [gRenderContext update]; diff --git a/tests/smoke/hello_cube/CMakeLists.txt b/tests/smoke/hello_cube/CMakeLists.txt index 8f9385f..f4a8a75 100644 --- a/tests/smoke/hello_cube/CMakeLists.txt +++ b/tests/smoke/hello_cube/CMakeLists.txt @@ -4,10 +4,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) if (WIN32) - add_executable(kraken_cube WIN32 main.cpp) + add_executable(kraken_cube WIN32 main_win.cpp) add_compile_definitions(UNICODE) else(WIN32) - add_executable(kraken_cube main.cpp) + add_executable(kraken_cube main_macos.mm) set(CMAKE_CXX_COMPILER "clang++") endif(WIN32) diff --git a/tests/smoke/hello_cube/main_macos.mm b/tests/smoke/hello_cube/main_macos.mm new file mode 100644 index 0000000..a3e8ee4 --- /dev/null +++ b/tests/smoke/hello_cube/main_macos.mm @@ -0,0 +1,33 @@ +#import "Cocoa/Cocoa.h" +#include "kraken.h" + +using namespace kraken; + +int main(int argc, const char * argv[]) +{ + @autoreleasepool { + [NSApplication sharedApplication]; + + // + // Create a window: + // + + // Style flags: + NSUInteger windowStyle = NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask; + + NSRect windowRect = NSMakeRect(0, 0, 640, 480); + NSWindow * window = [[NSWindow alloc] initWithContentRect:windowRect + styleMask:windowStyle + backing:NSBackingStoreBuffered + defer:NO]; + [window autorelease]; + + // Window controller: + NSWindowController * windowController = [[NSWindowController alloc] initWithWindow:window]; + [windowController autorelease]; + + [window orderFrontRegardless]; + [NSApp run]; + } + return 0; +} diff --git a/tests/smoke/hello_cube/main.cpp b/tests/smoke/hello_cube/main_win.cpp similarity index 100% rename from tests/smoke/hello_cube/main.cpp rename to tests/smoke/hello_cube/main_win.cpp