[Module] raylib-purebasic (Windows/Linux/macOS)

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
ccode_new
User
User
Posts: 21
Joined: Sat Jul 30, 2022 10:39 am

Re: [Module] raylib-purebasic (Windows/Linux/macOS)

Post by ccode_new »

Hello mk-soft,

did you test this?

That's why I've renamed the structures since I first used the RayLib.

This function also only needs Vector2.

This doesn't work!

Code: Select all

#include "raylib_pb_helper.h"
#include "rlgl.h"

void pbhelper_DrawTextPro(Font* font, const char *text, Vector2 *position, Vector2 *origin, float rotation, float fontSize, float spacing, Color tint) {
    if( font && text && position && origin) 
    
    rlPushMatrix();

        rlTranslatef(position->x, position->y, 0.0f);
        rlRotatef(rotation, 0.0f, 0.0f, 1.0f);
        rlTranslatef(-origin->x, -origin->y, 0.0f);

        DrawTextEx(*font, text, (Vector2){ 0.0f, 0.0f }, fontSize, spacing, tint);

    rlPopMatrix();
}
I found the mistake:
It is considered solved.

I had only one small mistake in this declaration (raylib.pbi)

DrawTextPro(*in_font.ray::Font, text.p-utf8, *in_position.ray::Vector2, *origin.ray::Vector2, rotation.rl_float, fontSize.rl_float, spacing.rl_float, tint.rl_ColorLong) __PBAS(DrawTextPro) (Mistake with float - Variable)

A small note:
The matrix structure exists both in "raylib.h" and in "rlgl.h".

(On MacOS the OSX_DEPLOYMENT_TARGET = 11.0) > 11 not work!


It works!

/*
The "raylib4.2" has so many great improvements and additional useful features.
I'm trying to keep porting it. (no ugly inline-c)
*/
ccode_new
User
User
Posts: 21
Joined: Sat Jul 30, 2022 10:39 am

Re: [Module] raylib-purebasic (Windows/Linux/macOS)

Post by ccode_new »

...
Last edited by ccode_new on Sun Mar 05, 2023 7:48 pm, edited 3 times in total.
Joubarbe
Enthusiast
Enthusiast
Posts: 555
Joined: Wed Sep 18, 2013 11:54 am
Location: France

Re: [Module] raylib-purebasic (Windows/Linux/macOS)

Post by Joubarbe »

Oh, so you actually ported the latest version of raylib? Thanks!
ccode_new
User
User
Posts: 21
Joined: Sat Jul 30, 2022 10:39 am

Re: [Module] raylib-purebasic (Windows/Linux/macOS)

Post by ccode_new »

:?:
How to statically build the "raylib" library on Windows with PureBasic compatibility? (.lib / .a)

(Using Microsoft Visual Studio C compiler or msys2)

Does anyone have experience with this?
User avatar
idle
Always Here
Always Here
Posts: 5040
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: [Module] raylib-purebasic (Windows/Linux/macOS)

Post by idle »

ccode_new wrote: Mon Feb 13, 2023 8:52 pm :?:
How to statically build the "raylib" library on Windows with PureBasic compatibility? (.lib / .a)

(Using Microsoft Visual Studio C compiler or msys2)

Does anyone have experience with this?
It's problematic to build it as a static lib on windows due to conflicting c run times. If you can get hold of the same sdk Fred uses to compile PB on windows you can do it but I think it requires a msdn sub to get the old version he uses.

Also note raylib parses a lot structures by value which is problematic for us in PB but it can be addressed easy enough with inline c I provided a couple of examples of using raylib4 wtih inline c here
viewtopic.php?t=79332
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: [Module] raylib-purebasic (Windows/Linux/macOS)

Post by chi »

ccode_new wrote: Mon Feb 13, 2023 8:52 pm How to statically build the "raylib" library on Windows with PureBasic compatibility? (.lib / .a)
I'm pretty sure you can't! PB's C runtime on Windows is very old and Raylib needs some of the newer features...

Fortunately, you can do it the other way around. I created a custom msvcrt.lib so you can use UCRT with PB (C backend only). Just rename the original msvcrt.lib (PB64Folder\PureLibraries\Windows\Libraries) to msvcrt_orig.lib and copy msvcrt_v143.lib from the zip file to the same folder. Now make a copy of msvcrt_v143.lib and rename it to msvcrt.lib. (Don't forget to rename msvcrt_orig.lib to msvcrt.lib if you want to go back and use the old CRT and/or the ASM backend)

To create a statically linked raylib.lib, just clone the Github repository and open raylib/projects/VS2022/Raylib.sln with VS and compile Release | x64. Replace your libraylib_win_x64.lib with the one you just created and you should be able to compile all examples statically linked without the need for raylib.dll. I've also included the 4.2 lib in the zip.

ray_msvcrt.7z (4.52MB)
Et cetera is my worst enemy
ccode_new
User
User
Posts: 21
Joined: Sat Jul 30, 2022 10:39 am

Re: [Module] raylib-purebasic (Windows/Linux/macOS)

Post by ccode_new »

@chi

Thanks very much!
The replacement of "msvcrt.lib" was successful.

I can now create a static library using "MS Visual Studio" and it works.


Can I tell PureBasic to use a different msvcrt.lib when linking?
So some kind of Makefile for PureBasic?
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: [Module] raylib-purebasic (Windows/Linux/macOS)

Post by chi »

ccode_new wrote: Wed Feb 15, 2023 2:09 am Thanks very much!
The replacement of "msvcrt.lib" was successful.

I can now create a static library using "MS Visual Studio" and it works.
Great, I'm glad to hear that! I wasn't 100% sure if everything would work on another computer...
ccode_new wrote: Wed Feb 15, 2023 2:09 am Can I tell PureBasic to use a different msvcrt.lib when linking?
So some kind of Makefile for PureBasic?
The easiest way would be to write a small IDE plugin to switch between libraries, but you could also intercept the linker command line and replace msvcrt there (but is more complex). I'll come up with something ;)
Et cetera is my worst enemy
Joubarbe
Enthusiast
Enthusiast
Posts: 555
Joined: Wed Sep 18, 2013 11:54 am
Location: France

Re: [Module] raylib-purebasic (Windows/Linux/macOS)

Post by Joubarbe »

Why do I have an error about ASM backend when I try to run any example? I thought PB 6 had a C backend by default?

EDIT: Wow, wait... All that time, I was still on ASM backend, since one of the betas of PB6. There's nothing in the documentation (?), and I had to read about adding the new compiler through the changelog. Something is wrong here.
gltianya
New User
New User
Posts: 6
Joined: Wed Jul 07, 2021 12:02 pm

Re: [Module] raylib-purebasic (Windows/Linux/macOS)

Post by gltianya »

chi wrote: Tue Feb 14, 2023 9:56 pm
ccode_new wrote: Mon Feb 13, 2023 8:52 pm How to statically build the "raylib" library on Windows with PureBasic compatibility? (.lib / .a)
I'm pretty sure you can't! PB's C runtime on Windows is very old and Raylib needs some of the newer features...

Fortunately, you can do it the other way around. I created a custom msvcrt.lib so you can use UCRT with PB (C backend only). Just rename the original msvcrt.lib (PB64Folder\PureLibraries\Windows\Libraries) to msvcrt_orig.lib and copy msvcrt_v143.lib from the zip file to the same folder. Now make a copy of msvcrt_v143.lib and rename it to msvcrt.lib. (Don't forget to rename msvcrt_orig.lib to msvcrt.lib if you want to go back and use the old CRT and/or the ASM backend)

To create a statically linked raylib.lib, just clone the Github repository and open raylib/projects/VS2022/Raylib.sln with VS and compile Release | x64. Replace your libraylib_win_x64.lib with the one you just created and you should be able to compile all examples statically linked without the need for raylib.dll. I've also included the 4.2 lib in the zip.

ray_msvcrt.7z (4.52MB)
Can you provide X86 of ray_msvcrt , or guide how to make it? Especially how to make msvcrt for x86 platform?
Thanks a lot.

Using the msvcrt_v143.lib you provided, I compiled the https://github.com/utelle/SQLite3MultipleCiphers/ source code into a static link library, and initially successfully used it in purebasic.

Steps: Replace msvcrt.lib and sqlite3.lib respectively, and use pbcompilerc.exe as the compilation backend.
English is not my mother tongue, this message is translated by Google
ccode_new
User
User
Posts: 21
Joined: Sat Jul 30, 2022 10:39 am

Re: [Module] raylib-purebasic (Windows/Linux/macOS)

Post by ccode_new »

Hi!

A small update to "RayLib 4.2" follows.

There are still some errors in the PureBasic source code. (From me and from Mr. Krahn)

By implementing the RayLib examples (from the website) or by trying them out, you always get to know new errors.

Update_Beta2.5 ( (March 2023)
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: [Module] raylib-purebasic (Windows/Linux/macOS)

Post by chi »

@ccode_new, @gltianya
You can use RuntimeSwitcher to create a custom msvcrt.lib (x86+x64) and switch between CRT and UCRT.
Et cetera is my worst enemy
Josepho
User
User
Posts: 65
Joined: Thu Oct 22, 2020 7:01 am

Re: [Module] raylib-purebasic (Windows/Linux/macOS)

Post by Josepho »

Hi i download the module from the last post of @code_new and im not getting errors but im not watching anything, am i doing something wrong?

Btw i also was using the asmcompiler the whole time, this was not very obvious to discover, i switched it to the c today
Post Reply