Decoupling GameObject from DirectX?

Started by
0 comments, last by Hodgman 8 years, 2 months ago

Does anyone have any recommendations/advice on decoupling game objects from directx? For example my current game object looks like so


struct MyGameObject
{
  void CreateDeviceDependentResources(ComPtr<ID2D1DeviceContext> const & renderTarget)
  {
       // Create Device Specific stuff like brush my game object wants to use
  }
  void CreateDeviceIndependentResources(ComPtr<ID2D1Factory2> const & factory)
  {
    // Create Brush Stroke Style
  }


  void Render(ComPtr<ID2D1DeviceContext> const & renderTarget)
  {
      renderTarget->DrawLine(...)
  }
}

Advertisement
Rename that class to D3DLine. Make it implement a platform-independent ILine interface. Add an ILine member to your game object.

This topic is closed to new replies.

Advertisement