Page 1 of 1

providing a C interface for Ogre3D

Posted: Sat May 28, 2005 5:14 pm
by boegel
I'm planning to set up a project to build a 3D modeller in Haskell, and I might use Ogre3D as render engine. The only problem is, Haskell can only use C functions, so I would need a C interface to Ogre3D. I heard a rumor that someone was willing to write this, but nobody seems to remember who he/she was :(

http://haskell.org/hawiki/H3D

Does anyone in here want to help building a C interface for Ogre3D ?

Posted: Wed Jun 01, 2005 6:37 pm
by LordMyth
May I ask why you want to go with the Haskell programming language?
I mean, it's probably faster to program your modeler in C++ or C# then converting OGRE to C (crazy idea if you ask me) and then using it in Haskell.

Posted: Wed Jun 01, 2005 7:23 pm
by jacmoe
@LordMyth:
There's absolutely no point in this - we choose what we choose - it's a matter of personal preferences.
@boegel:
I sincerely hope you find a solution!
A C-wrapper for Ogre could be useful for a lot of other things.. :)

Posted: Wed Jun 01, 2005 7:39 pm
by xavier
Jeez jacmoe, back off. It's a perfectly reasonable question, and was asked rather respectfully.

And unless you are involved in the effort, what do you care?

Posted: Wed Jun 01, 2005 8:16 pm
by jacmoe
I care about not reading language wars, that's all. :)

Other than that, I don't give a shit. :wink:

Posted: Wed Jun 01, 2005 8:20 pm
by LordMyth
Sorry if it sounded harsh, I was really only asking if he wanted to use Haskell at every price...
And why are you replying if you don't give a shit huh!

Posted: Wed Jun 01, 2005 8:27 pm
by jacmoe
xavier wrote:And unless you are involved in the effort, what do you care?
Merely a reply to xavier's polite question. :wink:

Posted: Wed Jun 01, 2005 8:43 pm
by boegel
LordMyth wrote:May I ask why you want to go with the Haskell programming language?
I mean, it's probably faster to program your modeler in C++ or C# then converting OGRE to C (crazy idea if you ask me) and then using it in Haskell.
Wow, I started a flame war unwillingly :)

@LordMyth, to answer our question: just because I wanted to try how Haskell would do while
implementing a 3D modeller. I don't want to do it because I think Haskell might be better at it than C++, but to show off Haskell's strenghts. It probably won't be just another modeller like Maya or 3DS Max, but something quite different. More mathematically, probably based on L-systems and the lot.

I hope this topic can go back to helping me with finding (or creating) a C interface to Ogre3D now... :D

@jacmoe: If you find it interesting, do you think you know a few people who might help me with this ? I do know some C, but not enough to do it on my own. And to start with, I'd only need some basic stuff, not every feature of Ogre3D.

Posted: Wed Jun 01, 2005 8:48 pm
by jacmoe
Maybe the script-bindings for Ogre (Lua, Python, etc) could be used/modified.
They are trying to fool C-like languages to use C++ Ogre.

There could even be a SWIG for Haskell ! :)

Posted: Wed Jun 01, 2005 9:04 pm
by haffax
Since swig already supports MzScheme this way might work when someone implements a Haskell binding for it. If you want to go for it yourself then be aware that the SWIG source is code directly from hell. :evil:
An unmaintainable mess. I really admire the SWIG developers for being able to work with it.

Posted: Wed Jun 01, 2005 10:21 pm
by lodi
A C-binding would also let you use the D language.

Posted: Wed Jun 01, 2005 10:27 pm
by jacmoe
And Delphi. :wink:

Posted: Wed Jun 01, 2005 10:32 pm
by BenO
we should port to D ^^ this would be better :P

Posted: Wed Jun 01, 2005 10:34 pm
by boegel
BenO wrote:we should port to D ^^ this would be better :P
I can see there is some animo to set up such a thing. How hard would it be to create a basic interface in C for Ogre3D ? Just as a test case, maybe I can go on from there myself... Anyone up for that ? :roll:

Posted: Wed Jun 01, 2005 10:35 pm
by jacmoe
we should port to D ^^ this would be better
It already is. It is called "Sinbad" - I kid you not.

:)

http://www.ogre3d.org/phpBB2/viewtopic. ... highlight=

Posted: Thu Jun 02, 2005 9:04 am
by BenO
well :O i saw it :o but, ( BurP ) ..

Posted: Thu Jun 02, 2005 4:08 pm
by LordMyth
If you want to generate all sorts of math-based meshes and stuff, OpenGL is probably easier. But then you will have to do everything yourself and that's something you don't like, I bet. But on the other side it is very useful to know OpenGL, when looking for work there will be a big chance they never heard about OGRE...

Would like something like this too

Posted: Sun Jun 05, 2005 4:10 pm
by Dawgmatix
Yep, a c interface would be great. :)
Any ideas about how this might be done???

Posted: Sun Jun 05, 2005 5:01 pm
by ahmedali
Ogre in C? I guess it will look like this, atleast it will not apear as ugly as quake's code.

uint node = createChildNode(mSceneMgr, Vector3() )
uint entity = createEntity(sceneManager, "dragon", "dragon.mesh'")
attachObject(node, entity)

traslateNode(node, Vector3)
or
nodeTraslate(node, Vector3)

May be not "uint" since ogre is managing objects.

Posted: Sun Jun 05, 2005 5:24 pm
by jacmoe
With a bit of work, you can make SWIG generate C from C++ - I found this post:
http://mailman.cs.uchicago.edu/pipermai ... 09461.html

Posted: Sun Jun 05, 2005 5:40 pm
by ssylvan
LordMyth wrote:May I ask why you want to go with the Haskell programming language?
I mean, it's probably faster to program your modeler in C++ or C# then converting OGRE to C (crazy idea if you ask me) and then using it in Haskell.
We feel that while there is a startup cost to interfacing to non-C libraries there are substantial benifits (from both a productivity and a maintenance standpoint) to using Haskell over C++.
Experience shows this to be true in other areas and I think it's true for graphics as well.
The main reason why that is, IMO, that you'd be hard pressed to find a problem domain which so neatly fits into the functional programming paradigm as graphics does.
Even the Doom 3 renderer is written in a functional style (albeit using C) internally, even though it interfaces with the rest of the engine in an OO style.

So anyway, I feel that if "someone" can get a nice interface between Haskell and some rendering system (maybe write one ourselves using the Haskell binding to OpenGL) there's a huge potential for high-level graphics programming that can surpass anything possible in conventional imperative languages such as C++ (see for instance Vertigo, an "embedded language" for shader programming in Haskell, at http://conal.net/Vertigo/).

Posted: Wed Jun 08, 2005 8:42 pm
by lodi
I just wanted to pop in to wish you luck with the C wrapper.

I've only casually fooled around with Haskell, but it's definitely one to look out for. I'm not sure how suited it is to interactive stuff (couldn't get my head around monads and the like) but for prototyping algorithms and mathematical computation, it can't be beat! It's very slow at the moment, but being a functional language with no side effects, it also has the potential to outperform c++, since it's much easier for the compiler to parallelize code.

D is a good complement to H; it supports garbage collection, unit testing, invariates, and all the other 'big, real world project' stuff right in the language, while maintaining support for inline assembly, and all kinds of low-level hackery.

As an aside, lately I've been partial to the 'scripting' languages. Ruby, in particular, is a wonderful blend of oo, closures, serialization/marshalling, and so on. When I'm programming in c++, I'm now constantly thinking how my code could have been better if I did things "the ruby way".

Anyway, good luck!

Posted: Sat Jun 11, 2005 3:55 pm
by ssylvan
Another cool language is Nemerle (www.nemerle.org).


It's .Net so anything you can do in .Net (like OpenGL and DirectX) is instantly supported.

It's OOP so it's quite intuitive to use the .Net libraries

It's FP so you get the benifits of less bugs and higher productivity that FP languages offer. Specifically it offers variants (like Haskell's algebraic data types), type inference, higher order functions (yes, C# has delegates but that's clunky), local function definitions etc...
I think partial application is in the works (right now you have to use the eta long form), at least I suggested some syntax on the developer list and it seems like all of the people behind the language are for it (it's only a matter of time before they implement it).

Anyway, it's a cool language because it's basically C# with less clunky syntax, and some more powerful FP tools.

It doesn't have the purity and laziness of Haskell, sadly, but when you want to interface with .Net that's probably somewhat impossible.

Posted: Sun Jun 12, 2005 11:21 pm
by iremembercliford
I might be interested in doing this, if someone could provide some details as to exactly what you were thinking.

Mike

marmarou at gmail dot com

Posted: Tue Jun 14, 2005 4:34 pm
by Promit
Nemerle + Axiom is probably the most productive thing to do right now, if you're dead set on functional languages...I assume Axiom will cooperate with Nemerle without any real difficulties.


Me, I never bought into the whole functional thing, but to each his own.