Implementing Async API
This commit is contained in:
@@ -320,6 +320,19 @@ void KRContext::loadResource(std::string path) {
|
||||
}
|
||||
}
|
||||
|
||||
KrResult KRContext::unloadResource(const KrUnloadResourceInfo* unloadResourceInfo)
|
||||
{
|
||||
if (unloadResourceInfo->resourceHandle < 0 || unloadResourceInfo->resourceHandle >= m_resourceMapSize) {
|
||||
return KR_ERROR_OUT_OF_BOUNDS;
|
||||
}
|
||||
KRResource* resource = m_resourceMap[unloadResourceInfo->resourceHandle];
|
||||
if (resource == nullptr) {
|
||||
return KR_ERROR_NOT_MAPPED;
|
||||
}
|
||||
// TODO - Need to implement unloading logic
|
||||
return KR_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void KRContext::detectExtensions() {
|
||||
m_bDetectedExtensions = true;
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ public:
|
||||
KRContext(const KrInitializeInfo* initializeInfo);
|
||||
~KRContext();
|
||||
|
||||
KrResult unloadResource(const KrUnloadResourceInfo* unloadResourceInfo);
|
||||
|
||||
void loadResource(const std::string &file_name, KRDataBlock *data);
|
||||
void loadResource(std::string path);
|
||||
|
||||
|
||||
@@ -36,7 +36,10 @@ KrResult KrLoadResource(const KrLoadResourceInfo* pLoadResourceInfo)
|
||||
|
||||
KrResult KrUnloadResource(const KrUnloadResourceInfo* pUnloadResourceInfo)
|
||||
{
|
||||
return KR_ERROR_NOT_IMPLEMENTED;
|
||||
if (!sContext) {
|
||||
return KR_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
return sContext->unloadResource(pUnloadResourceInfo);
|
||||
}
|
||||
|
||||
KrResult KrSaveResource(const KrSaveResourceInfo* pSaveResourceInfo)
|
||||
|
||||
@@ -39,6 +39,8 @@ typedef enum {
|
||||
KR_SUCCESS = 0,
|
||||
KR_ERROR_NOT_INITIALIZED = 1,
|
||||
KR_ERROR_NOT_IMPLEMENTED = 2,
|
||||
KR_ERROR_OUT_OF_BOUNDS = 3,
|
||||
KR_ERROR_NOT_MAPPED = 4,
|
||||
KR_RESULT_MAX_ENUM = 0x7FFFFFFF
|
||||
} KrResult;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user