Results 1 to 14 of 14
  1. #1

    BGECore Launcher Tutorial + Advanced Publishing Options

    Do you want to distribute your game under a non GPL license?
    Do you ever wonder why your game weight so much?
    Have you ever hoped there were a way to configure the resolution of your game before launching your game?
    Have you ever made a windows installer of your game and found that the save files didn't work?

    Here is the final guide in how to solve all these problems and more!

    If you're not interested in the technical details (I recommend reading it anyway) jump to "How to use the BGECore Launcher" at post #2



    How the Publishing Addon works and why you shouldn't use it


    Note: This includes the Save as Runtime addon.
    Note: I assume you already know how to use the addon.

    A Blender game starts from the active scene the last time the .blend file was saved. Therefore your game always starts from a .blend file. Compiling your game into an executable is a myth in Blender. What you may not know is that besides Blender there is another program that's capable of running your game, that is Blenderplayer. Blenderplayer is found in the same directory than your Blender installation, it is a subset of Blender that only includes the necessary to run the BGE, it doesn't even have interface. The best way to understand Blenderplayer is to learn to use it. It's pretty simple if you know how to use a terminal, if you don't here you have a basic guide: http://www.digitalcitizen.life/comma...basic-commands

    An example command to run Blenderplayer could be: blenderplayer.exe c:\games\mygame.blend
    If you run "blenderplayer.exe" without parameters it will prompt a help page.

    Now we know that Blenderplayer can also run blender games, and in fact that's exactly what happens when you click "Start" on the "Properties->Render->Standalone Player" menu inside blender.

    There is another way to use Blenderplayer though, thanks to a hack made, I assume, by moguri (the creator of the addon). As you probably know an executable is just a file, a file with a start and an end, which means that you can attach things to the end of the file (making the file longer) and nobody will notice. It's a pretty interesting way to hide things by the way, that's why it's usually used by virus and malicious software rather than legitimate programs. Blenderplayer is designed to, in case there is a .blend file attached at the end of the executable, ignore any command line params and run that file instead. Knowing this we can easily understand what the addon actually does:

    The addon first copies the Blenderplayer, and all files needed for it to run (.dll, python, etc) in the destination folder. Then copies the .blend file that the current instance of Blender has open (aka your game) inside the Blenderplayer. Lastly it renames the Blenderplayer with whatever name you give to the executable when asked where to save.

    So if you ever wondered why even to most simple game size is more than 100mb, this is the reason, you're not only distributing your game but also a subset of Blender with it, and that subset is rather heavy.

    Now, trough this system works well, it has problems of it's own, the most relevant of them all is probably the GPL license. The GPL is a freeware license with a particularity, it has a viral nature. This means that any software made using software licensed this way must also share the GPL, noncompliance doing this revokes the right provided by the GPL and therefore you would be distributing software (in this case the Blenderplayer) without permission. This means that either you publish your game under GPL or you make sure that the game can't be considered a derivative work of Blender, otherwise the Blender Foundation or any holder of software used by Blender (that also uses GPL) could sue you.

    The problem with attaching your .blend file inside the Blenderplayer is that it automatically makes it a derivative work (since they are on the same binary) and bounds it to GPL. Other .blend files on the same directory may not be bound to GPL since the Blender Fundation specifically considers them as program output, however this doesn't necessarily apply to Python files. What happens with the viral nature of GPL depending on how your Python files are linked and the structure of your project is not specified or in other words, rather unknown. You will find more information on the subject of GPL on blenderartists sticky thread: http://blenderartists.org/forum/show...-Answer-Thread

    There is a better way to publish games tough, using BGECore Launcher.



    What's BGECore Launcher

    BGECore Launcher is part of the BGECore Framework, however you can also use it without the framework. BGECore Launcher has been made in C and has as BSD-2 license, a permisive license that allows you to use and modify it even with commercial purposes (and with no viral nature).

    The basic thing this launcher does is execute a command that calls Blenderplayer and opens your game. In this sense is not different than a ".bat" or ".sh" script. However it has one immediate advantage over a script which is: It is an executable. Executing unknown scripts in any machine looks very dangerous to most inexperienced users, executing a an executable is just as dangerous but to the usual player it seems much more safe. Having an executable as a launcher also has other advantages, for example you can change its icon or the metadata that you find on "Right Click->Properties->Details" such as Copyright, File Description, etc.

    There is a recent post on blenderartists explaining how to do exactly that on blenderplayer: http://blenderartists.org/forum/show...GPL-workaround. Doing this on blenderplayer is a problem, you're hiding it's license, it isn't if you do that to the BGECore Launcher (the blenderplayer remains unchanged). The BSD license only requires to distribute a copy of itself somewhere within the folder of the game, the metadata of the launcher is irrelevant in order to apply the license itself. In any case I'm the only holder of the license and I guarantee that I won't sue anyone for whatever use they made of the BGECore Launcher.
    Last edited by elmeunick9; 29-May-16 at 12:55.



  2. #2
    How to use the BGECore Launcher

    Since the launcher is part of BGECore Framework usually you should download the framework first. The framework is found on github and can be directly downloaded with the following link: https://github.com/elmeunick9/BGECor...ive/master.zip.

    Once extracted you'll find the BGECore Launcher folder (aka Simple Launcher) on "BGECore/tools/Simple Launcher/".

    On that folder you should have a "config.txt" and 3 executable files e.j: "windows-32.exe". Those 3 files are the launchers for each specific platform, so "Linux-32" is an executable for Linux x32. You won't find a x64 version for Windows becouse the 32-bit version works just as fine (and having only one simplifies things). Also you may notice that for MacOS instead of an executable you have a folder, that folder should look just like a "launcher" on MacOS (Mac sure does wierd things). The launcher is tested on Windows and Linux, not in Macintosh. It would be very fortunate if it works just fine without any test, Mac users, you'll have to pry. You can also find a folder called "source", that's the source code of the launcher, wich consists basically in only one file called "launcher.c" plus some resources. Compiling the BGECore Launcher is strightforward since it is one simple file. But of course this is not nesscesary.

    So now that we have things ready lets start. First you should have a working directory where you have the files of your game and your blends. If you don't, create one. On this tutorial I'll create one called "PizzaGame" for example on MyDocuments folder (assuming Windows). Inside you should create two folders, one should be called "engine" and the other "data". This subfolders aren't enterly nesscesary but they will keep things much more organized.

    Inside the "engine" subfolder we will put blenderplayer and all the files it needs to run. To make it simple I will just copy all the files in my Blender installation folder inside the "engine" folder (including of course, the blenderplayer.exe).

    Inside the "data" subfolder we should put everything else, our entire game should be there, this means all our .blend files, resources, etc.

    Now on our game folder, in my case "PizzaGame", we should copy the BGECore Launcher for our OS, in my case "Windows-32.exe" and the configuartion file "config.txt".

    We are done copying files. Most users make their game in only one .blend file, but I am of the opinion that this shouldn't be the rule. That's why in order to identify wich .blend file Blenderplayer should run we need to use the "config.txt" file. Opening the configuartion file the first two lines are:

    player: engine/blenderplayer.exe
    blend: ../../template/data/game.blend
    Note: Like in Python, "#" starts a comment.

    The first line indicates the relative path to the Blenderplayer executable. In our case it is pointing exactly where we have copied Blender so we don't need to change it. The secend line is a relative path to the .blend file that we will use to start the game. Assuming that I named this blend file "startfile.blend" I should modify the second line to: "blend: data/startfile.blend".

    With this we should be able to start our game by just double clicking the launcher. As you can see there are a bunch of other options you can tweak on the configuration file (resolution, antialiasing, debug mode, etc...).

    Now we can rename our launcher to something else, e.j: "Pizza.exe", and change the icon and metadata with resource hacker (an external utility, easily found on google).

    At this point we have the same you would obtain using the addon but the Blenderplayer and your game are on their own separated folders, so it will be clear for anyone that they are diferent things and may have diferent licenses.

    Now you may think that distribuiting an entire copy of blender with your game is a waste of space, and you're probably right. In the BGECore Guide is explained under the section "Launching and distribuiting your game" wich files are precindible. (I could of course have make a python script that makes this automatically but that will be some other day).

    Advanced Publishing Options

    Even if our a game and blenderplayer are on diferent folders we are still distribuiting them together. Someone could think this is bounding us to the GPL. Wouldn't it be nice if we could just distrubuite our game files and make the launcher look in the computer for an installed blenderplayer? Well, it can be done.

    If you delete all the contents on the "engine" folder, the launcher will not know what blenderplayer to use. In such case the launcher will try to search it on the system. The search algorithm is pretty simple, it basically looks on "C:/Program Files/Blender Foundation/Blender/" for Windows systems and on "/usr/bin/" or "/opt/blender/" on other systems.

    In case that Blenderplayer is not found on the system the following message will appear:


    Notice that with our new working directory we don't need to export anything, when we want to distribuite it we can just compress our "PizzaGame" directory and that will be it. This efectivily means that we can work on a game and test it like the final user at the same time, increasing our workflow. A problem that may come with this is the automatic genaration of unnesscesary files (.blend1 and such), but don't worry, we have you covered: Inside the "BGECore/tools" directory you'll find a script called "clean.py". This script recursively cleans your working directory from blend security copies and compiled python objects, and you can easily tweak it to clean any given pattern.

    Speaking of compiled python. Do you know that you can not provide the source code of your game? To do that all you have to do is replace all your ".py" files with thier correspondent ".pyc" (automatically genearated when running the game for first time).

    Finally, if your game has a configuartion menu, it will have to store those values in the "config.txt" file. You can do it manually (opening, parsing, modifying, and saving the file with Python), or you can just use BGECore Framework API! (http://bgecore.royalwebhosting.net/u...iguration-file).

    You may not be aware of this, but the "C:/Program Files" directory, the default directory where programs and files are installed on Windows, and the "usr/bin/" on Linux, doesn't have write permissions without administrative privileges. This means that if your game is installed there, you'll have to open it with administrative privileges or you won't be able to save any data... or at last that was the rule before. BGECore Framework and also the launcher use a special directory in this case, to guarantee that you'll always have writte acces. The framework will always use that directory to store data, and the launcher will automatically create a copy of the config.txt file there and use it instead so that configurations can me modified even under a directry without writting acces.
    Attached Images Attached Images
    Last edited by elmeunick9; 29-May-16 at 10:57.



  3. #3
    Member Wisaam's Avatar
    Join Date
    May 2015
    Location
    Pakistan
    Posts
    197
    it gives me the error that VCRUNTIME140.dll is missing...

    Attached Images Attached Images
    Last edited by Wisaam; 29-May-16 at 13:03.



  4. #4
    Well that's becouse it's build on MSVC++15, wich is probably too new for your OS, your probably aren't using Windows 10. I'll see if I can somewhat statically link them. In the meantime it should work just fine installing the apropiate dlls: https://www.microsoft.com/en-us/down....aspx?id=48145

    Or you can build it youself with whatever compiler you see most fit.

    Edit: Now that I've loged in it's clear that you aren't using Windows 10
    Edit 2: I've updated the windows-32.exe launcher with static linking, now it should work without need of anything extra.
    Last edited by elmeunick9; 29-May-16 at 17:12.



  5. #5
    Member Wisaam's Avatar
    Join Date
    May 2015
    Location
    Pakistan
    Posts
    197
    I have three visual c++ redistributables currently on my pc...2008,2010,2013......should I remove all of them and just get the 2015 one?



  6. #6
    No, just install the new one. Optionally you can just search for the .dll on google and put it in the same folder, but using untrusted sources is not a good idea.



  7. #7
    Member Wisaam's Avatar
    Join Date
    May 2015
    Location
    Pakistan
    Posts
    197
    How would you solve the problem of people being able to open your blend file...??



  8. #8
    Member sdfgeoff's Avatar
    Join Date
    May 2010
    Location
    Kalpana One
    Posts
    5,183
    I once went and used launchers/wrote my own. Never to this level of complexity though. Then I relaized it didn't add anything to the game. So now I simply:
    Use a blend with:
    Always -> And -> Start game from file

    Then your game is not bundled with the blenderplayer and you can step around the GPL. Best of all, it takes all of ten seconds to do and doesn't require the user to have to worry about downloading a blenderplayer
    "Someone applied a roof texture to that wall" - martinsh

    Website: www.sdfgeoff.space



  9. #9
    Originally Posted by sdfgeoff View Post
    I once went and used launchers/wrote my own. Never to this level of complexity though. Then I relaized it didn't add anything to the game. So now I simply:
    Use a blend with:
    Always -> And -> Start game from file

    Then your game is not bundled with the blenderplayer and you can step around the GPL. Best of all, it takes all of ten seconds to do and doesn't require the user to have to worry about downloading a blenderplayer
    Yes it takes 10 seconds.

    More or less is a step arround GPL, but your game files and the GPL files are still in the same directory and it makes it look like your game is also GPL (actually like I said on "Advanced Publishing Options" the fact alone that the user downloads a blenderplayer could be enough to force you use GPL in your game, so it's not clear exactly what happens, personally I think that it's a valid workarround, but I'm not the judge).

    I don't know yours but BGECore Launcher adds a lot of things to the game besides just launching it. Launching options is one of them for example.

    With BGECore Launcher the user doesn't have to worry about downloading a blenderplayer neither. If you meant the creator of the game, he uses the one that comes with blender, if you meant the player, he uses the one on the "engine" directory.
    Last edited by elmeunick9; 29-May-16 at 16:26.



  10. #10
    Originally Posted by Wisaam View Post
    How would you solve the problem of people being able to open your blend file...??
    People is able to open your blend file no matter what method you use (excpet BPPlayer). All you have to do is extract the blend from the end of the blenderplayer executable and that's it. I did an addon some time ago that does exactly this, but the method is rather simple (look from the BLENDER header on the file and copy everything after from it to the end to a file with .blend extension).

    However there may be a way. You can compile your Python files and make them libload data from memory, that data can be stored in an encrypted form and then decrypted at runtime just before sending it to the Blenderplayer with libload. However this is out of the scope of this project, it could be part of BGECore Framework though.



  11. #11
    when i click on launch it starts and closes immediately
    Last edited by qartveli; 06-Jan-17 at 15:07.



  12. #12
    Originally Posted by qartveli View Post
    when i click on launch it starts and closes immediately
    May be for a buch of reasons, most probably it doesn't find the .blend. If you're using windows, try using the community addon for UPBGE (or the launcher that comes within, wich is not UPBGE specific): http://coredoc.royalwebhosting.net/

    For linux, make a shell script, nobody will think it's wierd there.

    The launcher that comes with it is a very simplified version of this one (it doesn't even use a config.txt file for now), so it's also less prone to bugs. More docs here: http://coredoc.royalwebhosting.net/ui/game_project.html



  13. #13
    i recorded video on screen and second before its closed says " ___ is not recognized as an internal or external command,
    operable program or batch file"



  14. #14
    Originally Posted by qartveli View Post
    i recorded video on screen and second before its closed says " ___ is not recognized as an internal or external command,
    operable program or batch file"
    Then it hasn't found the blenderplayer. Check if it outputs any meaningful message when running it on the terminal. Have you tried the launcher on the Community Addon?



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •