resolume / ffgl

BSD 3-Clause "New" or "Revised" License
110 stars 47 forks source link

Get FFGL host name and version #17

Closed rsodre closed 5 years ago

rsodre commented 5 years ago

Is there a built-in cross-platform way to get the host name (ex: Resolume, VDMX) and version (ex: 6.1.1)?

ResolumeMenno commented 5 years ago

No you would have to resort to platform specific api's which aren't part of FFGL if you need to know this information. If this is to know when to flip, you can detect this by which version of the plugin is being loaded. Resolume pre GL4.1 only loads plugins built with ffgl 1.6 and lower and requires the flip. Resolume with GL 4.1 support only loads plugins based on ffgl 2.0 and does not require the flip. So in your build config you could use the flag you use to determine which ffgl version to use to determine if you need the flip or not.

rsodre commented 5 years ago

Yes, but I need to flip for Resolume 6.0 only, not other hosts, not Resolume 5. Without knowing the host name and version, the only solution I see is to have a binary for 6.0 only.

jorisdejong commented 5 years ago

That said, I wouldn't mind functions for SetApplicationInfo and SetVersionInfo that the host can call.

Because older Resolume versions can't call these retro-actively, practically it would mean you'll be doing the same guesstimating as when checking for the ffgl version, but it could be useful to help with problems like these in the future.

jorisdejong commented 5 years ago

I'm all for helping you out here, but I'm not sure how having one binary would work? Are you going to call a different constructor, depending on version info that is only set at runtime?

rsodre commented 5 years ago

Identifying the host and version, I can build a different view matrix or flip axis/uv in the shader. That's what I'm doing now, but based on FFGL version, but this solution got busted on VDMX and Resolume 5.

In fact, just identifying the host is Resolume will work for me, I don't need version. if (FFGL1 && 64bit && Resolume) { Flip }

ResolumeMenno commented 5 years ago

This resolume 6.0.0 vs other hosts using ffgl 1.6 is not a new issue so if you havn't solved that yet you probably dont need to? Why dont you drop support for resolume 6.0.0-6.1.2 altogether and tell your users to download the free resolume update containing the 4.1 changes if they want to use your plugin?

jorisdejong commented 5 years ago

I'm probably being the annoying kid in the back row here, but I'm still confused. You have one binary that is compiled for both 64 bit and 32 bit, and that uses both the FFGL1.6 and FFGL2.0 API? Impressive.

Either way, there is nothing in the FFGL spec that does what you need. I definitely think it's a good idea to add it, but adding it now is not going to help identifying hosts in earlier versions (both VDMX and Resolume would return nothing).

Or is this not an FFGL specific question and are you asking about a general method in c++ to identify an application?

rsodre commented 5 years ago

I made a wrapper to both FFGL API, so by plugins can be compiled for 32, 64, FFGL1 or FFGL2. But it's not one binary for all. I was planning to have 2 binaries for each plugin:

I could easily ignore Resolume 6.0, but there's a lot of people out there that never update anything that's working, and I would have to explicitly declare "if you buy this, it will not work properly on Resolume 6.0 to 6.1.1", so as of now I need a third binary:

I hoped FFGL could give me the host name, but I understand it doesn't (please keep the suggestion for future specs). Now if there's a cross-platform way to check if I'm on Resolume I could discard that third binary.

sandercox commented 5 years ago

On Windows you can call GetModuleFileName with NULL as first argument to get the Application that is running your DLL. That should resolve to C:\Program Files\Resolume Arena 6\Arena.exe or C:\Program Files\Resolume Avenue 6\Avenue.exe if users din't move the binaries around. To make it super perfect you should use GetFileVersionInfo to get info about the version of the executable and you can check the information in the binary.

I haven't got a clue on how to do this on macOS though.

rsodre commented 5 years ago

you should use GetFileVersionInfo to get info about the version of the executable

I think this gives me the name of the library, not the executable. I can't find anywhere any reference on how to get the executing app from a library, neither on Windows or Mac.

But I think I found something to check Resolume. There's a function call FF_CONNECT, commented as "Custom Resolume plugin functions". Looks like it's not called on VDMX, I hope other hosts don't call that too. Can anyone from Resolume confirm that is called just from host code only? BTW, where is the base public repo you used to implement your host?

rsodre commented 5 years ago

Guess I was wrong about FF_CONNECT, it's called on VDMX too. Here's what worked for me:

Mac: Returns "Arena" in kCFBundleNameKey.

Windows: Since I've got juce_core already for all my multi-platform needs, juce::File::getSpecialLocation(juce::File::currentApplicationFile) returns the plugin installation folder, so I'll just require that the plugins are installed in the Resolume default vfx path and find "Resolume" in it.

Now I'm back on track....

ResolumeMenno commented 5 years ago

you should be able to use juce::File::hostApplicationPath to lift the installation location restriction. Using this might be dependent on correctly initializing the juce library as it needs the process's handle. I cant remember exactly what you needed to do but there's juce::Process::setCurrentModuleInstanceHandle and there's also EnableGuiSomethingSomething. The DllMain function for your plugin is in FFGLPluginInfoData.cpp. You can either not link with that cpp and implement your own elsewhere, or you could create a hook that gets called by this function.

The FFGL hosting part is implemented directly into Resolume's video engine and we're using this repository to do so.

rsodre commented 5 years ago

juce::File::hostApplicationPath

Works good! No need to initialize anything.Thanks!

For those who don't have Juce yet, I made a static library using Projucer, adding only the juce_core module. I include that lib anywhere i need to access sys info, registry, threads, xml, make http calls, etc.

jorisdejong commented 5 years ago

Re-opening this because we all thought it was a good idea to make it possible to pass this info from the host to the plugin

flyingrub commented 5 years ago

https://github.com/resolume/ffgl/pull/28

ResolumeMenno commented 5 years ago

Closing issue as it's now up to the hosts to set this info. FFGL plugins receive the host info in the CFreeFrameGLPlugin::SetHostInfo function and cache it in hostInfos. Resolume sets the name and version correctly.