Added OSC
Some checks failed
CI / Native Windows Build And Tests (push) Failing after 7s
CI / React UI Build (push) Has been cancelled
CI / Windows Release Package (push) Has been cancelled

This commit is contained in:
2026-05-03 12:17:03 +10:00
parent 1b56ede462
commit 254d4cd070
14 changed files with 499 additions and 0 deletions

View File

@@ -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))