Git Product home page Git Product logo

raylib-nelua's Introduction

UNMAINTAINED

This library it's really important to me, however I've been focusing on my own game framework and thus this library got unmaintained.

If you need bindings of raylib for Nelua, you should check out Kenta's one, it's updated and covers more of raylib stack: https://github.com/Its-Kenta/Raylib.nelua

raylib-nelua

raylib-nelua-logo

This is a Raylib binding for Nelua language.

How to use

First, install Nelua language and Raylib library.

Then, you can use raylib.nelua, you can use it as a project file or as a external library:

As project file

Just move raylib.nelua file to your project.

As external library

Clone or download this repository somewhere and then either:

  • use the -L option, for example: nelua -L ~/path/to/nelua-raylib my-game.nelua
  • use a neluacfg.lua script on the project's root directory or on your $HOME/.config/nelua with the content return { add_path = {'/path/to/nelua-raylib'} } (See about this here)

Quick Raylib-nelua specific changes:

This binding contains some extra features to better integrate with nelua language:

  • unbounded arrays are specified on arguments and return types; for example, Raylib.GetWaveData returns a *[0]float32 instead of just *float32
  • for every record an is_* field is defined on the type information; for example, ## rAudioBuffer.value.is_raudiobuffer is true;
  • several functions are also applied to records, for example, function Camera.UpdateCamera(camera: *Camera) is defined, which can be used as a method camera:UpdateCamera();
  • operator overloading functions for raymath.hfunctions defined:
    • Vector2:
      • __add: calls Vector2Add
      • __sub: calls Vector2Subtract
      • __len: calls Vector2Length
      • __unm: calls Vector2Negate
      • __div: calls Vector2Divide or Vector2DivideV
      • __mul: calls Vector2Scale or Vector2MultiplyV
    • Vector3:
      • __add: calls Vector3Add
      • __sub: calls Vector3Subtract
      • __len: calls Vector3Length
      • __unm: calls Vector3Negate
      • __mul: calls Vector3Scale or Vector3Multiply
      • __div: calls Vector3Divide or Vector3DivideV
    • Matrix:
      • __add: calls MatrixAdd
      • __sub: calls MatrixSubtract
      • __mul: calls MatrixMultiply
    • Quaternion:
      • __len: calls QuaternionLength
      • __mul: calls QuaternionMultiply

NOTE: TraceLogCallback and SetTraceLogCallback aren't imported

Example

require 'raylib'

-- [[ Initialization [[
local screen_width: integer <comptime> = 800
local screen_height: integer <comptime> = 450
Raylib.InitWindow(screen_width, screen_height, "raylib-nelua [core] example - keyboard input")

local ball_position: Vector2 = { screen_width / 2, screen_height / 2}

Raylib.SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
-- ]] Initialization ]]

-- [[ Main game loop [[
while not Raylib.WindowShouldClose() do -- Detect window close button or ESC key
  -- [[ Update [[
  if Raylib.IsKeyDown(KeyboardKey.KEY_RIGHT) then
    ball_position.x = ball_position.x + 2
  end
  if Raylib.IsKeyDown(KeyboardKey.KEY_LEFT) then
    ball_position.x = ball_position.x - 2
  end
  if Raylib.IsKeyDown(KeyboardKey.KEY_UP) then
    ball_position.y = ball_position.y - 2
  end
  if Raylib.IsKeyDown(KeyboardKey.KEY_DOWN) then
    ball_position.y = ball_position.y + 2
  end
   -- ]] Update ]]

   -- [[ Draw [[
  Raylib.BeginDrawing()
    Raylib.ClearBackground(RAYWHITE)
    Raylib.DrawText("move the ball with arrow keys", 10, 10, 20, DARKGRAY)
    Raylib.DrawCircleV(ball_position, 50, MAROON)
  Raylib.EndDrawing()
  -- ]] Draw ]]
end

-- [[ De-Initialization [[
Raylib.CloseWindow() -- Close window and OpenGL context
-- ]] De-Initialization ]]

raylib-nelua's People

Contributors

andre-la avatar edubart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

sodomon2

raylib-nelua's Issues

Add (3.0) [models] examples

  • models_animation
  • models_billboard
  • models_box_collisions
  • models_cubicmap
  • models_first_person_maze
  • models_geometric_shapes
  • models_material_pbr
  • models_mesh_generation
  • models_mesh_picking
  • models_loading
  • models_orthographic_projection
  • models_rlgl_solar_system
  • models_skybox
  • models_yaw_pitch_roll
  • models_heightmap
  • models_waving_cubes

from libregit: Review pointers

from: https://libregit.org/Andre-LA/raylib-nelua/issues/9
by: Andre-LA

review all pointers on the binding to see what are actual pointers or arrays:

(notation: is pointer is array[] - [x] type was checked)

Records:

  • Font: recs[] chars[]
  • Mesh: vertices[] texcoords[] texcoords2[] normals[] tangents[] colors[] indices[] animVertices[] animNormals[] boneIds[] boneWeights[] vboId[]
  • Shader locs[]
  • Material maps[] params[] (maybe, guessed because the commentary is on plural)
  • Model meshes[] materials[] meshMaterial[] bones[] bindPose[]
  • ModelAnimation bones[] framePoses[][]
  • AudioStream buffer

Functions:
note: bold functions can be methods

  • Raylib.LoadFileData(fileName: cstring, bytesRead: *cuint): *[0]cuchar
  • Raylib.GetDirectoryFiles(dirPath: cstring, count: *cint): *[0]cstring
  • Raylib.GetDroppedFiles(count: *cint): *[0]cstring
  • Raylib.CompressData(data: *[0]cuchar, dataLength: cint, compDataLength: *cint): *[0]cuchar
  • Raylib.DecompressData(compData: *[0]cuchar, compDataLength: cint, dataLength: *cint): *[0]cuchar
  • Raylib.UpdateCamera(camera: *Camera): void
  • Raylib.DrawLineStrip(points: *[0]Vector2, numPoints: cint, color: Color): void
  • Raylib.LoadImageEx(pixels: *[0]Color, width: cint, height: cint): Image
  • Raylib.GetImageData(image: Image): *[0]Color
  • Raylib.GetImageDataNormalized(image: Image): *[0]Vector4
  • Raylib.ImageToPOT(image: *Image, fillColor: Color): void
  • Raylib.ImageFormat(image: *Image, newFormat: cint): void
  • Raylib.ImageAlphaMask(image: *Image, alphaMask: Image): void
  • Raylib.ImageAlphaClear(image: *Image, color: Color, threshold: float32): void
  • Raylib.ImageAlphaCrop(image: *Image, threshold: float32): void
  • Raylib.ImageAlphaPremultiply(image: *Image): void
  • Raylib.ImageCrop(image: *Image, crop: Rectangle): void
  • Raylib.ImageResize(image: *Image, newWidth: cint, newHeight: cint): void
  • Raylib.ImageResizeNN(image: *Image, newWidth: cint, newHeight: cint): void
  • Raylib.ImageResizeCanvas(image: *Image, newWidth: cint, newHeight: cint, offsetX: cint, offsetY: cint, color: Color): void
  • Raylib.ImageMipmaps(image: *Image): void
  • Raylib.ImageDither(image: *Image, rBpp: cint, gBpp: cint, bBpp: cint, aBpp: cint): void
  • Raylib.ImageFlipVertical(image: *Image): void
  • Raylib.ImageFlipHorizontal(image: *Image): void
  • Raylib.ImageRotateCW(image: *Image): void
  • Raylib.ImageRotateCCW(image: *Image): void
  • Raylib.ImageColorTint(image: *Image, color: Color): void
  • Raylib.ImageColorInvert(image: *Image): void
  • Raylib.ImageColorGrayscale(image: *Image): void
  • Raylib.ImageColorContrast(image: *Image, contrast: float32): void
  • Raylib.ImageColorBrightness(image: *Image, brightness: cint): void
  • Raylib.ImageColorReplace(image: *Image, color: Color, replace: Color): void
  • Raylib.ImageExtractPalette(image: Image, maxPaletteSize: cint, extractCount: *cint): *[0]Color
  • Raylib.ImageClearBackground(dst: *Image, color: Color): void
  • Raylib.ImageDrawPixel(dst: *Image, posX: cint, posY: cint, color: Color): void
  • Raylib.ImageDrawPixelV(dst: *Image, position: Vector2, color: Color): void
  • Raylib.ImageDrawLine(dst: *Image, startPosX: cint, startPosY: cint, endPosX: cint, endPosY: cint, color: Color): void
  • _Raylib.ImageDrawLineV(dst: *Image, start: Vector2, end: Vector2, color: Color): void
  • Raylib.ImageDrawCircle(dst: *Image, centerX: cint, centerY: cint, radius: cint, color: Color): void
  • Raylib.ImageDrawCircleV(dst: *Image, center: Vector2, radius: cint, color: Color): void
  • Raylib.ImageDrawRectangle(dst: *Image, posX: cint, posY: cint, width: cint, height: cint, color: Color): void
  • Raylib.ImageDrawRectangle(dst: *Image, posX: cint, posY: cint, width: cint, height: cint, color: Color): void
  • Raylib.ImageDrawRectangleV(dst: *Image, position: Vector2, size: Vector2, color: Color): void
  • Raylib.ImageDrawRectangleRec(dst: *Image, rec: Rectangle, color: Color): void
  • Raylib.ImageDrawRectangleLines(dst: *Image, rec: Rectangle, thick: cint, color: Color): void
  • Raylib.ImageDraw(dst: *Image, src: Image, srcRec: Rectangle, dstRec: Rectangle, tint: Color): void
  • Raylib.ImageDrawText(dst: *Image, position: Vector2, text: cstring, fontSize: cint, color: Color): void
  • Raylib.ImageDrawTextEx(dst: *Image, position: Vector2, font: Font, text: cstring, fontSize: float32, spacing: float32, color: Color): void
  • Raylib.GenTextureMipmaps(texture: *Texture2D): void
  • Raylib.LoadFontEx(fileName: cstring, fontSize: cint, fontChars: *[0]cint, charsCount: cint): Font
  • Raylib.LoadFontData(fileName: cstring, fontSize: cint, fontChars: *[0]cint, charsCount: cint, type: cint): *[0]CharInfo
  • Raylib.GenImageFontAtlas(chars: *[0]CharInfo, recs: **[0]Rectangle, charsCount: cint, fontSize: cint, padding: cint, packMethod: cint): Image
  • Raylib.TextJoin(textList: *[0]cstring, count: cint, delimiter: cstring): cstring
  • Raylib.TextSplit(text: cstring, delimiter: cchar, count: *cint): *[0]cstring
  • Raylib.TextAppend(text: cstring, append: cstring, position: *cint): void
  • Raylib.TextToUtf8(codepoints: *[0]cint, length: cint): cstring
  • Raylib.GetCodepoints(text: cstring, count: *cint): *[0]cint
  • Raylib.GetNextCodepoint(text: cstring, bytesProcessed: *cint): cint
  • Raylib.CodepointToUtf8(codepoint: cint, byteLength: *cint): cstring
  • Raylib.LoadMeshes(fileName: cstring, meshCount: *cint): *[0]Mesh
  • Raylib.LoadMaterials(fileName: cstring, materialCount: *cint): *[0]Material
  • Raylib.SetMaterialTexture(material: *Material, mapType: cint, texture: Texture2D): void
  • Raylib.SetModelMeshMaterial(model: *Model, meshId: cint, materialId: cint): void
  • Raylib.LoadModelAnimations(fileName: cstring, animsCount: *cint): *[0]ModelAnimation
  • Raylib.MeshTangents(mesh: *Mesh): void
  • Raylib.MeshBinormals(mesh: *Mesh): void
  • Raylib.CheckCollisionRaySphereEx(ray: Ray, center: Vector3, radius: float32, collisionPoint: *Vector3): boolean
  • Raylib.UpdateVrTracking(camera: *Camera): void
  • Raylib.WaveFormat(wave: *Wave, sampleRate: cint, sampleSize: cint, channels: cint): void
  • Raylib.WaveCrop(wave: *Wave, initSample: cint, finalSample: cint): void
  • Raylib.GetWaveData(wave: Wave): *[0]float32
  • Raymath.Vector3OrthoNormalize(v1: *Vector3, v2: *Vector3): void
  • Raymath.QuaternionToAxisAngle(q: Quaternion, outAxis: *Vector3, outAngle: *float32): void

Add (3.0) [shapes] examples

  • shapes_basic_shapes
  • shapes_bouncing_ball
  • shapes_colors_palette
  • shapes_logo_raylib
  • shapes_logo_raylib_anim
  • shapes_rectangle_scaling
  • shapes_lines_bezier
  • shapes_collision_area
  • shapes_following_eyes
  • shapes_easings_ball_anim
  • shapes_easings_box_anim
  • shapes_easings_rectangle_array
  • shapes_draw_ring
  • shapes_draw_circle_sector
  • shapes_draw_rectangle_rounded

Add (3.0) [shaders] example

  • shaders_model_shader
  • shaders_shapes_textures
  • shaders_custom_uniform
  • shaders_postprocessing
  • shaders_palette_switch
  • shaders_raymarching
  • shaders_texture_drawing
  • shaders_texture_waves
  • shaders_julia_set
  • shaders_eratosthenes
  • shaders_basic_lighting
  • shaders_fog
  • shaders_simple_mask

Add `Music` and `AudioStream` methods

Just noticed now, these functions could be methods:

-- Music management functions
function Raylib.LoadMusicStream(fileName: cstring): Music <cimport'LoadMusicStream', cinclude'<raylib.h>', nodecl> end -- Load music stream from file
function Raylib.UnloadMusicStream(music: Music): void <cimport'UnloadMusicStream', cinclude'<raylib.h>', nodecl> end -- Unload music stream
function Raylib.PlayMusicStream(music: Music): void <cimport'PlayMusicStream', cinclude'<raylib.h>', nodecl> end -- Start music playing
function Raylib.UpdateMusicStream(music: Music): void <cimport'UpdateMusicStream', cinclude'<raylib.h>', nodecl> end -- Updates buffers for music streaming
function Raylib.StopMusicStream(music: Music): void <cimport'StopMusicStream', cinclude'<raylib.h>', nodecl> end -- Stop music playing
function Raylib.PauseMusicStream(music: Music): void <cimport'PauseMusicStream', cinclude'<raylib.h>', nodecl> end -- Pause music playing
function Raylib.ResumeMusicStream(music: Music): void <cimport'ResumeMusicStream', cinclude'<raylib.h>', nodecl> end -- Resume playing paused music
function Raylib.IsMusicPlaying(music: Music): boolean <cimport'IsMusicPlaying', cinclude'<raylib.h>', nodecl> end -- Check if music is playing
function Raylib.SetMusicVolume(music: Music, volume: float32): void <cimport'SetMusicVolume', cinclude'<raylib.h>', nodecl> end -- Set volume for music (1.0 is max level)
function Raylib.SetMusicPitch(music: Music, pitch: float32): void <cimport'SetMusicPitch', cinclude'<raylib.h>', nodecl> end -- Set pitch for a music (1.0 is base level)
function Raylib.SetMusicLoopCount(music: Music, count: cint): void <cimport'SetMusicLoopCount', cinclude'<raylib.h>', nodecl> end -- Set music loop count (loop repeats)
function Raylib.GetMusicTimeLength(music: Music): float32 <cimport'GetMusicTimeLength', cinclude'<raylib.h>', nodecl> end -- Get music time length (in seconds)
function Raylib.GetMusicTimePlayed(music: Music): float32 <cimport'GetMusicTimePlayed', cinclude'<raylib.h>', nodecl> end -- Get current music time played (in seconds)

-- AudioStream management functions
function Raylib.InitAudioStream(sampleRate: cuint, sampleSize: cuint, channels: cuint): AudioStream <cimport'InitAudioStream', cinclude'<raylib.h>', nodecl> end -- Init audio stream (to stream raw audio pcm data)
function Raylib.UpdateAudioStream(stream: AudioStream, data: pointer, samplesCount: cint): void <cimport'UpdateAudioStream', cinclude'<raylib.h>', nodecl> end -- Update audio stream buffers with data
function Raylib.CloseAudioStream(stream: AudioStream): void <cimport'CloseAudioStream', cinclude'<raylib.h>', nodecl> end -- Close audio stream and free memory
function Raylib.IsAudioStreamProcessed(stream: AudioStream): boolean <cimport'IsAudioStreamProcessed', cinclude'<raylib.h>', nodecl> end -- Check if any audio stream buffers requires refill
function Raylib.PlayAudioStream(stream: AudioStream): void <cimport'PlayAudioStream', cinclude'<raylib.h>', nodecl> end -- Play audio stream
function Raylib.PauseAudioStream(stream: AudioStream): void <cimport'PauseAudioStream', cinclude'<raylib.h>', nodecl> end -- Pause audio stream
function Raylib.ResumeAudioStream(stream: AudioStream): void <cimport'ResumeAudioStream', cinclude'<raylib.h>', nodecl> end -- Resume audio stream
function Raylib.IsAudioStreamPlaying(stream: AudioStream): boolean <cimport'IsAudioStreamPlaying', cinclude'<raylib.h>', nodecl> end -- Check if audio stream is playing
function Raylib.StopAudioStream(stream: AudioStream): void <cimport'StopAudioStream', cinclude'<raylib.h>', nodecl> end -- Stop audio stream
function Raylib.SetAudioStreamVolume(stream: AudioStream, volume: float32): void <cimport'SetAudioStreamVolume', cinclude'<raylib.h>', nodecl> end -- Set volume for audio stream (1.0 is max level)
function Raylib.SetAudioStreamPitch(stream: AudioStream, pitch: float32): void <cimport'SetAudioStreamPitch', cinclude'<raylib.h>', nodecl> end -- Set pitch for audio stream (1.0 is base level)
function Raylib.SetAudioStreamBufferSizeDefault(size: cint): void <cimport'SetAudioStreamBufferSizeDefault', cinclude'<raylib.h>', nodecl> end -- Default size for new audio streams

Add (3.0) [audio] examples

  • audio_module_playing
  • audio_music_stream
  • audio_raw_stream
  • audio_sound_loading
  • audio_multichannel_sound

Add (3.0) [core] examples

  • core_basic_window
  • core_basic_window_web
  • core_input_keys
  • core_input_mouse
  • core_input_mouse_wheel
  • core_input_gamepad
  • core_input_multitouch
  • core_input_gestures
  • core_2d_camera
  • core_2d_camera_platformer
  • core_3d_camera_mode
  • core_3d_camera_free
  • core_3d_camera_first_person
  • core_3d_picking
  • core_world_screen
  • core_custom_logging
  • core_window_letterbox
  • core_drop_files
  • core_random_values
  • core_scissor_test
  • core_storage_values
  • core_vr_simulator
  • core_loading_thread

Logo proposal

raylib-nelua is an interesting binding and having a logo can be nice.

Here is a logo proposal
image

I made a program to draw this logo that uses https://github.com/TSnake41/raylib-lua

local lua_color = rl.new("Color", 0x14, 0x43, 0x89, 255)

local width, height = 800, 450

rl.SetConfigFlags(rl.FLAG_VSYNC_HINT)
rl.InitWindow(800, 450, "raylib [shapes] example - basic shapes drawing")

while not rl.WindowShouldClose() do
  rl.BeginDrawing()

  rl.ClearBackground(rl.RAYWHITE)

  rl.DrawRectangle(width / 2 - 128, height / 2 - 128, 256, 256, lua_color)
  rl.DrawRectangle(width / 2 - 112, height / 2 - 112, 224, 224, rl.RAYWHITE)
  rl.DrawText("raylib", width / 2 - 44, height / 2 + 24, 50, lua_color)
  rl.DrawText("NeLua", width / 2 - 49, height / 2 + 64, 50, lua_color)

  rl.DrawText("this is NOT a texture!", 350, 370, 10, rl.GRAY)

  rl.EndDrawing()
end

rl.CloseWindow()

Add (3.0) [textures] examples

  • textures_logo_raylib
  • textures_mouse_painting
  • textures_rectangle
  • textures_srcrec_dstrec
  • textures_image_drawing
  • textures_image_generation
  • textures_image_loading
  • textures_image_processing
  • textures_image_text
  • textures_to_image
  • textures_raw_data
  • textures_particles_blending
  • textures_npatch_drawing
  • textures_background_scrolling
  • textures_sprite_button
  • textures_sprite_explosion
  • textures_bunnymark

Add (3.0) [text] examples

  • text_raylib_fonts
  • text_font_spritefont
  • text_font_loading
  • text_font_filters
  • text_font_sdf
  • text_format_text
  • text_input_box
  • text_writing_anim
  • text_rectangle_bounds
  • text_unicode

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.