Label, Button, LabelButton, ImageButton, CheckBox, ProgressBar, Slider, SliderBar, Toggle, ToggleGroup, StatusBar, GroupBox, Panel








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
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
;>-------------------------------------------------------------------------------------
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
;>-------------------------------------------------------------------------------------
+1Cyllceaux wrote: Mon Jan 10, 2022 4:59 pm since the C-Backend... maybe this would be a nice replacement for ogre?
you can also use it directly with c backend if your ok learning to use inline cccode_new wrote: Thu Jan 12, 2023 9:23 pm Hi!
I like the RayLib.
Can you update your source code to the current RayLib version 4.2?
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