3 questions....

Started by
5 comments, last by IFooBar 21 years, 8 months ago
hello i have a few questions on directx... 1)if the display mode is ''x'' bpp then does that mean that the depth stencil also has to have ''x'' bpp ? 2)is there a way to make a bounding rectangle? all ive heard of are bounding spheres. 3)how would i get my game loop to render independantly of the refresh rate ie: 30 fps on every machine. thank u.
[size=2]aliak.net
Advertisement
1) No, the depth/stencil buffer format is independent of the color/target buffer format

2) yes there is a bounding box, just store the length, width, and height of the box instead of the radius of the sphere

3) pseudo-code

      while (1){     ...     // peekMessage stuff...     DWORD startTime = GetTickCount();          Update();     Render();     SomeOtherPerFrameFunction();     while (GetTickCount() - startTime <= (1000/desiredFPS));}      


Remember that this only makes it go down to 30 FPS or whatever when the program would usually run faster. It won't boost a program running at 20 FPS to 30 FPS.

'There's something out there....something stupid...'
- Daria

DirectInput8 with the Keyboard

[edited by - masonium on August 11, 2002 12:20:59 AM]

[edited by - masonium on August 11, 2002 12:22:12 AM]
thanks u verry mucho
[size=2]aliak.net
A small clarification there:

1) on all newer nVidia chips, the depths *MUST* be the same. This was the reason for the inclusion of CheckDepthStencilMatch() in the DX8 API.

The newer nVidia drivers have an advanced option called something like "match Z depth to frame buffer depth" where they will override what an application sets and force the two to be the same. I think it turns it on by default.

Other manufacturers'' chips don''t have this restriction.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

so if i have a buffer format thast 32 bits then i have to use either D32 or D24S8 as the depth stencil and if i have a 16 bit buffer then it has to be either D16...etc...

is this correct?

edit--------------------------
oh and another thing about depthstencil formats. whats teh first/second/third formats i should be checking for if the card supports or no. i have it in this order:

  if(rxIsDepthFormatCompatible(d3d, D3DFMT_D24S8, surfaceFmt))		stencil = D3DFMT_D24S8;	else if(rxIsDepthFormatCompatible(d3d, D3DFMT_D24X4S4, surfaceFmt))		stencil = D3DFMT_D24X4S4;	else if(rxIsDepthFormatCompatible(d3d, D3DFMT_D15S1, surfaceFmt))		stencil = D3DFMT_D15S1;	else if(rxIsDepthFormatCompatible(d3d, D3DFMT_D32, surfaceFmt))		stencil = D3DFMT_D32;	else if(rxIsDepthFormatCompatible(d3d, D3DFMT_D24X8, surfaceFmt))		stencil = D3DFMT_D24X8;	else if(rxIsDepthFormatCompatible(d3d, D3DFMT_D16, surfaceFmt))		stencil = D3DFMT_D16;	else 		stencil = D3DFMT_UNKNOWN;  


thanks again

MY HQ

[edited by - alfmga on August 12, 2002 9:32:16 AM]
[size=2]aliak.net
1.
quote:"is this correct?"


For nVidia chips, yes. For others you can mix depths. Use CheckDepthStencilMatch() and you''ll be ok.


2. The order you check formats with CheckDepthStencilMatch() really depends on what your engine needs to do.
For example if you needed to do lots of stencil effects you''d check for 8 bit stencil buffers first, then 4 bits, then 1. Alternatively if you didn''t need stencil, but did need higher depth precision you''d check 32, then 24 etc. And finally if your app was running out of video memory you''d check for 16 first, then 32.


Here''s a snippet of code from our engine:

  // Depending on various things the engine will use an array that looks// like one or the other of the following two arrays:    D3DFORMAT   depths[] = {                    D3DFMT_D32,                    D3DFMT_D24S8,                    D3DFMT_D24X8,                    D3DFMT_D16,                    D3DFMT_D24X4S4,                    D3DFMT_D15S1,                    D3DFMT_D16_LOCKABLE                     };    D3DFORMAT   depths[] = {                    D3DFMT_D16,                    D3DFMT_D15S1,                    D3DFMT_D16_LOCKABLE,                    D3DFMT_D32,                    D3DFMT_D24X8,                    D3DFMT_D24S8,                    D3DFMT_D24X4S4                    };    // scan all 7 formats to find first match    for (UINT uiFormat=0; uiFormat<7; ++uiFormat)    {        // check that the depth format is available on this adapter        hr = pD3D->CheckDeviceFormat( uiAdapterOrdinal, deviceType, backBufferFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, depths[uiFormat] );        if (FAILED(hr))        {            continue;        }        // have a prospective format, now see if it works in current mode        hr = pD3D->CheckDepthStencilMatch( uiAdapterOrdinal, deviceType, backBufferFormat, backBufferFormat, depths[uiFormat] );        if (SUCCEEDED(hr))        {            return depths[ uiFormat ];        }    }  





--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

muchos gracias

Al Fareed
MY HQ
[size=2]aliak.net

This topic is closed to new replies.

Advertisement