Jump to content

Framework and BMX question or two


Madjack
 Share

Recommended Posts

So I've finally gotten my ex-Xors + BMX codebase to compile under Leadwerks.

 

From what I can tell, the way to go is to use Framework in order to have easy access to LE's various special fx. Is that correct? Any issues I should be aware of with Frameworks + BMX?

 

I've grabbed the copy from the SDK install and incorporated it into my code.

 

An initial problem is that some commands mentioned in the docs + wiki don't seem to be included in the BlitzMax version. Namely:

 

GetFrameworkLayer

GetFrameworkListener

GetLayerCamera

GetLayerWorld

 

What am I missing?

 

<edit> or could I write my own functions for the above? Something like;

 

Local LAYER_DEFAULT:TLayer = GetFrameworkLayer(1)
Local CAMERA:TCamera = GetFrameworkCamera(LAYER_DEFAULT)

Function GetFrameworkLayer:TLayer(LAYER_index:int)
select LAYER_index
 case -1; Return fw.background
 case 0; Return fw.Main
 case 1; Return fw.transparency
end select
End Function


Function GetFrameworkCamera:TCamera(LAYER_check:TLayer)
 Return LAYER_check.CAMERA
End Function

Link to comment
Share on other sites

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

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...