# DirectX 8 to 9 Questions

This topic is 4776 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey all, I'm converting my DirectX 8 code to 9 and have a few questions. 1. What do I do with the old SetVertexShader call (I just have a vertex fvf; I neither use, nor know how to use, vertex shaders). The documentation says I need to do something different, but I'm not sure what. 2. How do I determine if a device can render in windowed mode? I used to check the D3DCAPS2_CANRENDERWINDOWED flag, but this no longer exists, and I can't find anything else like it in the documentation. 3. Some methods/functions now ask me for an added parameter, a swap chain identifier. If my only swap chain is the regular primary & secondary buffer chain, do I simply use '0' as my swap chain value? 4. IDirect3D9Device::GetAdapterModeCount now asks for a pixel format parameter, but I want all display modes of all pixel formats; do I simply use D3DFMT_UNKNOWN as the value? And is this what I do for the other methods which likewise ask for this parameter? That's all for now; your help, as always, is much appreciated! Peace. :)

##### Share on other sites
Quote:
 Original post by BrianMJC1. What do I do with the old SetVertexShader call (I just have a vertex fvf; I neither use, nor know how to use, vertex shaders). The documentation says I need to do something different, but I'm not sure what.

Ah, the only one I know. :) Check out SetFVF(). You should be able to replace that SetVertexShader call with SetFVF(D3DFVF_CUSTOMVERTEX).

##### Share on other sites
Quote:
 Original post by BrianMJC1. What do I do with the old SetVertexShader call (I just have a vertex fvf; I neither use, nor know how to use, vertex shaders). The documentation says I need to do something different, but I'm not sure what.

You can directly change that to SetFVF, as HopeDagger said. In DirectX9, SetFVF takes your FVF and converts it into a vertex declaration. (Lookup the docs for details).

Quote:
 2. How do I determine if a device can render in windowed mode? I used to check the D3DCAPS2_CANRENDERWINDOWED flag, but this no longer exists, and I can't find anything else like it in the documentation.

Any device that supports Direct3D9 - i.e. has a DDI (Device Driver Interface) of 7+ - supports windowed mode.

Quote:
 3. Some methods/functions now ask me for an added parameter, a swap chain identifier. If my only swap chain is the regular primary & secondary buffer chain, do I simply use '0' as my swap chain value?

The documentation for that function will usually tell you what to pass.

Quote:
 4. IDirect3D9Device::GetAdapterModeCount now asks for a pixel format parameter, but I want all display modes of all pixel formats; do I simply use D3DFMT_UNKNOWN as the value? And is this what I do for the other methods which likewise ask for this parameter?

AFAIK, you use one of the following:
D3DFMT_A1R5G5B5
D3DFMT_A2R10G10B10
D3DFMT_A8R8G8B8
D3DFMT_R5G6B5
D3DFMT_X1R5G5B5
D3DFMT_X8R8G8B8

##### Share on other sites
The end of the help on D3DFORMAT mentions which formats are available for fullscreen (thus device enumeration). In fact the doc page EnumAdapterMode changes has the same list as Coder mentioned.

As a warning, I'll point out something I noticed way back when DX9 was new. The enum docs mention that 555 and 565 are enumerated identically. I haven't checked with a recent DX9, but as of DX9.0 (with no letters) the docs seemed to be wrong. Asking for each format would return different results. I don't know if this has been fixed in a more recent DX9 release.

##### Share on other sites
Thanks everyone for the help. I'm still trying to figure out the swap chain thing (the documentation typically describes the swap chain value as "An unsigned integer specifying the swap chain." which is not very helpful). I'll post back again when I either get it running or encounter more issues.

##### Share on other sites
I can't get the back buffer. I'm using the IDirect3DDevice9::GetBackBuffer method, which now takes that pesky iSwapChain parameter. I tried '0', I tried '1', both of which would seem reasonable to me to identify the one and only swap chain, neither of which works: I get a D3DERR_INVALIDCALL error in both cases. The DX9 documentation is severely lacking in explanation, and their one and only example of getting the back buffer uses '0' as the value, which I tried.

Here's my exact source code of GetBackBuffer which fails:
    hr = g_pd3dDev->GetBackBuffer (1, 0, D3DBACKBUFFER_TYPE_MONO, &pd3dBackBuffer);    if (FAILED (hr))        {        sReport = "csurface::DisplayFull -- Failed to get back buffer: ";        sReport += D3DError (hr);        Log (sReport);        return g_ceSError;        }

##### Share on other sites
Oops, sorry, false alarm - it works now. I was using D3DPOOL_SCRATCH instead of D3DPOOL_SYSTEMMEM to make my surfaces. The DX8 to 9 documentation recommended using scratch in terms of functioning similarly to DX8, but apparently this is not the case! Thanks again everyone. :)

##### Share on other sites

This topic is 4776 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628675
• Total Posts
2984169

• 13
• 12
• 9
• 10
• 9