Quick Sign In:  

Forum: VirtualDJ Plugins

Topic: Need help in developing plugin - Page: 2

This topic is old and might contain outdated or incorrect information.

djcelPRO InfinityModeratorMember since 2004
locodog wrote :
*Edit also could you please UL the png for example 4, to save a bit of effort?

Right click => Save As on the picture should work ;-)
 

Posted Thu 23 Apr 15 @ 5:52 pm
locoDogPRO InfinityModeratorMember since 2013
So it does, thanks.
 

Posted Thu 23 Apr 15 @ 6:15 pm
Hey again,
Is there anyway to control the Automix panel?
What I'm trying to do is to take action on the Automix playlist, add songs, get songs and that stuff.
How can I do it? Is there any example for some kind of plugin using Automix?

many many thanks
 

Posted Sat 01 Aug 15 @ 1:23 pm
Trying my hand at developing VDJ plugins. I'm using Visual Studio 2015 express on Windows 10 box. Was able to get DirectX9 installed-ish. (enough to get past not being able to find the #include <d3dx9.h> file).

So everything compiles fine, except at the very end when it looks like it's gonna start, I get the following error message: Unable to start program... MyPlugin8.dll is not a valid Win32 application.



1>------ Rebuild All started: Project: MyPlugin8, Configuration: Debug Win32 ------
1> MyPlugin8.cpp
1> Main.cpp
1> Generating Code...
1>Main.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification
1> Creating library D:\Development\desktop\VDJ\Debug\MyPlugin8.lib and object D:\Development\desktop\VDJ\Debug\MyPlugin8.exp
1> MyPlugin8.vcxproj -> D:\Development\desktop\VDJ\Debug\MyPlugin8.dll
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
 

Posted Thu 09 Jun 16 @ 3:19 am
Looks like I just needed to "attached to process..."?? Although now, the plugin shows, but crashes VDJ as soon as it's activated. Thoughts?
 

Posted Thu 09 Jun 16 @ 3:57 am
SBDJPRO Infinity Member since 2006
Best bet is to set the debugger to run VDJ automatically - you can't run a dll. Then you can just hit run and it will all go :)

As for the crash it's likely to be a bug in your code.
 

Posted Thu 09 Jun 16 @ 7:59 am
I haven't added anything to the code from the Video Plugin Example. unless my ctrl-c, ctrl-v process is off. :p

Does anyone have a solution file for Visual Studio 2015 that they could send with the sample code?

I'm still kinda suspecting DirectX9 might be the problem. I tried installing the SDK from a JUNE 2010 build, and the install fails at the very end and says I should close programs or contact DirectX support, even though no programs are open.

However, after the failed attempt to install, the <d3dx9.h> finally resolves. Thoughts?

 

Posted Thu 09 Jun 16 @ 3:58 pm
djcelPRO InfinityModeratorMember since 2004
http://www.virtualdj.com/wiki/Plugins_SDKv8_Example3.html

#define DIRECT3D_VERSION 0x9000
#include <d3dx9.h>
#pragma comment(lib, "d3dx9.lib")

Example of project with VS 2015:

<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="FPS"
ProjectGUID="{2CF765B5-EE3A-4644-8839-0708DD641BFF}"
RootNamespace="Text2D"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile=".\Documents\VirtualDJ\Plugins\VideoEffect\debug_FPS.dll"
LinkIncremental="2"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/VDJPlugin.pdb"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile=".\Documents\VirtualDJ\Plugins64\VideoEffect\debug_FPS.dll"
LinkIncremental="2"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/VDJPlugin.pdb"
SubSystem="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="0"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="0"
CallingConvention="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(NOINHERIT)"
OutputFile="$(OutDir)/FPS.dll"
LinkIncremental="1"
GenerateManifest="false"
ManifestFile=""
IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="false"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="0"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="0"
CallingConvention="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(NOINHERIT)"
OutputFile="$(OutDir)/FPS.dll"
LinkIncremental="1"
GenerateManifest="false"
ManifestFile=""
IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="false"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\src\main.cpp"
>
</File>
<File
RelativePath="..\..\src\RAMdetection.cpp"
>
</File>
<File
RelativePath="..\..\src\Text2D_D3D11.cpp"
>
</File>
<File
RelativePath="..\..\src\Text2D_D3D9.cpp"
>
</File>
<File
RelativePath="..\..\src\VideoCard.cpp"
>
</File>
</Filter>
<Filter
Name="SDK8"
>
<Filter
Name="Header Files"
>
<File
RelativePath="..\..\src\SDK8\FPS8.h"
>
</File>
<File
RelativePath="..\..\src\SDK8\VdjPlugin8.h"
>
</File>
<File
RelativePath="..\..\src\SDK8\VdjVideo8.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath="..\..\src\SDK8\FPS8.cpp"
>
</File>
</Filter>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath="..\..\src\bitmap.bmp"
>
</File>
<File
RelativePath="..\..\src\bitmap.bmp"
>
</File>
<File
RelativePath="..\plugin.rc"
>
</File>
<File
RelativePath="..\resource.h"
>
</File>
</Filter>
<Filter
Name="SDK6"
>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\src\SDK6\FPS.h"
>
</File>
<File
RelativePath="..\..\src\SDK6\VdjPlugin.h"
>
</File>
<File
RelativePath="..\..\src\SDK6\VdjVideo.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath="..\..\src\SDK6\FPS.cpp"
>
</File>
</Filter>
</Filter>
<Filter
Name="Header Files"
>
<File
RelativePath="..\..\src\OpenGL_VideoMemoryExt.h"
>
</File>
<File
RelativePath="..\..\src\RAMdetection.h"
>
</File>
<File
RelativePath="..\..\src\Text2D_D3D11.h"
>
</File>
<File
RelativePath="..\..\src\Text2D_D3D9.h"
>
</File>
<File
RelativePath="..\..\src\VideoCard.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>





 

Posted Thu 09 Jun 16 @ 10:19 pm
The application breaks on a call in the header file: vdjVideo8.h

LINE 141: HRESULT DrawDeck() {return vcb->DrawDeck();}

Unhandled exception at 0x0002AF79 in virtualdj8.exe: 0xC0000005: Access violation executing location 0x0002AF79.

DirectX9 is now installed fully...so that shouldn't be the issue anymore.
 

Posted Fri 10 Jun 16 @ 1:35 pm
I recopied the vdjVideo8.h file from here: http://www.virtualdj.com/wiki/Plugins_SDKv8_Video.html

and it started working. Maybe the ZIP of all the headers isn't up-to-date? I compared the files and nothing really looks changed, however some lines are in a different order.

Either way, I'm on my way! Thanks everyone for your help!

Goal is to create a Streaming Plugin that allows me to Stream content from the web into Virtual DJ via an RTSP link. This would allow DJ's to possibly provide each other with Live Streams of their sets and play them thru VDJ.

If anyone has any guidance or ideas to get me rolling in the right direction...I welcome them.

 

Posted Fri 10 Jun 16 @ 1:54 pm
Can someone explain what the equivilent calls for Windows would be for the commented out FOR Loop in the MAC defined section? I'm having trouble getting anything but a blank/black screen to show...


#if (defined(VDJ_WIN))

hr = GetTexture(VdjVideoEngineDirectX9, (void **) &D3DTexture, &vertices);
hr = D3DTexture->GetSurfaceLevel(0, &D3DSurface);

SAFE_RELEASE(D3DTexture);
SAFE_RELEASE(D3DSurface);

#elif (defined(VDJ_MAC))

hr = GetTexture(VdjVideoEngineOpenGL, (void **) &GLTexture, &vertices);

// glEnable(GL_TEXTURE_RECTANGLE_EXT);
// glBindTexture(GL_TEXTURE_RECTANGLE_EXT, GLTexture);
// glBegin(GL_TRIANGLE_STRIP);

//for(int j=0;j<4;j++)
//{
//glColorD3D(vertices[j].color);
//glTexCoord2f(vertices[j].tu, vertices[j].tv);
//glVertex3f(vertices[j].position.x, vertices[j].position.y, vertices[j].position.z);
//}

//glEnd();
#endif

 

Posted Fri 10 Jun 16 @ 5:23 pm
Or I will even take an example of simply dumping Text to the screen. I just need a starting point to see something I'm doing show on the screen. Or if the example is supposed to show something on the screen, maybe a screen shot of what it's supposed to show would be helpful, although it doesn't look like from what I can tell in the example that anything is going to show currently. Any help to get me started would be great.

some things I've tried...

HRESULT VDJ_API CMyPlugin8::OnDraw()
{

// ADD YOUR CODE HERE
HRESULT hr;
TVertex *vertices;
IDirect3DTexture9 *texture;
RECT font_rect = { 0,0,width,height };
int font_height;
const char *fps_string;

if (VideoWidth != width || VideoHeight != height)
{
hr = OnVideoResize(width, height);
}

GetDevice(VdjVideoEngineDirectX9, (void **)&D3DDevice);
if (D3DDevice != NULL) {
}


ID3DXFont *g_font = NULL;

hr = D3DXCreateFont(D3DDevice, //D3D Device

22, //Font height

0, //Font width

FW_NORMAL, //Font Weight

1, //MipLevels

false, //Italic

DEFAULT_CHARSET, //CharSet

OUT_DEFAULT_PRECIS, //OutputPrecision

ANTIALIASED_QUALITY, //Quality

DEFAULT_PITCH | FF_DONTCARE,//PitchAndFamily

"Arial", //pFacename,

&g_font); //ppFont

//Show our frames per second

hr = D3DDevice->BeginScene();

fps_string = "Testing";


//A pre-formatted string showing the current frames per second

SetRect(&font_rect, 0, 0, width, height);

font_height = g_font->DrawText(NULL, //pSprite
fps_string, //pString
-1, //Count
&font_rect, //pRect
DT_LEFT | DT_NOCLIP,//Format,
0xFFFFFFFF); //Color
if (!font_height) {
//dhLog("Error Drawing font");
}


#if (defined(VDJ_WIN))

hr = GetTexture(VdjVideoEngineDirectX9, (void **)&texture, &vertices);

vertices[0].position.x = 0.0f;
vertices[0].position.y = 0.0f;
vertices[0].position.z = 0.5f;
vertices[0].color = D3DCOLOR_RGBA(255, 255, 255, 255);
vertices[0].tu = 0.0f;
vertices[0].tv = 0.0f;

vertices[1].position.x = (float)width;
vertices[1].position.y = 0.f;
vertices[1].position.z = 0.5f;
vertices[1].color = D3DCOLOR_RGBA(255, 255, 255, 255);
vertices[1].tu = 1.0f;
vertices[1].tv = 0.0f;

vertices[2].position.x = (float)width;
vertices[2].position.y = (float)height;
vertices[2].position.z = 0.5f;
vertices[2].color = D3DCOLOR_RGBA(255, 255, 255, 255);
vertices[2].tu = 1.0f;
vertices[2].tv = 1.0f;

vertices[3].position.x = 0.0f;
vertices[3].position.y = (float)height;
vertices[3].position.z = 0.5f;
vertices[3].color = D3DCOLOR_RGBA(255, 255, 255, 255);
vertices[3].tu = 0.0f;
vertices[3].tv = 1.0f;

D3DDevice->SetTexture(0, texture);

D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (LPVOID)vertices, sizeof(vertices[0]));
hr = D3DTexture->GetSurfaceLevel(0, &D3DSurface);

SAFE_RELEASE(D3DTexture);
SAFE_RELEASE(D3DSurface);


#elif (defined(VDJ_MAC))

hr = GetTexture(VdjVideoEngineOpenGL, (void **)&GLTexture, &vertices);

// glEnable(GL_TEXTURE_RECTANGLE_EXT);
// glBindTexture(GL_TEXTURE_RECTANGLE_EXT, GLTexture);
// glBegin(GL_TRIANGLE_STRIP);

//for(int j=0;j<4;j++)
//{
//glColorD3D(vertices[j].color);
//glTexCoord2f(vertices[j].tu, vertices[j].tv);
//glVertex3f(vertices[j].position.x, vertices[j].position.y, vertices[j].position.z);
//}

//glEnd();
#endif
D3DDevice->EndScene();

//hr = DrawDeck();
return S_FALSE;
}
 

Posted Fri 10 Jun 16 @ 6:10 pm
Sorry for posting up a storm of responses to this thread. Hopefully everyone can bare with me as I try to figure this stuff out.

Looks like I just needed to add the following line to the OnStart() method:


HRESULT VDJ_API CMyPlugin8::OnStart()
{
// ADD YOUR CODE HERE
this->OnDraw(); //<--Added this

return S_OK;
}


This was able to get me the text "Testing" to show using my previously posted code... Still not sure why the vertices won't show.

 

Posted Fri 10 Jun 16 @ 6:57 pm
SBDJPRO Infinity Member since 2006
A few things:

1. You don't need to call OnDraw from OnStart. OnDraw will be called when it's required; calling it manually could create yourself more issues.
2. If you're just using DrawText then you're using the Rect, so I don't know what you want vertices for.
3. In your OnDraw you're creating resources and not releasing them so will be leaking memory like crazy.
4. In your OnDraw you're creating resources everytime that is called - it's better to create your resources in OnStart or OnDeviceInit (depending on the type of resource) and to release them in OnStop or OnDeviceClose.
5. Don't manually call BeginScene/EndScene - VDJ is calling your plugin OnDraw as part of render already and will handle all this for you.
5. In your OnDraw you draw the text. Then you get the VDJ video texture, then attempt to draw it. If this had been successful then you'd have just drawn over your text. You're also getting the vertices, setting them to fill the screen (which could destroy the aspect ratio of the video) then attempting to render them. If you're just trying to draw the VDJ video with text over it then do something like this:


HRESULT VDJ_API CMyPlugin8::OnLoad()
{
D3DDevice = NULL;
g_font = NULL;
return S_OK;
}

HRESULT VDJ_API CMyPlugin8::OnDeviceInit()
{
GetDevice(VdjVideoEngineDirectX9, (void **)&D3DDevice);
D3DXCreateFont(D3DDevice, 22, 0, FW_NORMAL, 1, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &g_font);
return S_OK;
}

HRESULT VDJ_API CMyPlugin8::OnDraw()
{
if (!g_font || !D3DDevice)
return S_FALSE;

DrawDeck();

RECT font_rect;
SetRect(&font_rect, 0, 0, width, height);
g_font->DrawText(NULL, fps_string, -1, &font_rect, DT_LEFT | DT_NOCLIP, 0xFFFFFFFF);

return S_OK;
}

HRESULT VDJ_API CMyPlugin8::OnDeviceClose()
{
if (g_font)
{
g_font->Release();
g_font = NULL;
}
D3DDevice = NULL;
return S_OK;
}


If you're wanting to draw the default VDJ video with modified vertices, then do something like this:


TVertex *v;
IDirect3DTexture9 *t;
GetTexture(VdjVideoEngineAny, (void**)&t, &v);
// modify vertices here
DrawDeck();


Finally if you're wanting to do something with your own vertices then have a play with something like this:


#define D3DFVF_TLVERTEX3D (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)

HRESULT VDJ_API CMyPlugin8::OnDeviceInit()
{
GetDevice(VdjVideoEngineAny, (void**)&device);
if (FAILED(device->CreateVertexBuffer(4 * sizeof(TVertex), D3DUSAGE_WRITEONLY, D3DFVF_TLVERTEX3D, D3DPOOL_DEFAULT, &vertexBuffer, NULL)))
return E_FAIL;
return S_OK;
}

HRESULT VDJ_API CMyPlugin8::OnDeviceClose()
{
if (vertexBuffer)
{
vertexBuffer->Release();
vertexBuffer = NULL;
}
device = NULL;
return S_OK;
}

bool CMyPlugin8::UpdateVertices()
{
if (FAILED(vertexBuffer->Lock(0, 0, (void**)&vertices, 0)))
{
vertexBuffer->Release();
vertexBuffer = NULL;
return false;
}
vertices[0].position.x = 0.0f;
vertices[0].position.y = 0.0f;
vertices[0].position.z = 0.5f;
vertices[0].color = D3DCOLOR_RGBA(255, 255, 255, 255);
vertices[0].tu = 0.f;
vertices[0].tv = 0.f;
vertices[1].position.x = (float)width;
vertices[1].position.y = 0.0f;
vertices[1].position.z = 0.5f;
vertices[1].color = D3DCOLOR_RGBA(255, 255, 255, 255);
vertices[1].tu = 1.f;
vertices[1].tv = 0.f;
vertices[2].position.x = (float)width;
vertices[2].position.y = (float)height;
vertices[2].position.z = 0.5f;
vertices[2].color = D3DCOLOR_RGBA(255, 255, 255, 255);
vertices[2].tu = 1.f;
vertices[2].tv = 1.f;
vertices[3].position.x = 0.0f;
vertices[3].position.y = (float)height;
vertices[3].position.z = 0.5f;
vertices[3].color = D3DCOLOR_RGBA(255, 255, 255, 255);
vertices[3].tu = 0.f;
vertices[3].tv = 1.f;
vertexBuffer->Unlock();
return true;
}

HRESULT VDJ_API CMyPlugin8::OnDraw()
{
if (!device)
return S_FALSE;

TVertex *v;
IDirect3DTexture9 *t;
GetTexture(VdjVideoEngineAny, (void**)&t, &v);

UpdateVertices();

device->SetTexture(0, t);

device->SetStreamSource(0, vertexBuffer, 0, sizeof(TVertex));
device->SetFVF(D3DFVF_TLVERTEX3D);
device->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, (LPVOID)vertices, sizeof(vertices[0]));

return S_OK;
}
 

Posted Fri 10 Jun 16 @ 9:59 pm
First of all, let me start with saying a big THANK YOU!!! This is exactly what I needed to see. Might I suggest you add this somewhere to the Wiki? As a developer with embedded C++ background, trying to pick up windows development poses it's challenges as you can tell. I'm reading up on DirectX9 and there has been some disconnect on what the VDJ classes are doing vs what DirectX is doing. So this clarification you provided is very helpful! THANK YOU!!

SBDJ wrote :
A few things:

1. You don't need to call OnDraw from OnStart. OnDraw will be called when it's required; calling it manually could create yourself more issues.
2. If you're just using DrawText then you're using the Rect, so I don't know what you want vertices for.
3. In your OnDraw you're creating resources and not releasing them so will be leaking memory like crazy.
4. In your OnDraw you're creating resources everytime that is called - it's better to create your resources in OnStart or OnDeviceInit (depending on the type of resource) and to release them in OnStop or OnDeviceClose.
5. Don't manually call BeginScene/EndScene - VDJ is calling your plugin OnDraw as part of render already and will handle all this for you.
5. In your OnDraw you draw the text. Then you get the VDJ video texture, then attempt to draw it. If this had been successful then you'd have just drawn over your text. You're also getting the vertices, setting them to fill the screen (which could destroy the aspect ratio of the video) then attempting to render them. If you're just trying to draw the VDJ video with text over it then do something like this:


1. I copied the example on the WIKI line for line. I'm now seeing that maybe the code from the example was just simply drawing a black square. If that's the case, maybe we could adjust the RGBA Alpha property down a little so that it is more transparent as to what is happening (pun intended). :p Then it can be seen that it's simply an overlay over the top...at least I think that's what it'll do. I'll have to see what happens when I don't call onDraw with a lower Alpha property.
2. At this point, I was just trying to get anything to show. I agree...I probably will never need both. However, I was finally able to get both text and the vertices to show, not sure yet how or why? :/
3. Oh, I know Memory is Leaking all over everything. I'll put some buckets under it :p. But seriously, I plan to clean up my memory soon. Just really cared about seeing some results.
4. Same as #3. Will start cleaning things up...now that I've got better direction.
5. Good to know. I did not know that at the time, and the DirectX Text example I found on the interwebs had that in there. I did notice that it wasn't needed and had already removed it before your post.
5. (your second #5) Agreed. Thanks for that example. That really helps.

Now...my next question is, does directX support outputting video, I'm sure it does...just not finding good examples yet? Like how could I hardcode my Plugin to play a defined MP4/AVI file? Not exactly what I want to do, but similar. My goal is to open an RTSP connection and dump it's contents to DirectX. This way I can have camera's around the venue and be able to put those feeds on the screen. Also could be cool for New Years to pull in a Times Square Video Feed. Thoughts?
 

Posted Sat 11 Jun 16 @ 4:45 pm
djcelPRO InfinityModeratorMember since 2004
About thé wiki examples, we will do it. We have tried to have basic examples and not many lines of complex code for new developper but showing the power of the VDJ sdk. Feel free to help us by giving us more feedbacks in order to improve the wiki.

You can have a look at the following example. Your needs are the same. Do not hesitate to send leadedge a PM and to share your project with him. Maybe you could work together on it.

leadedge wrote :
Sorry I don't have time right now to trace through your plugin code, but is this any help for you?
Maybe too complicated, but it should give some guide.

https://github.com/leadedge/Spout2/tree/master/VIRTUALDJ

Also :

https://github.com/Syphon/VirtualDJ

. . .

 

Posted Sun 12 Jun 16 @ 9:47 am
SBDJPRO Infinity Member since 2006
sirwesley wrote :
Now...my next question is, does directX support outputting video, I'm sure it does...just not finding good examples yet?

Not exactly I'm afraid.

sirwesley wrote :
Like how could I hardcode my Plugin to play a defined MP4/AVI file?

In simple terms you would usually use a decoding library such as FFMPEG, DirectShow or Media Foundation to actually decode the video and then use DirectX to actually display the decoded frames.

sirwesley wrote :
Not exactly what I want to do, but similar. My goal is to open an RTSP connection and dump it's contents to DirectX. This way I can have camera's around the venue and be able to put those feeds on the screen. Also could be cool for New Years to pull in a Times Square Video Feed. Thoughts?

Sounds good. If you get stuck then this is something we could add internally :)

Let me know if there's anything else I can help with :)
 

Posted Sun 12 Jun 16 @ 9:10 pm


(Old topics and forums are automatically closed)