So, I heard everyone love RayLib ? No, seriously: it's fast, unobtrusive and 
can be compiled for any non-mechanical teapot.

What's even more: it got not 1, not 2, but whole 4(!) Nim wrappers ! Except all 
of them are outdated for some extent now.

So, I decided to do something better. I implemented **converter script** to 
parse RayLib' headers into comprehensible Nim module. Took me <100 lines of 
q'n'd _CoffeeScript 2_ code, but it's here: 
[https://gist.github.com/Guevara-chan/2d10691e0146aae4c96ff534978529f8](https://gist.github.com/Guevara-chan/2d10691e0146aae4c96ff534978529f8)

Keep in mind, I only tested latest (2.6) version and you need some modern 
Node.js installed to use it. Outside of this should work like charm: 
    
    
    import raylib, lenientops
    
    InitWindow 800, 600, "RayLib/[nim]"
    60.SetTargetFPS
    
    var camera  = Camera(position: Vector3(z: -15.0f, y: 10), up: Vector3(y: 
0.5), fovy: 45.0)
    SetCameraMode(camera, CAMERA_ORBITAL)
    
    while not WindowShouldClose():
        UpdateCamera(camera)
        BeginDrawing()
        ClearBackground(raylib.BLACK)
        BeginMode3D(camera)
        DrawGrid(10, 1.0f)
        DrawSphere(Vector3(), 0.5f, raylib.RED)
        EndMode3D()
        let
            slogan  = "/Hello from Nim/"
            size    = 20
            width   = MeasureText(slogan, size)
        DrawText(slogan, (GetScreenWidth() - width) div 2, 
-100+GetScreenHeight() div 2, size, raylib.LIGHTGRAY)
        DrawRectangleV(Vector2(x: 10, y: 10), Vector2(x:GetScreenWidth()-20.0, 
y:GetScreenHeight()-20.0),Color(r:255, a:20))
        EndDrawing()
    
    
    Run

Reply via email to