- Install Visual Studio Code. You are free to use other text editors and IDEs but you will be on your own for the intellisense setup.
- [Optional] Install Doxygen for generating documentation.
- Install raylib dependencies for your operating system following the wiki here.
- Install emscripten in the
external
directory.# run these commands in the project root cd external git clone https://github.com/emscripten-core/emsdk.git cd emsdk # this is optional # rm -rf .git ./emsdk install latest ./emsdk activate latest # it shows you some information on updating the PATH either follow them or do it on your own # verify the installation emcc --check
- In
VSCode
, in the command center(Ctrl + Shift + P), choose theSelect configuration
option given by theC/C++
extension byMicrosoft
. Choose theraylib web
option. - There should be no errors when you open the project's
cpp
files inVSCode
. - [Optional] Install
live-server
usingpnpm i
. - Test your setup by running both the commands. Note that both commands should run successfully, especially the first one should not fail if you have setup everything correctly.
# building web
make PLATFORM=PLATFORM_WEB run
# building desktop PLATFORM=PLATFORM_DESKTOP is the default
make run
main.cpp
is the root of the project.src
andinclude
is where most code is going to be written in.- After making changes to the code, you have to run the
make
command with appropriate arguments. - You can use the experimental utility script
run
to run make on saving files. For which you will have to installentr
. You can probably do this using your package manager. - Note that the utility script runs
make
(i.e., it compiles the project usingmake
) for you but it does not run the build.
make run # or make run PLATFORM=PLATFORM_DESKTOP
# Alternatively, you can build first and run the binary yourself
make PLATFORM=PLATFORM_DESKTOP
./build/convex_hull
Whenever you make changes and build, you have to reload the html page for the changes to take effect. If the output is still not what you expected you can try Ctrl + F5 to reload without cache.
make PLATFORM=PLATFORM_WEB run # this will use emrun to open the page on your browser
# Alternatively, you can build first and open the html file on your own.
make PLATFORM=PLATFORM_WEB
emrun ./build/convex_hull.html
You can read about the flags here. When using live-server
, you just have to create the build using make
, whenever live-server detects changes it will reload the page for you.
pnpm live-server build --entry-file=convex_hull.html --wait=500 -q
# run this another terminal window when you make changes
make PLATFORM=PLATFORM_WEB
# using the experimental `run` script
# with this setup whenever you save changes on your editor, the page will reload.
# Note that with autosave it might trigger unnecessary reloads so it's your call whether you want to use this or not.
# run the script in one window
./run PLATFORM_WEB
# in another window run the live-server
pnpm live-server build --entry-file=convex_hull.html --wait=500 -q