raylib-cpp is a header-only C++ wrapper for raylib. It provides object-oriented wrappers around raylib's struct interfaces, making the API more idiomatic for C++ developers. To use it, you must link your project to raylib and include the header.
Installation Steps
- Set up a raylib project following their build and installation instructions.
- Ensure your
.cpp files are compiled with a C++ compiler. - Download
raylib-cpp. - Include the header in your source code:
#include "path/to/raylib-cpp.hpp"
#include "raylib-cpp.hpp"
int main() {
int screenWidth = 800;
int screenHeight = 450;
raylib::Window window(screenWidth, screenHeight, "raylib-cpp - basic window");
raylib::Texture logo("raylib_logo.png");
SetTargetFPS(60);
while (!window.ShouldClose())
{
BeginDrawing();
window.ClearBackground(raylib::Color::RayWhite());
DrawText("Congrats! You created your first window!", 190, 200, 20, raylib::Color::LightGray());
// Object methods.
logo.Draw(
screenWidth / 2 - logo.GetWidth() / 2,
screenHeight / 2 - logo.GetHeight() / 2);
EndDrawing();
}
return 0;
}