crosire / d3d8to9

A D3D8 pseudo-driver which converts API calls and bytecode shaders to equivalent D3D9 ones.
BSD 2-Clause "Simplified" License
875 stars 77 forks source link

Question about use #139

Closed Aenge closed 2 years ago

Aenge commented 2 years ago

I'm working on porting an older game to Windows 10. This old game uses d3d8. Can I include the source files of this repo in my project so that the d3d8 calls in the source will get converted to equivalent d3d9 calls and allow me to compile on windows 10?

crosire commented 2 years ago

Yes, that would work (just need to replace d3d8.h includes with the d3d8.hpp in the source directory). As long as you comply with the license.

Aenge commented 2 years ago

Yes, I will. Thanks

Aenge commented 2 years ago

While working on this project, I've needed access to more function calls from d3d8tex.h, so I copied what was done in the repo already:

typedef HRESULT(WINAPI *PFN_D3DXAssembleShader)(LPCSTR pSrcData, UINT SrcDataLen, const D3DXMACRO *pDefines, LPD3DXINCLUDE pInclude, DWORD Flags, LPD3DXBUFFER *ppShader, LPD3DXBUFFER *ppErrorMsgs);
typedef HRESULT(WINAPI *PFN_D3DXDisassembleShader)(const DWORD *pShader, BOOL EnableColorCode, LPCSTR pComments, LPD3DXBUFFER *ppDisassembly);
typedef HRESULT(WINAPI *PFN_D3DXLoadSurfaceFromSurface)(LPDIRECT3DSURFACE9 pDestSurface, const PALETTEENTRY *pDestPalette, const RECT *pDestRect, LPDIRECT3DSURFACE9 pSrcSurface, const PALETTEENTRY *pSrcPalette, const RECT *pSrcRect, DWORD Filter, D3DCOLOR ColorKey);
-------------------------ADDENDUM--------------------------------
typedef HRESULT(WINAPI *PFN_D3DXLoadSurfaceFromMemory)(LPDIRECT3DSURFACE9 pDestSurface, const PALETTEENTRY *pDestPalette, const RECT *pDestRect, LPCVOID pSrcMemory, D3DFORMAT SrcFormat, UINT SrcPitch, const PALETTEENTRY *pSrcPalette, const RECT *pSrcRect, DWORD Filter, D3DCOLOR ColorKey);
typedef HRESULT(WINAPI* PFN_D3DXCreateTexture)(LPDIRECT3DDEVICE9 pDevice, UINT Width, UINT Height, UINT MipLevels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, LPDIRECT3DTEXTURE9* ppTexture);
typedef HRESULT(WINAPI* PFN_D3DXCheckTextureRequirements)(LPDIRECT3DDEVICE9 pDevice, UINT* pWidth, UINT* pHeight, UINT* pNumMipLevels, DWORD Usage, D3DFORMAT* pFormat, D3DPOOL Pool);
typedef HRESULT(WINAPI* PFN_D3DXCheckCubeTextureRequirements)(LPDIRECT3DDEVICE9 pDevice, UINT* pSize, UINT* pNumMipLevels, DWORD Ussage, D3DFORMAT* pFormat, D3DPOOL Pool);
typedef HRESULT(WINAPI* PFN_D3DXCreateCubeTexture)(LPDIRECT3DDEVICE9 pDevice, UINT Size, UINT MipLevels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, LPDIRECT3DCUBETEXTURE9* ppCubeTexture);

One of my class has a member Direct3DTexture8* Tex and is suppose to be created using D3DXCreateTexture, but I'm unable to use Tex->GetProxyInterface() for the final param since Tex is null.

Is the correct way to handle this

IDirect3DTexture9* newTex{ nullptr };
D3DXCreateTexture(...., &newTex);
Class::Tex = new Direct3DTexture8(thisDevice, newTex);
crosire commented 2 years ago

Jup, that's the way to do it.