-
-
Notifications
You must be signed in to change notification settings - Fork 78
EmbeddingNPLRuntime
NPLRuntime comes with a general purpose executable for launching NPL based applications. This is the standard usage of NPLRuntime. However, some client application may prefer embedding NPLRuntime in their own executable file, or even as child window of their own application. This is possible via NPLRuntime dll (paraengineclient.dll
or static lib).
Please see https://github.com/LiXizhi/ParaCraftSDK/blob/master/samples/MyAppExe/MyApp.cpp for details.
#include "PEtypes.h"
#include "IParaEngineApp.h"
#include "IParaEngineCore.h"
#include "INPL.h"
#include "INPLRuntime.h"
#include "INPLRuntimeState.h"
#include "INPLAcitvationFile.h"
#include "NPLInterface.hpp"
#include "PluginLoader.hpp"
#include "MyApp.h"
using namespace ParaEngine;
using namespace NPL;
using namespace MyCompany;
// some lines omitted here ....
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR lpCmdLine, INT)
{
std::string sAppCmdLine;
if (lpCmdLine)
sAppCmdLine = lpCmdLine;
// TODO: add your custom command line here
sAppCmdLine += " mc=true noupdate=true";
CMyApp myApp(hInst);
return myApp.Run(0, sAppCmdLine.c_str());
}
To build your custom application, you must download NPLRuntime source code (for header files) and set CMAKE include directory properly.
- Download the sample at https://github.com/LiXizhi/ParaCraftSDK/blob/master/samples/MyAppExe
- Set CMAKE include directory to https://github.com/LiXizhi/NPLRuntime/tree/master/Client/trunk/ParaEngineClient/Core
-
paraengineclient.dll
is dynamically loaded at runtime via NPL plugin interface, which means that your executable does not need to link to any library file. **All you need when embedding NPLRuntime is header files. ** This decouples your host application executable from NPLRuntime library files which may be upgraded separately without rebuilding your host executable.- Main header files:
In most cases, you do not need to build these libraries, simply copy ParaEngineClient.dll
and other related dll files from the ParacraftSDK's ./redist
folder to your host application's executable directory. Make sure they are up to date.
However, one can also build NPL Runtime as Libraries manually. See CMake
options when building NPLRuntime from source code.
If you want to embed the entire NPLRuntime inside a single executable, we also give the option to statically link to it.
You can put NPLRuntime in a subdirectory and use following CMAKE options to build your app and NPLRuntime together.
# main NPL runtime and override default options to generate only static libs and skip some unused library
option(NPLRUNTIME_STATIC_LIB "static lib or not" ON)
option(NPLRUNTIME_LUAJIT21 "build luajit21 support GC64" OFF)
option(NPLRUNTIME_LUAJIT20 "build luajit2.0.4" OFF)
option(NPLRUNTIME_LUA51 "build lua5.1.5 with coco" ON)
option(NPLRUNTIME_SUPPORT_FBX "support FBX files (assimp)" OFF)
option(NPLRUNTIME_PHYSICS "include physics" OFF)
add_subdirectory (${PROJECT_SOURCE_DIR}/NPLRuntime/Client)
add_subdirectory (${PROJECT_SOURCE_DIR}/src)
For a complete example, please see AppLauncher. It generates a single executable without any external dll dependencies.
Download Paracraft | ParacraftSDK | copyright by tatfook 2016 | upload image