[Module] raylib-purebasic (Windows/Linux/macOS)
Re: [Module] raylib-purebasic (Windows/Linux/macOS)
Some simple raygui controls are now available:
Label, Button, LabelButton, ImageButton, CheckBox, ProgressBar, Slider, SliderBar, Toggle, ToggleGroup, StatusBar, GroupBox, Panel
Label, Button, LabelButton, ImageButton, CheckBox, ProgressBar, Slider, SliderBar, Toggle, ToggleGroup, StatusBar, GroupBox, Panel
Re: [Module] raylib-purebasic (Windows/Linux/macOS)
great stuff thanks
Re: [Module] raylib-purebasic (Windows/Linux/macOS)
Looks really nice Danilo. I am definitely keeping my eye on your work with this.Danilo wrote:Some simple raygui controls are now available:
Label, Button, LabelButton, ImageButton, CheckBox, ProgressBar, Slider, SliderBar, Toggle, ToggleGroup, StatusBar, GroupBox, Panel
Best wishes to the PB community. Thank you for the memories.
Re: [Module] raylib-purebasic (Windows/Linux/macOS)
Hi Danilo
This is a great work !
Best regards Saki
This is a great work !
Best regards Saki
地球上の平和
Re: [Module] raylib-purebasic (Windows/Linux/macOS)
Hello,
i just downloaded your raylib-Purebasic-Extension and i would like to thank you very much, its exactly what i am looking for.
I am working / compiling under MacOS Catalina with PureBasic 5.72 (x86).
Because some examples from the raylib-website are missing, i decided to add my first contribution, its the "models-cubicmap"-Example converted to PureBasic:
I compiles and runs unter MacOS-Catalina.
Best regards,
Mathias
i just downloaded your raylib-Purebasic-Extension and i would like to thank you very much, its exactly what i am looking for.
I am working / compiling under MacOS Catalina with PureBasic 5.72 (x86).
Because some examples from the raylib-website are missing, i decided to add my first contribution, its the "models-cubicmap"-Example converted to PureBasic:
Code: Select all
;*******************************************************************************************
;*
;* raylib [models] example - Cubicmap loading and drawing
;*
;* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM)
;*
;* This example has been created using raylib 1.8 (www.raylib.com)
;* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
;*
;* Copyright (c) 2015 Ramon Santamaria (@raysan5)
;*
;* Translated to PureBasic by Mathias Grundler, June 2020
;*
;********************************************************************************************
IncludePath "./../../" ; First we need to include
XIncludeFile "raylib.pbi" ; the raylib-purebasic import
EnableExplicit ; All variables have to be defined before use
UseModule ray ; Import the module
; Initialization
;>-------------------------------------------------------------------------------------
#SCREEN_WIDTH = 800
#SCREEN_HEIGHT = 450
InitWindow( #SCREEN_WIDTH, #SCREEN_HEIGHT, "raylib [models] example - cubesmap loading and drawing" )
If Not IsWindowReady() ; After creating the window, we check
End ; for errors at initialization.
EndIf ; In case of error at init we end the program.
; Define the camera To look into our 3d world
;>-------------------------------------------------------------------------------------
Define camera.Camera3D
Define cam_position.Vector3
Define cam_target.Vector3
Define cam_up.Vector3
InitVector3( @cam_position, 16.0, 14.0, 16.0 ) ; Camera position
InitVector3( @cam_target , 0.0, 0.0, 0.0 ) ; Camera looking at point
InitVector3( @cam_up , 0.0, 1.0, 0.0 ) ; Camera up vector (rotation towards target)
camera\position = cam_position
camera\target = cam_target
camera\up = cam_up
camera\fovy = 45.0 ; Camera field-of-view Y
camera\type = #CAMERATYPE_PERSPECTIVE ; Camera mode type
; NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Define mapimage.Image
LoadImageRaylib(@mapimage, "resources/cubicmap.png") ; Loaded in CPU memory (RAM)
Define cubicmap.Texture2D
LoadTextureFromImage(@cubicmap, @mapimage) ; Image converted to texture, GPU memory (VRAM)
Define meshvector.Vector3
InitVector3(@meshvector, 1.0, 1.0, 1.0 )
Define mesh.Mesh
GenMeshCubicmap(@mesh, @mapimage, @meshvector)
Define model.Model
LoadModelFromMesh(@model, @mesh)
Define texture.Texture2D
LoadTextureRayLib(@texture, "resources/cubicmap_atlas.png")
model\materials\maps\texture = texture
Define mapposition.Vector3
InitVector3(@mapposition, -16.0, 0.0, -8.0 ) ; Map position
UnloadImage(@mapimage) ; Once image has been converted to texture
SetCameraMode(@camera, #CAMERAMODE_ORBITAL)
SetTargetFPS(60) ; Set our game to run at 60 frames-per-second
;>-------------------------------------------------------------------------------------
; Main game loop
While Not WindowShouldClose() ; Detect window close button or ESC key
; Update
;>---------------------------------------------------------------------------------
UpdateCamera( @camera ) ; Update camera
;>---------------------------------------------------------------------------------
; Draw
;>---------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(#COLOR_RAYWHITE)
BeginMode3D(@camera)
DrawModel(@model, @mapposition, 1.0, #COLOR_WHITE)
EndMode3D()
Define drawpos.Vector2
InitVector2(@drawpos, #SCREEN_WIDTH - (cubicmap\width * 4) - 20.0, 20.0)
DrawTextureEx(@cubicmap, @drawpos, 0.0, 4.0, #COLOR_WHITE)
DrawRectangleLines(#SCREEN_WIDTH - (cubicmap\width * 4) - 20, 20, cubicmap\width * 4, cubicmap\height * 4, #COLOR_GREEN);
DrawTextRaylib("cubicmap image used to", 658, 90, 10, #COLOR_GRAY)
DrawTextRaylib("generate map 3d model", 658, 104, 10, #COLOR_GRAY)
DrawFPS(10, 10)
EndDrawing()
;>---------------------------------------------------------------------------------
If IsKeyPressed(#KEY_F1)
TakeScreenshot("screenshots/textures_image_loading.png")
EndIf
Wend
; De-Initialization
;>-------------------------------------------------------------------------------------
UnloadTexture(@cubicmap) ; Texture unloading
UnloadTexture(@texture) ; Texture unloading
UnloadModel(@model)
CloseWindowRaylib() ; Close window and OpenGL context
;>-------------------------------------------------------------------------------------
Best regards,
Mathias
Re: [Module] raylib-purebasic (Windows/Linux/macOS)
Here we go... another Example:
"texture_rectangle"
Whooops... just saw that this example is already done Sorry for posting the "same thing"...
With regards,
Mathias
"texture_rectangle"
Code: Select all
;*******************************************************************************************
;*
;* raylib [textures] rectangle - Texture loading and drawing a part defined by a rectangle
;*
;* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM)
;*
;* This example has been created using raylib 1.4 (www.raylib.com)
;* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
;*
;* Copyright (c) 2016 Ramon Santamaria (@raysan5)
;*
;* Translated to PureBasic by Mathias Grundler, June 2020
;*
;********************************************************************************************
IncludePath "./../../" ; First we need to include
XIncludeFile "raylib.pbi" ; the raylib-purebasic import
EnableExplicit ; All variables have to be defined before use
UseModule ray ; Import the module
; Initialization
;>-------------------------------------------------------------------------------------
#SCREEN_WIDTH = 800
#SCREEN_HEIGHT = 450
#MAX_FRAME_SPEED = 15
#MIN_FRAME_SPEED = 1
InitWindow( #SCREEN_WIDTH, #SCREEN_HEIGHT, "raylib [textures] example - image drawing" )
If Not IsWindowReady() ; After creating the window, we check
End ; for errors at initialization.
EndIf ; In case of error at init we end the program.
; NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Define scarfy.Texture2D
LoadTextureRayLib(@scarfy, "resources/scarfy.png")
Define position.Vector2
InitVector2(@position, 350.0, 280.0)
Define frameRec.Rectangle
InitRectangle(@frameRec, 0.0, 0.0, scarfy\width/6, scarfy\height)
Define currentFrame = 0
Define framesCounter = 0
Define framesSpeed = 8
SetTargetFPS(60) ; Set our game to run at 60 frames-per-second
;>-------------------------------------------------------------------------------------
; Main game loop
While Not WindowShouldClose() ; Detect window close button or ESC key
; Update
;>---------------------------------------------------------------------------------
framesCounter + 1
If (framesCounter >= (60 / framesSpeed))
framesCounter = 0
currentFrame + 1
If (currentFrame > 5)
currentFrame = 0
EndIf
frameRec\x = currentFrame * (scarfy\width/6)
EndIf
If (IsKeyPressed(#KEY_RIGHT))
framesSpeed +1
ElseIf (IsKeyPressed(#KEY_LEFT))
framesSpeed - 1
EndIf
If (framesSpeed > #MAX_FRAME_SPEED)
framesSpeed = #MAX_FRAME_SPEED
ElseIf (framesSpeed < #MIN_FRAME_SPEED)
framesSpeed = #MIN_FRAME_SPEED
EndIf
;>---------------------------------------------------------------------------------
; Draw
;>---------------------------------------------------------------------------------
BeginDrawing()
ClearBackground(#COLOR_RAYWHITE)
DrawTexture(@scarfy, 15, 40, #COLOR_WHITE)
DrawRectangleLines(15, 40, scarfy\width, scarfy\height, #COLOR_LIME)
DrawRectangleLines(15 + frameRec\x, 40 + frameRec\y, frameRec\width, frameRec\height, #COLOR_RED)
DrawTextRaylib("FRAME SPEED: ", 165, 210, 10, #COLOR_DARKGRAY)
DrawTextRaylib(Str(framesSpeed), 575, 210, 10, #COLOR_DARKGRAY)
DrawTextRaylib("PRESS RIGHT/LEFT KEYS to CHANGE SPEED!", 290, 240, 10, #COLOR_DARKGRAY)
Define i
For i = 0 To #MAX_FRAME_SPEED-1
If (i < framesSpeed)
DrawRectangle(250 + (21 * i), 205, 20, 20, #COLOR_RED)
EndIf
DrawRectangleLines(250 + (21 * i), 205, 20, 20, #COLOR_MAROON)
Next
DrawTextureRec(@scarfy, @frameRec, @position, #COLOR_WHITE)
DrawTextRaylib("(c) Scarfy sprite by Eiden Marsal", #SCREEN_WIDTH - 200, #SCREEN_HEIGHT - 20, 10, #COLOR_GRAY)
EndDrawing()
;>---------------------------------------------------------------------------------
If IsKeyPressed(#KEY_F1)
TakeScreenshot("screenshots/textures_rectangle.png")
EndIf
Wend
; De-Initialization
;>-------------------------------------------------------------------------------------
UnloadTexture(@scarfy) ; Texture unloading
CloseWindowRaylib() ; Close window and OpenGL context
;>-------------------------------------------------------------------------------------
With regards,
Mathias
Re: [Module] raylib-purebasic (Windows/Linux/macOS)
since the C-Backend... maybe this would be a nice replacement for ogre?
Re: [Module] raylib-purebasic (Windows/Linux/macOS)
Well I have just about had it with ogre , The reason, I've just spent 2 weeks trying to get it to animate an entity and I just keep failing . Anyway I'm going to try raylib for purebasic. Glad I looked at this thread . Bonjour
Re: [Module] raylib-purebasic (Windows/Linux/macOS)
Hi!
I like the RayLib.
Can you update your source code to the current RayLib version 4.2?
I like the RayLib.
Can you update your source code to the current RayLib version 4.2?
Re: [Module] raylib-purebasic (Windows/Linux/macOS)
@idle:
But that's not particularly nice.
But that's not particularly nice.
Re: [Module] raylib-purebasic (Windows/Linux/macOS)
Is there a way to use the "DrawTextPro" function without the detour:
ImageText -> LoadTextureFromImage -> DrawTextureEx
It is about the possibility of rotation of this function.
"DrawTextPro" doesn't work!
Enclosed:
I recompiled the "pbhelper" C files with this command:
"RLAPI void DrawTextPro(Font font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint);"
Regardless of whether :
"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)"
with __PBAS or RLAS
There is no error message, but the function does not work.
ImageText -> LoadTextureFromImage -> DrawTextureEx
It is about the possibility of rotation of this function.
"DrawTextPro" doesn't work!
Enclosed:
I recompiled the "pbhelper" C files with this command:
"RLAPI void DrawTextPro(Font font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint);"
Regardless of whether :
"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)"
with __PBAS or RLAS
There is no error message, but the function does not work.
Re: [Module] raylib-purebasic (Windows/Linux/macOS)
I had to do a little trickery with PB v6.00 because the vector3 and vector4 structures already exist.
raylib.pbi
raylib.pbi
Code: Select all
;//----------------------------------------------------------------------------------
;// Structures Definition
;//----------------------------------------------------------------------------------
;// Vector2 type
Structure Vector2 Align #PB_Structure_AlignC
x.rl_float
y.rl_float
EndStructure
;// Vector3 type
Structure Vector_3 Align #PB_Structure_AlignC
x.rl_float
y.rl_float
z.rl_float
EndStructure
Macro Vector3
Vector_3
EndMacro
;// Vector4 type
Structure Vector_4 Align #PB_Structure_AlignC
x.rl_float
y.rl_float
z.rl_float
w.rl_float
EndStructure
Macro Vector4
Vector_4
EndMacro
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive