Lightnet / raylib_cimgui_lua

This sample project low level raylib need to access for cimgui to use lua script to create widgets.

Repository from Github https://github.comLightnet/raylib_cimgui_luaRepository from Github https://github.comLightnet/raylib_cimgui_lua

raylib_cimgui_lua

License: MIT

Status:

  • work in progress.
  • prototype code.

Packages:

  • raylib 5.5
  • cimgui 1.92.1 ( imgui )
  • lua 5.4
  • OpenGL 3.3 ( raylib and local OS if driver pacakge exist )
  • glfw ( raylib )
  • CMake

Tools:

  • msys64

  • CMake

    Current config for windows with msys64 for small compiler. For later use for cross platform OS for desktop tests.

Important Notes:

imgui.end()

This does not work due to match end for if statement conflict due how lua api table work. To follow imgui format for easy to read and port to c/c++ to be use later.

Some change to keep it simple since c does not work on lua script. It will handle in c lua state side code.

Information:

This is sample project that use cimgui (c language programing) convert from imgui (c++ language programing ) to run with raylib but in abstraction low level by rlgl.h. Due to raylib.h can't be access to set up window and graphic.

By using the CMake for easy compile and fetch content to get those repo download to build the application. Reason is that there raylib have different type build compiler.

Currently using the simple lua script to run imgui widgets.

-- set up local or theme
imgui.StyleColorsDark()

function draw()-- this get call from c main loop.
    imgui.Begin("Lua UI")
    imgui.Text("Hello from Lua!")
    imgui.End()
end

function cleanup()-- not work on yet
    print("Lua cleanup called")
end

Note:

  • This is place holder code still need to make sure it coded and tested.

Features:

  • flags
  • Begin
  • End
  • Text
  • Textf
  • SliderFloat
  • Button
  • CheckBox
  • StyleColorsDark
  • StyleColorsLight
  • StyleColorsClassic
  • GetVersion
  • BeginMenuBar
  • EndMenuBar
  • BeginMainMenuBar
  • EndMainMenuBar
  • BeginMenu
  • EndMenu
  • MenuItem
  • BeginTooltip
  • EndTooltip
  • SetTooltip
  • ColorEdit3
  • ColorEdit4
  • ColorPicker3
  • ColorPicker4
  • ColorButton
  • BeginTabBar
  • EndTabBar
  • BeginTabItem
  • EndTabItem
  • IsItemHovered
  • IsItemActive
  • IsItemClicked
  • SameLine
  • Separator
  • Spacing
  • BeginTable
  • EndTable
  • TableNextRow
  • TableNextColumn
  • TableSetColumnIndex
  • InputText
  • InputTextMultiline
  • RadioButton
  • ProgressBar
  • TreeNode
  • TreePop
  • Bullet
  • TextColored
  • Combo
  • ListBox
  • PlotLines
  • PlotHistogram
  • VSliderFloat
  • BeginChild
  • EndChild
  • IsWindowAppearing
  • IsWindowCollapsed
  • IsWindowFocused
  • IsWindowHovered
  • GetWindowPos
  • GetWindowSize
  • GetWindowWidth
  • GetWindowHeight
  • CollapsingHeader

Theme:

  • imgui.GetStyleCustom(imgui.Col.Text)
  • imgui.SetStyleCustom(imgui.Col.Text, {0.0, 0.0, 1.0, 1.0}) -- Set blue text
  • imgui.SetStyleCustoms({ }) -- Table-based, not working

Flags:

  • imgui.WindowFlags.NoTitleBar

  • imgui.WindowFlags.NoResize

  • imgui.WindowFlags.NoMove

  • imgui.WindowFlags.NoScrollbar

  • imgui.WindowFlags.NoCollapse

  • imgui.WindowFlags.AlwaysAutoResize

  • imgui.WindowFlags.NoBackground

  • imgui.WindowFlags.NoSavedSettings

  • imgui.WindowFlags.NoMouseInputs

  • imgui.WindowFlags.MenuBar

  • imgui.WindowFlags.HorizontalScrollbar

  • imgui.WindowFlags.NoFocusOnAppearing

  • imgui.WindowFlags.NoBringToFrontOnFocus

  • imgui.WindowFlags.AlwaysVerticalScrollbar

  • imgui.WindowFlags.AlwaysHorizontalScrollbar

  • imgui.WindowFlags.NoNavInputs

  • imgui.WindowFlags.NoNavFocus

  • imgui.WindowFlags.NoDecoration

  • imgui.WindowFlags.NoInputs

  • imgui.WindowFlags.NoNav

  • imgui.ColorEditFlags.NoAlpha

  • imgui.ColorEditFlags.'Name'

  • imgui.Col.Text

  • imgui.Col.WindowBg

  • imgui.Col.Button

  • imgui.Col.ButtonHovered

  • imgui.Col.'Name'

    Work in progres.

render 3d:

work in progress.

render 2d:

work in progress.

Network:

Using the Enet https://github.com/zpl-c/enet without secure for learning.

This work in progress. As been rework and need relearn how code works.

Dev:

main.c

setup window
setup graphic
setup cimgui
setup lua

loop
  input
  graphic start
  imgui start frame
  imgui render ui stuff
  imgui end frame

  camera
  render mesh

  rlDrawRenderBatchActive();
  glUseProgram(0);
  imgui render draw data
  glfwSwapBuffers(window); 
clean up

There are four stage for imgui to handle imgui start, render ui, imgui end and imgui draw graphic. Well there is input to count as well. It all process under the hood.

Lua is added after imgui reason that script need to setup theme style else it would crashed.

Links and Credits:

About

This sample project low level raylib need to access for cimgui to use lua script to create widgets.


Languages

Language:C 93.4%Language:CMake 3.7%Language:Lua 2.6%Language:Batchfile 0.2%