Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

877890 Posts in 32888 Topics- by 24320 Members - Latest Member: BarracudaBlur

May 20, 2013, 04:48:58 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Irrlicht + SFML
Pages: [1]
Print
Author Topic: Irrlicht + SFML  (Read 1041 times)
kamac
Level 10
*****


Notorious posts editor


View Profile WWW Email
« on: November 17, 2011, 09:59:21 AM »

Hi.

Could someone give me an example of Irrlicht along with SFML? I need to use SFML for 2d and Irrlicht for 3d... And i need it very much  Waaagh!Hand Point Right!

I should ask if there's even such possibility... I guess i would have to make window with Irrlicht, get it's handle and pass it to SFML? I would love an example  CoffeeHand Metal Right
Logged

Skomakar'n
Level 10
*****


Vąutah


View Profile WWW Email
« Reply #1 on: November 17, 2011, 10:03:24 AM »

Since they both use OpenGL (Irrlicht does use DirectX and other things depending on platform and settings, I think, though, but let's assume there is a way to make it strictly run OpenGL at all times) there should probably be some way of wielding them together, but I have no idea how hard it would be, or whether it would be worth the time, and if it would simply be easier to tackle the problem at a lower level.
Logged

mak gam
Geisha Novia: Out now!
Bottoms Up!: Devlog

Royal Railway on Twitter.

Adam Emil
kamac
Level 10
*****


Notorious posts editor


View Profile WWW Email
« Reply #2 on: November 17, 2011, 10:06:28 AM »

Irrlicht can be set to use OpenGL. Yet, i have no idea how to merge them, and with which one make window to get it's handle for second one.
Logged

Skomakar'n
Level 10
*****


Vąutah


View Profile WWW Email
« Reply #3 on: November 17, 2011, 10:13:49 AM »

At least in SFML and Cocos2D, which are both libraries based on OpenGL, you can just write straight OpenGL code anywhere, and it will work (although for certain things I think you have to set a flag in SFML, and I haven't written any OpenGL code that has required that so far – I also think the flag has changed or been removed or something in SFML 2.0), and I don't really expect that the writers of Irrlicht would have put the OpenGL stuff in a special namespace or something either (or maybe they have, since you're not force to use OpenGL with it).

So because of this, maybe it would be possible for SFML just to push its own stuff to the already established matrices without even getting a handle to the window of Irrlicht. I'm just speculating my head off right now, though. I have no real idea. I'm just pondering.
Logged

mak gam
Geisha Novia: Out now!
Bottoms Up!: Devlog

Royal Railway on Twitter.

Adam Emil
kamac
Level 10
*****


Notorious posts editor


View Profile WWW Email
« Reply #4 on: November 17, 2011, 10:15:52 AM »

Well, it would be awesome to be able to use SFML + OpenGL which you can use at any place <?> as you said, to load 3d models/meshes. So if there's a way to do that, it'd awesome.
Logged

Liosan
Level 2
**


View Profile
« Reply #5 on: November 17, 2011, 10:19:16 AM »

Why on earth would anybody want to do something like that...? I'm not sure you can even make SFML display if it doesn't have the rendering context wrapped up in their own objects...

I'm just you would be better of if you just downloaded SFML's source, picked the bits you like (like a Sprite-drawing routine) and use them (almost) without any problems in Irrlicht.

Liosan
Logged

kamac
Level 10
*****


Notorious posts editor


View Profile WWW Email
« Reply #6 on: November 17, 2011, 10:22:12 AM »

Why would someone want to do that...


... I have to do very much 2d related stuff, i have made small gui class under SFML... And i need 3d models occasionally.
Logged

Skomakar'n
Level 10
*****


Vąutah


View Profile WWW Email
« Reply #7 on: November 17, 2011, 10:47:28 AM »

Maybe you could handle it from the other way. SFML has (very simple) 3D integration, but since there is pure OpenGL under the hood, you can extend that however you like.
Logged

mak gam
Geisha Novia: Out now!
Bottoms Up!: Devlog

Royal Railway on Twitter.

Adam Emil
kamac
Level 10
*****


Notorious posts editor


View Profile WWW Email
« Reply #8 on: November 17, 2011, 10:56:10 AM »

I presume it would be good to just use pure OpenGL with SFML but... I know nothing of how to do it either.  Undecided
Logged

Skomakar'n
Level 10
*****


Vąutah


View Profile WWW Email
« Reply #9 on: November 17, 2011, 11:22:40 AM »

Maybe you can still go along with this plan, but somehow run Irrlicht through SFML than the other way around.
Logged

mak gam
Geisha Novia: Out now!
Bottoms Up!: Devlog

Royal Railway on Twitter.

Adam Emil
BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #10 on: November 17, 2011, 12:11:42 PM »

Use SFML 2.0 and render to texture. Get the texture id (this will require hacking SFML a tiny amount). Render your 3d scene in irrlict, using the 2d texture on a plane. Profit.

I suspect this is easier than trying to save and restore openGL states as you switch between two engines, and trying to get them to share rendering directly to the screen.
Logged
Skomakar'n
Level 10
*****


Vąutah


View Profile WWW Email
« Reply #11 on: November 17, 2011, 01:31:40 PM »

Use SFML 2.0 and render to texture. Get the texture id (this will require hacking SFML a tiny amount). Render your 3d scene in irrlict, using the 2d texture on a plane. Profit.

I suspect this is easier than trying to save and restore openGL states as you switch between two engines, and trying to get them to share rendering directly to the screen.
... DroopKiss
Logged

mak gam
Geisha Novia: Out now!
Bottoms Up!: Devlog

Royal Railway on Twitter.

Adam Emil
Liosan
Level 2
**


View Profile
« Reply #12 on: November 18, 2011, 12:14:33 AM »

Use SFML 2.0 and render to texture. Get the texture id (this will require hacking SFML a tiny amount). Render your 3d scene in irrlict, using the 2d texture on a plane. Profit.
Wouldn't that require to separate rendering contexts? And, uh... due to the way those two libs are built, two windows...?

I presume it would be good to just use pure OpenGL with SFML but... I know nothing of how to do it either.  Undecided
It's simple, just invoke OpenGL functions Tongue Ok, it's simple for 2D - I've done it in a 2D game to do stuff that SFML couldn't do - cool lightning rendering, clipping in GUI, a circular health bar, batch rendering, normal mapping... etc. To use 3D with SFML you need to set up the OpenGL state for 3D rendering, then change it back to 2D for SFML code. To use SFML in an Irrlicht game you'd need to the same thing in the other direction Smiley

Setting and restoring the states shouldn't be much trouble - you should look at pushing the Projection and Modelview (and possibly the other two) matrices to the stack, using glFrustrum/glOrtho to set up the viewport, enable/disable depthtest and that should more or less be it. Probably a combination of Pop/PushMatrix + some copy-paste from either library's initialisation code would do the trick.

How much SFML do you use? Text and sprites, or something more? I still think picking SFML apart and using the interesting bits in an Irrlicht game is the way to go... SFML is waaay simpler than Irrlicht.

Liosan
Logged

BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #13 on: November 18, 2011, 04:45:36 PM »

Use SFML 2.0 and render to texture. Get the texture id (this will require hacking SFML a tiny amount). Render your 3d scene in irrlict, using the 2d texture on a plane. Profit.
Wouldn't that require to separate rendering contexts? And, uh... due to the way those two libs are built, two windows...?
Uh, yes, you are right, sorry. Not really an expert, but I'd imagine this is a problem mixing the two libraries for any case? It looks like you'd also have to tinker with sf::GlContext to fix this, it's somewhat designed to share windows, but not from arbitrary OpenGl code.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic