Creating Raylib Bindings for FreeBASIC (with AI)

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
c-sanchez
Posts: 155
Joined: Dec 06, 2012 0:38

Creating Raylib Bindings for FreeBASIC (with AI)

Post by c-sanchez »

Hello everyone,
I'd like to share a recent experiment I conducted, which yielded some fascinating results. The process is somewhat detailed, but I believe you'll find the conclusion as interesting as I did.

Before I begin, an important note: this analysis is not intended to disparage anyone's work. On the contrary, I believe that all contributions are valuable and essential for progress, as will become clear below.

The Origin: Two Bindings and a Question
Some time ago, I asked mysoft to create a Raylib (v4.2) binding for FreeBASIC, and he kindly provided a fully functional version. Later, I found an alternative implementation on GitHub by WIITD. When I asked mysoft for his thoughts on the differences, he indicated that, in his opinion, the other implementation (WIITD's) was not advisable to use.

The Experiment: Gemini as an Impartial Judge
With the recent advancements in AI, particularly Google Gemini's ability to handle context windows of up to 1 million tokens, I decided to put both implementations to the test. I provided the AI with both codebases and asked for a comparative analysis to determine which one was superior.
Although an AI can provide variable answers, its analysis tends to be impartial.
Here were its main conclusions:

Code: Select all

Feature           Version 1                                Version 2                                    Winner
-----------------------------------------------------------------------------------------------------------------
Code Style        Names with _, less clean.                Clean names, faithful to C API.              Version 2
Type Definition   Adds FB constructors.                    Pure UDTs, as in C.                          Version 2
Boolean Type      Uses boolean (incorrect, -1/0).          Uses bool (correct, 1/0).                    Version 2 (CRITICAL)
Consistency       Functional but inconsistent (RLColor).   More consistent (RayColor) and documented.   Version 2
Ease of Use       Includes all linking (#inclib).          User must link manually.                     Version 1
(I will attach Gemini's full response in the first reply to this thread).

The Next Step: Automating the Creation
Encouraged by this analysis, I asked the AI to create a Python script to generate the binding automatically. After several failed attempts, the AI's response was unexpected: "Forget the script, here is the version you need."
That's when it clicked. My real goal wasn't the script, but obtaining a high-quality binding. After correcting a few details, the AI successfully generated a new and improved binding for Raylib 4.2.
Intrigued, I asked it to detail the exact process it had followed to convert raylib.h to raylib.bi so that I could replicate it in the future.
(I will include these instructions in the second reply).

The Breakthrough: Beyond Version 4.2
To validate the method, I started a new conversation with the AI (from a clean slate), providing it only with the instructions it had given me. The result was a success:

· I gave it the instructions and the raylib.h for version 4.2. It generated it with only one minor error.
· I repeated the process with version 4.5. It succeeded.
· I continued with a major update, version 5.0. It succeeded again.
· Finally, I requested version 5.5, the most recent version to date. It also generated it successfully.

The result is what is likely the only existing binding for Raylib 5.5 for FreeBASIC, created entirely by an AI following a method it defined itself.

Fun fact: This post was originally written by me, but this final version was polished and refined by an AI for greater clarity.

I’ve created a GitHub repository to share the files. :)
Link: https://github.com/c-sanchez/freebasic-raylibs
c-sanchez
Posts: 155
Joined: Dec 06, 2012 0:38

Re: Creating Raylib Bindings for FreeBASIC (with AI)

Post by c-sanchez »

Gemini AI's Response on the Analysis of the Two Raylib Bindings
Absolutely! Let's analyze both versions of the Raylib header file (.bi) for FreeBASIC.

At first glance, it's important to note that both headers are for the same version of Raylib (4.2). The difference isn't in the version of the underlying library, but in how the C header has been translated and adapted for FreeBASIC.

After a detailed analysis, my conclusion is that Version 2 is superior in almost every technical and stylistic aspect, although it has a significant disadvantage in terms of ease of use for beginners.

Below, I'll explain why by breaking down the key differences.
Comparative Analysis
  • Code Style and Cleanliness (Point for Version 2)

    This is one of the most noticeable changes.

    Version 1: Uses underscore suffixes () on many struct members and function parameters (e.g., width, height_, data_, name_). This is commonly done to avoid conflicts with FreeBASIC's reserved keywords (like width, data, name). However, it makes the code less readable and departs from the original Raylib API.

    Code: Select all

    ' Version 1
    type Rectangle
    x as single
    y as single
    width_ as single ' -> underscore
    height_ as single ' -> underscore
    end type
    Version 2: Removes these underscores, resulting in a much cleaner API that is more faithful to the C original. This makes code written in FreeBASIC look much more like the official Raylib examples in C.

    Code: Select all

    ' Version 2
    type Rectangle
    x as single
    y as single
    width as single ' -> clean
    height as single ' -> clean
    end type
    To avoid conflicts, Version 2 often renames the parameter if it matches the type name, which is a more elegant solution. For example, in DrawRectangle, instead of color_, it uses RayColor as the parameter name.
  • Type Definitions (UDTs) and Constructors (Point for Version 2)

    Version 1: Defines constructors for basic types like Vector2, Vector3, RLColor, Camera2D, etc.

    Code: Select all

    ' Version 1
    type Vector2
    x as single
    y as single
    declare constructor()
    declare constructor(x as single, y as single)
    end type
    
    constructor Vector2(x as single, y as single)
    this.x = x
    this.y = y
    end constructor
    While this might seem like an advantage, it adds extra code that doesn't exist in the original C library. It's a layer of FreeBASIC "syntactic sugar" on top of a C API.

    Version 2: Removes all constructors, defining the Types as pure data structures, just like in C. This makes the header lighter and a more direct translation.

    Code: Select all

    ' Version 2
    type Vector2
    x as single
    y as single
    end type
    To initialize these structs, Version 2 uses the type<TypeName>(...) syntax in its color macros, which is the idiomatic way in FreeBASIC to create a temporary object without needing an explicit constructor.
  • Handling of Boolean Types (Critical Point for Version 2)

    This is the most important technical improvement.

    Version 1: Uses FreeBASIC's native boolean type for functions that return true/false. FB's boolean is an integer that is 0 for false and -1 for true.

    Code: Select all

    ' Version 1
    declare function WindowShouldClose() as boolean
    Version 2: Uses the bool type and includes "stdbool.bi". The bool type is designed to be compatible with C's _Bool, which is 0 for false and 1 for true.

    Code: Select all

    ' Version 2
    #include once "stdbool.bi"
    ...
    declare function WindowShouldClose() as bool
    Since Raylib is a C library, its boolean functions will return 0 or 1. Using bool (Version 2) is the correct and safe way to interface with the library. Using boolean (Version 1) could lead to subtle bugs, as the FB compiler expects a -1 for true, but the C function will give it a 1. Although FreeBASIC often handles this well in comparisons (If func() Then...), it is technically incorrect and less robust.
  • Naming and Consistency (Point for Version 2)

    Version 1: Uses RLColor for the color type.

    Version 2: Uses RayColor and renames the constant BLUE to RAYBLUE to avoid conflicts. It even adds a comment explaining the changes:

    Code: Select all

    '******** changes from base ********
    'color -> RayColor
    'blue -> RayBlue
    '***********************************
    This change (RLColor to RayColor) is more descriptive, and documenting the changes is an excellent practice.
  • Linking Dependencies (#inclib) (Point for Version 1)

    This is where Version 1 clearly wins.

    Version 1: Includes all the preprocessor logic to link the necessary libraries depending on the operating system (X11, GL on Linux; gdi32, winmm on Windows, etc.).

    Code: Select all

    ' Version 1
    #if defined(FB_CYGWIN) or defined(FB_LINUX) ...
    #inclib "GL"
    #inclib "X11"
    #endif
    ...
    This makes the header "plug-and-play." A user just has to include this file, and the compiler will handle linking everything necessary.

    Version 2: Has completely removed these #inclib directives.

    Code: Select all

    ' Version 2
    #inclib "raylib" ' -> Only links raylib, nothing else.
    This means the end-user is responsible for manually adding the #inclib directives to their source code or their compile command. This makes Version 2 less beginner-friendly.
Summary and Final Verdict

Code: Select all

Feature           Version 1                                Version 2                                    Winner
-----------------------------------------------------------------------------------------------------------------
Code Style        Names with _, less clean.                Clean names, faithful to C API.              Version 2
Type Definition   Adds FB constructors.                    Pure UDTs, as in C.                          Version 2
Boolean Type      Uses boolean (incorrect, -1/0).          Uses bool (correct, 1/0).                    Version 2 (CRITICAL)
Consistency       Functional but inconsistent (RLColor).   More consistent (RayColor) and documented.   Version 2
Ease of Use       Includes all linking (#inclib).          User must link manually.                     Version 1
Which one is better?

Version 2 is technically superior and the best choice for a serious project.

Why: It's more robust due to the correct use of the bool type, its API is cleaner, and it follows best practices for binding C to FreeBASIC. The resulting code will be easier to maintain and less prone to bugs. It reflects a deeper understanding of the subtleties of C and FreeBASIC interoperability.

However, it comes with a warning:

The lack of #inclib directives makes it harder to use "out of the box." A developer would need to know which libraries to add, which is a barrier for someone who just wants to start coding quickly.

My recommendation:
  • For an experienced developer: Use Version 2 without hesitation. Simply add the #inclib directives from Version 1 to your main project, and you'll enjoy a much better-designed header.
  • For a beginner: Version 1 might be easier to start with, as "it just works." But be aware of its technical shortcomings, especially if your project grows in complexity.
In short, Version 2 is the better header file, while Version 1 is the more complete package for beginners. The ideal solution would be to combine the best of both: the quality of Version 2 with the linking directives of Version 1.
c-sanchez
Posts: 155
Joined: Dec 06, 2012 0:38

Re: Creating Raylib Bindings for FreeBASIC (with AI)

Post by c-sanchez »

Detailed Guide to Converting a C Header (.h) to a FreeBASIC Binding (.bi)

The goal is to translate the syntax, data types, and structures from C to their FreeBASIC equivalents, paying close attention to the order of declarations, which is the most common cause of compilation errors.

Phase 1: Preparation
  • Get the C Header File: In this case, raylib.h.
  • Create the Destination File: An empty file that will be named raylib.bi.
  • Use a Good Text Editor: One with syntax highlighting for both C and FreeBASIC (like Visual Studio Code, Notepad++, etc.) will help you visually identify errors.
Phase 2: The Base Structure (The "Boilerplate")

Every FreeBASIC binding file should start and end with a specific structure.
  • Add Initial Directives: #pragma once prevents double inclusion of the file. The #include statements bring in necessary definitions from the FreeBASIC C-Runtime and the C-compatible bool type. #inclib links the Raylib library.

    Code: Select all

    #pragma once
    
    #include once "crt/long.bi"
    #include once "crt/stdarg.bi"
    #include once "stdbool.bi"
    
    #inclib "raylib"
  • Define the extern "C" Block: This tells the FreeBASIC compiler that the functions declared below use the C naming convention, which is crucial for the linker to find them in the .dll or .a library file.

    Code: Select all

    extern "C"
    
    ' ... all the binding content will go here ...
    
    end extern
Phase 3: The Conversion Process (Element by Element)

Now, go through the raylib.h file and convert each type of declaration. The order in which you add them to the .bi file is vital.

Step 3.1: #define and Constants

Numeric Constants: C #defines for constants like PI are converted to const in FreeBASIC.
  • C: #define PI 3.14159265358979323846f
  • FB: const PI = 3.14159265358979323846 (the f suffix is not needed).
Color Macros: C macros that initialize structs are converted to FreeBASIC #define macros using the type<T>() syntax.
  • C: #define LIGHTGRAY CLITERAL(Color){ 200, 200, 200, 255 }
  • FB: #define LIGHTGRAY type<RayColor>( 200, 200, 200, 255 ) (Note the change from Color to RayColor).
Step 3.2: typedef struct (User-Defined Types)
This is the most complex part. The general rule is: typedef struct { ... } Name; becomes Type Name ... End Type

This is the most complex part. The general rule is: typedef struct { ... } Name; becomes Type Name ... End Type.

Type Mapping:
  • int -> long
  • float -> single
  • unsigned char -> ubyte
  • unsigned int -> ulong
  • bool -> bool
  • void * -> any ptr
  • char * -> zstring ptr
  • const char * -> const zstring ptr
  • Type * -> Type ptr
  • Type ** -> Type ptr ptr
Simple Members: Each member must be on its own line.
  • C: float x; float y;
  • FB: x as single \n y as single
The Matrix Case: FreeBASIC does not allow var1, var2 as type. You must separate them.
  • C: float m0, m4, m8, m12;
  • FB: m0 as single \n m4 as single \n m8 as single \n m12 as single
Static Arrays:
  • char arrays for strings: char name[32]; becomes a fixed-size string: name as zstring * 32.
  • Other arrays: float params[4]; becomes params(0 to 3) as single.
Conflicting Names: If a member is named after an FB keyword (e.g., end, next, data), add a trailing underscore: end_. This is not a major issue in raylib.h, but it's good practice to be aware of.

Step 3.3: typedef Aliases
These are very important for ordering. They are declarations like typedef Vector4 Quaternion;

Translation: This is a direct translation to Type NewType as OldType.
  • C: typedef Vector4 Quaternion; -> FB: Type Quaternion as Vector4
  • C: typedef Texture Texture2D; -> FB: Type Texture2D as Texture
Step 3.4: enum (Enumerations)

Translation: typedef enum { ... } Name; becomes a type Name as long \n enum ... end enum block.
  • C: typedef enum { LOG_ALL = 0, LOG_TRACE, ... } TraceLogLevel;
  • FB:

Code: Select all

type TraceLogLevel as long
enum
    LOG_ALL = 0, LOG_TRACE, ...
end enum
Constant Aliases: #defines that use enum values (e.g., MOUSE_LEFT_BUTTON) must be declared after the enum has been defined. They become const.
  • C: #define MOUSE_LEFT_BUTTON MOUSE_BUTTON_LEFT
  • FB: const MOUSE_LEFT_BUTTON = MOUSE_BUTTON_LEFT
Step 3.5: Function Pointers (Callbacks)

Translation: typedef ret_type (*Name)(params); becomes Type Name as Function(params) as ret_type or Type Name as Sub(params) if ret_type is void.
  • C: typedef void (*AudioCallback)(void *bufferData, unsigned int frames);
  • FB: type AudioCallback as sub(byval bufferData as any ptr, byval frames as ulong)
Step 3.6: Function Declarations
Translation: RLAPI ret_type Name(params); becomes declare function Name(params) as ret_type or declare sub Name(params).
function vs sub: If the return type in C is void, it is a sub in FreeBASIC. For any other type, it is a function.
Parameters and byval:
  • Primitive data types (int, float, bool) are passed by value. Use byval.
  • C structs are passed by value (the entire structure is copied). Use byval.
  • Pointers (*) are passed by reference (the address is passed). Do not use byval.
  • C Example: void UpdateCamera(Camera *camera); -> FB: declare sub UpdateCamera(byval camera as Camera ptr)
  • C Example: void SetWindowIcon(Image image); -> FB: declare sub SetWindowIcon(byval image as Image)
Phase 4: The Assembly Order (The Key to Success!)

This is the critical step where most automated attempts fail. You must assemble the .bi file in the following strict order to avoid "variable not declared" errors:
  • Initial Boilerplate: #pragma, #include, #inclib, extern "C".
  • Constants and Macros: All #define and const that do not depend on anything else.
  • Base struct Definitions: Define the Types that do not depend on other custom Types (e.g., Vector2, RayColor, Matrix).
  • Opaque struct Definitions: The type rAudioBuffer as rAudioBuffer_ declarations. This allows other types to use them as pointers before they are fully defined.
  • Type Alias Definitions: Type Quaternion as Vector4, Type Texture2D as Texture. Now the compiler knows what these new names are.
  • Composite struct Definitions: Define the Types that use the aliases and base types (e.g., MaterialMap, which needs Texture2D and RayColor).
  • enum Definitions: Place all the enum blocks.
  • const Alias Definitions: Now that the enums are defined, you can add const MOUSE_LEFT_BUTTON = MOUSE_BUTTON_LEFT.
  • Callback type Definitions: Define the function pointer types.
  • Function Declarations: Finally, add all the declare sub/function statements. At this point, all parameter and return types have already been defined.
  • Final Boilerplate: end extern.
By following this order meticulously, you ensure that when the compiler reads a line, it already knows all the types and constants being used in that line. This was the secret to fixing the binding.
paul doe
Posts: 1878
Joined: Jul 25, 2017 17:22
Location: Argentina
Contact:

Re: Creating Raylib Bindings for FreeBASIC (with AI)

Post by paul doe »

Aha. Have you tested the header with the latest raylib version? I don't care what an AI says: if it doesn't work, it doesn't matter if you think it's 'superior'. All it matters is that it works.
c-sanchez wrote: Jun 08, 2025 1:58 [*]Type Definitions (UDTs) and Constructors (Point for Version 2)

Version 1: Defines constructors for basic types like Vector2, Vector3, RLColor, Camera2D, etc.

Code: Select all

' Version 1
type Vector2
x as single
y as single
declare constructor()
declare constructor(x as single, y as single)
end type

constructor Vector2(x as single, y as single)
this.x = x
this.y = y
end constructor
While this might seem like an advantage, it adds extra code that doesn't exist in the original C library. It's a layer of FreeBASIC "syntactic sugar" on top of a C API.

Version 2: Removes all constructors, defining the Types as pure data structures, just like in C. This makes the header lighter and a more direct translation.

Code: Select all

' Version 2
type Vector2
x as single
y as single
end type
To initialize these structs, Version 2 uses the type<TypeName>(...) syntax in its color macros, which is the idiomatic way in FreeBASIC to create a temporary object without needing an explicit constructor.
Good god, what's with you people and constructors? Here's the thing: FreeBasic will call a constructor, whether you like it or not, and whether you want it to or not. All you're doing here is making things more difficult and verbose to the end user. It doesn't matter if the header is 'faithful' to the original (although it does help with maintenance), only that the interface is the same.
c-sanchez wrote: Jun 08, 2025 1:58 [*]Handling of Boolean Types (Critical Point for Version 2)

This is the most important technical improvement.

Version 1: Uses FreeBASIC's native boolean type for functions that return true/false. FB's boolean is an integer that is 0 for false and -1 for true.

Code: Select all

' Version 1
declare function WindowShouldClose() as boolean
Version 2: Uses the bool type and includes "stdbool.bi". The bool type is designed to be compatible with C's _Bool, which is 0 for false and 1 for true.

Code: Select all

' Version 2
#include once "stdbool.bi"
...
declare function WindowShouldClose() as bool
Since Raylib is a C library, its boolean functions will return 0 or 1. Using bool (Version 2) is the correct and safe way to interface with the library. Using boolean (Version 1) could lead to subtle bugs, as the FB compiler expects a -1 for true, but the C function will give it a 1. Although FreeBASIC often handles this well in comparisons (If func() Then...), it is technically incorrect and less robust.
ty of Version 2 with the linking directives of Version 1.
Absolutely not. This is, in fact, a recipe for disaster. Try this in C:

Code: Select all

int main()
{
  int n = 1;

  printf("%d\n", !n);
  
  return 0;
}

Code: Select all

0
Now try the same thing in FreeBasic:

Code: Select all

dim as long n = 1

? not n

sleep()

Code: Select all

-2
Which FreeBasic will STILL interpret as true. So, any code than relies on a logic not in the original (ie while (!WindowShouldClose()) comes off wrong in FreeBasic, so anybody that wants to port the examples and isn't aware of the differences in compliment between C and FreeBasic will get tripped. You'll have to explicitly check against false in FreeBasic (do while (WindowShouldClose = 0)). Didn't the AI say that this looks dumb and 'less readable'?

Even more egregious: I would go so far as to overload operators (oh, the horror!) for types like Vector3 to make things easier on me. Look at this garbage:

Code: Select all

...
Quaternion characterRotate = QuaternionFromAxisAngle((Vector3){ 0.0f, 1.0f, 0.0f }, angle*DEG2RAD);
characterModel.transform = MatrixMultiply(QuaternionToMatrix(characterRotate), MatrixTranslate(position.x, position.y, position.z));
...

Code: Select all

// Add vector and float value
RMAPI Vector2 Vector2AddValue(Vector2 v, float add)
{
    Vector2 result = { v.x + add, v.y + add };

    return result;
}

// Subtract two vectors (v1 - v2)
RMAPI Vector2 Vector2Subtract(Vector2 v1, Vector2 v2)
{
    Vector2 result = { v1.x - v2.x, v1.y - v2.y };

    return result;
}

// Subtract vector by float value
RMAPI Vector2 Vector2SubtractValue(Vector2 v, float sub)
{
    Vector2 result = { v.x - sub, v.y - sub };

    return result;
}
Which can be easily replaced by operator overloads in FreeBasic to have sane and readablevector and matrix code. FreeBasic is not Java.

Idiosyncracies are inevitably going to creep up on codes, but I'd still recommend WIITD's header to raylib users (less prone to errors, way easier to use code). Point on the namings, though (I used RAY* on colors that conflicted with FreeBasic keywords as well in my headers).
paul doe
Posts: 1878
Joined: Jul 25, 2017 17:22
Location: Argentina
Contact:

Re: Creating Raylib Bindings for FreeBASIC (with AI)

Post by paul doe »

Code: Select all

#include once "stdbool.bi"

Code: Select all

FbTemp.bas(15) error 23: File not found, "stdbool.bi" in '#include once "stdbool.bi"'
My of course. Why am I not surprised? :roll:

This is why you always test garbage that an AI spits...
For a compatible fix:

Code: Select all

type as long bool
enum
  rl_false
  rl_true
end enum
DON'T use true and false directly, as they are FreeBasic intrinsics and redefining them is NOT a good idea. Also, using the FreeBasic intrinsics within the types is NOT recommended as well, as it screws up the size of the C structs you use to interface with raylib, and you WILL get incorrect results and/or crashes if you use them. You can ask your AI if you don't believe me but oh the horror, there are underscores in there :roll:
paul doe
Posts: 1878
Joined: Jul 25, 2017 17:22
Location: Argentina
Contact:

Re: Creating Raylib Bindings for FreeBASIC (with AI)

Post by paul doe »

Tested the bindings with the correction with an example that actually uses the struct in question, the 3D picking one from the 'core' examples:
Image

Ok, if we port the code as-is (minus some crap that isn't relevant), this is the result:

Code: Select all

#include once "raylib.bi"

const screenWidth as long = 800
const screenHeight as long = 450

InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking")

dim as Camera camera

with camera
  .position = type <Vector3>(10.0f, 10.0f, 10.0f)
  .target = type <Vector3>(0.0f, 0.0f, 0.0f)
  .up = type <Vector3>(0.0f, 1.0f, 0.0f)
  .fovy = 45.0f
  .projection = CAMERA_PERSPECTIVE
end with

dim as Vector3 cubePosition = (0.0f, 1.0f, 0.0f)
dim as Vector3 cubeSize = (2.0f, 2.0f, 2.0f)

dim as Ray ray
dim as RayCollision collision

SetTargetFPS(60)

do while (not WindowShouldClose())
  if (isCursorHidden()) then UpdateCamera(@camera, CAMERA_FIRST_PERSON)
  
  if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) then
    if (IsCursorHidden()) then
      EnableCursor()
    else
      DisableCursor()
    end if
  end if
  
  if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) then
    if (not collision.hit) then
      ray = GetScreenToWorldRay(GetMousePosition(), camera)
      
      collision = GetRayCollisionBox(ray, _
        type <BoundingBox>( _
          type <Vector3>(cubePosition.x - cubeSize.x / 2, cubePosition.y - cubeSize.y / 2, cubePosition.z - cubeSize.z / 2), _
          type <Vector3>(cubePosition.x + cubeSize.x / 2, cubePosition.y + cubeSize.y / 2, cubePosition.z + cubeSize.z / 2)))
    else
      collision.hit = rl_false
    end if
  end if
  
  BeginDrawing()
    ClearBackground(RAYWHITE)
    
    if (collision.hit) then
      DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, screenHeight * 0.1f, 30, GREEN)
    end if
    
    BeginMode3D(camera)
      if (collision.hit) then
        DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, RED)
        DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, MAROON)
        
        DrawCubeWires(cubePosition, cubeSize.x + 0.2f, cubeSize.y + 0.2f, cubeSize.z + 0.2f, GREEN)
      else
        DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, GRAY)
        DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, DARKGRAY)
      end if
      
      DrawRay(ray, MAROON)
      DrawGrid(10, 1.0f)
    EndMode3D()
  
    DrawText("Right click mouse to toggle camera controls", 10, 430, 10, GRAY)
  
  EndDrawing()
loop
I ported it exactly as it appears on the raylib site. But, if you run it, you'll notice that a few things are 'off', the most glaringly obvious is that you can't close the window in the FreeBasic code. It also behaves differently, as the original raylib code toggles the selection of the box when you click on it, whereas the FreeBasic one doesn't.

And this happens, naturally, because of the differences between how FreeBasic and C handle the not operator. To make the code work as expected in FreeBasic, if you use '1' to signify true, you have to explicitly check against the false value to get the desired results:

Code: Select all

#include once "raylib.bi"

const screenWidth as long = 800
const screenHeight as long = 450

InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking")

dim as Camera camera

with camera
  .position = type <Vector3>(10.0f, 10.0f, 10.0f)
  .target = type <Vector3>(0.0f, 0.0f, 0.0f)
  .up = type <Vector3>(0.0f, 1.0f, 0.0f)
  .fovy = 45.0f
  .projection = CAMERA_PERSPECTIVE
end with

dim as Vector3 cubePosition = (0.0f, 1.0f, 0.0f)
dim as Vector3 cubeSize = (2.0f, 2.0f, 2.0f)

dim as Ray ray
dim as RayCollision collision

SetTargetFPS(60)

do while (WindowShouldClose() = rl_false)
  if (isCursorHidden()) then UpdateCamera(@camera, CAMERA_FIRST_PERSON)
  
  if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) then
    if (IsCursorHidden()) then
      EnableCursor()
    else
      DisableCursor()
    end if
  end if
  
  if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) then
    if (collision.hit = rl_false) then
      ray = GetScreenToWorldRay(GetMousePosition(), camera)
      
      collision = GetRayCollisionBox(ray, _
        type <BoundingBox>( _
          type <Vector3>(cubePosition.x - cubeSize.x / 2, cubePosition.y - cubeSize.y / 2, cubePosition.z - cubeSize.z / 2), _
          type <Vector3>(cubePosition.x + cubeSize.x / 2, cubePosition.y + cubeSize.y / 2, cubePosition.z + cubeSize.z / 2)))
    else
      collision.hit = rl_false
    end if
  end if
  
  BeginDrawing()
    ClearBackground(RAYWHITE)
    
    if (collision.hit) then
      DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, screenHeight * 0.1f, 30, GREEN)
    end if
    
    BeginMode3D(camera)
      if (collision.hit) then
        DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, RED)
        DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, MAROON)
        
        DrawCubeWires(cubePosition, cubeSize.x + 0.2f, cubeSize.y + 0.2f, cubeSize.z + 0.2f, GREEN)
      else
        DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, GRAY)
        DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, DARKGRAY)
      end if
      
      DrawRay(ray, MAROON)
      DrawGrid(10, 1.0f)
    EndMode3D()
  
    DrawText("Right click mouse to toggle camera controls", 10, 430, 10, GRAY)
  
  EndDrawing()
loop
Now it works like the raylib example, and you can close the window as well.

Do note, however, that we can't simply use a FreeBasic's boolean in the RayCollision struct, as FreeBasic's booleans are 1 byte and the C code is expecting an int (long in FreeBasic).

Not trying to debase your analysis here, just trying to show that some 'improvements' aren't really improving anything.
Mysoft
Posts: 847
Joined: Jul 28, 2005 13:56
Location: Brazil, Santa Catarina, Indaial (ouch!)
Contact:

Re: Creating Raylib Bindings for FreeBASIC (with AI)

Post by Mysoft »

no oop garbage is required to use raylib in C... so no OOP garbage must be required to work with raylib in freebasic
anyone not understanding something as simple as that is simple an useless programmer... but we already know who are like that :) specially since he is also a coward.
Mysoft
Posts: 847
Joined: Jul 28, 2005 13:56
Location: Brazil, Santa Catarina, Indaial (ouch!)
Contact:

Re: Creating Raylib Bindings for FreeBASIC (with AI)

Post by Mysoft »

nice attempts csanches, but yeah you only tested with basic sample, so there's many mistakens in translation, that the AI will always keep doing wrong, that's why i keep doing semi-automated conversions myself... since the original translation is unusable because of the garbage.

also for the "not" stuff... yes... freebasic does not have a native "isnot" (WHY NOT???? EVEN AFTER 20 years since i asked that over and over)
but translating "!" to "not" is plain wrong... the closest is to have a macro like ...

Code: Select all

#define isnot 0=
but it isnt perfect regarding operator precendence, but that's how those should be translated and then used with crt "bool"
paul doe
Posts: 1878
Joined: Jul 25, 2017 17:22
Location: Argentina
Contact:

Re: Creating Raylib Bindings for FreeBASIC (with AI)

Post by paul doe »

So for a bit saner headers, you can use this one:

Code: Select all

''
'' raylib.bi - raylib v5.5 bindings for FreeBASIC
''
'' Generated based on raylib.h v5.5, following detailed conversion instructions.
'' Corrected based on compiler feedback from previous versions.
''
'' License: zlib/libpng
'' Copyright (c) 2013-2024 Ramon Santamaria (@raysan5)
''

#pragma once

#include once "crt/long.bi"
#include once "crt/stdarg.bi"

type as long bool
enum
  rl_false
  rl_true
end enum

#inclib "raylib"

extern "C"

'====================================================================================
' Boilerplate, Constantes y Macros
'====================================================================================

const RAYLIB_VERSION_MAJOR = 5
const RAYLIB_VERSION_MINOR = 5
const RAYLIB_VERSION_PATCH = 0
const RAYLIB_VERSION = "5.5"

const PI = 3.14159265358979323846
const DEG2RAD = (PI / 180.0)
const RAD2DEG = (180.0 / PI)

' Some Basic Colors
#define LIGHTGRAY  type<Color>( 200, 200, 200, 255 )   ' Light Gray
#define GRAY       type<Color>( 130, 130, 130, 255 )   ' Gray
#define DARKGRAY   type<Color>( 80, 80, 80, 255 )      ' Dark Gray
#define YELLOW     type<Color>( 253, 249, 0, 255 )     ' Yellow
#define GOLD       type<Color>( 255, 203, 0, 255 )     ' Gold
#define ORANGE     type<Color>( 255, 161, 0, 255 )     ' Orange
#define PINK       type<Color>( 255, 109, 194, 255 )   ' Pink
#define RED        type<Color>( 230, 41, 55, 255 )     ' Red
#define MAROON     type<Color>( 190, 33, 55, 255 )     ' Maroon
#define GREEN      type<Color>( 0, 228, 48, 255 )      ' Green
#define LIME       type<Color>( 0, 158, 47, 255 )      ' Lime
#define DARKGREEN  type<Color>( 0, 117, 44, 255 )      ' Dark Green
#define SKYBLUE    type<Color>( 102, 191, 255, 255 )   ' Sky Blue
#define BLUE       type<Color>( 0, 121, 241, 255 )     ' Blue
#define DARKBLUE   type<Color>( 0, 82, 172, 255 )      ' Dark Blue
#define PURPLE     type<Color>( 200, 122, 255, 255 )   ' Purple
#define VIOLET     type<Color>( 135, 60, 190, 255 )    ' Violet
#define DARKPURPLE type<Color>( 112, 31, 126, 255 )    ' Dark Purple
#define BEIGE      type<Color>( 211, 176, 131, 255 )   ' Beige
#define BROWN      type<Color>( 127, 106, 79, 255 )    ' Brown
#define DARKBROWN  type<Color>( 76, 63, 47, 255 )      ' Dark Brown

#define WHITE      type<Color>( 255, 255, 255, 255 )   ' White
#define BLACK      type<Color>( 0, 0, 0, 255 )         ' Black
#define BLANK      type<Color>( 0, 0, 0, 0 )           ' Blank (Transparent)
#define MAGENTA    type<Color>( 255, 0, 255, 255 )     ' Magenta
#define RAYWHITE   type<Color>( 245, 245, 245, 255 )   ' My own White (raylib logo)

'====================================================================================
' Definición de struct Base
'====================================================================================

type Vector2
    declare constructor()
    declare constructor(as single, as single)
    
    x as single
    y as single
end type

constructor Vector2() : end constructor

constructor Vector2(_x as single, _y as single)
  x = _x : y = _y
end constructor

type Vector3
    declare constructor()
    declare constructor(as single, as single, as single = 1.0f)
    
    x as single
    y as single
    z as single
end type

constructor Vector3() : end constructor

constructor Vector3(_x as single, _y as single, _z as single = 1.0f)
  x = _x : y = _y : z = _z
end constructor

type Vector4
    declare constructor()
    declare constructor(as single, as single, as single, as single = 1.0f)
    
    x as single
    y as single
    z as single
    w as single
end type

constructor Vector4(_x as single, _y as single, _z as single, _w as single = 1.0f)
  x = _x : y = _y : z = _z : w = _w
end constructor

type Matrix
    m0 as single
    m4 as single
    m8 as single
    m12 as single
    m1 as single
    m5 as single
    m9 as single
    m13 as single
    m2 as single
    m6 as single
    m10 as single
    m14 as single
    m3 as single
    m7 as single
    m11 as single
    m15 as single
end type

type Color
    r as ubyte
    g as ubyte
    b as ubyte
    a as ubyte
end type

type Rectangle
    x as single
    y as single
    width as single
    height as single
end type

'====================================================================================
' Definición de struct OPACOS
'====================================================================================

type rAudioBuffer as rAudioBuffer_
type rAudioProcessor as rAudioProcessor_

'====================================================================================
' Definición de Type Alias
'====================================================================================

type Quaternion as Vector4
type Texture2D as Texture
type TextureCubemap as Texture
type RenderTexture2D as RenderTexture
type Camera as Camera3D

'====================================================================================
' Definición de struct Compuestos
'====================================================================================

type Image
    data as any ptr
    width as long
    height as long
    mipmaps as long
    format as long
end type

type Texture
    id as ulong
    width as long
    height as long
    mipmaps as long
    format as long
end type

type RenderTexture
    id as ulong
    texture as Texture
    depth as Texture
end type

type NPatchInfo
    source as Rectangle
    left as long
    top as long
    right as long
    bottom as long
    layout as long
end type

type GlyphInfo
    value as long
    offsetX as long
    offsetY as long
    advanceX as long
    image as Image
end type

type Font
    baseSize as long
    glyphCount as long
    glyphPadding as long
    texture as Texture2D
    recs as Rectangle ptr
    glyphs as GlyphInfo ptr
end type

type Camera3D
    declare constructor()
    declare constructor(as Vector3, as Vector3, as Vector3, as single, as long)
    
    position as Vector3
    target as Vector3
    up as Vector3
    fovy as single
    projection as long
end type

constructor Camera3D() : end constructor

constructor Camera3D(_pos as Vector3, _target as Vector3, _up as Vector3, _fovy as single, _projection as long)
  position = _pos
  target = _target
  up = _up
  fovy = _fovy
  projection = _projection
end constructor

type Camera2D
    offset as Vector2
    target as Vector2
    rotation as single
    zoom as single
end type

type Mesh
    vertexCount as long
    triangleCount as long
    vertices as single ptr
    texcoords as single ptr
    texcoords2 as single ptr
    normals as single ptr
    tangents as single ptr
    colors as ubyte ptr
    indices as ushort ptr
    animVertices as single ptr
    animNormals as single ptr
    boneIds as ubyte ptr
    boneWeights as single ptr
    boneMatrices as Matrix ptr
    boneCount as long
    vaoId as ulong
    vboId as ulong ptr
end type

type Shader
    id as ulong
    locs as long ptr
end type

type MaterialMap
    texture as Texture2D
    color as Color
    value as single
end type

type Material
    shader as Shader
    maps as MaterialMap ptr
    params(0 to 3) as single
end type

type Transform
    translation as Vector3
    rotation as Quaternion
    scale as Vector3
end type

type BoneInfo
    name as zstring * 32
    parent as long
end type

type Model
    transform as Matrix
    meshCount as long
    materialCount as long
    meshes as Mesh ptr
    materials as Material ptr
    meshMaterial as long ptr
    boneCount as long
    bones as BoneInfo ptr
    bindPose as Transform ptr
end type

type ModelAnimation
    boneCount as long
    frameCount as long
    bones as BoneInfo ptr
    framePoses as Transform ptr ptr
    name as zstring * 32
end type

type Ray
    position as Vector3
    direction as Vector3
end type

type RayCollision
    hit as bool
    distance as single
    point as Vector3
    normal as Vector3
end type

type BoundingBox
    declare constructor()
    declare constructor(as Vector3, as Vector3)
    
    min as Vector3
    max as Vector3
end type

constructor BoundingBox() : end constructor

constructor BoundingBox(_min as Vector3, _max as Vector3)
  min = _min : max = _max
end constructor

type Wave
    frameCount as ulong
    sampleRate as ulong
    sampleSize as ulong
    channels as ulong
    data as any ptr
end type

type AudioStream
    buffer as rAudioBuffer ptr
    processor as rAudioProcessor ptr
    sampleRate as ulong
    sampleSize as ulong
    channels as ulong
end type

type Sound
    stream as AudioStream
    frameCount as ulong
end type

type Music
    stream as AudioStream
    frameCount as ulong
    looping as bool
    ctxType as long
    ctxData as any ptr
end type

type VrDeviceInfo
    hResolution as long
    vResolution as long
    hScreenSize as single
    vScreenSize as single
    eyeToScreenDistance as single
    lensSeparationDistance as single
    interpupillaryDistance as single
    lensDistortionValues(0 to 3) as single
    chromaAbCorrection(0 to 3) as single
end type

type VrStereoConfig
    projection(0 to 1) as Matrix
    viewOffset(0 to 1) as Matrix
    leftLensCenter(0 to 1) as single
    rightLensCenter(0 to 1) as single
    leftScreenCenter(0 to 1) as single
    rightScreenCenter(0 to 1) as single
    scale(0 to 1) as single
    scaleIn(0 to 1) as single
end type

type FilePathList
    capacity as ulong
    count as ulong
    paths as zstring ptr ptr
end type

type AutomationEvent
    frame as ulong
    type as ulong
    params(0 to 3) as long
end type

type AutomationEventList
    capacity as ulong
    count as ulong
    events as AutomationEvent ptr
end type

'====================================================================================
' Definición de enum
'====================================================================================

type ConfigFlags as long
enum
    FLAG_VSYNC_HINT         = &h00000040
    FLAG_FULLSCREEN_MODE    = &h00000002
    FLAG_WINDOW_RESIZABLE   = &h00000004
    FLAG_WINDOW_UNDECORATED = &h00000008
    FLAG_WINDOW_HIDDEN      = &h00000080
    FLAG_WINDOW_MINIMIZED   = &h00000200
    FLAG_WINDOW_MAXIMIZED   = &h00000400
    FLAG_WINDOW_UNFOCUSED   = &h00000800
    FLAG_WINDOW_TOPMOST     = &h00001000
    FLAG_WINDOW_ALWAYS_RUN  = &h00000100
    FLAG_WINDOW_TRANSPARENT = &h00000010
    FLAG_WINDOW_HIGHDPI     = &h00002000
    FLAG_WINDOW_MOUSE_PASSTHROUGH = &h00004000
    FLAG_BORDERLESS_WINDOWED_MODE = &h00008000
    FLAG_MSAA_4X_HINT       = &h00000020
    FLAG_INTERLACED_HINT    = &h00010000
end enum

type TraceLogLevel as long
enum
    LOG_ALL = 0
    LOG_TRACE
    LOG_DEBUG
    LOG_INFO
    LOG_WARNING
    LOG_ERROR
    LOG_FATAL
    LOG_NONE
end enum

type KeyboardKey as long
enum
    KEY_NULL            = 0
    KEY_APOSTROPHE      = 39
    KEY_COMMA           = 44
    KEY_MINUS           = 45
    KEY_PERIOD          = 46
    KEY_SLASH           = 47
    KEY_ZERO            = 48
    KEY_ONE             = 49
    KEY_TWO             = 50
    KEY_THREE           = 51
    KEY_FOUR            = 52
    KEY_FIVE            = 53
    KEY_SIX             = 54
    KEY_SEVEN           = 55
    KEY_EIGHT           = 56
    KEY_NINE            = 57
    KEY_SEMICOLON       = 59
    KEY_EQUAL           = 61
    KEY_A               = 65
    KEY_B               = 66
    KEY_C               = 67
    KEY_D               = 68
    KEY_E               = 69
    KEY_F               = 70
    KEY_G               = 71
    KEY_H               = 72
    KEY_I               = 73
    KEY_J               = 74
    KEY_K               = 75
    KEY_L               = 76
    KEY_M               = 77
    KEY_N               = 78
    KEY_O               = 79
    KEY_P               = 80
    KEY_Q               = 81
    KEY_R               = 82
    KEY_S               = 83
    KEY_T               = 84
    KEY_U               = 85
    KEY_V               = 86
    KEY_W               = 87
    KEY_X               = 88
    KEY_Y               = 89
    KEY_Z               = 90
    KEY_LEFT_BRACKET    = 91
    KEY_BACKSLASH       = 92
    KEY_RIGHT_BRACKET   = 93
    KEY_GRAVE           = 96
    KEY_SPACE           = 32
    KEY_ESCAPE          = 256
    KEY_ENTER           = 257
    KEY_TAB             = 258
    KEY_BACKSPACE       = 259
    KEY_INSERT          = 260
    KEY_DELETE          = 261
    KEY_RIGHT           = 262
    KEY_LEFT            = 263
    KEY_DOWN            = 264
    KEY_UP              = 265
    KEY_PAGE_UP         = 266
    KEY_PAGE_DOWN       = 267
    KEY_HOME            = 268
    KEY_END             = 269
    KEY_CAPS_LOCK       = 280
    KEY_SCROLL_LOCK     = 281
    KEY_NUM_LOCK        = 282
    KEY_PRINT_SCREEN    = 283
    KEY_PAUSE           = 284
    KEY_F1              = 290
    KEY_F2              = 291
    KEY_F3              = 292
    KEY_F4              = 293
    KEY_F5              = 294
    KEY_F6              = 295
    KEY_F7              = 296
    KEY_F8              = 297
    KEY_F9              = 298
    KEY_F10             = 299
    KEY_F11             = 300
    KEY_F12             = 301
    KEY_LEFT_SHIFT      = 340
    KEY_LEFT_CONTROL    = 341
    KEY_LEFT_ALT        = 342
    KEY_LEFT_SUPER      = 343
    KEY_RIGHT_SHIFT     = 344
    KEY_RIGHT_CONTROL   = 345
    KEY_RIGHT_ALT       = 346
    KEY_RIGHT_SUPER     = 347
    KEY_KB_MENU         = 348
    KEY_KP_0            = 320
    KEY_KP_1            = 321
    KEY_KP_2            = 322
    KEY_KP_3            = 323
    KEY_KP_4            = 324
    KEY_KP_5            = 325
    KEY_KP_6            = 326
    KEY_KP_7            = 327
    KEY_KP_8            = 328
    KEY_KP_9            = 329
    KEY_KP_DECIMAL      = 330
    KEY_KP_DIVIDE       = 331
    KEY_KP_MULTIPLY     = 332
    KEY_KP_SUBTRACT     = 333
    KEY_KP_ADD          = 334
    KEY_KP_ENTER        = 335
    KEY_KP_EQUAL        = 336
    KEY_BACK            = 4
    KEY_MENU            = 5
    KEY_VOLUME_UP       = 24
    KEY_VOLUME_DOWN     = 25
end enum

type MouseButton as long
enum
    MOUSE_BUTTON_LEFT    = 0
    MOUSE_BUTTON_RIGHT   = 1
    MOUSE_BUTTON_MIDDLE  = 2
    MOUSE_BUTTON_SIDE    = 3
    MOUSE_BUTTON_EXTRA   = 4
    MOUSE_BUTTON_FORWARD = 5
    MOUSE_BUTTON_BACK    = 6
end enum

type MouseCursor as long
enum
    MOUSE_CURSOR_DEFAULT       = 0
    MOUSE_CURSOR_ARROW         = 1
    MOUSE_CURSOR_IBEAM         = 2
    MOUSE_CURSOR_CROSSHAIR     = 3
    MOUSE_CURSOR_POINTING_HAND = 4
    MOUSE_CURSOR_RESIZE_EW     = 5
    MOUSE_CURSOR_RESIZE_NS     = 6
    MOUSE_CURSOR_RESIZE_NWSE   = 7
    MOUSE_CURSOR_RESIZE_NESW   = 8
    MOUSE_CURSOR_RESIZE_ALL    = 9
    MOUSE_CURSOR_NOT_ALLOWED   = 10
end enum

type GamepadButton as long
enum
    GAMEPAD_BUTTON_UNKNOWN = 0
    GAMEPAD_BUTTON_LEFT_FACE_UP
    GAMEPAD_BUTTON_LEFT_FACE_RIGHT
    GAMEPAD_BUTTON_LEFT_FACE_DOWN
    GAMEPAD_BUTTON_LEFT_FACE_LEFT
    GAMEPAD_BUTTON_RIGHT_FACE_UP
    GAMEPAD_BUTTON_RIGHT_FACE_RIGHT
    GAMEPAD_BUTTON_RIGHT_FACE_DOWN
    GAMEPAD_BUTTON_RIGHT_FACE_LEFT
    GAMEPAD_BUTTON_LEFT_TRIGGER_1
    GAMEPAD_BUTTON_LEFT_TRIGGER_2
    GAMEPAD_BUTTON_RIGHT_TRIGGER_1
    GAMEPAD_BUTTON_RIGHT_TRIGGER_2
    GAMEPAD_BUTTON_MIDDLE_LEFT
    GAMEPAD_BUTTON_MIDDLE
    GAMEPAD_BUTTON_MIDDLE_RIGHT
    GAMEPAD_BUTTON_LEFT_THUMB
    GAMEPAD_BUTTON_RIGHT_THUMB
end enum

type GamepadAxis as long
enum
    GAMEPAD_AXIS_LEFT_X        = 0
    GAMEPAD_AXIS_LEFT_Y        = 1
    GAMEPAD_AXIS_RIGHT_X       = 2
    GAMEPAD_AXIS_RIGHT_Y       = 3
    GAMEPAD_AXIS_LEFT_TRIGGER  = 4
    GAMEPAD_AXIS_RIGHT_TRIGGER = 5
end enum

type MaterialMapIndex as long
enum
    MATERIAL_MAP_ALBEDO = 0
    MATERIAL_MAP_METALNESS
    MATERIAL_MAP_NORMAL
    MATERIAL_MAP_ROUGHNESS
    MATERIAL_MAP_OCCLUSION
    MATERIAL_MAP_EMISSION
    MATERIAL_MAP_HEIGHT
    MATERIAL_MAP_CUBEMAP
    MATERIAL_MAP_IRRADIANCE
    MATERIAL_MAP_PREFILTER
    MATERIAL_MAP_BRDF
end enum

type ShaderLocationIndex as long
enum
    SHADER_LOC_VERTEX_POSITION = 0
    SHADER_LOC_VERTEX_TEXCOORD01
    SHADER_LOC_VERTEX_TEXCOORD02
    SHADER_LOC_VERTEX_NORMAL
    SHADER_LOC_VERTEX_TANGENT
    SHADER_LOC_VERTEX_COLOR
    SHADER_LOC_MATRIX_MVP
    SHADER_LOC_MATRIX_VIEW
    SHADER_LOC_MATRIX_PROJECTION
    SHADER_LOC_MATRIX_MODEL
    SHADER_LOC_MATRIX_NORMAL
    SHADER_LOC_VECTOR_VIEW
    SHADER_LOC_COLOR_DIFFUSE
    SHADER_LOC_COLOR_SPECULAR
    SHADER_LOC_COLOR_AMBIENT
    SHADER_LOC_MAP_ALBEDO
    SHADER_LOC_MAP_METALNESS
    SHADER_LOC_MAP_NORMAL
    SHADER_LOC_MAP_ROUGHNESS
    SHADER_LOC_MAP_OCCLUSION
    SHADER_LOC_MAP_EMISSION
    SHADER_LOC_MAP_HEIGHT
    SHADER_LOC_MAP_CUBEMAP
    SHADER_LOC_MAP_IRRADIANCE
    SHADER_LOC_MAP_PREFILTER
    SHADER_LOC_MAP_BRDF
    SHADER_LOC_VERTEX_BONEIDS
    SHADER_LOC_VERTEX_BONEWEIGHTS
    SHADER_LOC_BONE_MATRICES
end enum

type ShaderUniformDataType as long
enum
    SHADER_UNIFORM_FLOAT = 0
    SHADER_UNIFORM_VEC2
    SHADER_UNIFORM_VEC3
    SHADER_UNIFORM_VEC4
    SHADER_UNIFORM_INT
    SHADER_UNIFORM_IVEC2
    SHADER_UNIFORM_IVEC3
    SHADER_UNIFORM_IVEC4
    SHADER_UNIFORM_SAMPLER2D
end enum

type ShaderAttributeDataType as long
enum
    SHADER_ATTRIB_FLOAT = 0
    SHADER_ATTRIB_VEC2
    SHADER_ATTRIB_VEC3
    SHADER_ATTRIB_VEC4
end enum

type PixelFormat as long
enum
    PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1
    PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA
    PIXELFORMAT_UNCOMPRESSED_R5G6B5
    PIXELFORMAT_UNCOMPRESSED_R8G8B8
    PIXELFORMAT_UNCOMPRESSED_R5G5B5A1
    PIXELFORMAT_UNCOMPRESSED_R4G4B4A4
    PIXELFORMAT_UNCOMPRESSED_R8G8B8A8
    PIXELFORMAT_UNCOMPRESSED_R32
    PIXELFORMAT_UNCOMPRESSED_R32G32B32
    PIXELFORMAT_UNCOMPRESSED_R32G32B32A32
    PIXELFORMAT_UNCOMPRESSED_R16
    PIXELFORMAT_UNCOMPRESSED_R16G16B16
    PIXELFORMAT_UNCOMPRESSED_R16G16B16A16
    PIXELFORMAT_COMPRESSED_DXT1_RGB
    PIXELFORMAT_COMPRESSED_DXT1_RGBA
    PIXELFORMAT_COMPRESSED_DXT3_RGBA
    PIXELFORMAT_COMPRESSED_DXT5_RGBA
    PIXELFORMAT_COMPRESSED_ETC1_RGB
    PIXELFORMAT_COMPRESSED_ETC2_RGB
    PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA
    PIXELFORMAT_COMPRESSED_PVRT_RGB
    PIXELFORMAT_COMPRESSED_PVRT_RGBA
    PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA
    PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA
end enum

type TextureFilter as long
enum
    TEXTURE_FILTER_POINT = 0
    TEXTURE_FILTER_BILINEAR
    TEXTURE_FILTER_TRILINEAR
    TEXTURE_FILTER_ANISOTROPIC_4X
    TEXTURE_FILTER_ANISOTROPIC_8X
    TEXTURE_FILTER_ANISOTROPIC_16X
end enum

type TextureWrap as long
enum
    TEXTURE_WRAP_REPEAT = 0
    TEXTURE_WRAP_CLAMP
    TEXTURE_WRAP_MIRROR_REPEAT
    TEXTURE_WRAP_MIRROR_CLAMP
end enum

type CubemapLayout as long
enum
    CUBEMAP_LAYOUT_AUTO_DETECT = 0
    CUBEMAP_LAYOUT_LINE_VERTICAL
    CUBEMAP_LAYOUT_LINE_HORIZONTAL
    CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR
    CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE
end enum

type FontType as long
enum
    FONT_DEFAULT = 0
    FONT_BITMAP
    FONT_SDF
end enum

type BlendMode as long
enum
    BLEND_ALPHA = 0
    BLEND_ADDITIVE
    BLEND_MULTIPLIED
    BLEND_ADD_COLORS
    BLEND_SUBTRACT_COLORS
    BLEND_ALPHA_PREMULTIPLY
    BLEND_CUSTOM
    BLEND_CUSTOM_SEPARATE
end enum

type Gesture as long
enum
    GESTURE_NONE        = 0
    GESTURE_TAP         = 1
    GESTURE_DOUBLETAP   = 2
    GESTURE_HOLD        = 4
    GESTURE_DRAG        = 8
    GESTURE_SWIPE_RIGHT = 16
    GESTURE_SWIPE_LEFT  = 32
    GESTURE_SWIPE_UP    = 64
    GESTURE_SWIPE_DOWN  = 128
    GESTURE_PINCH_IN    = 256
    GESTURE_PINCH_OUT   = 512
end enum

type CameraMode as long
enum
    CAMERA_CUSTOM = 0
    CAMERA_FREE
    CAMERA_ORBITAL
    CAMERA_FIRST_PERSON
    CAMERA_THIRD_PERSON
end enum

type CameraProjection as long
enum
    CAMERA_PERSPECTIVE = 0
    CAMERA_ORTHOGRAPHIC
end enum

type NPatchLayout as long
enum
    NPATCH_NINE_PATCH = 0
    NPATCH_THREE_PATCH_VERTICAL
    NPATCH_THREE_PATCH_HORIZONTAL
end enum

'====================================================================================
' Definición de const de Alias
'====================================================================================

#define GetMouseRay GetScreenToWorldRay

const MOUSE_LEFT_BUTTON   = MOUSE_BUTTON_LEFT
const MOUSE_RIGHT_BUTTON  = MOUSE_BUTTON_RIGHT
const MOUSE_MIDDLE_BUTTON = MOUSE_BUTTON_MIDDLE

const MATERIAL_MAP_DIFFUSE      = MATERIAL_MAP_ALBEDO
const MATERIAL_MAP_SPECULAR     = MATERIAL_MAP_METALNESS

const SHADER_LOC_MAP_DIFFUSE      = SHADER_LOC_MAP_ALBEDO
const SHADER_LOC_MAP_SPECULAR     = SHADER_LOC_MAP_METALNESS

'====================================================================================
' Definición de type de Callbacks
'====================================================================================
paul doe
Posts: 1878
Joined: Jul 25, 2017 17:22
Location: Argentina
Contact:

Re: Creating Raylib Bindings for FreeBASIC (with AI)

Post by paul doe »

Code: Select all


type TraceLogCallback as sub cdecl(byval logLevel as long, byval text as const zstring ptr, byval args as va_list)
type LoadFileDataCallback as function(byval fileName as const zstring ptr, byval dataSize as long ptr) as ubyte ptr
type SaveFileDataCallback as function(byval fileName as const zstring ptr, byval data as any ptr, byval dataSize as long) as bool
type LoadFileTextCallback as function(byval fileName as const zstring ptr) as zstring ptr
type SaveFileTextCallback as function(byval fileName as const zstring ptr, byval text as zstring ptr) as bool
type AudioCallback as sub(byval bufferData as any ptr, byval frames as ulong)

'====================================================================================
' Declaración de Funciones
'====================================================================================

' Window and Graphics Device Functions
declare sub InitWindow(byval width as long, byval height as long, byval title as const zstring ptr)
declare sub CloseWindow()
declare function WindowShouldClose() as boolean
declare function IsWindowReady() as bool
declare function IsWindowFullscreen() as bool
declare function IsWindowHidden() as bool
declare function IsWindowMinimized() as bool
declare function IsWindowMaximized() as bool
declare function IsWindowFocused() as bool
declare function IsWindowResized() as bool
declare function IsWindowState(byval flag as ulong) as bool
declare sub SetWindowState(byval flags as ulong)
declare sub ClearWindowState(byval flags as ulong)
declare sub ToggleFullscreen()
declare sub ToggleBorderlessWindowed()
declare sub MaximizeWindow()
declare sub MinimizeWindow()
declare sub RestoreWindow()
declare sub SetWindowIcon(byval image as Image)
declare sub SetWindowIcons(byval images as Image ptr, byval count as long)
declare sub SetWindowTitle(byval title as const zstring ptr)
declare sub SetWindowPosition(byval x as long, byval y as long)
declare sub SetWindowMonitor(byval monitor as long)
declare sub SetWindowMinSize(byval width as long, byval height as long)
declare sub SetWindowMaxSize(byval width as long, byval height as long)
declare sub SetWindowSize(byval width as long, byval height as long)
declare sub SetWindowOpacity(byval opacity as single)
declare sub SetWindowFocused()
declare function GetWindowHandle() as any ptr
declare function GetScreenWidth() as long
declare function GetScreenHeight() as long
declare function GetRenderWidth() as long
declare function GetRenderHeight() as long
declare function GetMonitorCount() as long
declare function GetCurrentMonitor() as long
declare function GetMonitorPosition(byval monitor as long) as Vector2
declare function GetMonitorWidth(byval monitor as long) as long
declare function GetMonitorHeight(byval monitor as long) as long
declare function GetMonitorPhysicalWidth(byval monitor as long) as long
declare function GetMonitorPhysicalHeight(byval monitor as long) as long
declare function GetMonitorRefreshRate(byval monitor as long) as long
declare function GetWindowPosition() as Vector2
declare function GetWindowScaleDPI() as Vector2
declare function GetMonitorName(byval monitor as long) as const zstring ptr
declare sub SetClipboardText(byval text as const zstring ptr)
declare function GetClipboardText() as const zstring ptr
declare function GetClipboardImage() as Image
declare sub EnableEventWaiting()
declare sub DisableEventWaiting()

' Cursor-related functions
declare sub ShowCursor()
declare sub HideCursor()
declare function IsCursorHidden() as bool
declare sub EnableCursor()
declare sub DisableCursor()
declare function IsCursorOnScreen() as bool

' Drawing-related functions
declare sub ClearBackground(byval color as Color)
declare sub BeginDrawing()
declare sub EndDrawing()
declare sub BeginMode2D(byval camera as Camera2D)
declare sub EndMode2D()
declare sub BeginMode3D(byval camera as Camera3D)
declare sub EndMode3D()
declare sub BeginTextureMode(byval target as RenderTexture2D)
declare sub EndTextureMode()
declare sub BeginShaderMode(byval shader as Shader)
declare sub EndShaderMode()
declare sub BeginBlendMode(byval mode as long)
declare sub EndBlendMode()
declare sub BeginScissorMode(byval x as long, byval y as long, byval width as long, byval height as long)
declare sub EndScissorMode()
declare sub BeginVrStereoMode(byref config as VrStereoConfig)
declare sub EndVrStereoMode()

' VR stereo config functions
declare function LoadVrStereoConfig(byval device as VrDeviceInfo) as VrStereoConfig
declare sub UnloadVrStereoConfig(byref config as VrStereoConfig)

' Shader management functions
declare function LoadShader(byval vsFileName as const zstring ptr, byval fsFileName as const zstring ptr) as Shader
declare function LoadShaderFromMemory(byval vsCode as const zstring ptr, byval fsCode as const zstring ptr) as Shader
declare function IsShaderValid(byval shader as Shader) as bool
declare function GetShaderLocation(byval shader as Shader, byval uniformName as const zstring ptr) as long
declare function GetShaderLocationAttrib(byval shader as Shader, byval attribName as const zstring ptr) as long
declare sub SetShaderValue(byval shader as Shader, byval locIndex as long, byval value as any ptr, byval uniformType as long)
declare sub SetShaderValueV(byval shader as Shader, byval locIndex as long, byval value as any ptr, byval uniformType as long, byval count as long)
declare sub SetShaderValueMatrix(byval shader as Shader, byval locIndex as long, byval mat as Matrix)
declare sub SetShaderValueTexture(byval shader as Shader, byval locIndex as long, byval texture as Texture2D)
declare sub UnloadShader(byval shader as Shader)

' Screen-space-related functions
declare function GetScreenToWorldRay(byval position as Vector2, byval camera as Camera) as Ray
declare function GetScreenToWorldRayEx(byval position as Vector2, byval camera as Camera, byval width as long, byval height as long) as Ray
declare function GetWorldToScreen(byval position as Vector3, byval camera as Camera) as Vector2
declare function GetWorldToScreenEx(byval position as Vector3, byval camera as Camera, byval width as long, byval height as long) as Vector2
declare function GetWorldToScreen2D(byval position as Vector2, byval camera as Camera2D) as Vector2
declare function GetScreenToWorld2D(byval position as Vector2, byval camera as Camera2D) as Vector2
declare function GetCameraMatrix(byval camera as Camera) as Matrix
declare function GetCameraMatrix2D(byval camera as Camera2D) as Matrix

' Timing-related functions
declare sub SetTargetFPS(byval fps as long)
declare function GetFrameTime() as single
declare function GetTime() as double
declare function GetFPS() as long

' Custom frame control functions
declare sub SwapScreenBuffer()
declare sub PollInputEvents()
declare sub WaitTime(byval seconds as double)

' Random values generation functions
declare sub SetRandomSeed(byval seed as ulong)
declare function GetRandomValue(byval min as long, byval max as long) as long
declare function LoadRandomSequence(byval count as ulong, byval min as long, byval max as long) as long ptr
declare sub UnloadRandomSequence(byval sequence as long ptr)

' Misc. functions
declare sub TakeScreenshot(byval fileName as const zstring ptr)
declare sub SetConfigFlags(byval flags as ulong)
declare sub OpenURL(byval url as const zstring ptr)

' Utils functions
declare sub TraceLog cdecl(byval logLevel as long, byval text as const zstring ptr, ...)
declare sub SetTraceLogLevel(byval logLevel as long)
declare function MemAlloc(byval size as ulong) as any ptr
declare function MemRealloc(byval ptr as any ptr, byval size as ulong) as any ptr
declare sub MemFree(byval ptr as any ptr)

' Set custom callbacks
declare sub SetTraceLogCallback(byval callback as TraceLogCallback)
declare sub SetLoadFileDataCallback(byval callback as LoadFileDataCallback)
declare sub SetSaveFileDataCallback(byval callback as SaveFileDataCallback)
declare sub SetLoadFileTextCallback(byval callback as LoadFileTextCallback)
declare sub SetSaveFileTextCallback(byval callback as SaveFileTextCallback)

' Files management functions
declare function LoadFileData(byval fileName as const zstring ptr, byval dataSize as long ptr) as ubyte ptr
declare sub UnloadFileData(byval data as ubyte ptr)
declare function SaveFileData(byval fileName as const zstring ptr, byval data as any ptr, byval dataSize as long) as bool
declare function ExportDataAsCode(byval data as const ubyte ptr, byval dataSize as long, byval fileName as const zstring ptr) as bool
declare function LoadFileText(byval fileName as const zstring ptr) as zstring ptr
declare sub UnloadFileText(byval text as zstring ptr)
declare function SaveFileText(byval fileName as const zstring ptr, byval text as zstring ptr) as bool

' File system functions
declare function FileExists(byval fileName as const zstring ptr) as bool
declare function DirectoryExists(byval dirPath as const zstring ptr) as bool
declare function IsFileExtension(byval fileName as const zstring ptr, byval ext as const zstring ptr) as bool
declare function GetFileLength(byval fileName as const zstring ptr) as long
declare function GetFileExtension(byval fileName as const zstring ptr) as const zstring ptr
declare function GetFileName(byval filePath as const zstring ptr) as const zstring ptr
declare function GetFileNameWithoutExt(byval filePath as const zstring ptr) as const zstring ptr
declare function GetDirectoryPath(byval filePath as const zstring ptr) as const zstring ptr
declare function GetPrevDirectoryPath(byval dirPath as const zstring ptr) as const zstring ptr
declare function GetWorkingDirectory() as const zstring ptr
declare function GetApplicationDirectory() as const zstring ptr
declare function MakeDirectory(byval dirPath as const zstring ptr) as long
declare function ChangeDirectory(byval dir as const zstring ptr) as bool
declare function IsPathFile(byval path as const zstring ptr) as bool
declare function IsFileNameValid(byval fileName as const zstring ptr) as bool
declare function LoadDirectoryFiles(byval dirPath as const zstring ptr) as FilePathList
declare function LoadDirectoryFilesEx(byval basePath as const zstring ptr, byval filter as const zstring ptr, byval scanSubdirs as bool) as FilePathList
declare sub UnloadDirectoryFiles(byval files as FilePathList)
declare function IsFileDropped() as bool
declare function LoadDroppedFiles() as FilePathList
declare sub UnloadDroppedFiles(byval files as FilePathList)
declare function GetFileModTime(byval fileName as const zstring ptr) as long

' Compression/Encoding functionality
declare function CompressData(byval data as const ubyte ptr, byval dataSize as long, byval compDataSize as long ptr) as ubyte ptr
declare function DecompressData(byval compData as const ubyte ptr, byval compDataSize as long, byval dataSize as long ptr) as ubyte ptr
declare function EncodeDataBase64(byval data as const ubyte ptr, byval dataSize as long, byval outputSize as long ptr) as zstring ptr
declare function DecodeDataBase64(byval data as const ubyte ptr, byval outputSize as long ptr) as ubyte ptr
declare function ComputeCRC32(byval data as ubyte ptr, byval dataSize as long) as ulong
declare function ComputeMD5(byval data as ubyte ptr, byval dataSize as long) as ulong ptr
declare function ComputeSHA1(byval data as ubyte ptr, byval dataSize as long) as ulong ptr

' Automation events functionality
declare function LoadAutomationEventList(byval fileName as const zstring ptr) as AutomationEventList
declare sub UnloadAutomationEventList(byval list as AutomationEventList)
declare function ExportAutomationEventList(byval list as AutomationEventList, byval fileName as const zstring ptr) as bool
declare sub SetAutomationEventList(byval list as AutomationEventList ptr)
declare sub SetAutomationEventBaseFrame(byval frame as long)
declare sub StartAutomationEventRecording()
declare sub StopAutomationEventRecording()
declare sub PlayAutomationEvent(byval event as AutomationEvent)

' Input Handling Functions: keyboard
declare function IsKeyPressed(byval key as long) as bool
declare function IsKeyPressedRepeat(byval key as long) as bool
declare function IsKeyDown(byval key as long) as bool
declare function IsKeyReleased(byval key as long) as bool
declare function IsKeyUp(byval key as long) as bool
declare function GetKeyPressed() as long
declare function GetCharPressed() as long
declare sub SetExitKey(byval key as long)

' Input Handling Functions: gamepads
declare function IsGamepadAvailable(byval gamepad as long) as bool
declare function GetGamepadName(byval gamepad as long) as const zstring ptr
declare function IsGamepadButtonPressed(byval gamepad as long, byval button as long) as bool
declare function IsGamepadButtonDown(byval gamepad as long, byval button as long) as bool
declare function IsGamepadButtonReleased(byval gamepad as long, byval button as long) as bool
declare function IsGamepadButtonUp(byval gamepad as long, byval button as long) as bool
declare function GetGamepadButtonPressed() as long
declare function GetGamepadAxisCount(byval gamepad as long) as long
declare function GetGamepadAxisMovement(byval gamepad as long, byval axis as long) as single
declare function SetGamepadMappings(byval mappings as const zstring ptr) as long
declare sub SetGamepadVibration(byval gamepad as long, byval leftMotor as single, byval rightMotor as single, byval duration as single)

' Input Handling Functions: mouse
declare function IsMouseButtonPressed(byval button as long) as bool
declare function IsMouseButtonDown(byval button as long) as bool
declare function IsMouseButtonReleased(byval button as long) as bool
declare function IsMouseButtonUp(byval button as long) as bool
declare function GetMouseX() as long
declare function GetMouseY() as long
declare function GetMousePosition() as Vector2
declare function GetMouseDelta() as Vector2
declare sub SetMousePosition(byval x as long, byval y as long)
declare sub SetMouseOffset(byval offsetX as long, byval offsetY as long)
declare sub SetMouseScale(byval scaleX as single, byval scaleY as single)
declare function GetMouseWheelMove() as single
declare function GetMouseWheelMoveV() as Vector2
declare sub SetMouseCursor(byval cursor as long)

' Input Handling Functions: touch
declare function GetTouchX() as long
declare function GetTouchY() as long
declare function GetTouchPosition(byval index as long) as Vector2
declare function GetTouchPointId(byval index as long) as long
declare function GetTouchPointCount() as long

' Gestures and Touch Handling Functions
declare sub SetGesturesEnabled(byval flags as ulong)
declare function IsGestureDetected(byval gesture as ulong) as bool
declare function GetGestureDetected() as long
declare function GetGestureHoldDuration() as single
declare function GetGestureDragVector() as Vector2
declare function GetGestureDragAngle() as single
declare function GetGesturePinchVector() as Vector2
declare function GetGesturePinchAngle() as single

' Camera System Functions
declare sub UpdateCamera(byval camera as Camera ptr, byval mode as long)
declare sub UpdateCameraPro(byval camera as Camera ptr, byval movement as Vector3, byval rotation as Vector3, byval zoom as single)

' Basic Shapes Drawing Functions
declare sub SetShapesTexture(byval texture as Texture2D, byval source as Rectangle)
declare function GetShapesTexture() as Texture2D
declare function GetShapesTextureRectangle() as Rectangle
declare sub DrawPixel(byval posX as long, byval posY as long, byval color as Color)
declare sub DrawPixelV(byval position as Vector2, byval color as Color)
declare sub DrawLine(byval startPosX as long, byval startPosY as long, byval endPosX as long, byval endPosY as long, byval color as Color)
declare sub DrawLineV(byval startPos as Vector2, byval endPos as Vector2, byval color as Color)
declare sub DrawLineEx(byval startPos as Vector2, byval endPos as Vector2, byval thick as single, byval color as Color)
declare sub DrawLineStrip(byval points as const Vector2 ptr, byval pointCount as long, byval color as Color)
declare sub DrawLineBezier(byval startPos as Vector2, byval endPos as Vector2, byval thick as single, byval color as Color)
declare sub DrawCircle(byval centerX as long, byval centerY as long, byval radius as single, byval color as Color)
declare sub DrawCircleSector(byval center as Vector2, byval radius as single, byval startAngle as single, byval endAngle as single, byval segments as long, byval color as Color)
declare sub DrawCircleSectorLines(byval center as Vector2, byval radius as single, byval startAngle as single, byval endAngle as single, byval segments as long, byval color as Color)
declare sub DrawCircleGradient(byval centerX as long, byval centerY as long, byval radius as single, byval inner as Color, byval outer as Color)
declare sub DrawCircleV(byval center as Vector2, byval radius as single, byval color as Color)
declare sub DrawCircleLines(byval centerX as long, byval centerY as long, byval radius as single, byval color as Color)
declare sub DrawCircleLinesV(byval center as Vector2, byval radius as single, byval color as Color)
declare sub DrawEllipse(byval centerX as long, byval centerY as long, byval radiusH as single, byval radiusV as single, byval color as Color)
declare sub DrawEllipseLines(byval centerX as long, byval centerY as long, byval radiusH as single, byval radiusV as single, byval color as Color)
declare sub DrawRing(byval center as Vector2, byval innerRadius as single, byval outerRadius as single, byval startAngle as single, byval endAngle as single, byval segments as long, byval color as Color)
declare sub DrawRingLines(byval center as Vector2, byval innerRadius as single, byval outerRadius as single, byval startAngle as single, byval endAngle as single, byval segments as long, byval color as Color)
declare sub DrawRectangle(byval posX as long, byval posY as long, byval width as long, byval height as long, byval color as Color)
declare sub DrawRectangleV(byval position as Vector2, byval size as Vector2, byval color as Color)
declare sub DrawRectangleRec(byval rec as Rectangle, byval color as Color)
declare sub DrawRectanglePro(byval rec as Rectangle, byval origin as Vector2, byval rotation as single, byval color as Color)
declare sub DrawRectangleGradientV(byval posX as long, byval posY as long, byval width as long, byval height as long, byval top as Color, byval bottom as Color)
declare sub DrawRectangleGradientH(byval posX as long, byval posY as long, byval width as long, byval height as long, byval left as Color, byval right as Color)
declare sub DrawRectangleGradientEx(byval rec as Rectangle, byval topLeft as Color, byval bottomLeft as Color, byval topRight as Color, byval bottomRight as Color)
declare sub DrawRectangleLines(byval posX as long, byval posY as long, byval width as long, byval height as long, byval color as Color)
declare sub DrawRectangleLinesEx(byval rec as Rectangle, byval lineThick as single, byval color as Color)
declare sub DrawRectangleRounded(byval rec as Rectangle, byval roundness as single, byval segments as long, byval color as Color)
declare sub DrawRectangleRoundedLines(byval rec as Rectangle, byval roundness as single, byval segments as long, byval color as Color)
declare sub DrawRectangleRoundedLinesEx(byval rec as Rectangle, byval roundness as single, byval segments as long, byval lineThick as single, byval color as Color)
declare sub DrawTriangle(byval v1 as Vector2, byval v2 as Vector2, byval v3 as Vector2, byval color as Color)
declare sub DrawTriangleLines(byval v1 as Vector2, byval v2 as Vector2, byval v3 as Vector2, byval color as Color)
declare sub DrawTriangleFan(byval points as const Vector2 ptr, byval pointCount as long, byval color as Color)
declare sub DrawTriangleStrip(byval points as const Vector2 ptr, byval pointCount as long, byval color as Color)
declare sub DrawPoly(byval center as Vector2, byval sides as long, byval radius as single, byval rotation as single, byval color as Color)
declare sub DrawPolyLines(byval center as Vector2, byval sides as long, byval radius as single, byval rotation as single, byval color as Color)
declare sub DrawPolyLinesEx(byval center as Vector2, byval sides as long, byval radius as single, byval rotation as single, byval lineThick as single, byval color as Color)

' Splines drawing functions
declare sub DrawSplineLinear(byval points as const Vector2 ptr, byval pointCount as long, byval thick as single, byval color as Color)
declare sub DrawSplineBasis(byval points as const Vector2 ptr, byval pointCount as long, byval thick as single, byval color as Color)
declare sub DrawSplineCatmullRom(byval points as const Vector2 ptr, byval pointCount as long, byval thick as single, byval color as Color)
declare sub DrawSplineBezierQuadratic(byval points as const Vector2 ptr, byval pointCount as long, byval thick as single, byval color as Color)
declare sub DrawSplineBezierCubic(byval points as const Vector2 ptr, byval pointCount as long, byval thick as single, byval color as Color)
declare sub DrawSplineSegmentLinear(byval p1 as Vector2, byval p2 as Vector2, byval thick as single, byval color as Color)
declare sub DrawSplineSegmentBasis(byval p1 as Vector2, byval p2 as Vector2, byval p3 as Vector2, byval p4 as Vector2, byval thick as single, byval color as Color)
declare sub DrawSplineSegmentCatmullRom(byval p1 as Vector2, byval p2 as Vector2, byval p3 as Vector2, byval p4 as Vector2, byval thick as single, byval color as Color)
declare sub DrawSplineSegmentBezierQuadratic(byval p1 as Vector2, byval c2 as Vector2, byval p3 as Vector2, byval thick as single, byval color as Color)
declare sub DrawSplineSegmentBezierCubic(byval p1 as Vector2, byval c2 as Vector2, byval c3 as Vector2, byval p4 as Vector2, byval thick as single, byval color as Color)

' Spline segment point evaluation functions
declare function GetSplinePointLinear(byval startPos as Vector2, byval endPos as Vector2, byval t as single) as Vector2
declare function GetSplinePointBasis(byval p1 as Vector2, byval p2 as Vector2, byval p3 as Vector2, byval p4 as Vector2, byval t as single) as Vector2
declare function GetSplinePointCatmullRom(byval p1 as Vector2, byval p2 as Vector2, byval p3 as Vector2, byval p4 as Vector2, byval t as single) as Vector2
declare function GetSplinePointBezierQuad(byval p1 as Vector2, byval c2 as Vector2, byval p3 as Vector2, byval t as single) as Vector2
declare function GetSplinePointBezierCubic(byval p1 as Vector2, byval c2 as Vector2, byval c3 as Vector2, byval p4 as Vector2, byval t as single) as Vector2

' Basic shapes collision detection functions
declare function CheckCollisionRecs(byval rec1 as Rectangle, byval rec2 as Rectangle) as bool
declare function CheckCollisionCircles(byval center1 as Vector2, byval radius1 as single, byval center2 as Vector2, byval radius2 as single) as bool
declare function CheckCollisionCircleRec(byval center as Vector2, byval radius as single, byval rec as Rectangle) as bool
declare function CheckCollisionCircleLine(byval center as Vector2, byval radius as single, byval p1 as Vector2, byval p2 as Vector2) as bool
declare function CheckCollisionPointRec(byval point as Vector2, byval rec as Rectangle) as bool
declare function CheckCollisionPointCircle(byval point as Vector2, byval center as Vector2, byval radius as single) as bool
declare function CheckCollisionPointTriangle(byval point as Vector2, byval p1 as Vector2, byval p2 as Vector2, byval p3 as Vector2) as bool
declare function CheckCollisionPointLine(byval point as Vector2, byval p1 as Vector2, byval p2 as Vector2, byval threshold as long) as bool
declare function CheckCollisionPointPoly(byval point as Vector2, byval points as const Vector2 ptr, byval pointCount as long) as bool
declare function CheckCollisionLines(byval startPos1 as Vector2, byval endPos1 as Vector2, byval startPos2 as Vector2, byval endPos2 as Vector2, byval collisionPoint as Vector2 ptr) as bool
declare function GetCollisionRec(byval rec1 as Rectangle, byval rec2 as Rectangle) as Rectangle

' Texture Loading and Drawing Functions
declare function LoadImage(byval fileName as const zstring ptr) as Image
declare function LoadImageRaw(byval fileName as const zstring ptr, byval width as long, byval height as long, byval format as long, byval headerSize as long) as Image
declare function LoadImageAnim(byval fileName as const zstring ptr, byval frames as long ptr) as Image
declare function LoadImageAnimFromMemory(byval fileType as const zstring ptr, byval fileData as const ubyte ptr, byval dataSize as long, byval frames as long ptr) as Image
declare function LoadImageFromMemory(byval fileType as const zstring ptr, byval fileData as const ubyte ptr, byval dataSize as long) as Image
declare function LoadImageFromTexture(byval texture as Texture2D) as Image
declare function LoadImageFromScreen() as Image
declare function IsImageValid(byval image as Image) as bool
declare sub UnloadImage(byval image as Image)
declare function ExportImage(byval image as Image, byval fileName as const zstring ptr) as bool
declare function ExportImageToMemory(byval image as Image, byval fileType as const zstring ptr, byval fileSize as long ptr) as ubyte ptr
declare function ExportImageAsCode(byval image as Image, byval fileName as const zstring ptr) as bool
declare function GenImageColor(byval width as long, byval height as long, byval color as Color) as Image
declare function GenImageGradientLinear(byval width as long, byval height as long, byval direction as long, byval start as Color, byval end_ as Color) as Image
declare function GenImageGradientRadial(byval width as long, byval height as long, byval density as single, byval inner as Color, byval outer as Color) as Image
declare function GenImageGradientSquare(byval width as long, byval height as long, byval density as single, byval inner as Color, byval outer as Color) as Image
declare function GenImageChecked(byval width as long, byval height as long, byval checksX as long, byval checksY as long, byval col1 as Color, byval col2 as Color) as Image
declare function GenImageWhiteNoise(byval width as long, byval height as long, byval factor as single) as Image
declare function GenImagePerlinNoise(byval width as long, byval height as long, byval offsetX as long, byval offsetY as long, byval scale as single) as Image
declare function GenImageCellular(byval width as long, byval height as long, byval tileSize as long) as Image
declare function GenImageText(byval width as long, byval height as long, byval text as const zstring ptr) as Image
declare function ImageCopy(byval image as Image) as Image
declare function ImageFromImage(byval image as Image, byval rec as Rectangle) as Image
declare function ImageFromChannel(byval image as Image, byval selectedChannel as long) as Image
declare function ImageText(byval text as const zstring ptr, byval fontSize as long, byval color as Color) as Image
declare function ImageTextEx(byval font as Font, byval text as const zstring ptr, byval fontSize as single, byval spacing as single, byval tint as Color) as Image
declare sub ImageFormat(byval image as Image ptr, byval newFormat as long)
declare sub ImageToPOT(byval image as Image ptr, byval fill as Color)
declare sub ImageCrop(byval image as Image ptr, byval crop as Rectangle)
declare sub ImageAlphaCrop(byval image as Image ptr, byval threshold as single)
declare sub ImageAlphaClear(byval image as Image ptr, byval color as Color, byval threshold as single)
declare sub ImageAlphaMask(byval image as Image ptr, byval alphaMask as Image)
declare sub ImageAlphaPremultiply(byval image as Image ptr)
declare sub ImageBlurGaussian(byval image as Image ptr, byval blurSize as long)
declare sub ImageKernelConvolution(byval image as Image ptr, byval kernel as const single ptr, byval kernelSize as long)
declare sub ImageResize(byval image as Image ptr, byval newWidth as long, byval newHeight as long)
declare sub ImageResizeNN(byval image as Image ptr, byval newWidth as long, byval newHeight as long)
declare sub ImageResizeCanvas(byval image as Image ptr, byval newWidth as long, byval newHeight as long, byval offsetX as long, byval offsetY as long, byval fill as Color)
declare sub ImageMipmaps(byval image as Image ptr)
declare sub ImageDither(byval image as Image ptr, byval rBpp as long, byval gBpp as long, byval bBpp as long, byval aBpp as long)
declare sub ImageFlipVertical(byval image as Image ptr)
declare sub ImageFlipHorizontal(byval image as Image ptr)
declare sub ImageRotate(byval image as Image ptr, byval degrees as long)
declare sub ImageRotateCW(byval image as Image ptr)
declare sub ImageRotateCCW(byval image as Image ptr)
declare sub ImageColorTint(byval image as Image ptr, byval color as Color)
declare sub ImageColorInvert(byval image as Image ptr)
declare sub ImageColorGrayscale(byval image as Image ptr)
declare sub ImageColorContrast(byval image as Image ptr, byval contrast as single)
declare sub ImageColorBrightness(byval image as Image ptr, byval brightness as long)
declare sub ImageColorReplace(byval image as Image ptr, byval color as Color, byval replace as Color)
declare function LoadImageColors(byval image as Image) as Color ptr
declare function LoadImagePalette(byval image as Image, byval maxPaletteSize as long, byval colorCount as long ptr) as Color ptr
declare sub UnloadImageColors(byval colors as Color ptr)
declare sub UnloadImagePalette(byval colors as Color ptr)
declare function GetImageAlphaBorder(byval image as Image, byval threshold as single) as Rectangle
declare function GetImageColor(byval image as Image, byval x as long, byval y as long) as Color
declare sub ImageClearBackground(byval dst as Image ptr, byval color as Color)
declare sub ImageDrawPixel(byval dst as Image ptr, byval posX as long, byval posY as long, byval color as Color)
declare sub ImageDrawPixelV(byval dst as Image ptr, byval position as Vector2, byval color as Color)
declare sub ImageDrawLine(byval dst as Image ptr, byval startPosX as long, byval startPosY as long, byval endPosX as long, byval endPosY as long, byval color as Color)
declare sub ImageDrawLineV(byval dst as Image ptr, byval start as Vector2, byval end as Vector2, byval color as Color)
declare sub ImageDrawLineEx(byval dst as Image ptr, byval start as Vector2, byval end as Vector2, byval thick as long, byval color as Color)
declare sub ImageDrawCircle(byval dst as Image ptr, byval centerX as long, byval centerY as long, byval radius as long, byval color as Color)
declare sub ImageDrawCircleV(byval dst as Image ptr, byval center as Vector2, byval radius as long, byval color as Color)
declare sub ImageDrawCircleLines(byval dst as Image ptr, byval centerX as long, byval centerY as long, byval radius as long, byval color as Color)
declare sub ImageDrawCircleLinesV(byval dst as Image ptr, byval center as Vector2, byval radius as long, byval color as Color)
declare sub ImageDrawRectangle(byval dst as Image ptr, byval posX as long, byval posY as long, byval width as long, byval height as long, byval color as Color)
declare sub ImageDrawRectangleV(byval dst as Image ptr, byval position as Vector2, byval size as Vector2, byval color as Color)
declare sub ImageDrawRectangleRec(byval dst as Image ptr, byval rec as Rectangle, byval color as Color)
declare sub ImageDrawRectangleLines(byval dst as Image ptr, byval rec as Rectangle, byval thick as long, byval color as Color)
declare sub ImageDrawTriangle(byval dst as Image ptr, byval v1 as Vector2, byval v2 as Vector2, byval v3 as Vector2, byval color as Color)
declare sub ImageDrawTriangleEx(byval dst as Image ptr, byval v1 as Vector2, byval v2 as Vector2, byval v3 as Vector2, byval c1 as Color, byval c2 as Color, byval c3 as Color)
declare sub ImageDrawTriangleLines(byval dst as Image ptr, byval v1 as Vector2, byval v2 as Vector2, byval v3 as Vector2, byval color as Color)
declare sub ImageDrawTriangleFan(byval dst as Image ptr, byval points as Vector2 ptr, byval pointCount as long, byval color as Color)
declare sub ImageDrawTriangleStrip(byval dst as Image ptr, byval points as Vector2 ptr, byval pointCount as long, byval color as Color)
declare sub ImageDraw(byval dst as Image ptr, byval src as Image, byval srcRec as Rectangle, byval dstRec as Rectangle, byval tint as Color)
declare sub ImageDrawText(byval dst as Image ptr, byval text as const zstring ptr, byval posX as long, byval posY as long, byval fontSize as long, byval color as Color)
declare sub ImageDrawTextEx(byval dst as Image ptr, byval font as Font, byval text as const zstring ptr, byval position as Vector2, byval fontSize as single, byval spacing as single, byval tint as Color)
declare function LoadTexture(byval fileName as const zstring ptr) as Texture2D
declare function LoadTextureFromImage(byval image as Image) as Texture2D
declare function LoadTextureCubemap(byval image as Image, byval layout as long) as TextureCubemap
declare function LoadRenderTexture(byval width as long, byval height as long) as RenderTexture2D
declare function IsTextureValid(byval texture as Texture2D) as bool
declare sub UnloadTexture(byval texture as Texture2D)
declare function IsRenderTextureValid(byval target as RenderTexture2D) as bool
declare sub UnloadRenderTexture(byval target as RenderTexture2D)
declare sub UpdateTexture(byval texture as Texture2D, byval pixels as any ptr)
declare sub UpdateTextureRec(byval texture as Texture2D, byval rec as Rectangle, byval pixels as any ptr)
declare sub GenTextureMipmaps(byval texture as Texture2D ptr)
declare sub SetTextureFilter(byval texture as Texture2D, byval filter as long)
declare sub SetTextureWrap(byval texture as Texture2D, byval wrap as long)
declare sub DrawTexture(byval texture as Texture2D, byval posX as long, byval posY as long, byval tint as Color)
declare sub DrawTextureV(byval texture as Texture2D, byval position as Vector2, byval tint as Color)
declare sub DrawTextureEx(byval texture as Texture2D, byval position as Vector2, byval rotation as single, byval scale as single, byval tint as Color)
declare sub DrawTextureRec(byval texture as Texture2D, byval source as Rectangle, byval position as Vector2, byval tint as Color)
declare sub DrawTexturePro(byval texture as Texture2D, byval source as Rectangle, byval dest as Rectangle, byval origin as Vector2, byval rotation as single, byval tint as Color)
declare sub DrawTextureNPatch(byval texture as Texture2D, byval nPatchInfo as NPatchInfo, byval dest as Rectangle, byval origin as Vector2, byval rotation as single, byval tint as Color)

' Color/pixel related functions
declare function ColorIsEqual(byval col1 as Color, byval col2 as Color) as bool
declare function Fade(byval color as Color, byval alpha as single) as Color
declare function ColorToInt(byval color as Color) as long
declare function ColorNormalize(byval color as Color) as Vector4
declare function ColorFromNormalized(byval normalized as Vector4) as Color
declare function ColorToHSV(byval color as Color) as Vector3
declare function ColorFromHSV(byval hue as single, byval saturation as single, byval value as single) as Color
declare function ColorTint(byval color as Color, byval tint as Color) as Color
declare function ColorBrightness(byval color as Color, byval factor as single) as Color
declare function ColorContrast(byval color as Color, byval contrast as single) as Color
declare function ColorAlpha(byval color as Color, byval alpha as single) as Color
declare function ColorAlphaBlend(byval dst as Color, byval src as Color, byval tint as Color) as Color
declare function ColorLerp(byval color1 as Color, byval color2 as Color, byval factor as single) as Color
declare function GetColor(byval hexValue as ulong) as Color
declare function GetPixelColor(byval srcPtr as any ptr, byval format as long) as Color
declare sub SetPixelColor(byval dstPtr as any ptr, byval color as Color, byval format as long)
declare function GetPixelDataSize(byval width as long, byval height as long, byval format as long) as long

' Font Loading and Text Drawing Functions
declare function GetFontDefault() as Font
declare function LoadFont(byval fileName as const zstring ptr) as Font
declare function LoadFontEx(byval fileName as const zstring ptr, byval fontSize as long, byval codepoints as long ptr, byval codepointCount as long) as Font
declare function LoadFontFromImage(byval image as Image, byval key as Color, byval firstChar as long) as Font
declare function LoadFontFromMemory(byval fileType as const zstring ptr, byval fileData as const ubyte ptr, byval dataSize as long, byval fontSize as long, byval codepoints as long ptr, byval codepointCount as long) as Font
declare function IsFontValid(byval font as Font) as bool
declare function LoadFontData(byval fileData as const ubyte ptr, byval dataSize as long, byval fontSize as long, byval codepoints as long ptr, byval codepointCount as long, byval type as long) as GlyphInfo ptr
declare function GenImageFontAtlas(byval glyphs as const GlyphInfo ptr, byval glyphRecs as Rectangle ptr ptr, byval glyphCount as long, byval fontSize as long, byval padding as long, byval packMethod as long) as Image
declare sub UnloadFontData(byval glyphs as GlyphInfo ptr, byval glyphCount as long)
declare sub UnloadFont(byval font as Font)
declare function ExportFontAsCode(byval font as Font, byval fileName as const zstring ptr) as bool
declare sub DrawFPS(byval posX as long, byval posY as long)
declare sub DrawText(byval text as const zstring ptr, byval posX as long, byval posY as long, byval fontSize as long, byval color as Color)
declare sub DrawTextEx(byval font as Font, byval text as const zstring ptr, byval position as Vector2, byval fontSize as single, byval spacing as single, byval tint as Color)
declare sub DrawTextPro(byval font as Font, byval text as const zstring ptr, byval position as Vector2, byval origin as Vector2, byval rotation as single, byval fontSize as single, byval spacing as single, byval tint as Color)
declare sub DrawTextCodepoint(byval font as Font, byval codepoint as long, byval position as Vector2, byval fontSize as single, byval tint as Color)
declare sub DrawTextCodepoints(byval font as Font, byval codepoints as const long ptr, byval codepointCount as long, byval position as Vector2, byval fontSize as single, byval spacing as single, byval tint as Color)

' Text font info functions
declare sub SetTextLineSpacing(byval spacing as long)
declare function MeasureText(byval text as const zstring ptr, byval fontSize as long) as long
declare function MeasureTextEx(byval font as Font, byval text as const zstring ptr, byval fontSize as single, byval spacing as single) as Vector2
declare function GetGlyphIndex(byval font as Font, byval codepoint as long) as long
declare function GetGlyphInfo(byval font as Font, byval codepoint as long) as GlyphInfo
declare function GetGlyphAtlasRec(byval font as Font, byval codepoint as long) as Rectangle

' Text codepoints management functions
declare function LoadUTF8(byval codepoints as const long ptr, byval length as long) as zstring ptr
declare sub UnloadUTF8(byval text as zstring ptr)
declare function LoadCodepoints(byval text as const zstring ptr, byval count as long ptr) as long ptr
declare sub UnloadCodepoints(byval codepoints as long ptr)
declare function GetCodepointCount(byval text as const zstring ptr) as long
declare function GetCodepoint(byval text as const zstring ptr, byval codepointSize as long ptr) as long
declare function GetCodepointNext(byval text as const zstring ptr, byval codepointSize as long ptr) as long
declare function GetCodepointPrevious(byval text as const zstring ptr, byval codepointSize as long ptr) as long
declare function CodepointToUTF8(byval codepoint as long, byval utf8Size as long ptr) as const zstring ptr

' Text strings management functions
declare function TextCopy(byval dst as zstring ptr, byval src as const zstring ptr) as long
declare function TextIsEqual(byval text1 as const zstring ptr, byval text2 as const zstring ptr) as bool
declare function TextLength(byval text as const zstring ptr) as ulong
declare function TextFormat cdecl(byval text as const zstring ptr, ...) as const zstring ptr
declare function TextSubtext(byval text as const zstring ptr, byval position as long, byval length as long) as const zstring ptr
declare function TextReplace(byval text as const zstring ptr, byval replace as const zstring ptr, byval by_ as const zstring ptr) as zstring ptr
declare function TextInsert(byval text as const zstring ptr, byval insert as const zstring ptr, byval position as long) as zstring ptr
declare function TextJoin(byval textList as const zstring ptr ptr, byval count as long, byval delimiter as const zstring ptr) as const zstring ptr
declare function TextSplit(byval text as const zstring ptr, byval delimiter as byte, byval count as long ptr) as const zstring ptr ptr
declare sub TextAppend(byval text as zstring ptr, byval append as const zstring ptr, byval position as long ptr)
declare function TextFindIndex(byval text as const zstring ptr, byval find as const zstring ptr) as long
declare function TextToUpper(byval text as const zstring ptr) as const zstring ptr
declare function TextToLower(byval text as const zstring ptr) as const zstring ptr
declare function TextToPascal(byval text as const zstring ptr) as const zstring ptr
declare function TextToSnake(byval text as const zstring ptr) as const zstring ptr
declare function TextToCamel(byval text as const zstring ptr) as const zstring ptr
declare function TextToInteger(byval text as const zstring ptr) as long
declare function TextToFloat(byval text as const zstring ptr) as single

' Basic 3d Shapes Drawing Functions
declare sub DrawLine3D(byval startPos as Vector3, byval endPos as Vector3, byval color as Color)
declare sub DrawPoint3D(byval position as Vector3, byval color as Color)
declare sub DrawCircle3D(byval center as Vector3, byval radius as single, byval rotationAxis as Vector3, byval rotationAngle as single, byval color as Color)
declare sub DrawTriangle3D(byval v1 as Vector3, byval v2 as Vector3, byval v3 as Vector3, byval color as Color)
declare sub DrawTriangleStrip3D(byval points as const Vector3 ptr, byval pointCount as long, byval color as Color)
declare sub DrawCube(byval position as Vector3, byval width as single, byval height as single, byval length as single, byval color as Color)
declare sub DrawCubeV(byval position as Vector3, byval size as Vector3, byval color as Color)
declare sub DrawCubeWires(byval position as Vector3, byval width as single, byval height as single, byval length as single, byval color as Color)
declare sub DrawCubeWiresV(byval position as Vector3, byval size as Vector3, byval color as Color)
declare sub DrawSphere(byval centerPos as Vector3, byval radius as single, byval color as Color)
declare sub DrawSphereEx(byval centerPos as Vector3, byval radius as single, byval rings as long, byval slices as long, byval color as Color)
declare sub DrawSphereWires(byval centerPos as Vector3, byval radius as single, byval rings as long, byval slices as long, byval color as Color)
declare sub DrawCylinder(byval position as Vector3, byval radiusTop as single, byval radiusBottom as single, byval height as single, byval slices as long, byval color as Color)
declare sub DrawCylinderEx(byval startPos as Vector3, byval endPos as Vector3, byval startRadius as single, byval endRadius as single, byval sides as long, byval color as Color)
declare sub DrawCylinderWires(byval position as Vector3, byval radiusTop as single, byval radiusBottom as single, byval height as single, byval slices as long, byval color as Color)
declare sub DrawCylinderWiresEx(byval startPos as Vector3, byval endPos as Vector3, byval startRadius as single, byval endRadius as single, byval sides as long, byval color as Color)
declare sub DrawCapsule(byval startPos as Vector3, byval endPos as Vector3, byval radius as single, byval slices as long, byval rings as long, byval color as Color)
declare sub DrawCapsuleWires(byval startPos as Vector3, byval endPos as Vector3, byval radius as single, byval slices as long, byval rings as long, byval color as Color)
declare sub DrawPlane(byval centerPos as Vector3, byval size as Vector2, byval color as Color)
declare sub DrawRay(byval ray as Ray, byval color as Color)
declare sub DrawGrid(byval slices as long, byval spacing as single)

' Model 3d Loading and Drawing Functions
declare function LoadModel(byval fileName as const zstring ptr) as Model
declare function LoadModelFromMesh(byval mesh as Mesh) as Model
declare function IsModelValid(byval model as Model) as bool
declare sub UnloadModel(byval model as Model)
declare function GetModelBoundingBox(byval model as Model) as BoundingBox
declare sub DrawModel(byval model as Model, byval position as Vector3, byval scale as single, byval tint as Color)
declare sub DrawModelEx(byval model as Model, byval position as Vector3, byval rotationAxis as Vector3, byval rotationAngle as single, byval scale as Vector3, byval tint as Color)
declare sub DrawModelWires(byval model as Model, byval position as Vector3, byval scale as single, byval tint as Color)
declare sub DrawModelWiresEx(byval model as Model, byval position as Vector3, byval rotationAxis as Vector3, byval rotationAngle as single, byval scale as Vector3, byval tint as Color)
declare sub DrawModelPoints(byval model as Model, byval position as Vector3, byval scale as single, byval tint as Color)
declare sub DrawModelPointsEx(byval model as Model, byval position as Vector3, byval rotationAxis as Vector3, byval rotationAngle as single, byval scale as Vector3, byval tint as Color)
declare sub DrawBoundingBox(byval box as BoundingBox, byval color as Color)
declare sub DrawBillboard(byval camera as Camera, byval texture as Texture2D, byval position as Vector3, byval scale as single, byval tint as Color)
declare sub DrawBillboardRec(byval camera as Camera, byval texture as Texture2D, byval source as Rectangle, byval position as Vector3, byval size as Vector2, byval tint as Color)
declare sub DrawBillboardPro(byval camera as Camera, byval texture as Texture2D, byval source as Rectangle, byval position as Vector3, byval up as Vector3, byval size as Vector2, byval origin as Vector2, byval rotation as single, byval tint as Color)
declare sub UploadMesh(byval mesh as Mesh ptr, byval dynamic as bool)
declare sub UpdateMeshBuffer(byval mesh as Mesh, byval index as long, byval data as any ptr, byval dataSize as long, byval offset as long)
declare sub UnloadMesh(byval mesh as Mesh)
declare sub DrawMesh(byval mesh as Mesh, byval material as Material, byval transform as Matrix)
declare sub DrawMeshInstanced(byval mesh as Mesh, byval material as Material, byval transforms as const Matrix ptr, byval instances as long)
declare function GetMeshBoundingBox(byval mesh as Mesh) as BoundingBox
declare sub GenMeshTangents(byval mesh as Mesh ptr)
declare function ExportMesh(byval mesh as Mesh, byval fileName as const zstring ptr) as bool
declare function ExportMeshAsCode(byval mesh as Mesh, byval fileName as const zstring ptr) as bool
declare function GenMeshPoly(byval sides as long, byval radius as single) as Mesh
declare function GenMeshPlane(byval width as single, byval length as single, byval resX as long, byval resZ as long) as Mesh
declare function GenMeshCube(byval width as single, byval height as single, byval length as single) as Mesh
declare function GenMeshSphere(byval radius as single, byval rings as long, byval slices as long) as Mesh
declare function GenMeshHemiSphere(byval radius as single, byval rings as long, byval slices as long) as Mesh
declare function GenMeshCylinder(byval radius as single, byval height as single, byval slices as long) as Mesh
declare function GenMeshCone(byval radius as single, byval height as single, byval slices as long) as Mesh
declare function GenMeshTorus(byval radius as single, byval size as single, byval radSeg as long, byval sides as long) as Mesh
declare function GenMeshKnot(byval radius as single, byval size as single, byval radSeg as long, byval sides as long) as Mesh
declare function GenMeshHeightmap(byval heightmap as Image, byval size as Vector3) as Mesh
declare function GenMeshCubicmap(byval cubicmap as Image, byval cubeSize as Vector3) as Mesh
declare function LoadMaterials(byval fileName as const zstring ptr, byval materialCount as long ptr) as Material ptr
declare function LoadMaterialDefault() as Material
declare function IsMaterialValid(byval material as Material) as bool
declare sub UnloadMaterial(byval material as Material)
declare sub SetMaterialTexture(byval material as Material ptr, byval mapType as long, byval texture as Texture2D)
declare sub SetModelMeshMaterial(byval model as Model ptr, byval meshId as long, byval materialId as long)
declare function LoadModelAnimations(byval fileName as const zstring ptr, byval animCount as long ptr) as ModelAnimation ptr
declare sub UpdateModelAnimation(byval model as Model, byval anim as ModelAnimation, byval frame as long)
declare sub UpdateModelAnimationBones(byval model as Model, byval anim as ModelAnimation, byval frame as long)
declare sub UnloadModelAnimation(byval anim as ModelAnimation)
declare sub UnloadModelAnimations(byval animations as ModelAnimation ptr, byval animCount as long)
declare function IsModelAnimationValid(byval model as Model, byval anim as ModelAnimation) as bool

' Collision detection functions
declare function CheckCollisionSpheres(byval center1 as Vector3, byval radius1 as single, byval center2 as Vector3, byval radius2 as single) as bool
declare function CheckCollisionBoxes(byval box1 as BoundingBox, byval box2 as BoundingBox) as bool
declare function CheckCollisionBoxSphere(byval box as BoundingBox, byval center as Vector3, byval radius as single) as bool
declare function GetRayCollisionSphere(byval ray as Ray, byval center as Vector3, byval radius as single) as RayCollision
declare function GetRayCollisionBox(byval ray as Ray, byval box as BoundingBox) as RayCollision
declare function GetRayCollisionMesh(byval ray as Ray, byval mesh as Mesh, byval transform as Matrix) as RayCollision
declare function GetRayCollisionTriangle(byval ray as Ray, byval p1 as Vector3, byval p2 as Vector3, byval p3 as Vector3) as RayCollision
declare function GetRayCollisionQuad(byval ray as Ray, byval p1 as Vector3, byval p2 as Vector3, byval p3 as Vector3, byval p4 as Vector3) as RayCollision

' Audio Loading and Playing Functions
declare sub InitAudioDevice()
declare sub CloseAudioDevice()
declare function IsAudioDeviceReady() as bool
declare sub SetMasterVolume(byval volume as single)
declare function GetMasterVolume() as single
declare function LoadWave(byval fileName as const zstring ptr) as Wave
declare function LoadWaveFromMemory(byval fileType as const zstring ptr, byval fileData as const ubyte ptr, byval dataSize as long) as Wave
declare function IsWaveValid(byval wave as Wave) as bool
declare function LoadSound(byval fileName as const zstring ptr) as Sound
declare function LoadSoundFromWave(byval wave as Wave) as Sound
declare function LoadSoundAlias(byval source as Sound) as Sound
declare function IsSoundValid(byval sound as Sound) as bool
declare sub UpdateSound(byval sound as Sound, byval data as any ptr, byval sampleCount as long)
declare sub UnloadWave(byval wave as Wave)
declare sub UnloadSound(byval sound as Sound)
declare sub UnloadSoundAlias(byval alias as Sound)
declare function ExportWave(byval wave as Wave, byval fileName as const zstring ptr) as bool
declare function ExportWaveAsCode(byval wave as Wave, byval fileName as const zstring ptr) as bool
declare sub PlaySound(byval sound as Sound)
declare sub StopSound(byval sound as Sound)
declare sub PauseSound(byval sound as Sound)
declare sub ResumeSound(byval sound as Sound)
declare function IsSoundPlaying(byval sound as Sound) as bool
declare sub SetSoundVolume(byval sound as Sound, byval volume as single)
declare sub SetSoundPitch(byval sound as Sound, byval pitch as single)
declare sub SetSoundPan(byval sound as Sound, byval pan as single)
declare function WaveCopy(byval wave as Wave) as Wave
declare sub WaveCrop(byval wave as Wave ptr, byval initFrame as long, byval finalFrame as long)
declare sub WaveFormat(byval wave as Wave ptr, byval sampleRate as long, byval sampleSize as long, byval channels as long)
declare function LoadWaveSamples(byval wave as Wave) as single ptr
declare sub UnloadWaveSamples(byval samples as single ptr)
declare function LoadMusicStream(byval fileName as const zstring ptr) as Music
declare function LoadMusicStreamFromMemory(byval fileType as const zstring ptr, byval data as const ubyte ptr, byval dataSize as long) as Music
declare function IsMusicValid(byval music as Music) as bool
declare sub UnloadMusicStream(byval music as Music)
declare sub PlayMusicStream(byval music as Music)
declare function IsMusicStreamPlaying(byval music as Music) as bool
declare sub UpdateMusicStream(byval music as Music)
declare sub StopMusicStream(byval music as Music)
declare sub PauseMusicStream(byval music as Music)
declare sub ResumeMusicStream(byval music as Music)
declare sub SeekMusicStream(byval music as Music, byval position as single)
declare sub SetMusicVolume(byval music as Music, byval volume as single)
declare sub SetMusicPitch(byval music as Music, byval pitch as single)
declare sub SetMusicPan(byval music as Music, byval pan as single)
declare function GetMusicTimeLength(byval music as Music) as single
declare function GetMusicTimePlayed(byval music as Music) as single
declare function LoadAudioStream(byval sampleRate as ulong, byval sampleSize as ulong, byval channels as ulong) as AudioStream
declare function IsAudioStreamValid(byval stream as AudioStream) as bool
declare sub UnloadAudioStream(byval stream as AudioStream)
declare sub UpdateAudioStream(byval stream as AudioStream, byval data as any ptr, byval frameCount as long)
declare function IsAudioStreamProcessed(byval stream as AudioStream) as bool
declare sub PlayAudioStream(byval stream as AudioStream)
declare sub PauseAudioStream(byval stream as AudioStream)
declare sub ResumeAudioStream(byval stream as AudioStream)
declare function IsAudioStreamPlaying(byval stream as AudioStream) as bool
declare sub StopAudioStream(byval stream as AudioStream)
declare sub SetAudioStreamVolume(byval stream as AudioStream, byval volume as single)
declare sub SetAudioStreamPitch(byval stream as AudioStream, byval pitch as single)
declare sub SetAudioStreamPan(byval stream as AudioStream, byval pan as single)
declare sub SetAudioStreamBufferSizeDefault(byval size as long)
declare sub SetAudioStreamCallback(byval stream as AudioStream, byval callback as AudioCallback)
declare sub AttachAudioStreamProcessor(byval stream as AudioStream, byval processor as AudioCallback)
declare sub DetachAudioStreamProcessor(byval stream as AudioStream, byval processor as AudioCallback)
declare sub AttachAudioMixedProcessor(byval processor as AudioCallback)
declare sub DetachAudioMixedProcessor(byval processor as AudioCallback)

'====================================================================================
' Boilerplate Final
'====================================================================================

end extern
paul doe
Posts: 1878
Joined: Jul 25, 2017 17:22
Location: Argentina
Contact:

Re: Creating Raylib Bindings for FreeBASIC (with AI)

Post by paul doe »

So the example in question now becomes:

Code: Select all

#include once "raylib.bi"

const screenWidth as long = 800
const screenHeight as long = 450

InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking")

var camera = Camera(_
  Vector3(10.0f, 10.0f, 10.0f), _
  Vector3(0.0f, 0.0f, 0.0f), _
  Vector3(0.0f, 1.0f, 0.0f), _
  45.0f, CAMERA_PERSPECTIVE)

var cubePosition = Vector3(0.0f, 1.0f, 0.0f)
var cubeSize = Vector3(2.0f, 2.0f, 2.0f)

dim as Ray ray
dim as RayCollision collision

SetTargetFPS(60)

do while (not WindowShouldClose())
  if (isCursorHidden()) then UpdateCamera(@camera, CAMERA_FIRST_PERSON)
  
  if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)) then
    if (IsCursorHidden()) then
      EnableCursor()
    else
      DisableCursor()
    end if
  end if
  
  if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) then
    if (collision.hit = rl_false) then
      ray = GetScreenToWorldRay(GetMousePosition(), camera)
      
      collision = GetRayCollisionBox(ray, _
        BoundingBox( _
          Vector3(cubePosition.x - cubeSize.x / 2, cubePosition.y - cubeSize.y / 2, cubePosition.z - cubeSize.z / 2), _
          Vector3(cubePosition.x + cubeSize.x / 2, cubePosition.y + cubeSize.y / 2, cubePosition.z + cubeSize.z / 2)))
    else
      collision.hit = rl_false
    end if
  end if
  
  BeginDrawing()
    ClearBackground(RAYWHITE)
    
    if (collision.hit) then
      DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, screenHeight * 0.1f, 30, GREEN)
    end if
    
    BeginMode3D(camera)
      if (collision.hit) then
        DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, RED)
        DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, MAROON)
        
        DrawCubeWires(cubePosition, cubeSize.x + 0.2f, cubeSize.y + 0.2f, cubeSize.z + 0.2f, GREEN)
      else
        DrawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, GRAY)
        DrawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, DARKGRAY)
      end if
      
      DrawRay(ray, MAROON)
      DrawGrid(10, 1.0f)
    EndMode3D()
  
    DrawText("Right click mouse to toggle camera controls", 10, 430, 10, GRAY)
  
  EndDrawing()
loop
Which is much more readable and efficient than the original one. You're welcome.
D.J.Peters
Posts: 8642
Joined: May 28, 2005 3:28
Contact:

Re: Creating Raylib Bindings for FreeBASIC (with AI)

Post by D.J.Peters »

"raymath.bi" and "rlgl.bi" are missing from the raylib 5.5 package

Joshy
Imortis
Moderator
Posts: 1982
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: Creating Raylib Bindings for FreeBASIC (with AI)

Post by Imortis »

Mysoft wrote: Jun 08, 2025 16:38 no oop garbage is required to use raylib in C... so no OOP garbage must be required to work with raylib in freebasic
anyone not understanding something as simple as that is simple an useless programmer... but we already know who are like that :) specially since he is also a coward.
Your post has been reported. I have given you a warning. No need for insults here.
adeyblue
Posts: 357
Joined: Nov 07, 2019 20:08

Re: Creating Raylib Bindings for FreeBASIC (with AI)

Post by adeyblue »

Are you offering counselling to Paul at this difficult time? The mean men really did a number on him and his now urine soaked cornflakes
Imortis
Moderator
Posts: 1982
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: Creating Raylib Bindings for FreeBASIC (with AI)

Post by Imortis »

Congratulations Adeyblue! You have earned a 6 hour cool off ban because you were warned once already today.

Edit: For clarity, the message was not reported by the member at which both of these messages were clearly aimed. It was a third party.
Post Reply