#include "FFGLPluginInstance.h" #include "FFDebugMessage.h" #include FFGLPluginInstance:: FFGLPluginInstance() :m_ffPluginMain(NULL), m_ffInstanceID(INVALIDINSTANCE), m_numParameters(0) { int i; for (i=0; i=MAX_PARAMETERS) return; int i = paramNum; if (m_paramNames[i]!=NULL) delete m_paramNames[i]; m_paramNames[i] = new char[strlen(name)+1]; strcpy(m_paramNames[i], name); } const char *FFGLPluginInstance::GetParameterName(int paramNum) { if (paramNum<0 || paramNum>=MAX_PARAMETERS) return ""; if (m_paramNames[paramNum]!=NULL) return m_paramNames[paramNum]; return ""; } void FFGLPluginInstance::SetFloatParameter(int paramNum, float value) { if (paramNum<0 || paramNum>=m_numParameters || m_ffInstanceID==INVALIDINSTANCE || m_ffPluginMain==NULL) { //the parameter or the plugin doesn't exist return; } //make sure its a float parameter type DWORD ffParameterType = m_ffPluginMain(FF_GETPARAMETERTYPE,(DWORD)paramNum,0).ivalue; if (ffParameterType!=FF_TYPE_TEXT) { SetParameterStruct ArgStruct; ArgStruct.ParameterNumber = paramNum; //be careful with this cast.. ArgStruct.NewParameterValue is DWORD //for this to compile correctly, sizeof(DWORD) must == sizeof(float) *((float *)(unsigned)&ArgStruct.NewParameterValue) = value; m_ffPluginMain(FF_SETPARAMETER,(DWORD)(&ArgStruct), m_ffInstanceID); } } void FFGLPluginInstance::SetTime(double curTime) { if (m_ffInstanceID==INVALIDINSTANCE || m_ffPluginMain==NULL) { FFDebugMessage("Invalid SetTime call"); return; } m_ffPluginMain(FF_SETTIME, (DWORD)(&curTime), m_ffInstanceID); } float FFGLPluginInstance::GetFloatParameter(int paramNum) { if (paramNum<0 || paramNum>=m_numParameters || m_ffInstanceID==INVALIDINSTANCE || m_ffPluginMain==NULL) { FFDebugMessage("Invalid GetFloatParameter call"); return 0.f; } //make sure its a float parameter type DWORD ffParameterType = m_ffPluginMain(FF_GETPARAMETERTYPE,(DWORD)paramNum,0).ivalue; if (ffParameterType!=FF_TYPE_TEXT) { plugMainUnion result = m_ffPluginMain(FF_GETPARAMETER,(DWORD)paramNum, m_ffInstanceID); //make sure the call to get the parameter succeeded before //reading the float value if (result.ivalue!=FF_FAIL) { return result.fvalue; } } return 0.f; } DWORD FFGLPluginInstance::CallProcessOpenGL(ProcessOpenGLStructTag &t) { //make sure we have code to call otherwise return the unprocessed input if (m_ffPluginMain==NULL || m_ffInstanceID==INVALIDINSTANCE) { FFDebugMessage("Invalid CallProcessOpenGL call"); return FF_FAIL; } DWORD retVal = FF_FAIL; try { retVal = m_ffPluginMain(FF_PROCESSOPENGL, (DWORD)&t, m_ffInstanceID).ivalue; } catch (...) { FFDebugMessage("Error on call to FreeFrame::ProcessFrame"); retVal = FF_FAIL; } return retVal; } void FFGLPluginInstance::ReleaseParamNames() { int i; for (i=0; i