bmx-ng / gfx.mod

bgfx rendering library backend for BlitzMax
1 stars 2 forks source link

Renderer Selection #8

Open woollybah opened 6 years ago

woollybah commented 6 years ago

Some platforms support different renderers : Win32 -> GL, Dx9, Dx11 : macOS -> GL, metal...

It would be nice if there was an easy way we could select the renderer, for example via the Graphics statement...

Unfortunately, adding them as bit-wise "flags" would be an issue as there aren't many free bits left, so we'd either need add a new argument or allow it to be set another way, eg. via a SetBGFXRenderer(BGFX_RENDERER_TYPE_VULKAN)

Note that the renderer can only be set once.

GWRon commented 6 years ago

Can't you map existing flags? I mean, reuse flags for DX and the likes.

Also: consider making this bgfx-project a replacement for max2d also means you could replace brl.graphics . No need to limit to free bits left - just reuse what is already existing.

Dunno what this would mean for sdl.mod

davecamp commented 6 years ago

Just an idea up for scrutiny

I assume that bgfx already takes care of the best renderer to use for the end user when you use the BGFX_RENDERER_TYPE_COUNT flag?

In which case for other renderers whats your opinions on allowing users to have these ( changing the flag names ) BGFX_RENDERER_DEFAULT BGFX_RENDERER_METAL BGFX_RENDERER_D3D12 etc.

and add the parameter to the Max2DDriver function at https://github.com/bmx-ng/gfx.mod/blob/760d01ac4ba2153d9deb2386260c25fc36a7de2b/bgfxmax2d.mod/bgfxmax2d.bmx#L165

it would then look like

Function BGFXMax2DDriver:TBGFXMax2DDriver(BgfxRenderer:Int = BGFX_RENDERER_DEFAULT)

Checks would need to made to verify/and recreate the current back end that bgfx is using.

A dev would then get to choose via

SetGraphicsDriver BGfxMax2DDriver()

or

SetGraphicsDriver BGfxMax2DDriver(BGFX_RENDERER_METAL)
GWRon commented 6 years ago

Shouldn't it be for consistency BGfxMetalMax2DDriver() and the likes too?

And as said...reusing existing constants allows for simpler code. So you could check for DX or OpenGl instead of "DxMax2d or DxBGfx".