What's new

Back buffer format?

Doomulation

?????????????????????????
For you d3d gurus out there, I have a little question...
what the hell is backbuffer format and what good are they all? The coumentation explains shortly what every does (like 8 bit green, red, 1 bit alpha, etc). Not what they are needed for, nor what they represent.

I've found a working format to be X8R8G8B8... (I think). But...does this work across all computers? Or is there some way I must iterate over the format to use? Because there's no real function that returns all modes available, only one that checks if the format can be used.
 

Teamz

J'aime tes seins
the backbuffer is the buffer that is drawn off-screen and will be switched with the front buffer at the next frame
 

blight

New member
Like Teamz said, it's the back buffer where things are drawn onto which is then swapped with the currently displayed buffer which is then drawn on while the other is shown and so on - this is doublebuffering
The buffer is a memory area in your graphics cards RAM i think - so RGBA_8888 will require xres * yres * 4 bytes for the buffer (32 bits display depth) while RGBA_5551 would only require half as much ram but has less quality (5 bits for red, green and blue and 1 alpha bit - 16 bits)
The buffer is the destination of all drawing. I dunno about D3D but in OGL there are multiple buffers - like the COLOR BUFFER for the result of the render, and for example a DEPTH BUFFER which saves the distance for every rendered pixel on the screen (and when another one of some object behind the already rendered one is to be drawn it's depth value is checked against the actual value in the depth buffer and depending on how you set it up it draws it into the colorbuffer or rejects it)

HTH
 
Last edited:
OP
Doomulation

Doomulation

?????????????????????????
Oh I could esaily figure out the backbuffer, but thanks for the pointers.
I don't get the backbuffer format! The format. Which one to use, is it supported on all machines, must you enumerate a good one, etc.
This is my main question.

Oh and yes, dx has back buffers - and you can have more than one.
 

blight

New member
I only know OGL but i think these parts should be similar to D3D...
I told you that it's an area of RAM located in your graphics cards onboard ram... depending on the amount of ram and the selected output depth for the window you choose your format... typical formats would be RGBA_8888 or RGBA5551... pixels might have to be 4-byte aligned so RGB_888 might still need 32 bit like RGBA_8888... the depth is per pixel so if you have a window with 640x480 pixels the color buffer will require 640x480x4 bytes amount of RAM from your graphics card in RGBA_8888 mode, but only 640x480x2 bytes for RGBA_5551 mode... then there's the Z buffer - when you select a depth of 16 bits it's gonna use another 640x480x2 bytes of RAM from your card - when the card does not have enough RAM you get an error setting up the OpenGL (Direct3D) context.
Of course you also have to take the stencil, front, second back buffer and any other pixel buffers or other kind of buffers into account too, if you use such :p
I dunno if a card has to specifically support 16/32 bits rendering output or if it only depends on the VGA chip of the card but RGBA_8888 and RGBA_5551 are common 32 and 16 bit formats afaik
 
Last edited:

ingonab

New member
If you want 32bit colour rendering, use a triple 8 back buffer (D3DFMT_X8R8G8B8). If you want 16bit colour rendering, use a triple 4 back buffer (D3DFMT_X4R4G4B4). If you want to check if the device supports the format you want to use, call IDirect3D8/9::CheckDeviceFormat(...). If you want to know what format the device is currently using, call IDirect3D8/9::GetAdapterDisplayMode(...).

If you want 32bit colour rendering but D3DFMT_X8R8G8B8 is unsupported, exit with an error because you obviously can't go on.
 
Last edited:
OP
Doomulation

Doomulation

?????????????????????????
Hmm, I thought only the -8 one was supported with some calls.
So anyway, I should prolly only use those formats and forget the others?
 

ingonab

New member
Doomulation said:
Hmm, I thought only the -8 one was supported with some calls.
So anyway, I should prolly only use those formats and forget the others?

If you're rendering to a window, use whatever IDirect3D8/9::GetAdapterDisplayMode(...) gives you. Otherwise, for most purposes, D3DFMT_X8R8G8B8 should be all you'll ever need for a back buffer. All 3D cards will probably support this format. If not, just exit with an error.
 
Last edited:

Top