|
| 1 | +# Raylib Setup using Premake5 |
| 2 | +This is a simplified set of instructions for how to setup a project using premake. |
| 3 | + |
| 4 | +## Video Tutorial |
| 5 | +A video covering this process is here |
| 6 | +https://youtu.be/--gI9083QnU |
| 7 | + |
| 8 | +# Download this repository |
| 9 | +Download the game premake repository from |
| 10 | +https://github.com/raylib-extras/game-premake/ |
| 11 | +You can either download the zip file, or clone the repository. |
| 12 | +If you clone the repository, you may want to remove the stored history. Simply delete the .git directory to do this. |
| 13 | + |
| 14 | +Rename the directory whatever you want. This will be the name of your game. |
| 15 | + |
| 16 | +#(OPTIONAL) Get Raylib |
| 17 | +If you wish to use a specific version of raylib, follow the instructions below. If you want the current development version, skip this section and premake will download raylib for you. |
| 18 | + |
| 19 | +## Download Raylib |
| 20 | +Get the raylib sources from |
| 21 | +https://github.com/raysan5/raylib |
| 22 | +Download the zip file, or clone the repository. It doesn't matter what one you use. |
| 23 | +Put the raylib sources in a folder called raylib inside your game folder (The same folder this file is in). The folder must be named raylib, it can not be raylib-master. The raylib folder should contain all the sources from raylib (including the 'src' folder) |
| 24 | + |
| 25 | +# Example app |
| 26 | +This repository is pre-populated wit the raylib game template. It is a great starting point for your game. |
| 27 | +https://github.com/raysan5/raylib-game-template |
| 28 | + |
| 29 | +If you want to have a different starting point, simply replace the files in the game folder with your own files. |
| 30 | + |
| 31 | +## Using C++ |
| 32 | +By default this process is setup to build a project using C. If you want to use C++, you can replace your files with you own cpp files. There is is a simple C++ file in the _app dir. The raylib template is designed for C, not C++, but the version in this repository has been modified to work as C++ if you choose to rename the files. |
| 33 | + |
| 34 | +# Generate Projects |
| 35 | +For windows users, there are two batch files you can use depending on what compiler you are using. For linux users you can simply use a terminal. |
| 36 | +Only do ONE of these options depending on your compiler and platform. |
| 37 | +## Windows Users |
| 38 | +Visual Studio users should run |
| 39 | + |
| 40 | + premake-VisualStudio.bat |
| 41 | + |
| 42 | +This will generate a Visual Studio project. |
| 43 | + |
| 44 | +## MinGW-w64 Users |
| 45 | +Please make sure you have a recent version of MinGW-W64. The older versons from mingw.org will not work. |
| 46 | +We recomend the W64Devkit. I thas everything needed to build raylib. I can be downloaded from here https://github.com/skeeto/w64devkit/releases |
| 47 | + |
| 48 | +Once you have MinGW-W64 |
| 49 | +Run the batch file. |
| 50 | + |
| 51 | + premake-mingw.bat |
| 52 | + |
| 53 | +This will generate a makefile for you |
| 54 | + |
| 55 | +## Linux users |
| 56 | +cd to the game folder and run |
| 57 | + |
| 58 | + ./premake5 gmake2 |
| 59 | + |
| 60 | +This will generate a makefile for you. |
| 61 | + |
| 62 | +## macOS users |
| 63 | +cd to the game folder and run |
| 64 | + |
| 65 | + ./premake5.osx gmake2 |
| 66 | + |
| 67 | +This will generate a makefile for you. |
| 68 | + |
| 69 | +# Build your game |
| 70 | +Only do ONE of these options depending on your compiler and platform. |
| 71 | +## Windows Users |
| 72 | +Double click the .sln file that was generated in the folder. From here you can use the project as normal. |
| 73 | + |
| 74 | +## MinGW-w64 Users |
| 75 | +Open your compiler terminal (w64devkit if you are using it), change to the game folder and type |
| 76 | + |
| 77 | + make |
| 78 | + |
| 79 | +This will build your game |
| 80 | + |
| 81 | +## Linux/macOS users |
| 82 | +Open your terminal, change to the game folder and type. |
| 83 | + |
| 84 | + make |
| 85 | + |
| 86 | +This will build your starting game template |
| 87 | + |
| 88 | + |
| 89 | +# Building for other OpenGL targets |
| 90 | +If you need to build for a different OpenGL version than the default (OpenGL 3.3) you can specify an openGL version in your premake command line. Just modify the bat file or add the following to your command line |
| 91 | + |
| 92 | +## For OpenGL 1.1 |
| 93 | +--graphics=opengl11 |
| 94 | + |
| 95 | +## For OpenGL 2.1 |
| 96 | +--graphics=opengl21 |
| 97 | + |
| 98 | +## For OpenGL 4.3 |
| 99 | +--graphics=opengl43 |
| 100 | + |
| 101 | +# Building extra libs |
| 102 | +If you need to add a separate library to your game you can do that very easily. |
| 103 | +Simply copy the _lib folder and rename it to what you want your lib to be called. |
| 104 | +Replace lib.c with the sources for your library (just copy them in the folder). |
| 105 | +If you library has an include folder, copy that too. |
| 106 | +Then go to the premake5.lua file in the game folder, and link your library by calling link_to with the folder name for the library. |
| 107 | + |
| 108 | +link_to("LIB_FOLDER_NAME") |
| 109 | + |
| 110 | +Rerun premake and it will build your library for you. |
| 111 | +Note that by default link_to will add include dirs for your library folder and library/include. If you have other include needs you will have to add those to your premake file manually. |
0 commit comments