Skip to content

Commit f35d191

Browse files
committed
Fix for broken output
1 parent b9c63d3 commit f35d191

1 file changed

Lines changed: 31 additions & 63 deletions

File tree

src/plugins/FFGLTouchEngineFX/TouchEngineFX.cpp

Lines changed: 31 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ void main()
4646
#ifdef _WIN32
4747
void textureCallback(TED3D11Texture* texture, TEObjectEvent event, void* info)
4848
{
49+
if (event == TEObjectEventRelease) {
50+
// Release the texture
51+
FFGLLog::LogToHost("Releasing texture");
52+
}
53+
FFGLLog::LogToHost("Texture callback called");
4954
return;
5055
}
5156
#endif
@@ -122,7 +127,13 @@ FFResult FFGLTouchEngineFX::ProcessOpenGL(ProcessOpenGLStruct* pGL)
122127

123128
if (!isTouchEngineLoaded || !isTouchEngineReady || isTouchFrameBusy)
124129
{
125-
return FF_SUCCESS;
130+
ffglex::ScopedShaderBinding shaderBinding(shader.GetGLID());
131+
ffglex::ScopedSamplerActivation activateSampler(0);
132+
ffglex::Scoped2DTextureBinding textureBinding(SpoutTextureOutput);
133+
shader.Set("InputTexture", 0);
134+
shader.Set("MaxUV", 1.0f, 1.0f);
135+
quad.Draw();
136+
return FF_FAIL;
126137
}
127138

128139
if (pGL->numInputTextures < 1) {
@@ -137,6 +148,12 @@ FFResult FFGLTouchEngineFX::ProcessOpenGL(ProcessOpenGLStruct* pGL)
137148
return FF_FAIL;
138149
}
139150

151+
shader.Set("InputTexture", 0);
152+
FFGLTexCoords maxCoords = GetMaxGLTexCoords(*pGL->inputTextures[0]);
153+
shader.Set("MaxUV", maxCoords.s, maxCoords.t);
154+
quad.Draw();
155+
156+
//Iss
140157

141158
if (hasVideoOutput) {
142159
TouchObject<TETexture> TETextureToSend;
@@ -163,7 +180,12 @@ FFResult FFGLTouchEngineFX::ProcessOpenGL(ProcessOpenGLStruct* pGL)
163180

164181
RawTextureToSend->GetDesc(&RawTextureDesc);
165182

166-
if (!OutputInteropInitialized) {
183+
if (!OutputInteropInitialized || RawTextureDesc.Width != OutputWidth
184+
|| RawTextureDesc.Height != OutputHeight
185+
|| RawTextureDesc.Format != DXFormat) {
186+
187+
OutputWidth = RawTextureDesc.Width;
188+
OutputHeight = RawTextureDesc.Height;
167189

168190
OutputInterop.SetSenderName(SpoutIDOutput.c_str());
169191

@@ -187,29 +209,6 @@ FFResult FFGLTouchEngineFX::ProcessOpenGL(ProcessOpenGLStruct* pGL)
187209
OutputInteropInitialized = true;
188210
}
189211

190-
if (
191-
RawTextureDesc.Width != OutputWidth
192-
|| RawTextureDesc.Height != OutputHeight
193-
|| RawTextureDesc.Format != DXFormat
194-
) {
195-
OutputWidth = RawTextureDesc.Width;
196-
OutputHeight = RawTextureDesc.Height;
197-
198-
if (!OutputInterop.CleanupInterop()) {
199-
return FailAndLog("Failed to cleanup interop");
200-
}
201-
202-
if (!OutputInterop.CreateInterop(OutputWidth, OutputHeight, RawTextureDesc.Format, false)) {
203-
return FailAndLog("Failed to create interop");
204-
}
205-
206-
OutputInterop.spoutdx.CreateDX11Texture(D3DDevice.Get(), OutputWidth, OutputHeight, RawTextureDesc.Format, &D3DTextureOutput);
207-
208-
InitializeGlTexture(SpoutTextureOutput, OutputWidth, OutputHeight, GetGlType(RawTextureDesc.Format));
209-
210-
DXFormat = RawTextureDesc.Format;
211-
212-
}
213212

214213

215214
IDXGIKeyedMutex* keyedMutex;
@@ -276,39 +275,31 @@ FFResult FFGLTouchEngineFX::ProcessOpenGL(ProcessOpenGLStruct* pGL)
276275
return pushResult;
277276
}
278277

279-
TouchObject<TETexture> TETextureToReceive;
278+
280279
if (hasVideoInput) {
281280

282281
//Basic functions to get data out of resolume and into a texture.
283282
ffglex::ScopedShaderBinding shaderBinding(shader.GetGLID());
284283
ffglex::ScopedSamplerActivation activateSampler(0);
285284
ffglex::Scoped2DTextureBinding textureBinding(pGL->inputTextures[0]->Handle);
286285

287-
shader.Set("InputTexture", 0);
286+
/*shader.Set("InputTexture", 0);
288287
FFGLTexCoords maxCoords = GetMaxGLTexCoords(*pGL->inputTextures[0]);
289288
shader.Set("MaxUV", maxCoords.s, maxCoords.t);
290-
quad.Draw();
289+
quad.Draw();*/
291290

292291
GLint InputFormat = 0;
293292
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &InputFormat);
294293

295294

296-
if (!InputInteropInitialized) {
295+
if (!InputInteropInitialized || InputWidth != pGL->inputTextures[0]->Width
296+
|| InputHeight != pGL->inputTextures[0]->Height
297+
|| InputFormat != GLFormat) {
297298

298299
InputWidth = pGL->inputTextures[0]->Width;
299300
InputHeight = pGL->inputTextures[0]->Height;
300301
#ifdef _WIN32
301-
/*
302-
DXGI_FORMAT texformat = DXOutputFormat;
303-
304-
if (!InputInterop.CreateInterop(InputWidth, InputHeight, texformat, false)) {
305-
return FailAndLog("Failed to create interop");
306-
}
307302

308-
if(!InputInterop.frame.CreateAccessMutex(SpoutID.c_str())) {
309-
return FailAndLog("Failed to create access mutex");
310-
}
311-
*/
312303

313304
InputInterop.SetSenderName(SpoutIDInput.c_str());
314305

@@ -329,34 +320,11 @@ FFResult FFGLTouchEngineFX::ProcessOpenGL(ProcessOpenGLStruct* pGL)
329320
InitializeGlTexture(SpoutTextureInput, InputWidth, InputHeight, GetGlType(InputFormat));
330321

331322
InputInteropInitialized = true;
332-
#endif
333-
}
334-
335-
if (
336-
InputWidth != pGL->inputTextures[0]->Width
337-
|| InputHeight != pGL->inputTextures[0]->Height
338-
|| InputFormat != GLFormat
339-
) {
340-
341-
InputWidth = pGL->inputTextures[0]->Width;
342-
InputHeight = pGL->inputTextures[0]->Height;
343-
344-
#ifdef _WIN32
345-
if (!InputInterop.CleanupInterop()) {
346-
return FailAndLog("Failed to cleanup interop");
347-
}
348-
349-
if (!InputInterop.CreateInterop(InputWidth, InputHeight, GlToDXFromat(InputFormat), false)) {
350-
return FailAndLog("Failed to create interop");
351-
}
352-
353-
InputInterop.spoutdx.CreateDX11Texture(D3DDevice.Get(), InputWidth, InputHeight, GlToDXFromat(InputFormat), &D3DTextureInput);
354-
355-
InitializeGlTexture(SpoutTextureInput, InputWidth, InputHeight, GetGlType(InputFormat));
356323
#endif
357324
GLFormat = InputFormat;
358325
}
359326

327+
360328
#ifdef _WIN32
361329
InputInterop.WriteGLDXtexture(pGL->inputTextures[0]->Handle, GL_TEXTURE_2D, InputWidth, InputHeight, true, pGL->HostFBO);
362330

0 commit comments

Comments
 (0)