Setup your application directory, make sure you have a copy of the scripts directory in the SDK copied to it along with newton.dll and shaders.pak. You will also need to set up lua-gluefunctions.bmx in the same directory. This can be created by running:
SuperStrict
Framework leadwerks.engine
Import "PATH TO YOUR 2.x SDK FOLDERBMXFrameworkframework.bmx"
Import lugi.generator
generateGlueCode("lua-gluefunctions.bmx")
Notify "lua-gluefunctions.bmx Generation Complete"
End
Then use the following for a simple framework context:
SuperStrict
Framework leadwerks.ENGINE
Import "PATH TO YOUR 2.x SDK FOLDERBMXFrameworkframework.bmx"
Include "lua-gluefunctions.bmx"
AppTitle:String = "Blank"
GCSetMode(2)
RegisterAbstractPath "PATH TO YOUR 2.x SDK FOLDER"
Graphics(800,600)
AFilter(4)
TFilter(1)
Global fw:TFramework = TFramework.Create()
If Not fw RuntimeError "Failed to initialize engine."
SetScriptObject("fw", fw)
SetBackgroundColor(Vec4(0.0,0.0,0.5,1.0))
SetZoom(1.25)
SetStats(2)
PositionEntity(fw.Main.camera,Vec3(0.0,0.0,0.0))
Repeat
If KeyHit(KEY_ESCAPE) Exit
If AppTerminate() Exit
UpdateFramework()
RenderFramework()
Flip()
Forever
fw.renderer.gbuffer = Null
GCCollect()
End
Function StringToVec2:TVec2(text:String, scale:Float = 1.0)
Local t:TVec2 = Vec2(1)
Local sarr:String[]
sarr = text.split(",")
If sarr
If sarr.length > 0 t.x = Float(sarr[0]) * scale
If sarr.length > 1 t.y = Float(sarr[1]) * scale
EndIf
Return t
EndFunction
Function StringToVec3:TVec3(text:String, scale:Float = 1.0)
Local t:TVec3 = Vec3(1)
Local sarr:String[]
sarr = text.split(",")
If sarr
If sarr.length > 0 t.x = Float(sarr[0]) * scale
If sarr.length > 1 t.y = Float(sarr[1]) * scale
If sarr.length > 2 t.z = Float(sarr[2]) * scale
EndIf
Return t
EndFunction
Function StringToVec4:TVec4(text:String, scale:Float = 1.0)
Local t:TVec4 = Vec4(1)
Local sarr:String[]
sarr = text.split(",")
If sarr
If sarr.length > 0 t.x = Float(sarr[0]) * scale
If sarr.length > 1 t.y = Float(sarr[1]) * scale
If sarr.length > 2 t.z = Float(sarr[2]) * scale
If sarr.length > 3 t.w = Float(sarr[3]) * scale
EndIf
Return t
EndFunction
Function SetScriptObject(name:String, o:Object)
Local size:Int=GetStackSize()
lua_pushbmaxobject(luastate.L,o)
lua_setglobal(luastate.L,name)
SetStackSize(size)
EndFunction
Function GetStackSize:Int()
Return lua_gettop(luastate.L)
EndFunction
Function SetStackSize(size:Int)
Local currentsize:Int=GetStackSize()
If size<currentsize
lua_pop(luastate.L,currentsize-size)
EndIf
EndFunction