Added KrCompileAllShaders and stub implementation
This commit is contained in:
@@ -5,8 +5,15 @@
|
||||
|
||||
using namespace kraken;
|
||||
|
||||
enum ResourceMapping {
|
||||
output_bundle = 0,
|
||||
loaded_resource = 1,
|
||||
shader_compile_log = 2,
|
||||
};
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
bool failed = false;
|
||||
printf("Kraken Convert\n");
|
||||
printf("Initializing Kraken...\n");
|
||||
KrInitializeInfo init_info = {};
|
||||
@@ -20,7 +27,7 @@ int main( int argc, char *argv[] )
|
||||
|
||||
KrCreateBundleInfo create_bundle_info = {};
|
||||
create_bundle_info.sType = KR_STRUCTURE_TYPE_CREATE_BUNDLE;
|
||||
create_bundle_info.resourceHandle = 0;
|
||||
create_bundle_info.resourceHandle = ResourceMapping::output_bundle;
|
||||
create_bundle_info.pBundleName = "output";
|
||||
res = KrCreateBundle(&create_bundle_info);
|
||||
if (res != KR_SUCCESS) {
|
||||
@@ -31,15 +38,16 @@ int main( int argc, char *argv[] )
|
||||
|
||||
KrLoadResourceInfo load_resource_info = {};
|
||||
load_resource_info.sType = KR_STRUCTURE_TYPE_LOAD_RESOURCE;
|
||||
load_resource_info.resourceHandle = 1;
|
||||
load_resource_info.resourceHandle = ResourceMapping::loaded_resource;
|
||||
|
||||
KrMoveToBundleInfo move_to_bundle_info = {};
|
||||
move_to_bundle_info.sType = KR_STRUCTURE_TYPE_MOVE_TO_BUNDLE;
|
||||
move_to_bundle_info.bundleHandle = 0;
|
||||
move_to_bundle_info.bundleHandle = ResourceMapping::output_bundle;
|
||||
|
||||
char* output_bundle = nullptr;
|
||||
bool compile_shaders = false;
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
for (int i = 1; i < argc && !failed; i++) {
|
||||
char *arg = argv[i];
|
||||
if (arg[0] == '-') {
|
||||
continue;
|
||||
@@ -50,6 +58,9 @@ int main( int argc, char *argv[] )
|
||||
case 'o':
|
||||
output_bundle = arg;
|
||||
break;
|
||||
case 'c':
|
||||
compile_shaders = true;
|
||||
break;
|
||||
default:
|
||||
printf("Unknown command: -%c\n", command);
|
||||
break;
|
||||
@@ -62,31 +73,49 @@ int main( int argc, char *argv[] )
|
||||
res = KrLoadResource(&load_resource_info);
|
||||
if (res != KR_SUCCESS) {
|
||||
printf("[FAIL] (KrLoadResource)\n");
|
||||
failed = true;
|
||||
continue;
|
||||
}
|
||||
move_to_bundle_info.resourceHandle = 1;
|
||||
move_to_bundle_info.resourceHandle = ResourceMapping::loaded_resource;
|
||||
res = KrMoveToBundle(&move_to_bundle_info);
|
||||
if (res != KR_SUCCESS) {
|
||||
printf("[FAIL] (KrMoveToBundle)\n");
|
||||
failed = true;
|
||||
continue;
|
||||
}
|
||||
printf("[GOOD]\n");
|
||||
}
|
||||
|
||||
if (output_bundle) {
|
||||
if (compile_shaders && !failed) {
|
||||
printf("Compiling Shaders...\n");
|
||||
KrCompileAllShadersInfo compile_all_shaders_info = {};
|
||||
compile_all_shaders_info.sType = KR_STRUCTURE_TYPE_COMPILE_ALL_SHADERS;
|
||||
compile_all_shaders_info.logHandle = ResourceMapping::shader_compile_log;
|
||||
res = KrCompileAllShaders(&compile_all_shaders_info);
|
||||
if (res != KR_SUCCESS) {
|
||||
printf("[FAIL] (Error %i)\n", res);
|
||||
failed = true;
|
||||
}
|
||||
else {
|
||||
printf("[GOOD]\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (output_bundle && !failed) {
|
||||
printf("Bundling %s... ", output_bundle);
|
||||
KrSaveResourceInfo save_resource_info = {};
|
||||
save_resource_info.sType = KR_STRUCTURE_TYPE_SAVE_RESOURCE;
|
||||
save_resource_info.resourceHandle = 0;
|
||||
save_resource_info.resourceHandle = ResourceMapping::output_bundle;
|
||||
save_resource_info.pResourcePath = output_bundle;
|
||||
res = KrSaveResource(&save_resource_info);
|
||||
if (res != KR_SUCCESS) {
|
||||
printf("[FAIL] (Error %i)\n", res);
|
||||
failed = true;
|
||||
} else {
|
||||
printf("[GOOD]\n");
|
||||
}
|
||||
}
|
||||
|
||||
KrShutdown();
|
||||
return 0;
|
||||
return failed ? 1 : 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user