Semi-OT: Anyone have a C++ wrapper for OpenB3D?

BlitzMax Forums/MiniB3D Module/Semi-OT: Anyone have a C++ wrapper for OpenB3D?

BlitzSupport(Posted 2016) [#1]
Does anyone know of a C++ interface to OpenB3D, or have one they would be willing to release? I'm learning C++ and it would be cool to have a familiar 3D engine to play around with.

As far as I can tell, it just needs an externally-created window/OpenGL context, so I imagine SDL/GLFW or similar would be the easiest way to do this, but I also can't get function.cpp to build (MSVC at least doesn't like attempting to return a *Entity!), so wondering if anyone's done all this already...


RustyKristi(Posted 2016) [#2]
Hey James, This is what I know

SourceForge:
https://sourceforge.net/projects/minib3d/

Latest Version:
https://sourceforge.net/projects/minib3d/files/OpenB3D%201.12%20src.tar.gz/download

OpenB3D is already in C++ :)

https://github.com/markcwm/openb3d.mod/blob/master/openb3dlib.mod/openb3d/src/geom.cpp

Maybe you have mistaken it with minib3d which is mostly BMX+inline OpenGL code and a bit of cpp.

https://github.com/si-design/minib3d/tree/master/inc


angros47(Posted 2016) [#3]
You don't need a c++ wrapper, since OpenB3D is already written in C++. You just need to include the headers in your C++ project, and to compile using the library.

I remind you that OpenB3D does not create an OpenGL context, since both FreeBasic, and BlitzMax (the languages it is used mostly with) already have commands to do that. In C++, you can use glut, or sdl, to create a context (or you can use platform-specific commands)


BlitzSupport(Posted 2016) [#4]
Yeah, I realise it's already C++ -- that's why I was expecting to be able to use it from a C++ project.

I had figured out how to include the headers (I think), but my test fails while parsing functions.h, with lots of these:

functions.h(309): error C2059: syntax error: '__declspec(dllimport)'


Not sure why, as the #define section seems to set this to "", given BUILD_DLL isn't set anywhere. (I am only a beginner in C++, though!)


In C++, you can use glut, or sdl, to create a context


Yeah, that's what I thought -- was just hoping someone else had some code already that implements this!


angros47(Posted 2016) [#5]
You don't need to use functions.h, this is a file that is not even completely up-to-date, and it is useful only for non-OOP access (like the file functions.cpp, that is just an exporter for C). In C++, you can use directly global.h, entity.h, mesh.h and so on.

About glut, you can find hundred of examples to create a context


BlitzSupport(Posted 2016) [#6]
Man, although I got a simple GLUT project working early on in VS2015, I must have now spent nearly 4 hours trying to build the ob3d makefile using mingw32-make.exe (including locating a working LibGlee), or trying to import/build the headers in a VS2015 project!

As much as I'm starting to like the C++ language, the whole project setup/lib import aspect is absolute f***ing misery!

Next step I suppose is trying to do it all in CodeBlocks or similar.

EDIT: Hmm, I can at least include some of the headers in my GLUT project and get it building. Not sure how to resolve error LNK2019: unresolved external symbol "public: static void __cdecl Global::Graphics(void)" on calling Global::Graphics after the GL context setup, though, as that seems to be defined, and I've included global.h...


Kryzon(Posted 2016) [#7]
If I were you, since you have access to C++, I would take a look at other engines:

- https://godotengine.org/features
- http://www.gameplay3d.io/features.html
- http://polycode.org/features/
- http://www.ogre3d.org/about/features
- https://urho3d.github.io/
- https://www.panda3d.org/manual/index.php/Features

(I checked to make sure all these can be used with C++)


RustyKristi(Posted 2016) [#8]
..or you should just check out how Munch's wrapper works particularly the GLUT part.


If you're trying to learn C++ with a 3D engine, Irrlicht is by far the easiest to setup and work with, and you can mess around with the B3D wrapper by AquaLung in case you want to help out with some improvements.

http://irrlicht.sourceforge.net/docu/example001.html

https://github.com/teto/irrlicht/blob/master/examples/01.HelloWorld/main.cpp


BlitzSupport(Posted 2016) [#9]
Yeah, thanks all, I might have to try another engine, was hoping to just work with the familiar Blitz3D style in C++, never really been keen on the over-complicated approaches taken by most other 3D engines. Bit naive, I guess!


RustyKristi(Posted 2016) [#10]
What you could do is pick which 3d engine you will be most comfortable with, preferably with already an existing wrapper if you're going to use it with B3D or Max.

So if you're into that path there's SoftPixel which objectively follows the same commands as B3D but with my recent tests it seems a bit broken, or go with Irrlicht which is in need of a blitz like command (maybe through wrapping) so others can make use of.

Ogre is another beast but it already does have a basic wrapper and another wide user base.


angros47(Posted 2016) [#11]
BlitzSupport, the error "unresolved external symbol" makes me think that you haven't linked your C++ program with the library.


BlitzSupport(Posted 2016) [#12]
@RustyKristi: I'd forgotten about SoftPixel, might give that one a go -- I'm trying to learn C++, so don't need a Blitz wrapper for this. (I have OpenB3D for that, and I love it.)

@angros47: I might have to try again after taking a few breaths... I wasn't able to build the ob3d makefile, so I assume that's an important part of the problem... !

Irrlicht looks worth a try, but I like that SoftPixel appears to have a physics setup built-in.

Not keen on all of this stuff (why can't anyone do a simple Blitz3D-style API?!), but I guess it's the C++ way!

video::RenderSystem* spRenderer = spDevice->getRenderSystem(); // Render system for drawing operations
video::RenderContext* spContext = spDevice->getRenderContext(); // Render context for back buffer controll
io::InputControl* spControl = spDevice->getInputControl(); // Controller for keyboard- and the mouse input events

scene::SceneGraph* spScene = spDevice->createSceneGraph(); // Scene graph system to handle a lots of scene objects
spScene->setLighting(true); // Activates global lighting



Kryzon(Posted 2016) [#13]
I'm trying to learn C++

Nuclear Fusion (as opposed to Nuclear Basic, which uses its own BASIC-derivative script) specifically mentions "learning C++" in their product page:
http://www.nuclearglory.com/products/nf/

It's probably as close as it would get to a Blitz3D 2.0 -- including the problems associated with being developed by a single person.
http://www.blitzbasic.com/Community/posts.php?topic=103836#1253847

MadJack and Naughty Alien have used it before, maybe you can send them an e-mail if you want to know more about it.


RustyKristi(Posted 2016) [#14]
Ok got it. Maybe I can help you with your decision on some critical factors, which I could slightly break it down for you. Of course, these are engines which are open source and with a very loose license aka MIT/BSD.

User base
Torque, Ogre and Irrlicht wins this one hands down. Panda3D is also C++ but mostly active users use python. Torque uses TorqueScript which has C++ syntax but you can always go full C++.

Active Dev Team
Torque3D and Ogre.

Active Forums/Tutorials/Youtube
Torque, Ogre and Irrlicht wins this one again. Check the number of post/help DAILY.

Known Games
Torque3D (Life is Feudal, BeamNG)
Ogre3D (Zombie Driver, Torchlight 1 & 2, Open MorrowWind Project, Scrap Mechanic)
Irrlicht (Build A World)

Pure C++
Ogre3D

I'd lean more towards Ogre3D and Torque3D since they are constantly updating, which btw both now supports Physically Based Rendering. Panda3D also has one but it's only a mod and not official. Irrlicht and Ogre already has support for mobile devices like Android but still experimental.

Some will argue that Ogre3D is only a renderer but with a ton of user contributions listed in their wiki, you can piece it together and make a game. ie. Input/Sound. All graphics feature are already supported one form or another like scene management, occlusion, lod, etc, hardware instancing. The only problem with Ogre is you can't rely on default shaders that comes with the SDK/examples because it's all over the place and messy, you have to build your own.

I'm not a big fan of these engines but have used them for quite some time and based on statistics alone and the track record, all of them are proven tech throughout the years.

BUT if you like the modern ones, C++ support, fully opensource with a Unity3D Feel, just go straight to GoDot or Urho3D. ;-)

Still, don't take my word for it. Investigate and have a look around on their respective forums, demos, mods, ask questions and there you go!


BlitzSupport(Posted 2016) [#15]
Great writeup, RK, many thanks -- it is the open source side of things I'm looking at. Did a bit of reading about a few engines last night, might actually give Urho3D a go, though I think all of them are far more low level than they need to be! It'll take me time to look into these/try them out, but it's handy to have a reference like this -- appreciate it!


RustyKristi(Posted 2016) [#16]
No problem. Yes I forgot to mention a few things with Urho3D, while it is a "frontrunner" along with other modern engines, I suggest looking the community and project in detail before you make the move.

I really hate airing out darker side truths to a project with a good potential so I guess you have to discover it for yourself. Maybe it's just my opinion or just cold hard facts which you might figure out soon if you dig deeper with what's going on there.

IF I were you that is just beginning with C++, I would go with the easiest which is between those 3, honestly.

Anyway, it's your decision so good luck! :)