2D Graphics with Direct3D

I am trying to use Direct3D to render 2D graphics, as recommended by everyone since rejecting DirectDraw. In fact, there is no 3D information that I care about, and just want to be able to do things like draw lines, circles and related images on top of each other. So my questions

  • I need to upload many images from files and draw them on top of each other. Will the textures go?
  • A very silly question, but I can’t find anything: how do you visualize one surface on another?
  • Do you have to do everything on one texture and then draw it for the screen as a sprite or just draw a lot of textures?
  • How do you draw lines, etc. on texture / surface / sprite? I guess there is a better way than getting the device context and using GDI to draw on it?
+4
source share
1 answer
  • Yes
  • Create two triangles forming a quad. Set UV values ​​accordingly. UV values ​​are set in the range from 0 to 1. So, for 1024x1024 (or actually ANY-resolution texture, so this is done so), the upper left is 0.0, and the lower right is 1.1. ID3DXSprite will help you here.
  • It’s best to put several “frames” in one texture to change the texture too often (this is expensive).
  • You can use D3DPT_LINELIST / STRIP ... Otherwise, use two triangles (see ID3DXLine ).
+3
source

Source: https://habr.com/ru/post/1333552/


All Articles