Archived

This topic is now archived and is closed to further replies.

emmai

I'd like to write front buffer

Recommended Posts

Guest Anonymous Poster
I''m now convert a 2d game to directx9... the game is
previously using GDI...all graphics output is render to a canvas,
and then blit to game window''s client area.

the solution I''m using now is copy the canvas to back buffer,then present it to front buffer...because copy canvas to backbuffer spend many times,so the performance is not increased.

if I can write frontbuffer,I can gain more FPS..

Share this post


Link to post
Share on other sites
...at the expense of image quality. Performance of DX will not be an issue with a game ported from GDI unless you are doing something REALLY wrong. You really should use double buffering, especially with smaller games. Don't draw to a canvas using GDI and give it to DX, do it all in DX using textured quads if you actually care about performance.

[edited by - nagromo on March 19, 2004 11:24:20 PM]

Share this post


Link to post
Share on other sites
quote:
I''m not sure you can .. but why would you need to??

Indeed, I don''t think it''s possible to write to the front-buffer.

quote:
the solution I''m using now is copy the canvas to back buffer,then present it to front buffer...because copy canvas to backbuffer spend many times,so the performance is not increased.

if I can write frontbuffer,I can gain more FPS..

- Actually, no. Writing to the back-buffer should be faster than writing to the front-buffer directly.
- Writing to the front-buffer presents *horrible* tearing.

If I were you, I''d port the whole GDI graphics thing to DirectX. It''ll take sometime, but the performance gain is worth it.

Muhammad Haggag
Bitwise account: MHaggag -

Share this post


Link to post
Share on other sites
I beleave I read that the next version of DirectX is going to give you access to the front buffer but at the moment you can''t.

Share this post


Link to post
Share on other sites
I doubt that direct access to the front buffer will be available any time soon via D3D. Allowing this would restrict the caching ability of the hardware and causes a CPU stall waiting for the hardware to render everything that the app has submitted over the last 2 or 3 frames. It would also break some of the swap effects.

What you might have read was that a future version of D3D would allow a pixel shader to read from the render target that it was also writing to.

Why are you using DX9 for this sort of game? Just use DirectDraw7. It allows direct access to the front buffer and you can get a GDI DC from each of the surfaces should you need it.

Share this post


Link to post
Share on other sites
Flipping the back buffer onto the front buffer is more or less instant. It only changes a memory pointer of the back buffer to be the pointer of the front buffer.
Plus if you draw directly to the front buffer you will get terrible flickering.

Share this post


Link to post
Share on other sites