Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 18, 2021. It is now read-only.
/raylib-phpcppPublic archive

PHP bindings for raylib, a simple and easy-to-use library to enjoy videogames programming

License

NotificationsYou must be signed in to change notification settings

oraoto/raylib-phpcpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP bindings forraylib, a simple and easy-to-use library to learn videogames programming.

It’s developed usingPHP-CPP, so it’s called raylib-phpcpp.

Example

<?phpInitWindow(800,450,"raylib [core] example - basic window");SetTargetFPS(60);while (!WindowShouldClose()){BeginDrawing();ClearBackground(RAYWHITE());DrawText("Congrats! You created your first window!",190,200,20,LIGHTGRAY());EndDrawing();}CloseWindow();

See moreexamples.

Build

Run

mkdir build&&cd buildcmake ..make -j$(nproc)

Then you havelibraylib-phpcpp.so in build directory.

Mapping C to PHP

  • All C functions are exposed as PHP global functions, for example:
    Craylib-phpcpp
    WindowShouldClose()WindowShouldClose()
    InitWindow(800, 450, “title”)InitWindow(800, 450, “title”)
  • Color constants are exposed as global functions, for example:
    Craylib-phpcpp
    LIGHTGRAYLIGHTGRAY()
    GREENGREEN()
  • All C enums are exposed as global constants withRL_ prefix:
    Craylib-phpcpp
    FLAG_SHOW_LOGORL_FLAG_SHOW_LOGO
    KEY_COMMARL_KEY_COMMA
  • Constructor for simple structs (struct without array and pointer members) are exposed as function, for example to create aCamera2D:
    <?php$offset =Vector2(1,1);$target =Vector2(0,0);$camera =Camera2D($offset,$target,1.0,1.0);
  • Accessor for struct fields are implemented as__get and__set, some update operation are more cumbersome:
    <?php$v =Vector2(1,2);// $v->x += 1; doesn't work$v->x =$v->x +1;$camera =Camera2D(Vector2(1,1),Vector2(0,0),1.0,1.0);// $camera->target->x = 1; // doesn't work$target =$camera->target;$target->x =1;$camera->target =$target;
  • Known name conflicts
    raylib-phpcppPHP
    ImageCopygd extension
    ImageCropgd extension

    You should disable gd extension while exploring raylib :)

  • API differences

    TBD.

    Function
    GetDroppedFiles
    ImageExtractPalette
    LoadModelAnimations
    LoadMeshes
    LoadMaterials

Completeness

Most functions and features are supported.

For most file and text functions, you can use counterparts in PHP.

License

raylib-phpcpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. CheckLICENSE for further details.

About

PHP bindings for raylib, a simple and easy-to-use library to enjoy videogames programming

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp