Another attempt at 3D external using openb3d
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Another attempt at 3D external using openb3d
Hello, Continuing my mad obsession with 3D externals for windows Livecode, I have thrown together another one.
This one uses the OpenB3D library. OpenB3D uses openGL and is primarily intended for use in FreeBASIC. It has a long history too. From what I can gather....
Blitz3D used Direct X 7 and was discontinued, a new cross platform language was created, BlitzMax. BlitzMax users wanted 3D functionality that was cross platform....Enter MiniB3D.
It started out as MiniB3D. MiniB3D gave BlitzMax users Blitz3D functionality. It was also "extended" giving BlitzMax users a more complete 3D replacement for Blitz3D such as terrains etc... It was then ported to IOS, creating iMiniB3D. iMiniB3D was then stripped of it's objective c ties to create OpenB3D.
OpenB3D is still under development. It currently supports win32 and linux and has recently been ported to OSX for use in BlitzMax. so I got to thinking...
I have created an external for livecode that takes the livecode stack and creates an opengl context, the stack then loads the functions explicitly from the openb3d.dll and maps them to livecode functions and commands. They are mapped in such a way that it is fairly true to the original Blitz3D syntax (which I liked)
global camera
put CreateCamera() into camera etc...
The only thing I really did was create the context and openB3D does the rest. It is a remarkable library!
I will upload my wrapper dll and source later if anyone is interested. Maybe someone in the know could add an opengl context in Linux and OSX too, maybe even IOS!
			
			
									
									
						This one uses the OpenB3D library. OpenB3D uses openGL and is primarily intended for use in FreeBASIC. It has a long history too. From what I can gather....
Blitz3D used Direct X 7 and was discontinued, a new cross platform language was created, BlitzMax. BlitzMax users wanted 3D functionality that was cross platform....Enter MiniB3D.
It started out as MiniB3D. MiniB3D gave BlitzMax users Blitz3D functionality. It was also "extended" giving BlitzMax users a more complete 3D replacement for Blitz3D such as terrains etc... It was then ported to IOS, creating iMiniB3D. iMiniB3D was then stripped of it's objective c ties to create OpenB3D.
OpenB3D is still under development. It currently supports win32 and linux and has recently been ported to OSX for use in BlitzMax. so I got to thinking...
I have created an external for livecode that takes the livecode stack and creates an opengl context, the stack then loads the functions explicitly from the openb3d.dll and maps them to livecode functions and commands. They are mapped in such a way that it is fairly true to the original Blitz3D syntax (which I liked)
global camera
put CreateCamera() into camera etc...
The only thing I really did was create the context and openB3D does the rest. It is a remarkable library!
I will upload my wrapper dll and source later if anyone is interested. Maybe someone in the know could add an opengl context in Linux and OSX too, maybe even IOS!
Re: Another attempt at 3D external using openb3d
OK, here are some bits and pieces.
The attached zip file has the compiled external extopenb3d.dll, the source for it, the ubiquitous Utah teapot model and a couple of stacks to test.
As well as these files, you will need to go onto sourceforge and download the latest openb3d.dll for win32. (For these tests I used V0.7).
Once you have the openb3d.dll, put it alongside these files OR stick it in your system32 / sysWOW64 folder (depending if you are running a 32 or 64 bit win32.
All commands are available (but not tested) Most are documented on Blitz3D docs website and some are not ( such as stencils, shadows and stuff ). If anyone wants I could rattle up some instructions or whatever.
There are only two major differences to the command set:
1. Graphics3D needs the title of the window passed to it along with the width and height (so that we can grab the handle) This will probably change in the future so I can go fullscreen, open another window or something I shall have to have a think about it.
2. Since "Flip" is a reserved keyword in LC I have used "Swap" instead.
You must call "Graphics3D before calling any other commands.
I'm not going to go in to too much detail at the moment unless anyone else wants info due to the fact that this murky section of the forum is not frequented by a lot of people.
			
							The attached zip file has the compiled external extopenb3d.dll, the source for it, the ubiquitous Utah teapot model and a couple of stacks to test.
As well as these files, you will need to go onto sourceforge and download the latest openb3d.dll for win32. (For these tests I used V0.7).
Once you have the openb3d.dll, put it alongside these files OR stick it in your system32 / sysWOW64 folder (depending if you are running a 32 or 64 bit win32.
All commands are available (but not tested) Most are documented on Blitz3D docs website and some are not ( such as stencils, shadows and stuff ). If anyone wants I could rattle up some instructions or whatever.
There are only two major differences to the command set:
1. Graphics3D needs the title of the window passed to it along with the width and height (so that we can grab the handle) This will probably change in the future so I can go fullscreen, open another window or something I shall have to have a think about it.
2. Since "Flip" is a reserved keyword in LC I have used "Swap" instead.
You must call "Graphics3D before calling any other commands.
I'm not going to go in to too much detail at the moment unless anyone else wants info due to the fact that this murky section of the forum is not frequented by a lot of people.
- Attachments
- 
			
		
		
				- extopenb3d.zip
- extopenb3d external for Livecode win32
- (173.98 KiB) Downloaded 1426 times
 
Re: Another attempt at 3D external using openb3d
Hmm, .dll in externals folder, in livecode folder, in SySWoW64 folder, set the externals of this stack to path on my hard drive instead of yours still can't find external.
			
			
									
									
						- 
				paul@researchware.com
- VIP Livecode Opensource Backer 
- Posts: 153
- Joined: Wed Aug 26, 2009 7:42 pm
- Contact:
Re: Another attempt at 3D external using openb3d
Is this an old style External or a LC9 widget/library (i.e the DLL is wrapped using LiveCode Builder)?
			
			
									
									Paul Dupuis
Researchware, Inc.
						Researchware, Inc.
Re: Another attempt at 3D external using openb3d
Posted in 2014, I'm guessing not LC9 Widget Builder thing.
Downloaded 322 times and nobody got it working...
			
			
									
									
						Downloaded 322 times and nobody got it working...
Re: Another attempt at 3D external using openb3d
I did loool. Thanks for letting me know.Downloaded 322 times and nobody got it working...
I got this going again just now (26th Oct 2021) using this recipe.
Originally this was tested on 32 bit windows XP so that's what I have used here in a virtual machine.
Download and install LiveCode V8.0.2 (The last version that worked semi OK on windows XP)
Download the original extopenb3d.zip attachment from above
Download V0.7 of OpenB3D.dll https://osdn.net/frs/g_redir.php?m=jais ... +win32.zip
Dropped the OpenB3D.dll into c:\Windows\System32 folder
dropped the extopenb3d.dll external into C:\Program Files\RunRev\LiveCode Business 8.0.2\Externals folder
in that folder there is a file called "externals.txt". Edit that file and add the line to the bottom "extopenb3d,extopenb3d.dll"
Now when you load the IDE you should have access to the 3D commands.
I extracted the attached zip file to my desktop. There should be 3 files. The livecode stack, 3d model and sphere map.
Double click on the stack to launch it and there should be spinning teapot.
---------------------
I haven't tested this on Windows 10 \ 64 Bit \ LiveCode 9 etc... and don't really intend to because nowadays this should be done using the LiveCode Builder FFI. In theory all we need to do is get/create an OpenGL context from a widget and start issuing the 3D commands. I have tried in the past but LCB stuff is beyond me at the moment.
- Attachments
- 
			
		
		
				- 3D_V8.0.2_Oct 2021.zip
- (77.17 KiB) Downloaded 1014 times
 
Re: Another attempt at 3D external using openb3d
OK so it works in windows 10 64 bit as well.
Installed 8.0.2 on windows 10 64 bit.
dropped openb3d.dll into Windows\SysWoW64 folder
dropped extopenb3d.dll external into C:\Program Files (x86)\RunRev\LiveCode Business 8.0.2\Externals then modified the external.txt file as above
Screenshots for both xp and win 10 below are attached
			
							
			
									
									
						Installed 8.0.2 on windows 10 64 bit.
dropped openb3d.dll into Windows\SysWoW64 folder
dropped extopenb3d.dll external into C:\Program Files (x86)\RunRev\LiveCode Business 8.0.2\Externals then modified the external.txt file as above
Screenshots for both xp and win 10 below are attached
Re: Another attempt at 3D external using openb3d
I guess its a dead end for free loaders using last community edition. Maybe there will be another pandemic and I can get a low priced Livecode again.
			
			
									
									
						- 
				richmond62
- Livecode Opensource Backer 
- Posts: 10202
- Joined: Fri Feb 19, 2010 10:17 am
Re: Another attempt at 3D external using openb3d
I wonder how accurate "free loaders" is when one considers how the contributions with advice and sample codeI guess its a dead end for free loaders using last community edition.
has dwindled to a trickle with the removal of the community editions?
Re: Another attempt at 3D external using openb3d
Jeezo I just noticed they have removed every community download. What a waste!  
			
			
									
									
						
Re: Another attempt at 3D external using openb3d
They are still hosting them here: https://community.livecode.com
			
			
									
									
						Re: Another attempt at 3D external using openb3d
WELL HOT DOG! IT WORKED! Thanks Klaus and n. allan!
So what changed from 8 to 9 that killed this kind of feature ?
Well the new stack works the old ones pop an error dialogue with no info.
Oh wait, i fixed something?
I moved the OpenStack to card script of the old teapot and it worked.
Then I opened the new teapot and it stole the 3D context.
There can only be one!
Cool, moved the stack script of shadow test to the card script. Now it's workin.
Works on Community 8.1.10 Shadow test died on that.
Built app out of 8.0.2 crashes, on start up. 8.1.10 too.
Moved externals into Runtime folder, then a copy in with with the built exe, builds work.
Sooo what was this stuff about creating a GL context in Extensions Builder?
And what was the process behind building this .dll? I downloaded the updated openb3D.dll to test but then I realized there was no external built against it.
Quick Reference:
			
			
									
									
						So what changed from 8 to 9 that killed this kind of feature ?
Well the new stack works the old ones pop an error dialogue with no info.
Oh wait, i fixed something?
I moved the OpenStack to card script of the old teapot and it worked.
Then I opened the new teapot and it stole the 3D context.
There can only be one!
Cool, moved the stack script of shadow test to the card script. Now it's workin.
Works on Community 8.1.10 Shadow test died on that.
Built app out of 8.0.2 crashes, on start up. 8.1.10 too.
Moved externals into Runtime folder, then a copy in with with the built exe, builds work.
Sooo what was this stuff about creating a GL context in Extensions Builder?
And what was the process behind building this .dll? I downloaded the updated openb3D.dll to test but then I realized there was no external built against it.
Quick Reference:
- The external commands of the stack ,ie DLL
 CameraClsColor
 BrushAlpha
 BrushColor
 Animate
 AntiAlias
 AmbientLight
 AddMesh
 MeshCullRadius
 TexToBuffer
 BackBufferToTex
 BufferToTex
 Swap
 BrushShininess
 BrushFX
 BrushBlend
 BrushTexture
 CameraViewport
 ClearTextureFilters
 CameraZoom
 ClearWorld
 CameraClsMode
 CameraProject
 CameraProjMode
 ClearCollisions
 CameraFogColor
 CameraFogMode
 Collisions
 ClearSurface
 CameraRange
 CameraFogRange
 EntityAutoFade
 EntityBlend
 EntityBox
 EntityColor
 EntityFX
 EntityAlpha
 EntityShininess
 EntityRadius
 EntityPickMode
 FitMesh
 EntityParent
 FreeBrush
 FreeTexture
 FreeShadow
 EntityOrder
 FlipMesh
 FreeEntity
 EntityType
 EntityTexture
 HideEntity
 PaintEntity
 LightRange
 MoveEntity
 ModifyTerrain
 PaintMesh
 HandleSprite
 LightConeAngles
 LightColor
 PaintSurface
 NameEntity
 Graphics3D
 SetCubeMode
 ResetEntity
 ScaleSprite
 StencilMesh
 PositionMesh
 RotateMesh
 RotateTexture
 ScaleEntity
 PointEntity
 RotateSprite
 RotateEntity
 RenderWorld
 ScaleMesh
 ScaleTexture
 ShowEntity
 StencilAlpha
 StencilMode
 PositionTexture
 SetCubeFace
 SpriteViewMode
 PositionEntity
 StencilClsColor
 SetAnimTime
 VertexNormal
 TurnEntity
 TFormVector
 UpdateWorld
 TranslateEntity
 TextureFilter
 TextureBlend
 TFormPoint
 UpdateNormals
 TFormNormal
 UseStencil
 UpdateTexCoords
 VertexColor
 TextureCoords
 VertexCoords
 ShadeEntity
 SetFloat4
 UseFloat
 SetInteger4
 SetFloat
 UseFloat2
 UseFloat4
 ShadeMesh
 SetFloat2
 SetFloat3
 UseFloat3
 SetInteger
 SetInteger2
 SetInteger3
 ShadeSurface
 UseInteger
 VoxelSpriteMaterial
 Wireframe
 VertexTexCoords
 ShaderTexture
 UseInteger4
 ShaderMaterial
 UseSurface
 UseInteger2
 AddToOctree
 UseMatrix
 UseInteger3
Re: Another attempt at 3D external using openb3d
Sorry for the late reply I normally get notified of a reply on here but it appears not...
In version 9 the graphics are drawn using the skia library. I tried it in the early v9 release and you could see the teapot for a millisecond then it was immediately drawn over. I assume this was the skia library rendering the card over my teapot during the "on paint" win32 function.
As a result I gave up and never gave it a second thought. This project might become feasible again when they ditch skia in version 10.
In this external, the gl context is hacked/created in c. The livecode windowid() is "massaged" into an HWND type and the context is created from that so that everything is painted/flipped right into your livecode stack.
The idea for LCB would be to ditch the external dll altogether and simply wrap the calls to openb3d.dll using LCB. This can be done today, right now, no problem. The problem is creating the context with skia painting over the stack every microsecond.
We could create a new separate OpenGL window easily but it kind of defeats the purpose of integrating it into LiveCode. I want to create stacks in livecode and paint to them in Livecode.
Lets see what happens with V10.
If you are simply interested in the general process of building an external then this is essentially the same tutorial I followed back in the day https://livecode.fandom.com/wiki/Working_with_DLL (The website is a complete mess of ads and is frankly annoying.) Download the ExternalsSDK and have a play on the older versions it was quite cool IMHO. If you don't know c/cpp you can probably still get by with that tutorial.
The code for this external could probably just be pasted into that project cpp file and click build. There are no fancy libraries required. All the #includes are fairly standard
			
			
									
									
						I'm glad someone had some success. I can't really offer much help with the building of standalone and including externals etc as I rarely build them. I can only assume if it works in the IDE, there is some way of using them in a standalone.WELL HOT DOG! IT WORKED!
In version 8 and below, the stacks (in windows os at least) appear to be just another native window so you can grab the handle of that window and manipulate it with the windows API. It was a hack at best.So what changed from 8 to 9 that killed this kind of feature ?
In version 9 the graphics are drawn using the skia library. I tried it in the early v9 release and you could see the teapot for a millisecond then it was immediately drawn over. I assume this was the skia library rendering the card over my teapot during the "on paint" win32 function.
As a result I gave up and never gave it a second thought. This project might become feasible again when they ditch skia in version 10.
I would hold fire on this until we see what's happening with version 10. If they are dumping skia then it will be wasted time.Sooo what was this stuff about creating a GL context in Extensions Builder?
In this external, the gl context is hacked/created in c. The livecode windowid() is "massaged" into an HWND type and the context is created from that so that everything is painted/flipped right into your livecode stack.
The idea for LCB would be to ditch the external dll altogether and simply wrap the calls to openb3d.dll using LCB. This can be done today, right now, no problem. The problem is creating the context with skia painting over the stack every microsecond.
We could create a new separate OpenGL window easily but it kind of defeats the purpose of integrating it into LiveCode. I want to create stacks in livecode and paint to them in Livecode.
Lets see what happens with V10.
As above, the process of building the external dll may become redundant. we can simply call all the openb3d functions from LCB and it would be rather neat. We could also make calls to OS directly from LCB to create the OpenGL context.And what was the process behind building this .dll? I downloaded the updated openb3D.dll to test but then I realized there was no external built against it.
If you are simply interested in the general process of building an external then this is essentially the same tutorial I followed back in the day https://livecode.fandom.com/wiki/Working_with_DLL (The website is a complete mess of ads and is frankly annoying.) Download the ExternalsSDK and have a play on the older versions it was quite cool IMHO. If you don't know c/cpp you can probably still get by with that tutorial.
The code for this external could probably just be pasted into that project cpp file and click build. There are no fancy libraries required. All the #includes are fairly standard