\$50

Image of the Day Submit

IOTD | Top Screenshots

D3DX8 and D3DX9 in one project

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

9 replies to this topic

#1KN4CK3R  Members

Posted 01 July 2013 - 04:10 PM

Hi,

I want to use D3DX8 and D3DX9 (Sprite and Font class) in one project. Using D3D8 and D3D9 together is not a problem but the X variants have the same function and class name for DX8 and DX9. This causes problems while executing the (test) program.

//D3D8 part
LPDIRECT3DDEVICE8 device;
....
ID3DXSprite *sprite;
D3DXCreateSprite(device, &sprite);
sprite->Release();

//and D3D9 part in an other file
LPDIRECT3DDEVICE9 device;
....
ID3DXSprite *sprite;
D3DXCreateSprite(device, &sprite);
sprite->Release();


The D3D8 part will run fine but the D3D9 part crashes in the D3DXCreateSprite method. I checked the generated assemblercode and it turns out that both D3DXCreateSprite methods are the same so the code tries to initialize the D3DX9 Sprite with the D3DX8 Sprite code what can't work.

I hoped something like this could work but for sure it does not:

namespace D3D8
{
#include <d3dx8.h>
#pragma comment(lib, "d3d8.lib")
#pragma comment(lib, "d3dx8.lib")
}

D3D8::ID3DXSprite *sprite;
D3D8::D3DXCreateSprite(device, &sprite);
sprite->Release();


The compiler doesn't create seperate methods.

Anyone has an idea how I can include both DX versions in one project? One solution could be to dynamicly load the d3dx_....dll and use GetProcAddress for D3DXCreateSprite but I hope there is an "build in" solution.

#2kauna  Members

Posted 01 July 2013 - 07:23 PM

Why do you need D3DX8? What are the functions in D3DX8 which aren't available in the D3DX9?

Cheers!

#3KN4CK3R  Members

Posted 02 July 2013 - 12:22 AM

it is an overlay for dx apps and should work with DX8 (yeah some older programs use it ;)) and DX9.
Internaly it checks which version the game uses and then uses my DX8 or DX9 renderer.

#4RealNoname  Members

Posted 02 July 2013 - 06:35 AM

Sorry to say this, but in VC++ you have no way to tell the compiler "that's the right dll". There are 2 solutions to your problem:

1. GetProcAddress all of D3DX8 needed functions dynamically.

2. Wrap those functions in separate library and static-link.

It's additional work, but probably the only solution.

#5KN4CK3R  Members

Posted 02 July 2013 - 09:46 AM

I tested your second idea 5 minutes before because I thought it would work but now the DX8 part is ignored and the DX9 D3DXCreateSprite gets called for both. Maybe I have done something wrong with it. GetProcAddress with D3DX8 will not work (found it out yesterday) because there isn't a d3dx8_....dll. The provided file in the DX8 SDK is a static library.

I will attach the project and it would be very cool if you could check if I did something wrong.

#6Dave Hunt  Members

Posted 02 July 2013 - 09:56 AM

Create two DLLs that contain the DX functionality you need, one compiled against DX8, the other compiled against DX9. Then have your application dynamically load the appropriate DLL at runtime. Note that your are not dynamically loading DX, only the version of your DLL compiled against the desired DX version.

#7KN4CK3R  Members

Posted 02 July 2013 - 09:57 AM

yes, this would work but I don't want to split this part in different DLLs.

#8Dave Hunt  Members

Posted 02 July 2013 - 11:30 AM

Sorry, but that is the correct way to do it.

Why do you care that they are in different DLLs?

#9KN4CK3R  Members

Posted 03 July 2013 - 08:42 AM

I ended up in this solution. Works fine and without big codechanges but is not portable.

http://stackoverflow.com/questions/10036733/modifying-a-compiled-static-library

Renamed D3DXCreateSprite in the d3dx8 header and library to D3DXCreateSprit8. Now the conflicts are gone.

#10Dave Hunt  Members

Posted 03 July 2013 - 09:43 AM

I'm confused as to how an outright hack is preferable to a clean and simple solution, but if you're happy, then carry on.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.