raylib headers

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
BasicCoder2
Posts: 3524
Joined: Jan 01, 2009 7:03

Re: raylib headers

Postby BasicCoder2 » Mar 27, 2020 23:25

Where should I extract the raylib-2.6.0-Win32-migw folder to?
I extracted the raylib-fb-master folder to C:/FreeBASIC/
paul doe
Posts: 1175
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: raylib headers

Postby paul doe » Mar 28, 2020 0:06

Inside the raylib-2.6.0-Win32-mingw zip, in the /bin folder, it's the binary (the .dll) you need. Dump it into the folder where the examples are. You should then be able to run them.
paul doe
Posts: 1175
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: raylib headers

Postby paul doe » Mar 28, 2020 0:15

@fxm: I see that sancho3 reviewed the topic 'Using libraries in FreeBasic' by SJ Zero on February 06, 2018, under 'Community Tutorials'. Mind if I rewrite it completely? (it's quite outdated by now). Also, I think a link to it directly in the Table of Contents might prove useful, since this has to be one of the issues that trip beginners the most...
BasicCoder2
Posts: 3524
Joined: Jan 01, 2009 7:03

Re: raylib headers

Postby BasicCoder2 » Mar 28, 2020 0:29

paul doe wrote:Inside the raylib-2.6.0-Win32-mingw zip, in the /bin folder, it's the binary (the .dll) you need. Dump it into the folder where the examples are. You should then be able to run them.


Now it complains "The code execution cannot proceed because libgcc_s_dw2-1.dll was not found. Reinstalling the program may fix this problem."
Not sure what "reinstalling the program" involves.
paul doe
Posts: 1175
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: raylib headers

Postby paul doe » Mar 28, 2020 0:37

@BasicCoder2: see here for a description of the problem you're having:

https://www.freebasic.net/forum/viewtopic.php?f=14&t=28380&start=15#p269653

Or you can use the 64-bit version which does not have the issue you're reporting (the dll itself needs another one, the gcc runtime).

@Joshy: any chance you can provide the 32-bit binaries with gcc's runtime statically linked, if you have them handy?
jepalza
Posts: 61
Joined: Feb 24, 2010 10:08
Location: Spain (Bilbao)

Re: raylib headers

Postby jepalza » May 10, 2020 10:42

Example converted from C to FB

Fichero "arkanoid.bas"

Code: Select all

/'******************************************************************************************
*
*   raylib - sample game: arkanoid
*
*   Sample game Marc Palau and Ramon Santamaria
*
*   This game has been created using raylib v1.3 (www.raylib.com)
*   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
*   Copyright (c) 2015 Ramon Santamaria (@raysan5)
*
*******************************************************************************************'/
#include "raylib.bi"


#Define BOOL UByte


#define PLAYER_MAX_LIFE         5
#define LINES_OF_BRICKS         5
#define BRICKS_PER_LINE        20

enum GameScreen
   LOGO=0 , TITLE, GAMEPLAY, ENDING
End Enum

type Player2
    As Vector2 position
    As Vector2 SIZE
    As Integer life
End type

type Ball2
    As Vector2 position
    As Vector2 speed
    As Integer radius
    As BOOL active
End Type

type Brick2
    As Vector2 position
    As BOOL active
End Type

Dim Shared as BOOL gameOver  = FALSE
Dim Shared as BOOL pause  = FALSE
Dim Shared as Player2 player 
Dim Shared as Ball2 ball 
Dim Shared as Brick2 brick(LINES_OF_BRICKS,BRICKS_PER_LINE)
Dim Shared as Vector2 brickSize



Declare Sub InitGame()           ' Initialize game
Declare Sub UpdateGame()         ' Update game (one frame)
Declare Sub DrawGame()           ' Draw game (one frame)
Declare Sub UnloadGame()         ' Unload game
Declare Sub UpdateDrawFrame()    ' Update and Draw (one frame)

Dim Shared As Integer screenWidth,screenHeight
screenWidth=1024
screenHeight=768

    InitWindow(screenWidth, screenHeight, "sample game: arkanoid")
    InitGame()

    SetTargetFPS(60)
    while ( Not WindowShouldClose() )    ' Detect window close button or ESC key
        UpdateDrawFrame()
    Wend

    UnloadGame()         ' Unload loaded data (textures, sounds, models...)
    CloseWindow()        ' Close window and OpenGL context
    End

Sub InitGame()
    brickSize = type( GetScreenWidth()/BRICKS_PER_LINE, 40 )
    ' initialize player
    player.position = Type( screenWidth/2, screenHeight*7/8 )
    player.size = Type( screenWidth/10, 20 )
    player.life = PLAYER_MAX_LIFE
    ' initialize ball
    ball.position = Type( screenWidth/2, screenHeight*7/8 - 30 )
    ball.speed = Type( 0, 0 )
    ball.radius = 7
    ball.active = FALSE
    'initialize bricks
    Dim As Integer initialDownPosition = 50
    for i As Integer= 0 To  LINES_OF_BRICKS-1
        for j As Integer = 0 to BRICKS_PER_LINE-1
            brick(i, j).position = Type ( j*brickSize.x + brickSize.x/2, i*brickSize.y + initialDownPosition)
            brick(i, j).active = TRUE
        Next
    Next
End Sub

Sub UpdateGame()
   If gameOver=0 Then
       If IsKeyPressed(Asc("P")) Then pause =  Not pause
      If pause=0 Then ' Player movement logic
     
         If (IsKeyDown(KEY_LEFT)) then player.position.x -= 5
         if ((player.position.x - player.size.x/2) <= 0) Then player.position.x = player.size.x/2
         if (IsKeyDown(KEY_RIGHT)) Then player.position.x += 5
         if ((player.position.x + player.size.x/2) >= screenWidth) Then player.position.x = screenWidth - player.size.x/2
       
           ' ball launching loic
         if ball.active=0 Then
            if (IsKeyPressed(KEY_SPACE)) Then
                 ball.active = TRUE
                 ball.speed = Type ( 0, -5 )
            End If
         End If
         
         ' ball movement logic
         if (ball.active) Then
            ball.position.x += ball.speed.x
            ball.position.y += ball.speed.y
         Else
             ball.position = Type( player.position.x, screenHeight*7/8 - 30 )
         End If
         
         ' Collision logic: ball vs walls
         if (((ball.position.x + ball.radius) >= screenWidth) Or ((ball.position.x - ball.radius) <= 0)) Then ball.speed.x *= -1
         if ((ball.position.y - ball.radius) <= 0) Then ball.speed.y *= -1
         if ((ball.position.y + ball.radius) >= screenHeight) Then
            ball.speed = Type (0, 0 )
            ball.active = FALSE
            player.life-=1
         End If
         
         ' Collision logic: ball vs player
         if (CheckCollisionCircleRec(ball.position, ball.radius, _
             Type ( player.position.x - player.size.x/2, player.position.y - player.size.y/2, player.size.x, player.size.y) )) Then
             if (ball.speed.y > 0) Then
                 ball.speed.y *= -1
                 ball.speed.x = (ball.position.x - player.position.x)/(player.size.x/2)*5
             End If
         End If
         
         '  Collision logic: ball vs bricks
         for i As integer= 0 To LINES_OF_BRICKS-1
             for j As Integer= 0 To BRICKS_PER_LINE-1
                 If (brick(i, j).active) Then
                    If ( ((ball.position.y - ball.radius) <= (brick(i, j).position.y + brickSize.y/2))  And _
                            ((ball.position.y - ball.radius) > (brick(i, j).position.y + brickSize.y/2 + ball.speed.y))  And _
                            ((Abs(ball.position.x - brick(i, j).position.x)) < (brickSize.x/2 + ball.radius*2/3))  And  (ball.speed.y < 0)) Then
                            brick(i, j).active = FALSE
                            ball.speed.y *= -1
                    ElseIf (((ball.position.y + ball.radius) >= (brick(i, j).position.y - brickSize.y/2))  And _
                            ((ball.position.y + ball.radius) < (brick(i, j).position.y - brickSize.y/2 + ball.speed.y))  And _
                            ((Abs(ball.position.x - brick(i, j).position.x)) < (brickSize.x/2 + ball.radius*2/3))  And  (ball.speed.y > 0)) Then
                            brick(i, j).active = FALSE
                            ball.speed.y *= -1
                    ElseIf (((ball.position.x + ball.radius) >= (brick(i, j).position.x - brickSize.x/2))  And _
                            ((ball.position.x + ball.radius) < (brick(i, j).position.x - brickSize.x/2 + ball.speed.x))  And _
                            ((Abs(ball.position.y - brick(i, j).position.y)) < (brickSize.y/2 + ball.radius*2/3))  And  (ball.speed.x > 0)) Then
                            brick(i, j).active = FALSE
                            ball.speed.x *= -1
                    ElseIf (((ball.position.x - ball.radius) <= (brick(i, j).position.x + brickSize.x/2))  And _
                            ((ball.position.x - ball.radius) > (brick(i, j).position.x + brickSize.x/2 + ball.speed.x))  And _
                            ((abs(ball.position.y - brick(i, j).position.y)) < (brickSize.y/2 + ball.radius*2/3))  And  (ball.speed.x < 0)) Then
                            brick(i, j).active = FALSE
                            ball.speed.x *= -1
                    End If
                 End If
             Next
         Next
           
         ' Game over logic
         if (player.life <= 0) Then
            gameOver = TRUE
         Else
            gameOver = TRUE
         
             For i As Integer= 0 To  LINES_OF_BRICKS-1
                 For j As Integer = 0 to BRICKS_PER_LINE-1
                      if (brick(i, j).active) Then gameOver = FALSE
                 Next
             Next
         End If
         
      End If     
   Else
     if (IsKeyPressed(KEY_ENTER)) Then
         InitGame()
       gameOver = FALSE
     End If
   End If
     
End Sub

Sub DrawGame()
    BeginDrawing()
        ClearBackground(RAYWHITE)
        if gameOver=0 Then
              ' Draw player bar
              DrawRectangle(player.position.x - player.size.x/2, player.position.y - player.size.y/2, player.size.x, player.size.y, BLACK)
            for i As Integer = 0 To player.life-1
               DrawRectangle(20 + 40*i, screenHeight - 30, 35, 10, LIGHTGRAY)
            Next
            DrawCircleV(ball.position, ball.radius, MAROON)
             For i As Integer= 0 To  LINES_OF_BRICKS-1
              for j As Integer = 0 to BRICKS_PER_LINE-1
                    if (brick(i, j).active) Then
                        if ((i + j) mod 2 = 0) Then
                            DrawRectangle(brick(i, j).position.x - brickSize.x/2, brick(i, j).position.y - brickSize.y/2, brickSize.x, brickSize.y, GRAY)
                        else
                            DrawRectangle(brick(i, j).position.x - brickSize.x/2, brick(i, j).position.y - brickSize.y/2, brickSize.x, brickSize.y, DARKGRAY)
                        End If
                    End If
               Next
             Next

            if (pause) Then DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY)
        else
             DrawText("PRESS (ENTER) TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS (ENTER) TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY)
        End If
       
    EndDrawing()
End Sub

Sub UnloadGame()
End Sub

Sub UpdateDrawFrame()
    UpdateGame()
    DrawGame()
End Sub

jepalza
Posts: 61
Joined: Feb 24, 2010 10:08
Location: Spain (Bilbao)

Re: raylib headers

Postby jepalza » May 10, 2020 11:23

Another one. Camera perspective.

Code: Select all

/'******************************************************************************************
*
*   raylib [models] example - Show the difference between perspective and orthographic projection
*
*   This program is heavily based on the geometric objects example
*
*   This example has been created using raylib 2.0 (www.raylib.com)
*   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
*   Example contributed by Max Danielsson (@autious) and reviewed by Ramon Santamaria (@raysan5)
*
*   Copyright (c) 2018 Max Danielsson (@autious) and Ramon Santamaria (@raysan5)
*
*******************************************************************************************'/

#include "raylib.bi"

#define FOVY_PERSPECTIVE    45.0f
#define WIDTH_ORTHOGRAPHIC  10.0f

    Dim As Integer screenWidth = 800
    Dim As Integer screenHeight = 450
   
    InitWindow(screenWidth, screenHeight, "raylib (models) example - geometric shapes")
   
    Dim As Camera camera
    camera.position = Type ( 0.0f, 10.0f, 10.0f )
    camera.target = Type ( 0.0f, 0.0f, 0.0f )
    camera.up = Type ( 0.0f, 1.0f, 0.0f )
    camera.fovy = 45.0f
    camera.type = CAMERA_PERSPECTIVE
   
    SetTargetFPS(60)               ' Set our game to run at 60 frames-per-second
   
    While (WindowShouldClose()=0)    ' Detect window close button or ESC key
        if (IsKeyPressed(KEY_SPACE)) Then
            if (camera.type = CAMERA_PERSPECTIVE) Then
                camera.fovy = WIDTH_ORTHOGRAPHIC
                camera.type = CAMERA_ORTHOGRAPHIC
            Else
                camera.fovy = FOVY_PERSPECTIVE
                camera.type = CAMERA_PERSPECTIVE
            End If
        End If
       

        BeginDrawing()
            ClearBackground(RAYWHITE)
            BeginMode3D(camera)
                DrawCube(Type (-4.0f, 0.0f, 2.0f), 2.0f, 5.0f, 2.0f, RED)
                DrawCubeWires(Type (-4.0f, 0.0f, 2.0f), 2.0f, 5.0f, 2.0f, GOLD)
                DrawCubeWires(Type (-4.0f, 0.0f, -2.0f), 3.0f, 6.0f, 2.0f, MAROON)
                DrawSphere(Type (-1.0f, 0.0f, -2.0f), 1.0f, GREEN)
                DrawSphereWires(Type (1.0f, 0.0f, 2.0f), 2.0f, 16, 16, LIME)
                DrawCylinder(Type (4.0f, 0.0f, -2.0f), 1.0f, 2.0f, 3.0f, 4, SKYBLUE)
                DrawCylinderWires(Type (4.0f, 0.0f, -2.0f), 1.0f, 2.0f, 3.0f, 4, DARKBLUE)
                DrawCylinderWires(Type (4.5f, -1.0f, 2.0f), 1.0f, 1.0f, 2.0f, 6, BROWN)
                DrawCylinder(Type (1.0f, 0.0f, -4.0f), 0.0f, 1.5f, 3.0f, 8, GOLD)
                DrawCylinderWires(Type (1.0f, 0.0f, -4.0f), 0.0f, 1.5f, 3.0f, 8, PINK)
                DrawGrid(10, 1.0f)        ' Draw a grid
            EndMode3D()
            DrawFPS(10, 10)
        EndDrawing()

    Wend
   
    CloseWindow()       ' Close window and OpenGL context
jepalza
Posts: 61
Joined: Feb 24, 2010 10:08
Location: Spain (Bilbao)

Re: raylib headers

Postby jepalza » May 10, 2020 11:24

3D Walk

Code: Select all

/'******************************************************************************************
*
*   raylib (core) example - 3d camera first person
*
*   This example has been created using raylib 1.3 (www.raylib.com)
*   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
*   Copyright (c) 2015 Ramon Santamaria (@raysan5)
*
*******************************************************************************************'/
#include "raylib.bi"

#define MAX_COLUMNS 20


    Dim As Integer  screenWidth = 800
    Dim As Integer  screenHeight = 450
   
    InitWindow(screenWidth, screenHeight, "raylib (core) example - 3d camera first person")
   
    Dim As Camera camera
    camera.position = type ( 4.0f, 2.0f, 4.0f )
    camera.target = type ( 0.0f, 1.8f, 0.0f )
    camera.up = type ( 0.0f, 1.0f, 0.0f )
    camera.fovy = 60.0f
    camera.type = CAMERA_PERSPECTIVE
   
    Dim As Single heights(MAX_COLUMNS)
    Dim As Vector3 positions(MAX_COLUMNS)
    Dim As Color colors(MAX_COLUMNS)
   
    for i As integer = 0 To MAX_COLUMNS-1
        heights(i) = GetRandomValue(1, 12)
        positions(i) = type ( GetRandomValue(-15, 15), heights(i)/2, GetRandomValue(-15, 15) )
        colors(i) = Type ( GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 )
    Next
   
    SetCameraMode(camera, CAMERA_FIRST_PERSON) ' Set a first person camera mode
    SetTargetFPS(60)                           ' Set our game to run at 60 frames-per-second
   
    while WindowShouldClose()=0                ' Detect window close button or ESC key
        UpdateCamera(@camera)                  ' Update camera
        BeginDrawing()
            ClearBackground(RAYWHITE)
            BeginMode3D(camera)
                DrawPlane(type ( 0.0f, 0.0f, 0.0f ), Type( 32.0f, 32.0f ), LIGHTGRAY) ' Draw ground
                DrawCube(type ( -16.0f, 2.5f, 0.0f ), 1.0f, 5.0f, 32.0f, BLUE)     ' Draw a blue wall
                DrawCube(type ( 16.0f, 2.5f, 0.0f ), 1.0f, 5.0f, 32.0f, LIME)      ' Draw a green wall
                DrawCube(type ( 0.0f, 2.5f, 16.0f ), 32.0f, 5.0f, 1.0f, GOLD)     ' Draw a yellow wall
                for  i As integer= 0 To MAX_COLUMNS-1
                    DrawCube(positions(i), 2.0f, heights(i), 2.0f, colors(i))
                    DrawCubeWires(positions(i), 2.0f, heights(i), 2.0f, MAROON)
               Next
            EndMode3D()
            DrawRectangle( 10, 10, 220, 70, Fade(SKYBLUE, 0.5f))
            DrawRectangleLines( 10, 10, 220, 70, BLUE)
            DrawText("First person camera default controls:", 20, 20, 10, BLACK)
            DrawText("- Move with keys: W, A, S, D", 40, 40, 10, DARKGRAY)
            DrawText("- Mouse move to look around", 40, 60, 10, DARKGRAY)
        EndDrawing()
    Wend
    CloseWindow()       ' Close window and OpenGL context


c-sanchez
Posts: 126
Joined: Dec 06, 2012 0:38

Re: raylib headers

Postby c-sanchez » May 13, 2020 18:58

Thank you very much by port raylib to freebasic :D
That is really cool :D

By the way, it would also be cool to have a port of raygui
https://github.com/raysan5/raygui
Looks nice to make immediate-mode interfaces, I guess is a good alternative to wxwidgets, qt, gtk, ingui, etc
Coolman
Posts: 228
Joined: Nov 05, 2010 15:09

Re: raylib headers

Postby Coolman » May 15, 2020 17:10

Yeah, that would be a really good thing for freebasic.
Mysoft
Posts: 776
Joined: Jul 28, 2005 13:56
Location: Brazil, Santa Catarina, Indaial (ouch!)
Contact:

Re: raylib headers

Postby Mysoft » May 16, 2020 16:17

who was the genius bright fellow, that converted a beauty .h interface into fellow garbage OOP?? genius people these days...
Mysoft
Posts: 776
Joined: Jul 28, 2005 13:56
Location: Brazil, Santa Catarina, Indaial (ouch!)
Contact:

Re: raylib headers

Postby Mysoft » May 16, 2020 16:44

ok fixed that sagacity... removed all fantastic oop code... and all fake boolean... as well fixed all sources that were using 'not' as logic when its boolean... later i will submit the fix to my github and i wont bother doing a pull request... as the author is probabily to bright to want to fix it anyway...

https://drive.google.com/open?id=1X6-lx ... ErIiutMchu
counting_pine
Site Admin
Posts: 6190
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: raylib headers

Postby counting_pine » May 17, 2020 15:40

Hi Mysoft,
I'm glad that you found the headers posted here useful enough to adapt to your needs.
Any improvements or contributions you want to make to the code are welcomed, and other people here may perhaps find them useful.
But I'm sorry - we don't want that kind of abusive language or unconstructive criticism here.
I request that you redact the offensive content in your posts.
Thanks.
jepalza
Posts: 61
Joined: Feb 24, 2010 10:08
Location: Spain (Bilbao)

Re: raylib headers

Postby jepalza » May 18, 2020 5:41

Mysoft wrote:ok fixed that sagacity... removed all fantastic oop code... and all fake boolean... as well fixed all sources that were using 'not' as logic when its boolean... later i will submit the fix to my github and i wont bother doing a pull request... as the author is probabily to bright to want to fix it anyway...


Your words seem VERY offensive to me. You're not the smartest guy in the world to fix something. You should be a little more humble. We are in this forum for fun, not out of obligation or making money. If you are so smart, you should sign at NASA, and leave us to the poor mortals who are idiots, according to you.

In other matter, you have NOT fixed the examples, NONE does not work. You have left it half done.
IchMagBier
Posts: 52
Joined: Jan 13, 2018 8:47
Location: Germany
Contact:

Re: raylib headers

Postby IchMagBier » May 18, 2020 6:54

Mysoft wrote:who was the genius bright fellow, that converted a beauty .h interface into fellow garbage OOP?? genius people these days...

Hey, that was me :)
Good to hear, that you like my work. I have added some constructors to Raylib's structs, no OOP besides that. They are completely optional though and only needed in the examples.

Mysoft wrote:https://drive.google.com/open?id=1X6-lxjIjRED9qOcYLtt9N3ErIiutMchu

Be sure to change the examples as well, they do not work without the constructors.

c-sanchez wrote:By the way, it would also be cool to have a port of raygui
https://github.com/raysan5/raygui
Looks nice to make immediate-mode interfaces, I guess is a good alternative to wxwidgets, qt, gtk, ingui, etc

I am looking for a good GUI-toolkit aswell, since I do not really like working with GTK-3 and QT seems rather expensive for any commercial work. I may look into Raygui, but I would prefer a GUI that looks native to the operating system it is running on.

Return to “Libraries”

Who is online

Users browsing this forum: Bing [Bot] and 7 guests