Skip to content

Latest commit

 

History

History
159 lines (132 loc) · 4.23 KB

lua.md

File metadata and controls

159 lines (132 loc) · 4.23 KB

Lua Support Roadmap

Why do we need Lua?

Lua is a simple, small, fast, easy to learn embeddable language. It can be very useful in projects such as Algine, since there are a lot of things that we can do much easier with language like Lua.

Firstly, we need Lua to get rid of awful, overcomplicated, inflexible, hard to maintain json configs that we are now using in Creators.

Secondly, we need Lua to simplify developer's lives - not all projects need to be written in C++, so in this case easy to learn language like Lua would be a great solution.

And finally, we need Lua to create Editor, since it will be much easier to create it using language like Lua.

Status

Lua support is provided by the solgen library.

An approximate list of classes that need lua support to be implemented:

Creators:

  • Creator
  • ShaderCreator
  • ShaderDefinitionGenerator
  • ShaderProgramCreator
  • TextureCreator
  • Texture2DCreator
  • TextureCubeCreator
  • ImageCreator
  • FramebufferCreator
  • RenderbufferCreator
  • OutputListCreator (removed, some functionality was moved to OutputList)
  • InputLayoutShapeLocationsCreator (removed, InputLayoutShapeLocations was extended in functionality)
  • ModelCreator
  • ShapeCreator

Core:

  • Engine
  • Object
  • Log
  • IOProvider
  • IOSystem
  • IOStream
  • StandardIOStream
  • StandardIOSystem
  • AssetsIOStream
  • AssetsIOSystem
  • Buffer
  • ArrayBuffer
  • IndexBuffer
  • UniformBuffer
  • Shader
  • ShaderProgram
  • Texture
  • Texture2D
  • TextureCube
  • Framebuffer
  • Renderbuffer
  • InputLayout
  • OutputList
  • Resources
  • Point
  • Rect
  • Color
  • Font
  • FontLibrary
  • FontMetrics
  • FontRenderer

Widgets:

  • Paint
  • Painter
  • RoundRect
  • Alignment
  • Container
  • Dimen
  • ImageWidget
  • Label
  • Layout
  • LinearLayout
  • RelativeLayout
  • SizePolicy
  • Unit
  • Units
  • Widget

Std:

  • InputLayoutShapeLocations
  • Mesh
  • Model
  • Shape
  • Rotatable
  • Translatable
  • Scalable
  • Rotator
  • EulerRotator
  • FreeRotator
  • Animation
  • AnimationBlender
  • Animator
  • Bone
  • BonesStorage
  • Camera
  • Material
  • AMTLManager
  • AMTLMaterialManager

Glm:

  • vec3
  • vec4
  • mat3
  • mat4
  • quat
  • basic functions

Tulz:

  • Array
  • UnsignedArray
  • IntArray
  • FloatArray
  • DoubleArray

In reality this list will be much bigger

TODOs

  • Redefine Lua's require to load Algine types (base, widgets, core (base+widgets), std, glm, tulz), e.g. require('algine:core')
  • Redefine Lua's tostring for tables
  • Redefine Lua's print to add ability to print tables

Useful pages

Hints

  • To create binding to overloaded function use static_cast<return_type (T::*)(args)>(&T::function_name)
  • To create binding to overloaded static function use static_cast<return_type (*)(args)>(&T::function_name)
  • If you bind class member function to lambda, then the 1st argument will be self: usertype["function"] = [](const sol::object &self, ...) { self.as<T>().function(...); };
  • Lua::new_enum allows you to create an enum and then make it as a class member
  • Lua::new_property creates property and additionally makes getter and setter
  • If you inherit Scriptable, then you also need to define static void registerLuaUsertype(Lua *lua)