a740g / raylib-64

QB64-PE bindings for raylib (a simple and easy-to-use library to learn videogames programming)

Home Page:https://qb64phoenix.com/forum/showthread.php?tid=1776

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

raylib for QB64-PE

raylib

raylib for QB64-PE is a QB64-PE binding library for raylib. raylib is a simple and easy-to-use library to enjoy videogames programming.

raylib is highly inspired by Borland BGI graphics lib and by XNA framework and it's specially well suited for prototyping, tooling, graphical applications, embedded systems and education.

Screenshot 1 Screenshot 2 Screenshot 3 Screenshot 4

SUPPORTED PLATFORMS

API Windows (x86-64) Linux (x86-64) macOS (x86-64)
core ✔️ ✔️ ✔️
reasings ✔️ ✔️ ✔️
physac ✔️ ✔️ ✔️
raymath 🚧 🚧 🚧
raygui

EXAMPLE

' raylib [core] example - Basic window

'$INCLUDE:'include/raylib.bi'

Const screenWidth = 800
Const screenHeight = 450

InitWindow screenWidth, screenHeight, "raylib [core] example - basic window"

SetTargetFPS 60

Do Until WindowShouldClose
    BeginDrawing

    ClearBackground RAYWHITE

    DrawText "Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY

    EndDrawing
Loop

CloseWindow

System

'$INCLUDE:'include/raylib.bas'

More examples are available in the repository.

FAQ

Why are you loading the shared library using C/C++? Why not use QB64's built-in DECLARE DYNAMIC LIBRARY?

  • When I initially started out, I wanted to use DECLARE DYNAMIC LIBRARY to keep things simple. However, some QB64 language limitations got in the way. For example, you cannot return UTDs from functions and subs and functions cannot take UDT variables by value (yet). raylib does a lot of both. So, I had to make a hard choice of wrapping these functions in C/C++ in a QB64-friendly way. Also, I used a custom autogen program to do the heavy lifting and it made a lot of sense to do the autogen to C/C++.

Where is the source for the autogen program?

  • It served it's purpose and helped me kickstart the project and now it has retired. I am not going to share it because I am not proud of the way I wrote it. 😁

Why does some raylib TYPEs like Camera, Texture2D, Sound etc. generate an error?

  • Some TYPEs and TYPE member variables had to be renamed to resolve clashes with QB64 keywords. E.g. Sound is RSound. Also QB64 does not support TYPE aliases. So, there is no Camera. It's just Camera2D or Camera3D. There is no Texture2D. It's just Texture.

Why have you changed a lot of raylib functions like LoadTexture, GetMousePosition, GetMonitorPosition etc. to QB64 SUBs? Should't these be FUNCTIONSs?

  • Unfortunately, QB64 does not support returning UDTs from FUNCTIONs and many raylib functions return UDTs. So, to work around this limitation, I changed many raylib funtions to SUBs that would otherwise be a FUNCTION. The return value is returned to the caller via a SUB parameter. This is usually the last parameter and has the name retVal.

What QB64 statements and functions should I avoid while using raylib?

  • Any statement or functions that require the QB64 graphics OpenGL window (including all input stuff) should be avoided. Use the raylib alternatives for those.

Does all of raylib work with QB64?

  • Well, mostly. Callbacks are a challenge. But, it can be done if you are willing to mix a little bit of C with QB64. Stuff requiring usage of pointers can be a little difficult. I plan to simplify these by carefully wrapping more raylib functions inside QB64 friendly routines. Also, I have included pointer support routines for cases where you have to work with raylib structs (TYPEs) that contain pointers and arrays.

Which version of QB64 should I use with raylib-64?

I found a bug. How can I help?

  • Let me know using GitHub issues or fix it yourself and submit a PR!

NOTE

  • Lots of functions using strings are not wrapped yet. Use these carefully by null-terminating strings before passing them off to raylib functions. If possible, help me wrap these functions. See include/raylib.bas for details.

CREDITS

HELP NEEDED

  • Port all possible raylib examples from raylib - examples
  • Wrap all possible raylib functions that take a string to ensure stings are null-terminated
  • Wrap all possible raylib functions that take pointers and C-style arrays
  • Also see TODO section below

TODO

  • Bindings for raymath
  • Bindings for raygui

Made with ❤️

About

QB64-PE bindings for raylib (a simple and easy-to-use library to learn videogames programming)

https://qb64phoenix.com/forum/showthread.php?tid=1776

License:MIT License


Languages

Language:C++ 51.6%Language:FreeBasic 24.1%Language:BASIC 20.4%Language:GLSL 3.1%Language:Visual Basic 6.0 0.5%Language:C 0.4%