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.
API | Windows (x86-64) | Linux (x86-64) | macOS (x86-64) |
---|---|---|---|
core | ✔️ | ✔️ | ✔️ |
reasings | ✔️ | ✔️ | ✔️ |
physac | ✔️ | ✔️ | ✔️ |
raymath | 🚧 | 🚧 | 🚧 |
raygui | ❌ | ❌ | ❌ |
' 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.
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 SUB
s? Should't these be FUNCTIONS
s?
- Unfortunately, QB64 does not support returning UDTs from
FUNCTION
s and many raylib functions return UDTs. So, to work around this limitation, I changed many raylib funtions toSUB
s that would otherwise be aFUNCTION
. The return value is returned to the caller via a SUB parameter. This is usually the last parameter and has the nameretVal
.
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?
- Always use the latest version of QB64-PE from https://github.com/QB64-Phoenix-Edition/QB64pe/releases/latest. QB64-PE has hade a number of bug fixes and improvements that make this library possible. QB64 v2.0.2 or other forks of QB64 are not supported and may not work at all.
I found a bug. How can I help?
- Let me know using GitHub issues or fix it yourself and submit a PR!
- 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.
- Ramon Santamaria for the awesome raylib library
- grymmjack for the raylib-64 logo
- Martin Olivier for Dylib (cross-platform dynamic library loader)
- Various artists for the example assets taken directly from the raylib repository
- 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
- Bindings for raymath
- Bindings for raygui
Made with ❤️