providing a C interface for Ogre3D

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
boegel
Gnoblar
Posts: 3
Joined: Sat May 28, 2005 5:11 pm
Location: Belgium
Contact:

providing a C interface for Ogre3D

Post 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 ?
There are only 10 kinds of people in the world, those who know binary and those who don't
User avatar
LordMyth
Gremlin
Posts: 181
Joined: Thu Jan 06, 2005 10:19 pm
Location: Belgium
Contact:

Post 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.
Have a kiss from me!
Gentoo Linux on AMD64 3200+
NForce4 Chipset
Dual Channel DDR 2x512MB
PCX 16 GeForce 6600 256MB
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post 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.. :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post 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?
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

I care about not reading language wars, that's all. :)

Other than that, I don't give a shit. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
LordMyth
Gremlin
Posts: 181
Joined: Thu Jan 06, 2005 10:19 pm
Location: Belgium
Contact:

Post 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!
Have a kiss from me!
Gentoo Linux on AMD64 3200+
NForce4 Chipset
Dual Channel DDR 2x512MB
PCX 16 GeForce 6600 256MB
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post 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:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
boegel
Gnoblar
Posts: 3
Joined: Sat May 28, 2005 5:11 pm
Location: Belgium
Contact:

Post 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.
There are only 10 kinds of people in the world, those who know binary and those who don't
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post 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 ! :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 7
Contact:

Post 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.
team-pantheon programmer
creators of Rastullahs Lockenpracht
lodi
Greenskin
Posts: 103
Joined: Sat Jul 24, 2004 7:06 pm

Post by lodi »

A C-binding would also let you use the D language.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

And Delphi. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
BenO
Goblin
Posts: 241
Joined: Mon Apr 18, 2005 5:03 pm

Post by BenO »

we should port to D ^^ this would be better :P
Benjamin RIGAUD
Software Engineer
boegel
Gnoblar
Posts: 3
Joined: Sat May 28, 2005 5:11 pm
Location: Belgium
Contact:

Post 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:
There are only 10 kinds of people in the world, those who know binary and those who don't
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post 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=
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
BenO
Goblin
Posts: 241
Joined: Mon Apr 18, 2005 5:03 pm

Post by BenO »

well :O i saw it :o but, ( BurP ) ..
Benjamin RIGAUD
Software Engineer
User avatar
LordMyth
Gremlin
Posts: 181
Joined: Thu Jan 06, 2005 10:19 pm
Location: Belgium
Contact:

Post 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...
Have a kiss from me!
Gentoo Linux on AMD64 3200+
NForce4 Chipset
Dual Channel DDR 2x512MB
PCX 16 GeForce 6600 256MB
Dawgmatix
Gnoblar
Posts: 1
Joined: Sun Jun 05, 2005 4:08 pm

Would like something like this too

Post by Dawgmatix »

Yep, a c interface would be great. :)
Any ideas about how this might be done???
User avatar
ahmedali
Gnome
Posts: 302
Joined: Fri Feb 20, 2004 8:52 pm
Location: Lahore, Pakistan

Post 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.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post 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
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
ssylvan
Gnoblar
Posts: 22
Joined: Sun Jun 05, 2005 5:29 pm

Post 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/).
lodi
Greenskin
Posts: 103
Joined: Sat Jul 24, 2004 7:06 pm

Post 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!
ssylvan
Gnoblar
Posts: 22
Joined: Sun Jun 05, 2005 5:29 pm

Post 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.
iremembercliford
Gnoblar
Posts: 1
Joined: Sun Jun 12, 2005 11:18 pm

Post 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
Promit
Gnoblar
Posts: 7
Joined: Sun Jun 12, 2005 9:15 pm

Post 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.
Post Reply