Jump to content

Blender 3D: Noob to Pro/Making exe

From Wikibooks, open books for an open world

This tutorial will show you how to make an executable for your game made in Blender.

Note: The methods listed in the "Windows" and "GNU/Linux or Mac OS X" sections work only for the operating system you are on when you create the file. To make it cross platform, use the "BlenderPlayer" method.

Windows

[edit | edit source]

First create a folder that will hold all your game information. Name it something meaningful, like "Yo Frankie!".

The folder must contain four files that you can copy from your blender installation directory.(under windows it should be "C:\Program Files\Blender Foundation\Blender") They are:

  1. SDL.dll
  2. python24.dll (Or other relevant python file; python25.dll, python26.dll etc.)
  3. pthreadVC2.dll
  4. zlib.dll

(sometimes you will need the following also...

  1. avformat-51.dll
  2. avutil-49.dll
  3. avcodec-51.dll

They are in the same folder.)

Not quite a Noob Note: If you are using the latest version of Blender you WILL need the following files)

I am running windows xp media edition and blender 2.46, here is a full list of files i needed:

  1. avcodec-51.dll
  2. avformat-52.dll
  3. avutil-49.dll
  4. libfaac-0.dll
  5. libfaad-0.dll
  6. libmp3lame-0.dll
  7. libx264-59.dll
  8. pthreadVC2.dll
  9. python25.dll
  10. SDL.dll
  11. swscale-0.dll
  12. vcomp90.dll
  13. xvidcore.dll
  14. zlib.dll

On Blender 2.48a (Windows XP Media Center 2002, SP3), these .manifest files are also required:

  1. blender.exe.manifest
  2. blenderplayer.exe.manifest
  3. Microsoft.VC90.CRT.manifest
  4. Microsoft.VC90.OpenMP.manifest

If you use random Python module in your game, you will have to add one more file to your game directory. For Blender 2.49 it would be python26.zip, which you can find in Blender main directory (where blender.exe is). Otherwise there may be some errors during executing the game in system without installed Python.

Since Blender 2.56 you will need to enable Save As Runtime; first open blender with the game that you have created and open the file menu. Click on User Preferences then select Add Ons then Game Engine, check the box Game Engine Save As Runtime and return to the file menu. Save As Runtime will appear as an option in the export menu then save to the new folder that you have created and rename the file yourgamename.exe,

and then you can run the game!

If you encounter errors during the "Save As Runtime" process (I'm on Windows 7) you can right click on the Blender icon and select "Run as administrator". So you will have your fresh .exe and you can spread it with a piece of your favourite pepperoni pizza.

Making A Screensaver (Windows Only)

[edit | edit source]
  1. First, save your runtime (that's the .exe addressed above.) via File->Save Game as Runtime. ("Save Runtime" in older versions)
  2. Now, go to your .exe game and rename it .scr - for instance, if your game was NotMyGame.exe, rename it to NotMyGame.scr. You can now right click to Install it, and then use it as your regular screensaver by applying it as you would any other screensaver (right click on desktop, properties... You know the drill.)

Screensavers are not games, and so they should not accept input. At most, they should be videos showing what your game does. If you just rename your regular game as a .scr, it will be remarkably boring, because your game needs input and screensavers do not.

Intel screensaver bug

[edit | edit source]

There is a caveat with Intel Integrated Graphics drivers, found in many laptops though. The graphics driver shuts off OpenGL acceleration for screensavers, for some obscure reason. The way to work around this is to rename the .scr extension to a .sCr as the driver's algorithm is dependent on case-sensitive characters. If you experience very low framerates in your screensaver, you should attempt this fix, It is tested and reported to work.

GNU/Linux or Mac OS X

[edit | edit source]

Open blender with the game that you have created and open the file menu. Click on Save Game as Runtime and then save to the new folder that you have created and rename the file yourgamename...

and then you can run the game!

BlenderPlayer

[edit | edit source]

The methods shown above only create an executable for your operating system. Well, BlenderPlayer can fix that.

  1. Make a new folder to store all your game data.
  2. Then save your .blend file into the directory.
  3. You can skip this step and the next step if you do not want a Windows version. For the Windows users, copy blenderplayer.exe to the new folder from a Windows copy of Blender. Then copy all your DLL files for Blender as mentioned for Windows to the folder.
  4. Next you have to make an MS-DOS batch file (for UNIX users, this is the shell script equivalent). In a simple text editor, in CR-LF mode if available (Notepad is always in this mode, and NOT a word processor!), copy and paste this text:
    blenderplayer.exe yourgamename.blend
    Save it as YourGameName-Windows.bat in your game folder.
  5. You can skip this step if you do not want a UNIX (basically Mac OS X and GNU/Linux) port. For GNU/Linux (at least), make a shell script. (A shell script is the UNIX term for a batch file.) In a simple text editor, in LF mode (unfortunately Notepad can't be used), copy and paste this text:
    #!/bin/bash
    ./blenderplayer.app/Contents/MacOS/blenderplayer yourgamename.blend

    Save the file as YourGameName-UNIX.sh in your game folder. You will need to have BlenderPlayer in the same directory as the .blend game file.
  6. Write a readme for your program. This is again best done with a simple text editor like Notepad or gedit, but it does not matter which mode it is in. You should include the name of the game, a description, perhaps a walkthrough or hints, and if you made a *NIX port, mention that it requires BlenderPlayer, available with Blender.
[edit | edit source]

Blender and the BlenderPlayer fall under the GNU General Public License. Blend files are copyrighted to their respected owners and do not fall under the GPL as long as they are not packed in the BlenderPlayer. If a user does not want the blend files to fall under the GPL, it is recommended not to use the "Save Game as Runtime" feature. To put it another way, the user must keep the blend files and the BlenderPlayer in separate files. More information can be found at http://www.blender.org/education-help/faq/gpl-for-artists/. (Blender 2.4 now has a run game from file actuator.)

Proprietary Blend Files

[edit | edit source]

Blender has no built-in functionality to "lock" or protect user generated content. As a result, anyone who has Blender can open and/or modify blend files. However, it's still possible to lock blend files. Common methods involve encrypting the blend file and then temporary decrypting it at runtime. This can be accomplished by using python scripts or by using external 3rd party applications (which are feasible under the GPL v2).