Skip to content

[Graphics] Support DirectX in Addition to OpenGL #558

Description

@nitoygo

Overview

Add support for DirectX as an alternative rendering backend alongside the existing OpenGL implementation.

The rendering API should be selectable through config.ini, allowing the application to choose which graphics backend to initialize and use at runtime without requiring code changes or recompilation.

Requirements

  • Add a DirectX rendering backend alongside the existing OpenGL backend.

  • Preserve the existing OpenGL implementation and behavior.

  • Introduce a configuration option in config.ini to select the rendering backend.

  • The application should read the configured backend during initialization.

  • Supported values should include at least:

    • opengl
    • directx
  • Define a sensible default backend for backwards compatibility, preferably opengl.

  • Invalid or unsupported backend values should produce a clear configuration error and/or fall back to the default backend.

  • Keep backend-specific code isolated so that rendering logic is not unnecessarily coupled to either OpenGL or DirectX.

Example Configuration

[graphics]
renderer=opengl

[graphics.opengl]
CoreProfile=1

or:

[graphics]
renderer=directx

[graphics.directx]
...

Implementation Considerations

  • Introduce a common renderer abstraction/interface where appropriate.
  • Move renderer-specific initialization, resource management, drawing, and shutdown logic behind the abstraction.
  • Avoid scattering checks such as if renderer == ... throughout the game/application code.
  • Ensure both backends expose the functionality required by the existing rendering pipeline.
  • Consider how textures, shaders, buffers, render targets, synchronization, and window/context/device initialization map between OpenGL and DirectX.
  • Ensure the selected backend is initialized before any renderer-dependent resources are created.
  • Maintain existing OpenGL behavior when no renderer is explicitly configured.

Acceptance Criteria

  • The application can run using OpenGL through config.ini.
  • The application can run using DirectX through config.ini.
  • OpenGL remains the default when no renderer is configured.
  • Invalid renderer configuration is handled gracefully.
  • Renderer selection does not require recompiling the application.
  • Common game/application rendering code is independent of the underlying graphics API where practical.
  • Existing OpenGL functionality and performance are not regressed.
  • DirectX-specific code is isolated from the OpenGL implementation.
  • Both renderers can be initialized and shut down cleanly.
  • Documentation/configuration examples are updated to describe the available rendering backends.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions