Add CMake scripts for collecting assets, switch to Vulkan inspired public api
This commit is contained in:
@@ -35,6 +35,21 @@ macro (add_sources)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro (add_standard_asset)
|
||||
file (RELATIVE_PATH _relPath "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
foreach (_src ${ARGN})
|
||||
if (_relPath)
|
||||
list (APPEND KRAKEN_STANDARD_ASSETS "${_relPath}/${_src}")
|
||||
else()
|
||||
list (APPEND KRAKEN_STANDARD_ASSETS "${_src}")
|
||||
endif()
|
||||
endforeach()
|
||||
if (_relPath)
|
||||
# propagate KRAKEN_STANDARD_ASSETS to parent directory
|
||||
set (KRAKEN_STANDARD_ASSETS ${KRAKEN_STANDARD_ASSETS} PARENT_SCOPE)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro (add_public_header)
|
||||
file (RELATIVE_PATH _relPath "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
foreach (_src ${ARGN})
|
||||
@@ -158,5 +173,6 @@ IF(CMAKE_BUILD_TYPE MATCHES DEBUG)
|
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/export/lib/win)
|
||||
ENDIF(CMAKE_BUILD_TYPE MATCHES DEBUG)
|
||||
|
||||
add_subdirectory(kraken_standard_assets)
|
||||
add_subdirectory(tests)
|
||||
add_subdirectory(tools)
|
||||
|
||||
@@ -3,7 +3,7 @@ add_subdirectory(public)
|
||||
set(KRAKEN_PUBLIC_HEADERS "${KRAKEN_PUBLIC_HEADERS}" PARENT_SCOPE)
|
||||
|
||||
# Private Implementation
|
||||
add_sources(context.cpp)
|
||||
add_sources(kraken.cpp)
|
||||
add_sources(KRAmbientZone.cpp)
|
||||
add_sources(KRAnimation.cpp)
|
||||
add_sources(KRAnimationAttribute.cpp)
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
#include "public/context.h"
|
||||
|
||||
#include "KRContext.h"
|
||||
|
||||
namespace kraken {
|
||||
|
||||
Context* sContext = nullptr;
|
||||
|
||||
class Context::impl
|
||||
{
|
||||
public:
|
||||
impl();
|
||||
~impl();
|
||||
bool loadResource(const char* szPath);
|
||||
|
||||
private:
|
||||
KRContext mContext;
|
||||
};
|
||||
|
||||
/* static */
|
||||
Context* Context::Get()
|
||||
{
|
||||
if (!sContext) {
|
||||
sContext = new Context();
|
||||
}
|
||||
return sContext;
|
||||
}
|
||||
|
||||
Context::Context()
|
||||
{
|
||||
mImpl = new impl();
|
||||
}
|
||||
|
||||
Context::~Context()
|
||||
{
|
||||
delete mImpl;
|
||||
}
|
||||
|
||||
bool Context::loadResource(const char* szPath)
|
||||
{
|
||||
return mImpl->loadResource(szPath);
|
||||
}
|
||||
|
||||
bool Context::impl::loadResource(const char* szPath)
|
||||
{
|
||||
mContext.loadResource(szPath);
|
||||
// TODO: update KRContext::loadResource to return success/fail boolean
|
||||
return true;
|
||||
}
|
||||
|
||||
Context::impl::impl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Context::impl::~impl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}; // namespace kraken
|
||||
35
kraken/kraken.cpp
Normal file
35
kraken/kraken.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "public/kraken.h"
|
||||
|
||||
#include "KRContext.h"
|
||||
|
||||
namespace {
|
||||
|
||||
KRContext* sContext = nullptr;
|
||||
|
||||
}; // anonysmous namespace
|
||||
|
||||
KrResult KrInitialize(const KrInitializeInfo* pInitializeInfo)
|
||||
{
|
||||
if (!sContext) {
|
||||
sContext = new KRContext();
|
||||
}
|
||||
return KR_SUCCESS;
|
||||
}
|
||||
|
||||
KrResult KrShutdown()
|
||||
{
|
||||
if (sContext) {
|
||||
delete sContext;
|
||||
sContext = nullptr;
|
||||
}
|
||||
return KR_SUCCESS;
|
||||
}
|
||||
|
||||
KrResult KrLoadResource(const KrLoadResourceInfo* pLoadResourceInfo)
|
||||
{
|
||||
if (!sContext) {
|
||||
return KR_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
sContext->loadResource(pLoadResourceInfo->pResourcePath);
|
||||
return KR_SUCCESS;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
//
|
||||
// kraken.h
|
||||
// kraken
|
||||
//
|
||||
// Created by Kearwood Gilbert on 2015-11-06.
|
||||
// Copyright © 2015 Kearwood Software. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
//! Project version number for kraken.
|
||||
FOUNDATION_EXPORT double krakenVersionNumber;
|
||||
|
||||
//! Project version string for kraken.
|
||||
FOUNDATION_EXPORT const unsigned char krakenVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <kraken/PublicHeader.h>
|
||||
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
add_public_header(kraken.h)
|
||||
add_public_header(context.h)
|
||||
set(KRAKEN_PUBLIC_HEADERS "${KRAKEN_PUBLIC_HEADERS}" PARENT_SCOPE)
|
||||
|
||||
@@ -33,4 +33,34 @@
|
||||
|
||||
#include "context.h"
|
||||
|
||||
#define KR_NULL_HANDLE 0
|
||||
|
||||
typedef enum {
|
||||
KR_SUCCESS = 0,
|
||||
KR_ERROR_NOT_INITIALIZED = 1,
|
||||
KR_ERROR_WRONG_THREAD = 2,
|
||||
KR_RESULT_MAX_ENUM = 0x7FFFFFFF
|
||||
} KrResult;
|
||||
|
||||
typedef enum {
|
||||
KR_STRUCTURE_TYPE_INITIALIZE = 0,
|
||||
KR_STRUCTURE_TYPE_SHUTDOWN = 1,
|
||||
KR_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
|
||||
} KrStructureType;
|
||||
|
||||
typedef struct {
|
||||
KrStructureType sType;
|
||||
void* pNext;
|
||||
} KrInitializeInfo;
|
||||
|
||||
typedef struct {
|
||||
KrStructureType sType;
|
||||
void* pNext;
|
||||
const char* pResourcePath;
|
||||
} KrLoadResourceInfo;
|
||||
|
||||
KrResult KrInitialize(const KrInitializeInfo* pInitializeInfo);
|
||||
KrResult KrShutdown();
|
||||
KrResult KrLoadResource(const KrLoadResourceInfo* pLoadResourceInfo);
|
||||
|
||||
#endif // KRAKEN_H
|
||||
|
||||
2
kraken_standard_assets/CMakeLists.txt
Normal file
2
kraken_standard_assets/CMakeLists.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
set(KRAKEN_STANDARD_ASSETS "${KRAKEN_STANDARD_ASSETS}" PARENT_SCOPE)
|
||||
add_standard_asset(hrtf_kemar.krbundle)
|
||||
@@ -7,6 +7,32 @@ using namespace kraken;
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
printf("Kraken Convert\n");
|
||||
printf("Initializing Kraken...\n");
|
||||
KrInitializeInfo init_info = {};
|
||||
init_info.sType = KR_STRUCTURE_TYPE_INITIALIZE;
|
||||
init_info.pNext = NULL;
|
||||
KrResult res = KrInitialize(&init_info);
|
||||
if (res != KR_SUCCESS) {
|
||||
printf("Failed to initialize Kraken!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
KrLoadResourceInfo load_resource_info = {};
|
||||
|
||||
for (int i = 0; i < argc; i++) {
|
||||
char *arg = argv[i];
|
||||
if (arg[0] != '-') {
|
||||
load_resource_info.pResourcePath = arg;
|
||||
res = KrLoadResource(&load_resource_info);
|
||||
if (res != KR_SUCCESS) {
|
||||
printf("Failed to load resource: %s\n", arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
KrShutdown();
|
||||
/*
|
||||
Context* context = Context::Get();
|
||||
|
||||
for (int i = 0; i < argc; i++) {
|
||||
@@ -15,7 +41,6 @@ int main( int argc, char *argv[] )
|
||||
context->loadResource(arg);
|
||||
}
|
||||
}
|
||||
|
||||
printf("Kraken Convert\n");
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user