开发者

2D graphics with Direct3D

开发者 https://www.devze.com 2023-02-01 23:44 出处:网络
I\'m trying to use Direct3D to render 2D graphics, as recommended by everyone since DirectDraw\'s deprecation. There really isn\'t any 3D-ness I care about, and just want to be able to do things like

I'm trying to use Direct3D to render 2D graphics, as recommended by everyone since DirectDraw's deprecation. There really isn't any 3D-ness I care about, and just want to be able to do things like draw lines, circles, and blit images onto each other. My questions are thus

  1. I need to load a lot of images from files开发者_StackOverflow中文版, and draw them onto each other. Would textures be the way to go?
  2. Very stupid question, but I can't seem to find anything: How do you render one surface onto another?
  3. Should you render everything onto a single texture and then draw that to screen as a sprite, or just draw many textures?
  4. How do you draw lines, etc, onto a texture/surface/sprite? I assume there's a better way than getting a device context and using GDI to draw on it?


  1. Yes
  2. Create 2 triangles forming a quad. Set the UV values appropriately. UV values are set in the range 0 to 1. So for a 1024x1024 (Or in fact ANY resolution texture which is why it is done this way) image the top left is 0,0 and the bottom right is 1,1. ID3DXSprite will help you here.
  3. Its best to put multiple "frames" in one texture to avoid changing the texture too often (this is expensive).
  4. You could use D3DPT_LINELIST/STRIP ... Failing that use 2 triangles (See ID3DXLine).
0

精彩评论

暂无评论...
验证码 换一张
取 消