Direct2D but generate background from 3D Model

Started by
2 comments, last by h8CplusplusGuru 6 years, 8 months ago

So the application itself is 2D and layered but I want to build the background bitmap from a Blender 3D model.

When I make an appeal to Saint Google there seem to be an awful lot of ways of getting to the desired result.

The process I have in mind is to do the following. Please comment on the practicality or otherwise of this approach.

Use a background thread to:

  • Load the model
  • Create a 3D buffer for rendering into
  • Render into the buffer
  • Copy the 3D buffer to a 2D buffer somewhere

The main loop will

  • Blit? copy the 2D background to the backbuffer of the swap chain
  • Overlay the background with various sprites
  • Swap buffers

Which leads to the following questions.

What is the best option for exporting a Blender model for use by DirectX.

Which API should I use to create a 3D buffer for rendering the model into? As it only gets rendered on scene changes, every 10-20 seconds, am I correct in assuming it shouldn't be part of the swap chain? In managing the background buffer is it best to, or must I, use a "dummy" device of some kind?

How do I turn a 3D buffer into a 2D bitmap for load into the 2D swap chain?

What is the best way to set up the 2D buffer  so asto minimise the cost of the copy for every frame by the main loop?

Advertisement

Hi,

Does the background move ? I'm not familiar with Direct2D. You can always just go full D3D and render quads for the 2D stuff, it will certainly be very fast.

As for loading models from Blender (or any other program) you'll need a loader. It's not that hard to code an .obj loader yourself, otherwise you can probably find some code. It depends on the format your game engines uses so I would just make it myself if I were you, it basically comes down to parsing a text file (for .obj).

You will render your 3D model/background to an offscreen texture, and use that texture like any other. Try ogre3d 1.10 for a simple 3D API

This topic is closed to new replies.

Advertisement