DirectX's effects and Irrlicht

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
cyberion
Posts: 30
Joined: Tue Oct 23, 2007 5:53 pm

DirectX's effects and Irrlicht

Post by cyberion »

I have got a problem with Irrlicht device and Irrlicht device :( I
have to create some interesting effect in Irrlicht like (blowing up,
transitions, rain, fog) an I have a lot of examples dedicated to
DirectX, but I don't have an idea how can I join DirectX and
Irrlicht devices into one device in order to create the effect
described above. In attachment ( sample.cpp ) function called
PaintWindow doesn't work if I write some part of C++ code shown
below:

case WM_PAINT: // we get this message when we're supposed to paint.
PaintWindow(hWnd);


I'v got a book about programming games, but I have to USE DirectX's
effect and music (but it's not a problem because it is a music not
D3D)

Here is link http://chomikuj.pl/cyberion/samples/sample.cpp to all C++ code

Can someone help me :(
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

I can try to help, but it's maybe not exactly the help you where looking for.

The first thing you have to understand is why you cannot use WM_PAINT.
When you program a normal windows applications like, for example Word or Firefox or other tools, you have a very different behavior for drawing windows compared to game programming. WM_PAINT is very useful if you have applications which rarely change the graphic output. Like only when the user types something or when he resizes stuff. Then you tell the windows system you want to redraw a certain part of the screen and it will do so.

Games (and other 3D applications) on the other hand draw different things all the time. Usually around 60 times per second (that depends on your framerate). To be able to do that they use a completely different mechanism. They update the whole screen on each frame - but do that very fast. For that reason DirectX was made available which is very good in supporting you in that.

There are some ways to mix both systems, but it's rarely done and I think it's not even possible as soon as your game runs in fullscreen.

Irrlicht actually handles WM_PAINT (in CIrrDeviceWin32.cpp - take a look!), but it doesn't do anything with it.

Ok, so I hope you now see that you should not and don't even want to use WM_PAINT.

The next question is if you want to use Direct3D. There is some way to access Direct3D by using IVideoDriver::getExposedVideoData(), but you also shouldn't do so until you have a very good reason for that. Irrlicht offers you functionality on a higher level and once you hack around Irrilcht you can't use so much of that anymore.

I think what you should do is not to try to hack in some DirectX code in Irrlicht using some tricks. You might think you get some results that way fast, but you won't get anything useful. What I would recommend to do is trying to understand _why_ the DirectX code works. And once you understood that you can do the same stuff in Irrlicht. If you think it will take you longer that way to get some results - it won't. Learning the stuff is the only way to get something working in the end.

There is also another way to learn the same stuff. That's do not start with Irrlicht, but try to work with DirectX directly. This will basically teach you why it's useful to use Irrlicht, but will give you a deeper understanding. Or even better - start with OpenGL which will teach you the same stuff, but is way easier to use.
Last edited by CuteAlien on Mon Nov 26, 2007 6:11 pm, edited 1 time in total.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

Well, you are kinda looking at the problem the wrong way. You can't exactly "merge the devices". But, I figured you already knew that in this thread http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=24853

An Irrlicht device creates a DirectX device (if you use that API) and is a helper to make programming easier. So basically, what you would need to do is to rework the calls in your sample to the Irrlicht equivalent.

Code: Select all

g_pd3dDevice->BeginScene();
becomes

Code: Select all

driver->beginScene(true, true, video::SColor(255,0,0,255));

Code: Select all

		D3DXMatrixRotationY( &matWorld, 1.0f);//timeGetTimehhh()/10000.0f );
would end up being something like

Code: Select all

		mySceneNode.setRotation(vector3df(0,ISceneNode.getRotation().Y + 0.1f);
It is going to take some time to make some book code into the Irrlicht equivalent, especially if you are new to it. You can start by looking at your code there and the code right here http://irrlicht.sourceforge.net/docu/index.html
Notice the similarities? Both create a device, load up a mesh and then draw it continually.
Crud, how do I do this again?
cyberion
Posts: 30
Joined: Tue Oct 23, 2007 5:53 pm

DirectX's effects and Irrlicht

Post by cyberion »

Thank you so much ! :D :D :) :)

The worst thing in all case is using DirectX's functions and Irrlicht's functions...
Post Reply