Code: Select all
virtual FFResult SetTextParameter(unsigned int index, const char *value);
virtual char* GetTextParameter(unsigned int index);
Code: Select all
FFResult CFreeFrameGLPlugin::SetTextParameter(unsigned int index, const char *value)
{
return FF_FAIL;
}
char* CFreeFrameGLPlugin::GetTextParameter(unsigned int index)
{
return (char *)FF_FAIL;
}
Code: Select all
float GetFloatParameter(unsigned int dwIndex) override;
char* GetTextParameter(unsigned int dwIndex) override;
Code: Select all
FFResult SpxlLabelParams::SetTextParameter(unsigned int dwIndex, const char *value)
{
// Check range
if (dwIndex < 0 || dwIndex >= m_paramsCount)
return FF_FAIL;
// Grab a pointer to the relevant local paramater info struct
LocalParamInfo * p = &m_localParams[dwIndex];
if (value != NULL && value[0] != 0)
{
// Nonempty value, so use value
// Avoid reallocating if not changing
if (p->text != NULL && strcmp(p->text, value))
{
delete p->text;
p->text = _strdup(value);
}
}
else if (p->defaultText != NULL && p->defaultText[0] != 0)
{
// Value is empty, default is nonempty, so use default
// Avoid reallocating if not changing
if (p->text != NULL && strcmp(p->text, p->defaultText))
{
delete p->text;
p->text = _strdup(p->defaultText);
}
}
else
{
// Value and default are both empty, so save an empty string
// Avoid reallocating if not changing
if (p->text != NULL && p->text[0] != 0)
{
delete p->text;
p->text = _strdup("");
}
}
return FF_SUCCESS;
}
char* SpxlLabelParams::GetTextParameter(unsigned int dwIndex)
{
char * retValue = "";
// Check range
if (0 <= dwIndex && dwIndex < m_paramsCount)
{
retValue = _strdup(m_localParams[dwIndex].text);
};
return retValue;
}
Code: Select all
class SpxlLabelParams : public CFreeFrameGLPlugin
{
public:
typedef struct LocalParamInfoStruct
{
unsigned int index;
char * displayName;
int ffType;
float defaultValue;
float value;
char * defaultText;
char * text;
char * uniformName;
GLint uniformLocation;
LocalParamInfoStruct() :
index(0),
displayName(NULL),
ffType(-1),
value(0.0f),
defaultValue(0.0f),
defaultText(NULL),
text(NULL),
uniformName(NULL),
uniformLocation(-1)
{
// Empty constructor
}
} LocalParamInfo;
// Other class stuff follows
}
The FFGLSDK-provided declarations don't say much about how the "char *" parameter and return value are to be treated. I had some issues with my plugin crashing, and I don't know if it was because an earlier iteration had
Code: Select all
retValue = m_localParams[dwIndex].text;
Any insight?
I noticed that Resolume both sets every parameter value and requests the string version of every value for every frame, which is why I have comparisons and deletes in my code when I'm storing the value coming in from Resolume. I haven't got around to figuring out how to test if I'm leaking memory.
I was also kinda hoping to be able to have my plugin update the value of the text parameter in Resolume, but it seems Resolume does not display (nor perhaps in any way use) the string I return.
-subpixel