start using the dispatcher
This commit is contained in:
@@ -10,6 +10,11 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceCreateInfo*
|
||||
*instance = malloc(sizeof(struct gnInstance_t));
|
||||
(*instance)->hasDebugger = GN_FALSE;
|
||||
(*instance)->layers = loaderLayerArrayListCreate();
|
||||
dispatcher_init(&(*instance)->dispatch);
|
||||
dispatcher_set_function_array_size(&(*instance)->dispatch, sizeof(gnInstanceFunctions));
|
||||
|
||||
dispatcher_create_layer(&(*instance)->dispatch, loadAPIInstanceFunctions, &info->coreAPI);
|
||||
|
||||
loaderLayerArrayListAdd(&(*instance)->layers, loadLayer((loaderInfo){
|
||||
.api = info->coreAPI,
|
||||
.layerToLoad = api_layer
|
||||
@@ -41,11 +46,17 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceCreateInfo*
|
||||
(*instance)->currentLayer = ((*instance)->layers.count - 1);
|
||||
for (int i = 0; i < (*instance)->layers.count; i++) (*instance)->layers.data[i].layerIndex = i;
|
||||
(*instance)->callingLayer = &(*instance)->layers.data[(*instance)->layers.count - 1];
|
||||
gnReturnCode core_code = (*instance)->callingLayer->instanceFunctions._gnCreateInstance((*instance), info);
|
||||
|
||||
gnInstanceFunctions* instance_funcs = (gnInstanceFunctions*)((*instance)->dispatch.first_layer->function_array);
|
||||
gnReturnCode core_code = instance_funcs->_gnCreateInstance((*instance), info);
|
||||
if (unsupportedExtension) return GN_UNLOADED_EXTENSION;
|
||||
return core_code;
|
||||
}
|
||||
|
||||
void gnDestroyInstance(gnInstanceHandle instance) {
|
||||
instance->callingLayer->instanceFunctions._gnDestroyInstance(instance);
|
||||
void gnDestroyInstance(gnInstanceHandle* instance) {
|
||||
if (instance == GN_NULL_HANDLE) return;
|
||||
|
||||
gnInstanceFunctions* instance_funcs = (gnInstanceFunctions*)((*instance)->dispatch.first_layer->function_array);
|
||||
instance_funcs->_gnDestroyInstance((*instance));
|
||||
*instance = GN_NULL_HANDLE;
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
#include "core/gryphn_return_code.h"
|
||||
#include "core/src/instance/gryphn_debugger.h"
|
||||
#include <gryphn_extensions.h>
|
||||
#include "Dispatcher/dispatcher.h"
|
||||
|
||||
typedef struct gnApplicationInfo {
|
||||
gnString applicationName;
|
||||
@@ -26,14 +27,16 @@ typedef struct gnInstanceCreateInfo {
|
||||
#include <loader/src/gryphn_loader.h>
|
||||
struct gnInstance_t {
|
||||
struct gnPlatformInstance_t* instance;
|
||||
gnDebuggerCreateInfo debugger;
|
||||
gnBool enabledExtensions[GN_EXT_MAX];
|
||||
dispatcher dispatch;
|
||||
|
||||
loaderLayerArrayList layers;
|
||||
loaderLayer* callingLayer;
|
||||
uint32_t currentLayer;
|
||||
gnBool enabledExtensions[GN_EXT_MAX];
|
||||
gnBool hasDebugger;
|
||||
gnDebuggerCreateInfo debugger;
|
||||
};
|
||||
#endif
|
||||
|
||||
gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceCreateInfo* info);
|
||||
void gnDestroyInstance(gnInstanceHandle instance);
|
||||
void gnDestroyInstance(gnInstanceHandle* instance);
|
||||
|
Reference in New Issue
Block a user