c-smile / sciter-sdk

Sciter is an embeddable HTML/CSS/scripting engine
http://sciter.com
Other
2.11k stars 224 forks source link

Rendering using D3D9 #182

Open bugproof opened 3 years ago

bugproof commented 3 years ago

Is it possible to render directly with D3D9 without rendering using CPU first (e.g. https://github.com/c-smile/sciter-sdk/blob/master/demos.lite/win32-bitmap/plain-win.cpp)? Is there any way to implement a custom renderer in form of some plugin so it can be used without access to the source code?

c-smile commented 3 years ago

Sciter uses Direct2D as primary rendering backend on Windows.

Direct2D uses DXGI infrastructure, see:

https://docs.microsoft.com/en-us/windows/win32/direct2d/direct2d-and-direct3d-interoperation-overview and https://docs.microsoft.com/en-us/windows/win32/direct3ddxgi/d3d10-graphics-programming-guide-dxgi

Seems like DXGI can work only with D3D10 but I am not sure.

Check https://github.com/c-smile/sciter-sdk/tree/master/demos.lite/sciter-directx

Try to convince DXGI to work on top D3D9 stack, it seems that D3D10 device can be created on D3D9: https://docs.microsoft.com/en-us/windows/win32/direct2d/direct2d-and-direct3d-interoperation-overview#creating-a-dxgi-surface

bugproof commented 3 years ago

It's not possible to use Direct2D with D3D9 https://stackoverflow.com/questions/43409898/retrieve-id2d1devicecontext-from-idirect3ddevice9

I couldn't find any mention of creating D3D10 device on D3D9. It would be nice if rendering backend could be swapped with something else but I think it doesn't expose any abstract class/interface so we could replace it.

c-smile commented 3 years ago

You can use Sciter.Lite and render content into a bitmap (texture). See: https://github.com/c-smile/sciter-sdk/tree/master/demos.lite/win32-bitmap demo.