mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
Updated Easy Raylib Setup for Windows with Visual Studio (markdown)
@ -1,89 +1,66 @@
|
||||
Video tutorial here: https://youtu.be/aeiA8HpL6Q4
|
||||
Video tutorial here: https://youtu.be/oHIh01L6xQQ
|
||||
|
||||
# Easy Raylib Setup for Visual Studio
|
||||
### Using Premake5
|
||||
# Download Files
|
||||
Download the game premake repository from
|
||||
https://github.com/raylib-extras/game-premake/tree/no_edit
|
||||
Download the zip file, or clone the repository. It doens't matter what one you use.
|
||||
Rename the folder whatever you want. This will be where your entire game proejct will be located.
|
||||
|
||||
https://github.com/raylib-extras/game-premake
|
||||
|
||||
## Download Visual Studio 2019
|
||||
Get Visual Studio from https://visualstudio.microsoft.com/downloads/
|
||||
The community edition is free and is perfectly suited for game development with raylib.
|
||||
|
||||

|
||||
|
||||
## Install Visual Studio
|
||||
Run the installer to put Visual Studio 2019 on your computer. See https://docs.microsoft.com/en-us/cpp/build/vscpp-step-0-installation?view=msvc-160 for more info.
|
||||
Be sure to install the Desktop development with C++ and Universal Windows Platform development workflows.
|
||||
|
||||

|
||||
|
||||
## Create a folder for your game
|
||||
Create a folder for you game. It can be anywhere on your computer.
|
||||
|
||||

|
||||
|
||||
## Download the Raylib Sources
|
||||
Download the raylib source code, from
|
||||
# Download raylib
|
||||
Get the raylib sources from
|
||||
https://github.com/raysan5/raylib
|
||||
You can get the zip file or clone the repository in git, both will work the same.
|
||||
Do not use the folder from the windows installer, it does not have the correct structure.
|
||||
Download the zip file, or clone the repository. It doens't matter what one you use.
|
||||
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)
|
||||
|
||||

|
||||
# Rename the _app folder
|
||||
Rename the _app folder to whatever you want your game's executable name to be.
|
||||
|
||||
## Copy Raylib into your game folder
|
||||
Extract the zip file, or copy the cloned raylib repository into a folder named raylib in your game folder. source code.
|
||||
## Using C++
|
||||
By default this process is setup to build a project using C. If you want to use C++, simply rename the main.c file that is inside the _app folder to main.cpp. The scripts will take care of the rest.
|
||||
|
||||

|
||||
This folder should contain all the raylib
|
||||
# Generate Projects
|
||||
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.
|
||||
Only do ONE of these options depending on your compiler and platform.
|
||||
## Windows Users
|
||||
Visual Studio users should run
|
||||
|
||||
## Download Premake5
|
||||
Download premake version 5.0 from https://premake.github.io/
|
||||
premake-VisualStudio.bat
|
||||
|
||||
This will generate a Visual Studio project.
|
||||
|
||||
## MinGW-w64 Users
|
||||
Run the batch file.
|
||||
|
||||

|
||||
premake-mingw.bat
|
||||
|
||||
https://premake.github.io/download.html#v5
|
||||
|
||||
Put the premake5.exe into your game folder.
|
||||
This will generate a makefile for you
|
||||
|
||||
## Linux users
|
||||
cd to the game folder and run
|
||||
|
||||

|
||||
./premake5 gmake2
|
||||
|
||||
## Download the premake5.lua and premake-2019.bat file from raylibExras
|
||||
Download the premake5.lua and premake-2019.bat files from
|
||||
https://github.com/raylib-extras/game-premake
|
||||
This will generate a makefile for you.
|
||||
|
||||
# Build your game
|
||||
Only do ONE of these options depending on your compiler and platform.
|
||||
## Windows Users
|
||||
Double click the .sln file that was generated in the folder. If you are using Visual Studio 2022 you will be asked to upgrade the project, the defaults are fine, accept them and it will load.
|
||||
From here you can use the prouject as normal.
|
||||
|
||||
## MinGW-w64 Users
|
||||
Open your compiler terminal (w64devkit if you are using it), change to the game folder and type
|
||||
|
||||

|
||||
Copy them into your game folder.
|
||||
make
|
||||
|
||||
This will build your game
|
||||
|
||||
## Linux users
|
||||
Open your terminal, change to the game folder and type.
|
||||
|
||||
## Setup your game's source code
|
||||
Make a folder for your actual game’s source code. In this case we will be starting with the “advanced game” template from the raylib sources, since it is a great place to start any project from. Be sure to copy at least one C or CPP file that has a main function into this folder. If you are unsure what to do , simply copy the code from one of the examples.
|
||||
|
||||

|
||||
|
||||
## Setup premake5.lua file
|
||||
Open the premake5.lua file in notepad++ or some other text editor (regular notepad is fine).
|
||||
Find the two instances of “YourGame” and replace them with the name of your game project.
|
||||
|
||||

|
||||

|
||||
Save the file and close it.
|
||||
|
||||
## Run premake-2019.bat
|
||||
Double click the premake-2019.bat file, or run it from a console. This will generate all the visual studio project files for the game. You will end up with a .sln file for your game in the root folder.
|
||||
|
||||

|
||||
|
||||
The same premake system can be used on linux, just use the command premake5 gmake instead of premake5 vs2019
|
||||
|
||||
## Open your .sln file
|
||||
Double click the sln file to open your game project in Visual Studio. It will include both your game files and the raylib library, all ready to build.
|
||||
|
||||

|
||||
|
||||
## Develop your game.
|
||||
You can now build, debug, and run your game from Visual Studio.
|
||||
|
||||

|
||||
|
||||
make
|
||||
|
||||
This will build your game
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user