Added OSC
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
#include "ControlServer.h"
|
||||
#include "OpenGLComposite.h"
|
||||
#include "GLExtensions.h"
|
||||
#include "OscServer.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
@@ -325,6 +326,7 @@ OpenGLComposite::OpenGLComposite(HWND hWnd, HDC hDC, HGLRC hRC) :
|
||||
InitializeCriticalSection(&pMutex);
|
||||
mRuntimeHost = std::make_unique<RuntimeHost>();
|
||||
mControlServer = std::make_unique<ControlServer>();
|
||||
mOscServer = std::make_unique<OscServer>();
|
||||
}
|
||||
|
||||
OpenGLComposite::~OpenGLComposite()
|
||||
@@ -411,6 +413,8 @@ OpenGLComposite::~OpenGLComposite()
|
||||
destroyTemporalHistoryResources();
|
||||
destroyLayerPrograms();
|
||||
destroyDecodeShaderProgram();
|
||||
if (mOscServer)
|
||||
mOscServer->Stop();
|
||||
if (mControlServer)
|
||||
mControlServer->Stop();
|
||||
|
||||
@@ -843,6 +847,16 @@ bool OpenGLComposite::InitOpenGLState()
|
||||
}
|
||||
mRuntimeHost->SetServerPort(mControlServer->GetPort());
|
||||
|
||||
OscServer::Callbacks oscCallbacks;
|
||||
oscCallbacks.updateParameter = [this](const std::string& layerKey, const std::string& parameterKey, const std::string& valueJson, std::string& error) {
|
||||
return UpdateLayerParameterByControlKeyJson(layerKey, parameterKey, valueJson, error);
|
||||
};
|
||||
if (mRuntimeHost->GetOscPort() > 0 && !mOscServer->Start(mRuntimeHost->GetOscPort(), oscCallbacks, runtimeError))
|
||||
{
|
||||
MessageBoxA(NULL, runtimeError.c_str(), "OSC control server failed to start", MB_OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Prepare the runtime shader program generated from the active shader package.
|
||||
char compilerErrorMessage[1024];
|
||||
if (! compileDecodeShader(sizeof(compilerErrorMessage), compilerErrorMessage))
|
||||
@@ -1163,6 +1177,9 @@ bool OpenGLComposite::Start()
|
||||
|
||||
bool OpenGLComposite::Stop()
|
||||
{
|
||||
if (mOscServer)
|
||||
mOscServer->Stop();
|
||||
|
||||
if (mControlServer)
|
||||
mControlServer->Stop();
|
||||
|
||||
@@ -2120,6 +2137,19 @@ bool OpenGLComposite::UpdateLayerParameterJson(const std::string& layerId, const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenGLComposite::UpdateLayerParameterByControlKeyJson(const std::string& layerKey, const std::string& parameterKey, const std::string& valueJson, std::string& error)
|
||||
{
|
||||
JsonValue parsedValue;
|
||||
if (!ParseJson(valueJson, parsedValue, error))
|
||||
return false;
|
||||
|
||||
if (!mRuntimeHost->UpdateLayerParameterByControlKey(layerKey, parameterKey, parsedValue, error))
|
||||
return false;
|
||||
|
||||
broadcastRuntimeState();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenGLComposite::ResetLayerParameters(const std::string& layerId, std::string& error)
|
||||
{
|
||||
if (!mRuntimeHost->ResetLayerParameters(layerId, error))
|
||||
|
||||
Reference in New Issue
Block a user