Files
kraken/tools/convert/main.cpp

78 lines
2.1 KiB
C++
Raw Normal View History

#include "main.h"
#include <stdio.h>
#include "kraken.h"
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;
2019-07-28 16:46:46 -07:00
init_info.resourceMapSize = 1024;
KrResult res = KrInitialize(&init_info);
if (res != KR_SUCCESS) {
printf("Failed to initialize Kraken!\n");
return 1;
}
2019-07-28 16:46:46 -07:00
KrCreateBundleInfo create_bundle_info = {};
create_bundle_info.sType = KR_STRUCTURE_TYPE_CREATE_BUNDLE;
create_bundle_info.resourceHandle = 0;
create_bundle_info.pBundleName = "output";
res = KrCreateBundle(&create_bundle_info);
if (res != KR_SUCCESS) {
printf("Failed to create bundle.\n");
KrShutdown();
return 1;
}
KrLoadResourceInfo load_resource_info = {};
2019-07-28 16:46:46 -07:00
load_resource_info.sType = KR_STRUCTURE_TYPE_LOAD_RESOURCE;
load_resource_info.resourceHandle = 1;
KrMoveToBundleInfo move_to_bundle_info = {};
move_to_bundle_info.sType = KR_STRUCTURE_TYPE_MOVE_TO_BUNDLE;
move_to_bundle_info.bundleHandle = 0;
2019-08-17 21:57:55 -07:00
for (int i = 1; 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);
}
2019-07-28 16:46:46 -07:00
move_to_bundle_info.resourceHandle = 1;
res = KrMoveToBundle(&move_to_bundle_info);
if (res != KR_SUCCESS) {
printf("Failed to move resource to bundle.\n");
}
}
}
2019-07-28 16:46:46 -07:00
KrSaveResourceInfo save_resource_info = {};
save_resource_info.sType = KR_STRUCTURE_TYPE_SAVE_RESOURCE;
save_resource_info.resourceHandle = 0;
save_resource_info.pResourcePath = "output.krbundle";
res = KrSaveResource(&save_resource_info);
if (res != KR_SUCCESS) {
2019-08-03 18:53:05 -07:00
printf("Failed to save bundle.\nError %i\n", res);
2019-07-28 16:46:46 -07:00
}
KrShutdown();
/*
Context* context = Context::Get();
for (int i = 0; i < argc; i++) {
char *arg = argv[i];
if (arg[0] != '-') {
context->loadResource(arg);
}
}
*/
return 0;
}