PDA

Click to See Complete Forum and Search --> : Troubles using loadmeshfromX


Douchekop
Jul 14th, 2002, 12:42 PM
While initializing the game I use this code for setting the d3d device (The exact parameters are not important)

Code01:

Set gD3DDevice = Nothing
Set gD3DDevice = gD3D.CreateDevice(AdapterNumber, DeviceType, frmMain.hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, d3dp_p)


Then I use this code to load an object:

Code02:

Set Mesh = gD3DX.LoadMeshFromX(strMesh, D3DXMESH_MANAGED, gD3DDevice, Nothing, mtrlBuffer, nMaterials)


If I want to change the resolution etc. of the game changing the mode and using code01 I get this error:

Run-time error '-2005530520 (88760868)':
Automation error

And code01 is highlighted.

Without code02 I don't get that error.

What is the problem?

Zaei
Jul 14th, 2002, 01:01 PM
Your mesh stores a reference to the D3DDevice, which means that when you "Set gD3DDevice = Nothing", it isnt actually being freed. So, when you try to create another one, it fails. You need to delete the mesh, and ALL objects that need a D3D Device object FIRST.

As a suggestion, dont delete, then re-create your device to change resolution. Use the Reset() method of the Direct3DDevice8 object instead. You will still have to re-create all meshes, textures, index and vertex buffers, etc, though.

Z.

Douchekop
Jul 15th, 2002, 07:25 AM
Is it not possible to change the resolution without losing everything in the D3DDevice?
And how is that done in the Examples in the DX SDK?
How is that done in most games? Because I think it is an essential part of the compatibility of a game.

Zaei
Jul 15th, 2002, 11:35 AM
You cant. When re-sizing, you lose everything that you have created with the D3DDevice (this is not exactly true, objects created with the D3DPOOL_SYSTEMMEM flag set are still good). The samples follow this (I believe the method is InvalidateDeviceObjects()), and so do commercial games. If you want to avoid this, you might want to have a little screen pop up at the start of the game, presenting the various screen resolutions, etc (Like Max Payne, for instance).

Z.