Page 2 of 3

Re: raylib game framework

Posted: Thu Apr 02, 2020 6:44 am
by Josh
Regardless of what Raylib offers, the system would need to be rethought how Pb integrates libs.

Due to the amount of commands in Raylib, Pb's command set becomes less and less transparent, and at some point the user has no room for his own command and variable names.

At some point, it would have to be reconsidered whether a prefixed module name would make sense for libs in general.

Re: raylib game framework

Posted: Sat Apr 04, 2020 5:00 pm
by chi
Josh wrote:Regardless of what Raylib offers, the system would need to be rethought how Pb integrates libs.

Due to the amount of commands in Raylib, Pb's command set becomes less and less transparent, and at some point the user has no room for his own command and variable names.

At some point, it would have to be reconsidered whether a prefixed module name would make sense for libs in general.
Agreed! Besides, it would only make sense if Fred would implement Raylib to PB.

Re: raylib game framework

Posted: Mon Apr 27, 2020 8:40 pm
by Danilo

Re: raylib game framework

Posted: Tue Apr 28, 2020 3:15 pm
by chi
Oh, something is going on :mrgreen:

Re: raylib game framework

Posted: Tue Apr 28, 2020 4:51 pm
by Danilo
Is it okay to let all functions and structures begin with "rl" directly,
and all enumeration begin with "rl::"?

It looks like this (It is from Large Screenshot and shows a rotating scene with 5 cubes)

Code: Select all

ProcedureC MyCustomLogger( logType.rl_int, *text.Ascii )
    Protected msg.s
    If *text
        msg.s = PeekS(*text,-1,#PB_UTF8)
    EndIf
    Debug Str(logType)+": "+msg
EndProcedure

rlSetTraceLogLevel(rl::#LOG_ALL)
rlSetTraceLogCallback( @MyCustomLogger() )

rlSetConfigFlags( rl::#FLAG_VSYNC_HINT       |
                  rl::#FLAG_MSAA_4X_HINT     |
                  rl::#FLAG_WINDOW_RESIZABLE )

rlSetExitKey(rl::#KEY_ESCAPE)

rlInitWindow( 1000, 500, "pbRaylib" )
If Not rlIsWindowReady() ; Error at init!
    End
EndIf

rlSetWindowSize( 0.8*rlGetMonitorWidth(0), 0.6*rlGetMonitorHeight(0) )

rlSetWindowPosition( 0.5 * ( rlGetMonitorWidth(0)  - rlGetScreenWidth()  ),
                     0.5 * ( rlGetMonitorHeight(0) - rlGetScreenHeight() ))

rlTraceLog(rl::#LOG_INFO,"Holla die Waldfee! Let's try Thai: 'สวัสดี ครับ'!")

Debug rlGetMonitorWidth(0)
Debug rlGetMonitorHeight(0)

Define pos.rlVector2
rlGetWindowPosition(@pos)
Debug pos\x
Debug pos\y

Define i
For i = 0 To 10
    Debug rlGetMonitorName(i)
Next

rlSetClipboardText("กลุ่มประเทศผู้ส่งออกน้ำมันหรือโอเปคจะประชุมที่กรุงเวียนนาระหว่างวันที่ 19 ถึง 20 กันยายน เป็นการประชุมตามปกติ แต่ได้รับความสนใจจากชาวโลกอย่างมากเพราะราคาน้ำมันที่ขึ้นสูงในปัจจุบัน")
Debug rlGetClipboardText()

Debug rlGetWorkingDirectory()

Dim files.s(0)
Debug rlGetDirectoryFiles(files(),rlGetWorkingDirectory())
Debug ArraySize(files())


Define camera.rlCamera3D
camera\position\x = 0.0
camera\position\y = 7.0
camera\position\z = 10
camera\target\x = 0.0
camera\target\y = 0.0
camera\target\z = 0.0
camera\up\x = 0.0
camera\up\y = 1.0
camera\up\z = 0.0
camera\fovy = 30.0
camera\type = rl::#CAMERA_ORTHOGRAPHIC
camera\type = rl::#CAMERA_PERSPECTIVE

Define cube1.rlVector3 : cube1\x =  0.0 : cube1\y = 1.0 : cube1\z =  0.0
Define cube2.rlVector3 : cube2\x = -1.5 : cube2\y = 0.5 : cube2\z =  2.5
Define cube3.rlVector3 : cube3\x =  1.5 : cube3\y = 1.5 : cube3\z =  2.5
Define cube4.rlVector3 : cube4\x = -1.5 : cube4\y = 0.5 : cube4\z = -2.5
Define cube5.rlVector3 : cube5\x =  1.5 : cube5\y = 0.6 : cube5\z = -2.5

Repeat
    Define value.f
    value.f + 0.5
    camera\position\x = 0 - Sin(Radian(value)) * 10
    camera\position\z = 0 - Cos(Radian(value)) * 10
    rlBeginDrawing()
        rlClearBackground(RGBA($20,$20,$20,$FF))
        rlBeginMode3D(@camera)
            rlDrawCube     (@cube1,2,2,2,RGBA($FF,$FF,$00,$FF))
            rlDrawCubeWires(@cube1,2,2,2,RGBA($00,$00,$00,$FF))
            rlDrawCube     (@cube2,1,1,1,RGBA($FF,$00,$00,$FF))
            rlDrawCubeWires(@cube2,1,1,1,RGBA($00,$00,$00,$FF))
            rlDrawCube     (@cube3,1,3,1,RGBA($00,$00,$FF,$FF))
            rlDrawCubeWires(@cube3,1,3,1,RGBA($00,$00,$00,$FF))
            rlDrawCube     (@cube4,1,1,1,RGBA($00,$FF,$FF,$FF))
            rlDrawCubeWires(@cube4,1,1,1,RGBA($00,$00,$00,$FF))
            rlDrawCube     (@cube5,1,1.2,1,RGBA($FF,$00,$FF,$FF))
            rlDrawCubeWires(@cube5,1,1.2,1,RGBA($00,$00,$00,$FF))
            rlDrawGrid(10, 1.0)
        rlEndMode3D()
    rlEndDrawing()
Until rlWindowShouldClose() Or rlIsKeyDown(rl::#KEY_ESCAPE)

Re: raylib game framework

Posted: Tue Apr 28, 2020 10:20 pm
by chi
Danilo wrote:Is it okay to let all functions and structures begin with "rl" directly,
and all enumeration begin with "rl::"?
If it's me you're asking, I would prefer "rl_" for functions and structures for better readability. It would also be easier to distinguish between PB and RayLib functions. But maybe that's just me :oops:

Code: Select all

Repeat
  Define value.f
  value.f + 0.5
  camera\position\x = 0 - Sin(Radian(value)) * 10
  camera\position\z = 0 - Cos(Radian(value)) * 10
  rl_BeginDrawing()
    rl_ClearBackground(RGBA($20,$20,$20,$FF))
    rl_BeginMode3D(@camera)
      rl_DrawCube     (@cube1,2,2,2,RGBA($FF,$FF,$00,$FF))
      rl_DrawCubeWires(@cube1,2,2,2,RGBA($00,$00,$00,$FF))
      rl_DrawCube     (@cube2,1,1,1,RGBA($FF,$00,$00,$FF))
      rl_DrawCubeWires(@cube2,1,1,1,RGBA($00,$00,$00,$FF))
      rl_DrawCube     (@cube3,1,3,1,RGBA($00,$00,$FF,$FF))
      rl_DrawCubeWires(@cube3,1,3,1,RGBA($00,$00,$00,$FF))
      rl_DrawCube     (@cube4,1,1,1,RGBA($00,$FF,$FF,$FF))
      rl_DrawCubeWires(@cube4,1,1,1,RGBA($00,$00,$00,$FF))
      rl_DrawCube     (@cube5,1,1.2,1,RGBA($FF,$00,$FF,$FF))
      rl_DrawCubeWires(@cube5,1,1.2,1,RGBA($00,$00,$00,$FF))
      rl_DrawGrid(10, 1.0)
    rl_EndMode3D()
  rl_EndDrawing()
Until rl_WindowShouldClose() Or rl_IsKeyDown(rl::#KEY_ESCAPE)
[/size]
May I ask if you are planning to cover all modules and libs, including rres (when ready) and raygui? humming "I want it all I want it all I want it all.....and I want it now!" :)

Re: raylib game framework

Posted: Tue Apr 28, 2020 11:34 pm
by IdeasVacuum
... I think Chi has a valid point 8)

Re: raylib game framework

Posted: Wed Apr 29, 2020 5:46 am
by Danilo
chi wrote:
Danilo wrote:Is it okay to let all functions and structures begin with "rl" directly,
and all enumeration begin with "rl::"?
If it's me you're asking, I would prefer "rl_" for functions and structures for better readability. It would also be easier to distinguish between PB and RayLib functions. But maybe that's just me :oops:
I would like to make it flexible using macros:

Code: Select all

Macro RAYLIB_PREFIX
    rl_
EndMacro

Macro RAYLIB_NAME(_name_)
    RAYLIB_PREFIX#_name_
EndMacro
The problem is, when you do it like this, you will not get any AutoComplete in the PB IDE.
I think AutoComplete is more important than flexible prefix... so I have to use a fixed one like 'rl_'.

Re: raylib game framework

Posted: Wed Apr 29, 2020 10:14 am
by chi
Danilo wrote:I think AutoComplete is more important than flexible prefix...
RL without AutoComplete would be pretty lame ^^

Speaking of AutoComplete... How about adding the module names to the prefix?

Code: Select all

rl_core_InitWindow()
rl_core_WindowShouldClose()
rl_shapes_DrawPixel()
rl_text_GetFontDefault()

Re: raylib game framework

Posted: Wed Apr 29, 2020 3:52 pm
by Fred
why not using 'rl::' like your constant ?

Re: raylib game framework

Posted: Wed Apr 29, 2020 4:20 pm
by Danilo
Fred wrote:why not using 'rl::' like your constant ?
Because procedure names still collide with PureBasic‘s functions.

Now I import raylib‘s CloseWindow() as rl_CloseWindow(), with
modules I would need to write rl::rl_CloseWindow() ( Double-Whopper ;) ),
because rl::CloseWindow() is not possible with PB.

Re: raylib game framework

Posted: Wed Apr 29, 2020 8:25 pm
by Fred
I see.

Re: raylib game framework

Posted: Wed Apr 29, 2020 11:57 pm
by StarBootics
Josh wrote:Regardless of what Raylib offers, the system would need to be rethought how Pb integrates libs.

Due to the amount of commands in Raylib, Pb's command set becomes less and less transparent, and at some point the user has no room for his own command and variable names.

At some point, it would have to be reconsidered whether a prefixed module name would make sense for libs in general.
I know I'm currently experiencing this with my game developement. The names of the commands are the same as the command some where in certain library. Sometime I'm able to change the names but it's not always easy to do.

I'm considering some sort of tool to remove temporarily the game related libraries while I'm working on my game project.

@Fred : If you consider to add more and more libraries to PureBasic in the future you will have to add a way to tell the compiler to ignore some libraries, maybe project file can store this information to configure the compiler about the libraries to ignore and/or the one to use.

Another way around is to do like in C/C++, you need the Sin() function for example you have to add Include <math.h> in your source code somewhere.

Or like Josh suggested, the standard libraries should be available with module prefix. That way is not really a problem except if you use the "UseModule" keyword because the compiler don't know what function belong to what module.

So you are the boss after all but I hope will figure the problem out and give us a solution soon.

Best regards
StarBootics

Re: raylib game framework

Posted: Sun May 03, 2020 2:24 am
by Danilo
chi wrote:May I ask if you are planning to cover all modules and libs, including rres (when ready) and raygui? humming "I want it all I want it all I want it all.....and I want it now!" :)
Just raylib for now. I think you could translate raygui to PureBasic code easily or code your own GUI. ;)

I switched to using a module few days ago, and for the problematic names I currently just add "Raylib" to the function name, for example:

Code: Select all

; CHANGED FUNCTION NAMES:
;
;   GetClipboardText()          =>  GetClipboardTextRaylib()
;   SetClipboardText()          =>  SetClipboardTextRaylib()
;
;   CloseWindow()               =>  CloseWindowRaylib()
;   SetWindowTitle()            =>  SetWindowTitleRaylib()
;   HideWindow()                =>  HideWindowRaylib()
;
;   LoadImage()                 =>  LoadImageRaylib()
;   ImageFormat()               =>  ImageFormatRaylib()
;   LoadTexture()               =>  LoadTextureRaylib()
;   LoadFont()                  =>  LoadFontRaylib()
[/size]

It's a few names that need to add something, all other functions can be used directly. It looks like this:

Code: Select all

UseModule ray

SetConfigFlags( #FLAG_MSAA_4X_HINT     |
                ;#FLAG_FULLSCREEN_MODE  |
                #FLAG_VSYNC_HINT       |
                #FLAG_WINDOW_RESIZABLE )

SetTraceLogLevel(#LOG_NONE)
SetExitKey(#KEY_ESCAPE)

InitWindow( 1000, 500, "pbRaylib" )

If Not IsWindowReady() ; Error at init!
    End
EndIf

SetTargetFPS(60)

Define camera.Camera3D
InitVector3( @camera\position, 0.0,  10,  15 )
InitVector3( @camera\target,   0.0, 0.0, 0.0 )
InitVector3( @camera\up,       0.0, 1.0, 0.0 )
camera\fovy = 30.0
camera\type = #CAMERATYPE_ORTHOGRAPHIC
camera\type = #CAMERATYPE_PERSPECTIVE

SetCameraMode(@camera, #CAMERAMODE_ORBITAL)

Define cube1.Vector3 : InitVector3( @cube1, 0.0, 1.01,  0.0 )
Define cube2.Vector3 : InitVector3( @cube2,-1.5, 0.51,  2.5 )
Define cube3.Vector3 : InitVector3( @cube3, 1.5, 1.51,  2.5 )
Define cube4.Vector3 : InitVector3( @cube4,-1.5, 0.51, -2.5 )
Define cube5.Vector3 : InitVector3( @cube5, 1.5, 0.61, -2.5 )
Define grnd.Vector3  : InitVector3( @grnd , 0.0,-0.05,  0.0 )

NewList cubes.Vector3()
AddElement(cubes())
InitVector3( @cubes(), 0.0, 2.52, 0.0 )

Define.Vector2 v1, v2, v3, v4
InitVector2( @v1,  0,200 ) : InitVector2( @v2,100,500 )
InitVector2( @v3,100,500 ) : InitVector2( @v4,400,800 )

Define sector.Vector2 : InitVector2(@sector,204,504)

Repeat
    UpdateCamera(@camera)
    BeginDrawing()
        ClearBackground(#COLOR_RAYWHITE)
        BeginMode3D(@camera)
            DrawCube     (@grnd ,10,0.09,10,RGBA($90,$90,$90,$FF))
            DrawCube     (@cube1,2,  2,2,RGBA($FF,$FF,$00,$FF))
            DrawCubeWires(@cube1,2,  2,2,RGBA($00,$00,$00,$FF))
            DrawCube     (@cube2,1,  1,1,RGBA($FF,$00,$00,$FF))
            DrawCubeWires(@cube2,1,  1,1,RGBA($00,$00,$00,$FF))
            DrawCube     (@cube3,1,  3,1,RGBA($00,$00,$FF,$FF))
            DrawCubeWires(@cube3,1,  3,1,RGBA($00,$00,$00,$FF))
            DrawCube     (@cube4,1,  1,1,RGBA($00,$FF,$FF,$FF))
            DrawCubeWires(@cube4,1,  1,1,RGBA($00,$00,$00,$FF))
            DrawCube     (@cube5,1,1.2,1,RGBA($FF,$00,$FF,$FF))
            DrawCubeWires(@cube5,1,1.2,1,RGBA($00,$00,$00,$FF))
            BeginBlendMode(#BLEND_ALPHA)
                DrawCubeWires(@cubes(),1,1,1,RGBA($00,$00,$00,$FF))
                DrawCube     (@cubes(),1,1,1,RGBA($F0,$F0,$F0,$80))
            EndBlendMode()
            DrawGrid(20, 0.5)
        EndMode3D()
        DrawCircleGradient(200,200,100,    RGBA($00,$00,$00,$FF),RGBA($FF,$FF,$00,$FF))
        DrawEllipse       (450,200,100,100,RGBA($00,$00,$00,$FF))
        DrawEllipseLines  (450,200,101,101,RGBA($FF,$FF,$00,$FF))
        DrawEllipseLines  (450,200,100,100,RGBA($FF,$FF,$00,$80))
        DrawEllipseLines  (450,200,102,102,RGBA($FF,$FF,$00,$80))

        DrawRectangleGradientH(600,100,100,100,RGBA($00,$00,$00,$FF),RGBA($FF,$FF,$00,$FF))
        DrawRectangleGradientV(750,100,100,100,RGBA($00,$00,$00,$FF),RGBA($FF,$FF,$00,$FF))
        
        DrawLineBezier(@v1,@v2,3,RGBA($00,$FF,$FF,$FF))
        DrawLineBezier(@v3,@v4,3,RGBA($00,$FF,$FF,$FF))
        
        DrawCircleSector     (@sector, 200, 0, 360, 8, RGBA($40,$40,$FF,$FF))
        DrawCircleSectorLines(@sector, 200, 0, 360, 8, RGBA($00,$00,$00,$FF))
        
        ;DrawRectangle(5,8,83,23,RGBA($00,$00,$00,$FF))
        DrawFPS(10,10)
    EndDrawing()
    If IsKeyPressed(#KEY_F1)
        TakeScreenshot("example_004.png")
    EndIf
Until WindowShouldClose() Or IsKeyDown(#KEY_ESCAPE)
[/size]

Re: raylib game framework

Posted: Sun May 03, 2020 10:50 am
by Cyllceaux
"long time ago" I started to port it by myself. I stopped it cause of ByVal Structures. (Pure Basic did not support it)
I wrote with ray about this and he said, I have to write my own wrapper in C. :(
Now he support pointers vor structures... which is great :)