Thread: Setting the BackBuffer

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    4

    Setting the BackBuffer

    Hi, I've been searching how to change the main Back Buffer and unfortunatelly didn't find anything helpful. Basicly I need to change the main pointer to a BackBuffer to a pointer of a surface compatible with the back buffer format. The idea is to get some frames from the main stream and anylyze data in them without using lock methods that are lowing the performance.

    So I will:

    1.Switch pointers of BackBuffer and my surface.
    2.Anylyze data in BackBuffer.
    3.Wait 0.5s
    4.Switch back the pointers.
    5.Analyze data in my surface.
    6.Wait 0.5s
    7.Switch pointers of BackBuffer and my surface.
    8.Anylyze data in BackBuffer.
    ...

    I need only to point me. And maybe also some suggestions about setting my surface format compatible with BackBuffer format. I'm writing my code in C++, DirectX 9.

  2. #2
    Registered User
    Join Date
    Jan 2010
    Posts
    4
    Nevermind. I will set the render target(the default one is Back Buffer). But Does the GetBackBuffer(UINT iSwapChain,UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9 ** ppBackBuffer) method returns only the pointer to Back Buffer or it copyies a whole surface? And when I'm accessing the surface that GetBackBuffer method returned me do I have any possibility to avoid locking the surface?(In fact I don't know how the mechanism of locking surface works). What will happen If I don't lock the surface? The compilator threats this like a mistake?

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I'm assuming this is for Direct3D. There is no way to 'analyze' any surface without first locking it. Locking it will return a pointer to the buffer. Not all surfaces can be locked. Whether they can or not depends on the memory pool they are in. If you want to lock the backbuffer on every frame then you are going to take a serious performance hit. If you don't lock the surface there is no way to get the pixel/texel data from the surface. Remember if you feel you need to access the texels/pixels of a surface and a shader just won't do....you are probably taking the wrong approach.

    There is a better way to do this via shaders. If you pre-cache a pointer to the back buffer surface (a texture/surface in itself) and send that as an input texture to the shader then you can access any part of the surface/texture you need to.

    What is with all this analyzing of pixel data recently? Don't you people realize that image recognition and the like can be done via filters which are much faster than attempting to analyze everything on a per-pixel/texel basis? I believe abachler would probably agree with me on this since he has done quite a bit of research into this very thing.
    Last edited by VirtualAce; 02-21-2010 at 07:19 PM.

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    4
    Thanks for reply. Could you throw some functions names with which I could do that(pre-caching the pointer and getting pixels from an input texture in shader)?

  5. #5
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    No but you can do some research in the SDK and books and figure it out.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  2. VS .net project setting question
    By Jumper in forum C++ Programming
    Replies: 1
    Last Post: 05-13-2004, 11:03 AM
  3. Your favourite fantasy game setting?
    By fry in forum Game Programming
    Replies: 4
    Last Post: 10-16-2002, 06:26 AM
  4. DirectDraw Backbuffer clipping windowed-mode
    By beem in forum Game Programming
    Replies: 4
    Last Post: 06-25-2002, 01:17 AM