Sign in to follow this  
salman83

formats

Recommended Posts

Hi all, I am newbie to DirectX. While reading, I come across different formats. They are used for different purposes (e.g. back buffer, depth stencil etc.). But, I want to know what a format actually is. And what is back buffer format and Adapter format. As, it is confusing. Because the DirectX docs says that when scene is about to be rendered, DirectX simply flips the back buffer pointers. Any help will be appreciated. Thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by salman83
Hi all,

I am newbie to DirectX. While reading, I come across different formats. They are used for different purposes (e.g. back buffer, depth stencil etc.). But, I want to know what a format actually is.

When you load or create a texture, or back buffer, or stencil buffer, it's really just plain memory. Bytes.

The format tells the DirectX how to interpret those bytes.

e.g, D3DFMT_A8R8G8B8 is a 32-bit ARGB format. Every 4 bytes is a pixel, where the first 8 bits are the blue value (0 - 255), the next 8 bits are the green value (0 - 255), and so on. If you were to create a surface with D3DFMT_R5G6B5 instead, the surface will use half as much memory (16 bits per pixel instead of 32) and red, green and blue only have 5, 6 and 5 pixels, respectively.
There are also formats for depth/stencil buffers (D3DFMT_D24S8 for a 32-bit depth/stencil buffer with 24 bits of depth range and 8 bits of stencil range per pixel).

Quote:
Original post by salman83
And what is back buffer format and Adapter format. As, it is confusing. Because the DirectX docs says that when scene is about to be rendered, DirectX simply flips the back buffer pointers.

The back buffer is the memory, the image that you're rendering to. When you call DrawPrimitive, the pixels don't end up on the screen right away, they're rendered to the back buffer. When you call Present(), the backbuffer is put to the screen. That is, if you only have 1 back buffer. When you create the device, you can specify how many back buffers you want. They're like a queue. And you can also specify how the back buffer is put to the screen. Flip (replace the back buffer with the screen buffer), Discard (discard the screen buffer), and so on. This is all documented.

Adapters are an abstract term that can be thought of as video cards. If you're on a multi-card, multi-monitor system, you can select which adapter to create the device on, this will determine, for instance, which screen it'll end up on if it's full-screen. For starters though, D3DADAPTER_DEFAULT is good.



You've asked a broad question, so if you want more specific answers, please ask more specific questions.

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