🚀 The union of Raylib and Emscripten!
We have already made a library, but that procedure is with a operating system using APT, however, the procedure can be adapted to any other operating system, simply by finding the corresponding package names for your package manager and/or installation paths.
First, you must have the following packages properly installed on your system:
sudo apt install libasound2-dev mesa-common-dev libx11-dev libxrandr-dev \
libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev \
build-essential cmake make g++ \
freeglut3-dev libglfw3 libglfw3-dev
The session must have been started by X11, if it is on Wayland, end the session and log in again choosing installed, we show you how to do this in a video, but in short, just run these commands below:
Remember to have :
Note that the argument was not used:
-DBUILD_SHARED_LIBS=ON.
CODEcmake -B build -DPLATFORM=PLATFORM_DESKTOP -DPLATFORM=Desktop;Web .
cmake --build build
sudo cmake --install build/
Note that you do not need to compile the
.so, as there is none.
Here is another summary of where the files are copied to, including the
libraylib.afile:
CODE[sudo] password for marcos:
-- Install configuration: "Debug"
-- Installing: /usr/local/lib/libraylib.a
-- Installing: /usr/local/include/raylib.h
-- Installing: /usr/local/include/rlgl.h
-- Installing: /usr/local/include/raymath.h
-- Installing: /usr/local/lib/pkgconfig/raylib.pc
-- Installing: /usr/local/lib/cmake/raylib/raylib-config-version.cmake
-- Installing: /usr/local/lib/cmake/raylib/raylib-config.cmake
Testing and running
Now just create an example file:
main.cppwith the code below:
CODE#include "raylib.h"
int main(){
InitWindow(800, 450, "raylib [core] example - basic window");
while (!WindowShouldClose()){
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
EndDrawing();
}
CloseWindow();
return 0;
}
To compile, first make sure you have a base HTML file to use, you can
Example running in the browser. Open the image in a new tab to see it in a higher resolution, if you want.
If you want to use the same code to run as a desktop, as you may already know, the command should be:
g++ main.cpp -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 && ./a.out.
Remember that the example is without
ASYNCIFY, for more information see here.↗ Original-Artikel auf dev.to lesenVollständiger Original-BerichtAusführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
SOCIAL SHARE CARD GENERATOR