Sign in to follow this  
KN4CK3R

D3DX8 and D3DX9 in one project

Recommended Posts

KN4CK3R    128

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.

 

Thanks for your help!

Share this post


Link to post
Share on other sites
kauna    2922

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

 

Cheers!

Share this post


Link to post
Share on other sites
KN4CK3R    128
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.

Share this post


Link to post
Share on other sites
RealNoname    157

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.

Share this post


Link to post
Share on other sites
KN4CK3R    128

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.

Share this post


Link to post
Share on other sites
Dave Hunt    4872

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this