mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 09:00:44 +00:00
Apple minimal Nuklear implementation using AppKit
This commit is contained in:
committed by
Baldur Karlsson
parent
2d6290bab1
commit
fca14eac32
@@ -135,6 +135,8 @@ endif()
|
||||
|
||||
if(APPLE)
|
||||
list(APPEND SRC
|
||||
apple/nuklear_appkit.mm
|
||||
apple/nuklear_appkit.h
|
||||
apple/official/metal-cpp.cpp
|
||||
apple/official/metal-cpp.h
|
||||
apple/apple_platform.cpp
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,27 @@
|
||||
/******************************************************************************
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2022 Baldur Karlsson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#define NK_APPKIT_OBJC_IMPLEMENTATION
|
||||
#define NK_API
|
||||
#include "nuklear_appkit.h"
|
||||
@@ -216,26 +216,64 @@ void NuklearShutdown()
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
#include "apple/official/metal-cpp.h"
|
||||
extern "C" void *const NSDefaultRunLoopMode;
|
||||
|
||||
#define NK_APPKIT_IMPLEMENTATION
|
||||
#include "apple/nuklear_appkit.h"
|
||||
|
||||
static nk_appkit_window *window;
|
||||
static AppkitFont *font;
|
||||
static NS::Application *pSharedApplication = NULL;
|
||||
|
||||
nk_context *NuklearInit(int width, int height, const char *title)
|
||||
{
|
||||
TEST_ERROR("NuklearInit: Not Implemented");
|
||||
return NULL;
|
||||
if(!nk_appkit_core_initialize())
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
pSharedApplication = NS::Application::sharedApplication();
|
||||
|
||||
window = nk_appkit_window_create(width, height, title);
|
||||
if(!window)
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
nk_context *ctx = nk_appkit_create(window);
|
||||
font = nk_appkit_create_font("Menlo Regular", 9);
|
||||
nk_appkit_init(font);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
bool NuklearTick(nk_context *ctx)
|
||||
{
|
||||
TEST_ERROR("NuklearTick: Not Implemented");
|
||||
return false;
|
||||
NS::AutoreleasePool *pAutoreleasePool = NS::AutoreleasePool::alloc()->init();
|
||||
while(true)
|
||||
{
|
||||
NS::Event *event = pSharedApplication->nextEventMatchingMask(
|
||||
(int)NS::EventMaskAny, NS::Date::distantPast(), (NS::String *)NSDefaultRunLoopMode, true);
|
||||
if(event == NULL)
|
||||
break;
|
||||
pSharedApplication->sendEvent(event);
|
||||
}
|
||||
pAutoreleasePool->release();
|
||||
nk_appkit_new_frame();
|
||||
|
||||
if(nk_appkit_window_is_closed(window))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void NuklearRender()
|
||||
{
|
||||
TEST_ERROR("NuklearRender: Not Implemented");
|
||||
nk_appkit_render(nk_rgb(30, 30, 30));
|
||||
}
|
||||
|
||||
void NuklearShutdown()
|
||||
{
|
||||
TEST_ERROR("NuklearShutdown: Not Implemented");
|
||||
nk_appkit_delete_font(font);
|
||||
nk_appkit_shutdown();
|
||||
nk_appkit_window_delete(window);
|
||||
nk_appkit_core_shutdown();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user