DirectX - Window Size and BackBuffer Size

Started by
4 comments, last by Namethatnobodyelsetook 14 years, 5 months ago
Hey all So I'm using DirectX 9 and C++, with a windowed app. I'm wondering how you can create (or set the size of) the window based on what size you want the backbuffer or client area to be. So for example, if I set the size of the window when I create it to 500x500, then the whole window is that size. The actual drawing area is smaller, as there is a menu at the top, and a border around the window. Also, with different Windows themes, the size of the menu and border can change... So my question is: Can you get the window to automatically resize to fit a client area of exactly 500x500 pixels? Thanks!
Advertisement
1. Create a rect of 500,500.
2. Call AdjustWindowRect(Ex)
3. Compute new width and height, pass them to CreateWindow using the same info passed to AdjustRect(Ex).
Excellent!

AdjustWindowRectEx was exactly what I was after :)

Thank you!

Is this the normal way to adjust the window size for DirectX / C++ games?
Quote:Original post by NightCabbage
Is this the normal way to adjust the window size for DirectX / C++ games?

Yes, it's the normal way to adjust for games or any app that wants a specific client size (video players, etc.).
Thanks again NTNBET!

Also, quick question...

Is D3DFMT_X8R8G8B8 the best BackBufferFormat to use? (as standard)

Thanks!
In general yes. It's been supported forever. It's the most common format used for backbuffers and uncompressed textures. You can use X8R8G8B8 without checking for support, as everything made since the mid-90s will support it.

Only a few formats are available for backbuffers, so your options are limited.

There is generally no reason to use a 16-bit backbuffer these days, so let's just ignore those.

There is some support for A2R10G10B10 buffers, but you'd want to have code to fall back on X8R8G8B8 when a card doesn't support it. The extra few bits don't make enough of a difference to be worth handling two formats.

A8R8G8B8 is the same as the X8R8G8B8, except it allows you to store alpha values in your backbuffer. One pass can write an alpha value, and a subsequent pass can use D3DBLEND_DESTALPHA / INVDESTALPHA to blend based on that alpha value. It's useful on rare occasions. One caveat about this format is when calling CheckDeviceFormat or CheckDepthStencilMatch, you must pass in X8R8G8B8 as the 'adapter' format, while passing A8R8G8B8 as the rendertarget format.

This topic is closed to new replies.

Advertisement