Shared LE Setup
From Leadwerks Developer Wiki
Contents |
Introduction
It is possible to setup Leadwerks Engine (=LE) in a way, that you don't need to copy any engine files to your project folders. This setup works for all languages, including the non-engine.dll based language BlitzMax.
This is of course no requirement, but convenient in order to save hdd space. The folder names suggested here may be chosen differently.
Installation
To create the shared LE setup, first you need to create a root folder called c:\le. Under that folder, create the 3 subfolders: bin, media, include:
c:\le\bin c:\le\media c:\le\include
Now copy the following files from your Leadwerks SDK directory to the bin folder: engine.dll, newton.dll, jointlibrary.dll.
Then copy the following files from your Leadwerks SDK directory to the media folder: shaders.pak.
Finally copy the header files from your Leadwerks SDK directory for the language which you are using into the include folder. If you are using C, they would be engine.h and engine.cpp.
Now you need to add c:\le\bin to your System Path. This is done by selecting My Computer/Properties/Advanced/Environment Variables/System Variables: find the variable called "Path" and press the Edit button and add c:\le\bin to the end of the "Path" variable.
Using Shared LE Setup in your projects
To use the shared LE files in your projects, set the include directory of your project to c:\le\include, and add engine.cpp from the c:\le\include directory to your project's source files. Only one line of code is needed in your programs: RegisterAbstractPath("c:/le/media"); This line should come right after the Initialize() statement (or after Framework Leadwerks.Engine in BlitzMax. Since BlitzMax does not automatically add the AppDir to the abstract file system, you need also to say RegisterAbstractPath(AppDir) in BlitzMax, but you have done that anyway, since it was always needed in BlitzMax):
#include "engine.h"
int main(void)
{
Initialize();
RegisterAbstractPath("c:/le/media");
Graphics(800,600);
CreateWorld();
CreateCamera();
while(!KeyHit())
{
RenderWorld();
DrawText(0,0,"Shared LE Setup Test");
Flip(0);
}
return Terminate();
}
From now on you don't ever have to copy any SDK files to your projects anymore, and can have lots of small and big projects without using any additional disk space, and having the engine files automatically always up-to-date in all your projects. You can still access all your project specific media under your project directory like always, either using the abstract:: file system or a direct relative path. In addition, you can also have some common models and materials stored in the c:\le\media directory or it's subfolders, which saves you even more space, and which you need to copy to the final distributable.
Distributing projects
When your game or project is ready, you need to copy the distributable engine files to your distributable version of your project folder. You don't want to distribute the source code of your project or of the Leadwerks Engine, so it's good to have a seperate distributable project folder. Copy the files engine.dll and newton.dll from c:\le\bin and the file shaders.pak from c:\le\media to your project's root directory. You need also to change the line with RegisterAbstractPath() to RegisterAbstractPath(".");. This could be done conveniently with a #ifdef since you probably have also other debug code which you want to eliminate in your final game.
