Adding LuxCore to own application

Discussion related to the LuxCore functionality, implementations and API.
Post Reply
Ernest
Posts: 9
Joined: Sun Mar 31, 2019 11:30 am

Adding LuxCore to own application

Post by Ernest »

After LuxCore got a more liberal license to also be integrated into commercial products I would like to give it a try.
Right now I use a modified version of yafaray to render photorealistic images which is quite closely integrated into my app.

My first idea was to use the LuxCore SDK but it was not what I expected to find inside a SDK. I was more looking for the 'classic' headers, libs and binaries style SDK.

Then I cloned the three repos named in the WindowCompile repo. This worked so far but I cannot use the created debug libraries because all project miss the _DEBUG define (by intension?) which leads to incompatible STL debug levels and CRTs in Visual Studio.

I started to fix all used packages but this is a lot of work which must be done again if a library is updated and more important many feature won't be used like reading images from disk. I have all of them in memory already.

So my questions are:

- Is there a reason why _DEBUG is missing (besides horribly slowing down the code)?
- Would it be possible or a good idea to extract the image handling to a separate library which can be 'injected' via an interface to minimize the dependencies of the rendering core code?
- What is the purpose behind the LuxCore SDK, how is it intended to be used?
- Are threre any experiences how to tightly integrate LuxCore into an application or recommendations how to proceed?

Any help is appreciated. Thanks in advance.
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Adding LuxCore to own application

Post by Dade »

Ernest wrote: Sun Mar 31, 2019 12:37 pm My first idea was to use the LuxCore SDK but it was not what I expected to find inside a SDK. I was more looking for the 'classic' headers, libs and binaries style SDK.
I downloaded the SDK archive and I noticed is incorrectly packed, 2 files (include\luxcore\cfg.h and include\luxcore\luxcore.h) were missing. You can download a correctly packed SDK from the very latest sources from this link: https://drive.google.com/file/d/1iwu3uy ... sp=sharing

It is even better if you compile the SDK package on your own. It requires only 3 commands as described in https://github.com/LuxCoreRender/Window ... README.txt

Code: Select all

cd C:\Path\to\luxcorerender\WindowsCompile\
.\cmake-build-x64.bat /dll
create-sdk.bat
Once you have the SDK package, you only need to include "include\luxcore\luxcore.h" and to link luxcore.lib in order to use the LuxCore API in your app. You will need to have luxcore.dll (and all other dlls in "lib" directory) in your path to execute the application too.

For an example of how use the API, check the samples directory, for instance: https://github.com/LuxCoreRender/LuxCor ... onsole.cpp

The API documentation is available in Doxygen format inside the luxcore.h: https://github.com/LuxCoreRender/LuxCor ... /luxcore.h
Ernest wrote: Sun Mar 31, 2019 12:37 pm Then I cloned the three repos named in the WindowCompile repo. This worked so far but I cannot use the created debug libraries because all project miss the _DEBUG define (by intension?) which leads to incompatible STL debug levels and CRTs in Visual Studio.
It is cmake to generate the VisualStudio Project. Once you have run the "cmake-build-x64.bat", you can directly open the VisualStudio project at "C:\Path\to\WindowsCompile\Build_CMake\LuxCore\LuxRays.sln"

You can than switch between "Release" and "Debug" configurations inside VS and build the version you are looking for. You can also compile the "Debug" version instead of the "Release" by using the "/debug" option of cmake-build-x64.bat script.
Ernest wrote: Sun Mar 31, 2019 12:37 pm - Is there a reason why _DEBUG is missing (besides horribly slowing down the code)?
I assume, you were using the "Release" (i.e. the default version) so it was the reason why "_DEBUG" wasn't defined.
Ernest wrote: Sun Mar 31, 2019 12:37 pm - Would it be possible or a good idea to extract the image handling to a separate library which can be 'injected' via an interface to minimize the dependencies of the rendering core code?
It is all packed inside the luxcore.dll (see below) so it shouldn't be a problem.
Ernest wrote: Sun Mar 31, 2019 12:37 pm - What is the purpose behind the LuxCore SDK, how is it intended to be used?
At the very core, it is just LuxCore compiled as DLL instead as static library so your app will not need to be linked again all libraries LuxCore needs. You have to link only with luxcore.lib and nothing else.
Ernest wrote: Sun Mar 31, 2019 12:37 pm - Are threre any experiences how to tightly integrate LuxCore into an application or recommendations how to proceed?
The only real and public application developed over LuxCore up to now is BlendLuxCore, the plugin for Blender (but it is written in python).
Support LuxCoreRender project with salts and bounties
Ernest
Posts: 9
Joined: Sun Mar 31, 2019 11:30 am

Re: Adding LuxCore to own application

Post by Ernest »

Thanks for your help. Using a DLL is much easier.

I built luxcore myself again as you suggested with .\cmake-build-x64.bat luxcore /dll /debug but the define _DEBUG is still missing in debug config. Also the C++ runtime is set to ReleaseDynamic instead of DebugDynamic. I can of course fix this manually but this will not solve the problem with the external dependencies referenced from lux projects like boost. They are also build without _DEBUG setting and against Release CRT. This would imply to also build all dependencies myself which is quite some work to do. Is there an easier solution?

I also use boost in my project. Maybe I can switch the used boost libs to my debug build. At the moment I am not sure whether boost is the only affected lib.

Does none of the lux developers use a debug config on Windows?
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Adding LuxCore to own application

Post by Dade »

Ernest wrote: Sun Mar 31, 2019 10:35 pm I built luxcore myself again as you suggested with .\cmake-build-x64.bat luxcore /dll /debug but the define _DEBUG is still missing in debug config. Also the C++ runtime is set to ReleaseDynamic instead of DebugDynamic. I can of course fix this manually but this will not solve the problem with the external dependencies referenced from lux projects like boost. They are also build without _DEBUG setting and against Release CRT. This would imply to also build all dependencies myself which is quite some work to do. Is there an easier solution?
I'm a *nix user so I'm not very familiar with all Windows related intricacies but why do you need to compile LuxCore DLL in debug mode ?

Can't you link your app compiled in debug mode with a DLL compiled in release mode ?

We probably need some help from @Acasta69 for this Windows related stuff.
Support LuxCoreRender project with salts and bounties
acasta69
Developer
Developer
Posts: 472
Joined: Tue Jan 09, 2018 3:45 pm
Location: Italy

Re: Adding LuxCore to own application

Post by acasta69 »

Dade wrote: Sun Mar 31, 2019 11:22 pmwhy do you need to compile LuxCore DLL in debug mode ?

Can't you link your app compiled in debug mode with a DLL compiled in release mode ?
I was also wondering about that...
Actually I never had the need to build LuxCore in debug mode.
There could be something to be modified in the cmake config, I remember I did that once for the old Luxrender, but it was long time ago. I'll try to look into that later.
But I also remember that building dependencies in debug mode was not needed at all, at least in that case...

If you need debug deps, you'll have to build them yourself. There are a couple of scripts in the WindowsCompile repo that could help you doing that: getdeps.bat downloads required deps and build-deps-x64.bat builds them in release mode.
Maybe you could try modifying build-deps-x64.bat to build only boost in debug mode.
Support LuxCoreRender project with salts and bounties

Windows 10 64 bits, i7-4770 3.4 GHz, RAM 16 GB, GTX 970 4GB v445.87
Ernest
Posts: 9
Joined: Sun Mar 31, 2019 11:30 am

Re: Adding LuxCore to own application

Post by Ernest »

Just FYI:

Linking against release build succeeds but crashes at the first luxcore call with std::string as a parameter (as I expected).

Would be interesting to know how this can work for @Acasta69 except everything is compiled without _DEBUG and against release runtime.

I already created a debug build for boost but I think several other libs will follow (e.g Half.lib)
acasta69
Developer
Developer
Posts: 472
Joined: Tue Jan 09, 2018 3:45 pm
Location: Italy

Re: Adding LuxCore to own application

Post by acasta69 »

Ernest wrote: Sun Apr 07, 2019 9:05 pm Would be interesting to know how this can work for @Acasta69 except everything is compiled without _DEBUG and against release runtime.
I've just built with

Code: Select all

cmake-build-x64.bat /dll /debug
create-sdk.bat
Apart from having to manually gather the built executables from Debug folders, everything seems to run without problems (I am running luxcoreui).

I'm not sure if this is enough to answer your question.
Support LuxCoreRender project with salts and bounties

Windows 10 64 bits, i7-4770 3.4 GHz, RAM 16 GB, GTX 970 4GB v445.87
Post Reply