XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

Drawing onto a Direct3D Texture

Last post 02/11/2009 23:48 by PhilTaylor. 3 replies.
  • 29/10/2009 11:07

    Drawing onto a Direct3D Texture

    Hi Guys,

    Please forgive my ignorance...

    I am trying to render a bitmap image onto a Direct3D primative and then use the mouse to draw on the texture.

    I've searched all over google to no avail, however I'm sure I've seen examples of this in the past, could somebody please point me in right direction.

    Regards

    Stefano x
  • 29/10/2009 23:39 In reply to

    Re: Drawing onto a Direct3D Texture

    You'd have to do this as a 2-step process:
    1) draw a quad ( 2 triangles ) with a texture ( many, many examples of this )
    2) calculate where on the quad the mouse clicks hit, map those locations to texture coordinates, and then lock the texture and update it at those locations.

    if the quad is at z==0 and fullscreen, this is basically a paint program, but using the 3d pipeline. then the mapping is relatively straightfoward.

    if the quad is "in the scene, at some z value" then you have to use a variation of the "pick" sample to get the mouse coordinates as world coordinates, map those to the primitive, and then to the texture map.

    hth
    http://www.futuregpu.net ex-Aces Lead PM/ex DX SDK PM/ex D3D Evangelist now LRB Launch Native Title Wrangler
  • 30/10/2009 12:05 In reply to

    Re: Drawing onto a Direct3D Texture

     
    Thanks Phil thats fantastic, I'm actually projecting a image onto a hemisphere, So I guess as long as I can work out what the 2D screen coordinates are in 3D world coordinates then I'm golden right? Does DirectX provide me with the facility to do this, or am I on my own?

    Cheers

    Stefan
  • 02/11/2009 23:48 In reply to

    Re: Drawing onto a Direct3D Texture

    older DX9 SDKs had a "Pick" sample that mapped mouse coordinates back into 3D space, thats definitely some code you want to track down.
    http://www.futuregpu.net ex-Aces Lead PM/ex DX SDK PM/ex D3D Evangelist now LRB Launch Native Title Wrangler
Page 1 of 1 (4 items) Previous Next