GLBasic forum

Codesnippets => Inline / 3rd party => Topic started by: Schranz0r on 2020-May-03

Title: Raylib for GLBasic! (hosted on Github)
Post by: Schranz0r on 2020-May-03
HUHU,

i start a new Project, and it works nice so far! :)

(https://github.com/SliverLIVE/RayLib/raw/master/raylib_for_glbasic.png)
GITHUB (https://github.com/SliverLIVE/Raylib-for-GLBasic)

This (https://github.com/SliverLIVE/Raylib-for-GLBasic (https://github.com/SliverLIVE/Raylib-for-GLBasic)) is a wrapper from this: https://www.raylib.com (https://www.raylib.com)
Instructions on Github. Feel free to help on this!
I also need maybe a better way to handle the Structs (Font, Image, Texture, Vector4, Vector3...) in GLBasic...
Any suggestions are welcome :)
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: Qedo on 2020-May-04
Congratulations Schranz0r very very very interesting project.
I will try it to understand the potential that seems high.
One question: What about multi-platform? think of Android and others
Thank you so much
Ciao
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: Schranz0r on 2020-May-04
It's Cross platform, so it should be fine on Android.  :good:
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: Schranz0r on 2020-May-04
So i changed the way to handle things!
The Types from GLBasic are now the same as the Structs from Raylib.
All functions and Types related to Raylib starting with the prefix "RL_"

Sample Code:
Code: (glbasic) [Select]
LOCAL Title$ = "Raylib for GLBasic!"

RL_InitWindow(800,600, Title$)
RL_SetTargetFPS(60)


LOCAL col_lightgray AS RL_Color
col_lightgray.Set(200, 200, 200, 255)

LOCAL col_raywhite AS RL_Color
col_raywhite.Set(245, 245, 245, 255)

LOCAL col_red AS RL_Color
col_red.Set(255, 0, 0,255)


LOCAL fnt_default AS RL_Font
fnt_default = RL_GetFontDefault()

LOCAL fnt_PermMarker AS RL_Font
fnt_PermMarker = RL_LoadFont("fonts/PermanentMarker.ttf")

WHILE NOT RL_WindowShouldClose()

RL_BeginDrawing()

RL_ClearBackground(col_lightgray)
RL_DrawText("Congrats! You created your first window!", 190, 200, 20, col_red)
RL_DrawTextEx(fnt_PermMarker, "Oh, hi...! I'm the new Font!", 200, 250, 40, 2, col_raywhite)

RL_EndDrawing()

WEND

RL_CloseWindow()
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: dreamerman on 2020-May-04
Very interesting.. This may be huge for several reasons. As RayLib is cross platform, based on OpenGL and support WebGL and has 2d, 3d, music, net, compression, win related functions and so on. It all depends on how much it's mature or rather tested on real devices like mobiles and how much effort is put to keep it compatible with recent Android updates. I'm curious about that, due all current Android problems and absence of other platforms like Linux in GLB. Another big advantage over other such solutions is no dependencies for other libraries, no crazy problems with compilation.

For me important thing is that in contrast to many other 'game dev libraries' here You have access to more basic drawing routines, and some equivalent to GLB StartPoly / PolyVector can be written, so let's say some handmade spriteBatch functions - as this allows for multi layer animated tile map and so on. On other hand it goes on current GLBasic status with compilation for HTML5-WebGL (that could be used on iOS/MacOS), and all Android problems.

btw. using RL_ as prefix may be most readable and clean solution for GLB - adding some object interface can cause issues with other things.
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: Schranz0r on 2020-May-04
Hi dreamerman,

if you like/can/want, you can help me with this :)
Have some other ideas in mind!  :x
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: bigsofty on 2020-May-05
Nicely done sir! Too late to look at it tonight, will enjoy a proper look tomorrow.  :good:
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: spacefractal on 2020-May-05
the main problem is its not combatible with current glbasic apps and is impossible to redone and update those, newer for the bigger projects. So we should not breaking that combatible at all with old apps. This is actuelly very important. Combatible was also in mind when im added some Android features to a GLBASIC command directly as its should been.

Gernot would not like to breaking combatible with old apps at all as well. A beginner cant property use this too.

But a Plugin system in glbasic would been very great. etc a way possible to automatic replace a glbasic command to a suitable FUNCTION used by the wrapper, etc a Prototype list, that can been picked up by the PRECOMPILER.

But dont mind me, this such of a project is very great and sure its can been done. Im take a look how such a wrapper can been done later. This is NOT important now at all! Get it work first is first priotity.

EDIT: Im have a idea how to do that by replacing g++ to launch the "wrapper" tool first and then g++ from the tool to perform that task. So dont think about that by now. Im need to do that tool first.
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: Schranz0r on 2020-May-05
But, to make it work from the compiler i have to wrapp it in the Sourcecode (c/c++)...
And wrapp this in C++ is much easier then in GLBasic itself!

In Source: Add Lib, Include Headerfile

Pseudo-code:
Code: (glbasic) [Select]
namespace Raylib{
    void SETSCREEN(int width, int height, bool fullscreen)
    {
        InitWindow(width, height, __GLBASIC__::project_name.c_str()); // didn't know the internal projectname... :)
        if(fullscreen)
            ToggleFullscreen();
    }
}

no need to wrapp the whole thing in a gbas file, simple direkt calls...
This way you can say to the compiler to use the Raylib:: and not the __GLBASIC__:: namespace for this functions
 
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: spacefractal on 2020-May-05
using namespace can been complicered, a least for me, which require updating glb.h file as well me thinks. But its dont matter at all how!

We do a plugin system later. Its actuelly not important now. But later its will. But im have a idea about it.

We do defensivt need a tool to do that before launching the final exe code (g++).
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: SnooPI on 2020-May-06
Awesome Schranz0r!  :good:

But you don't continue your Irrlicht Wrapper?
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: Schranz0r on 2020-May-09
@SnooPI:
I just start the Wrapper from Irrlicht-Engine, was never into it to complete it ^^

Update to Raylib:

All Core-Functions are now in!
See https://www.raylib.com/cheatsheet/cheatsheet.html for what's inside Core!
Only one function is skipped: void SetTraceLogCallback(TraceLogCallback callback);
I see no use, and didn't know how to do it in GLBasic atm. :)
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: bigsofty on 2020-May-09
Great stuff and a lot of fun to mess around with, thank you Schranz0r!  :happy:

One thing, did you write a Raylib to GLB parser type of util or did you do the conversion by hand (via find/replace etc.) for all the various calls/enums?
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: Schranz0r on 2020-May-10
For the functions i wrote a program, just a simple one...
I do the most part by hand :)
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: bigsofty on 2020-May-10
Cool beans, I may try to convert some of the C demos if I get the time to GLB, I'll keep you informed how this works out. ;)
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: Schranz0r on 2020-May-11
Nice, maybe we can include it then into the Repo.
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: erico on 2020-May-12
Superb project!
I will have to give it a go! :)
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: Heiko on 2020-May-20
Really nice Schranz0r.
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: dreamerman on 2020-Jun-05
Sadly I don't have to much free time, and can't participate in this at moment. This is a great example how to use C++ inline and external libraries, I'll need to take a deep look into it to see better way of using Steam API if possible.
Quote from: Schranz0r
no need to wrapp the whole thing in a gbas file, simple direkt calls...
This way you can say to the compiler to use the Raylib:: and not the __GLBASIC__:: namespace for this functions
So Your saying that there is a possibility to override all standard GLB functions this way and use this as alternative? Very interesting, and may be very useful - in case of bugs/instability in core GLB, testing performance and as final build target. From what I saw on raylib webdoc additional libs may be needed in case of need for additional stuff like rumble effects - SDL2.
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: SnooPI on 2020-Jun-06
Very good job Schranz0r.

But you know very well that for RAYLIB you must compile in DOS mode, and therefore program completely differently from GLB.
I'm not sure that GLB programmers like this  ;)
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: Schranz0r on 2020-Jun-06
It is working very well SnooPI! :)
Were did you get that information about "DOS-Mode"?
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: SnooPI on 2020-Jun-07
RAYLIB creates its own opengl context... no?

So you have to do it in dos mode if you don't want to have more than one context.
At least according to my logic, but maybe I'm wrong  :-[
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: MrPlow on 2020-Jun-08
Oooh - this looks nice :)
Title: Re: Raylib for GLBasic! (hosted on Github)
Post by: siatek on 2021-Mar-22
Well done  Mr. Schranz0r