D3D background picture

Hi folks,

What I need to do is fill the background of my window with a particular bitmap. Bitmap can be of any size... 200x100, 640x480, 1920x1080, etc. and it should stretch to fill the window. Much like your desktop's background picture. This is in a D3D windowed app written in VB.NET using Feb2006 MDX. All 3D and sprite rendering is done on top of the background image.

How do I do this My current knowledge tells me I have to load a texture, keep it a square (512x512 lets assume) and the blit a sprite and then render everything on top of that. Is there a better way Is there a function much like the CLEAR function but draws an image rather than fill a color

Thank you in advance.




Answer this question

D3D background picture

  • Rafer

     

    The easiest way is to define an Ortogonal Projection (or 2D)

    To draw on a window you need to define 3 matrix, projection, view and World

    Instead of defining a perspective projection you define an orthogonal projection

    This way you will have a 2D coordinate to draw (actually the Z is still there but since
    you don't have the 3D effect you see it as a depth value)

    You define the View with Lookat from 0,0,-10 to 0,0,0 so you look strait
    into the 2D from a Z in front of the screen

    Your World Matrix will be according to the 2D value so translation is enough

    Your Ortogonal Matrix is done by a special projection function, you set this projection
    transform to the projection transform of the render

    Something like -10,-10,0 to 10,10,0  will center the 0,0,0 in the middle of your screen

    Then you need to render a Quad so a VertexBuffer of 2 triangles
    You need to set Light to False, to load and set a texture, to draw it in 2D

    When you draw the background texture give it a big Z value so it will be
    in the background of everything in front of it...

    In your render you define Perpective Projection to draw in 3D, then you define
    a Orthogonal projection to draw your 2D stuff on top of the 3D

    Hope this can help





  • MichaelMCSE

    http://www.gamedev.net/community/forums/topic.asp topic_id=387929

    Posting to multiple forums rarely gets you better answers, please post to one at a time and try others if you get no responses.



  • D3D background picture