Page 1 of 1

Do string parameters work in FFGL Plugins?

Posted: Wed Apr 24, 2013 06:09
by elio
Do String parameters from FFGL Plugins work in Resolume?
I've been trying FF_TYPE_TEXT but just the definition (without even getting or setting parameter values) makes Resolume crash.

SetParamInfo(FFPARAM_Bridge, "SharedMemoryName", FF_TYPE_TEXT, "xxxx");

Thanks for helping me! Elio

Re: Do string parameters work in FFGL Plugins?

Posted: Wed Apr 24, 2013 13:17
by bangnoise
Yep they work - we use them for the Syphon plugins (now redundant in Resolume, but still functional). We don't use the FFGL SDK, but code is at http://code.google.com/p/syphon-impleme ... FFreeFrame

Re: Do string parameters work in FFGL Plugins?

Posted: Wed Apr 24, 2013 15:40
by elio
Hey thanks for this. I'll have a look on it.
Just realized that the FFGL SDK seems to have a bug regarding strings.
I'm just about to create a fix.

Re: Do string parameters work in FFGL Plugins?

Posted: Wed Apr 24, 2013 15:52
by elio
FFGL.cpp seems to be buggy for String parameters (Version 1.5 - but Freeframe.cpp of Version 1.6 seems to be coded the same way)
In the documentation it says that strings are passed by memory location. But in FFGL.cpp getParameterDefault and instantiateGL treat them as values.
Here's a fix for FFGL.cpp of Freeframe 1.5:

Code: Select all

@@ -145,11 +145,16 @@ DWORD getParameterDefault(DWORD index)
 		if (dwRet == FF_FAIL) return FF_FAIL;
 	}
 
+	DWORD dwType = s_pPrototype->GetParamType(DWORD(index));
 	void* pValue = s_pPrototype->GetParamDefault(index);
 	if (pValue == NULL) return FF_FAIL;
 	else {
 		DWORD dwRet;
-		memcpy(&dwRet, pValue, 4);
+		if ( dwType == FF_TYPE_TEXT ) {
+			dwRet = (DWORD) pValue;
+		} else {
+			memcpy(&dwRet, pValue, 4);
+		}
 		return dwRet;
 	}
 }
@@ -253,11 +258,15 @@ DWORD instantiateGL(const FFGLViewportStruct *pGLViewport)
 	// Initializing instance with default values
 	for (int i = 0; i < s_pPrototype->GetNumParams(); ++i)
   {
-		//DWORD dwType = s_pPrototype->GetParamType(DWORD(i));
+		DWORD dwType = s_pPrototype->GetParamType(DWORD(i));
 		void* pValue = s_pPrototype->GetParamDefault(DWORD(i));
 		SetParameterStruct ParamStruct;
 		ParamStruct.ParameterNumber = DWORD(i);
-		memcpy(&ParamStruct.NewParameterValue, pValue, 4);
+		if ( dwType == FF_TYPE_TEXT ) {
+			ParamStruct.NewParameterValue = (DWORD) pValue;
+		} else {
+			memcpy(&ParamStruct.NewParameterValue, pValue, 4);
+		}
 		dwRet = pInstance->SetParameter(&ParamStruct);
 		if (dwRet == FF_FAIL)
     {