Skip to content

Commit

Permalink
Merge pull request #15 from medcelerate/Unloading
Browse files Browse the repository at this point in the history
Unloading
  • Loading branch information
medcelerate authored Jul 9, 2024
2 parents e91e886 + 2205c73 commit 05c33de
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 9 deletions.
44 changes: 39 additions & 5 deletions FFGLTouchEngine/src/TouchEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ FFGLTouchEngine::FFGLTouchEngine()
// Parameters
SetParamInfof(0, "Tox File", FF_TYPE_FILE);
SetParamInfof(1, "Reload", FF_TYPE_EVENT);
SetParamInfof(2, "Unload", FF_TYPE_EVENT);
SetParamInfof(3, "Clear Instance", FF_TYPE_EVENT);

MaxParamsByType = 30;

//This is the starting point for the parameters
OffsetParamsByType = 2;
//This is the starting point for the parameters and is equal to the number of parameters above.
OffsetParamsByType = 4;

MaxParamsByType = 30;

ConstructBaseParameters();

Expand Down Expand Up @@ -403,11 +404,28 @@ FFResult FFGLTouchEngine::DeInitGL()

FFResult FFGLTouchEngine::SetFloatParameter(unsigned int dwIndex, float value) {

if (dwIndex == 1) {
if (dwIndex == 1 && value == 1) {
LoadTouchEngine();
LoadTEFile();
return FF_SUCCESS;
}

if (dwIndex == 2 && value == 1) {
if (isTouchEngineLoaded)
{
TEInstanceSuspend(instance);
TEInstanceUnload(instance);
}
ResetBaseParameters();
return FF_SUCCESS;
}

if (dwIndex == 3 && value == 1) {
ResetBaseParameters();
ClearTouchInstance();
return FF_SUCCESS;
}

if (!isTouchEngineLoaded || !isTouchEngineReady) {
return FF_SUCCESS;
}
Expand Down Expand Up @@ -978,6 +996,22 @@ void FFGLTouchEngine::ResumeTouchEngine() {

}

void FFGLTouchEngine::ClearTouchInstance() {
if (instance != nullptr)
{
if (isTouchEngineLoaded)
{
TEInstanceSuspend(instance);
TEInstanceUnload(instance);
}
isInteropInitialized = !OutputInterop.CleanupInterop();
instance.reset();
D3DContext.reset();
isGraphicsContextLoaded = false;
}
return;
}

void FFGLTouchEngine::InitializeGlTexture(GLuint& texture, uint16_t width, uint16_t height)
{
if (texture != 0) {
Expand Down
1 change: 1 addition & 0 deletions FFGLTouchEngine/src/TouchEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class FFGLTouchEngine : public CFFGLPlugin
void LoadTouchEngine();
void ResumeTouchEngine();
void GetAllParameters();
void ClearTouchInstance();
void eventCallback(TEEvent event, TEResult result, int64_t start_time_value, int32_t start_time_scale, int64_t end_time_value, int32_t end_time_scale);
void linkCallback(TELinkEvent event, const char* identifier);

Expand Down
45 changes: 41 additions & 4 deletions FFGLTouchEngineFX/src/TouchEngineFX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,14 @@ FFGLTouchEngineFX::FFGLTouchEngineFX()
// Parameters
SetParamInfof(0, "Tox File", FF_TYPE_FILE);
SetParamInfof(1, "Reload", FF_TYPE_EVENT);
SetParamInfof(2, "Unload", FF_TYPE_EVENT);
SetParamInfof(3, "Clear Instance", FF_TYPE_EVENT);

//This is the starting point for the parameters and should be the count of manually added parameters.
OffsetParamsByType = 4;

MaxParamsByType = 30;

//This is the starting point for the parameters
OffsetParamsByType = 2;
MaxParamsByType = 30;


ConstructBaseParameters();
Expand Down Expand Up @@ -535,11 +538,28 @@ FFResult FFGLTouchEngineFX::DeInitGL()

FFResult FFGLTouchEngineFX::SetFloatParameter(unsigned int dwIndex, float value) {

if (dwIndex == 1) {
if (dwIndex == 1 && value == 1) {
LoadTouchEngine();
LoadTEFile();
return FF_SUCCESS;
}

if (dwIndex == 2 && value == 1) {
if (isTouchEngineLoaded)
{
TEInstanceSuspend(instance);
TEInstanceUnload(instance);
}
ResetBaseParameters();
return FF_SUCCESS;
}

if (dwIndex == 3 && value == 1) {
ResetBaseParameters();
ClearTouchInstance();
return FF_SUCCESS;
}

if (!isTouchEngineLoaded || !isTouchEngineReady) {
return FF_SUCCESS;
}
Expand Down Expand Up @@ -1269,6 +1289,23 @@ void FFGLTouchEngineFX::ResumeTouchEngine() {

}

void FFGLTouchEngineFX::ClearTouchInstance() {
if (instance != nullptr)
{
if (isTouchEngineLoaded)
{
TEInstanceSuspend(instance);
TEInstanceUnload(instance);
}
InputInteropInitialized = !InputInterop.CleanupInterop();
OutputInteropInitialized = !OutputInterop.CleanupInterop();
instance.reset();
D3DContext.reset();
isGraphicsContextLoaded = false;
}
return;
}

void FFGLTouchEngineFX::InitializeGlTexture(GLuint& texture, uint16_t width, uint16_t height)
{
if (texture != 0) {
Expand Down
1 change: 1 addition & 0 deletions FFGLTouchEngineFX/src/TouchEngineFX.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class FFGLTouchEngineFX : public CFFGLPlugin
void LoadTouchEngine();
void ResumeTouchEngine();
void GetAllParameters();
void ClearTouchInstance();
void eventCallback(TEEvent event, TEResult result, int64_t start_time_value, int32_t start_time_scale, int64_t end_time_value, int32_t end_time_scale);
void linkCallback(TELinkEvent event, const char* identifier);

Expand Down

0 comments on commit 05c33de

Please sign in to comment.