mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 02:15:34 +00:00
gpu,gpu/backend: implement generic backend.NewDevice
NewDevice creates a Device given an API, which is the necessary GPU resources for a backend. Convert gpu.New to take an API instead of a backend.Device directly. In turn, this frees us to later unexport the backend package along with the backend implementations (for now just gioui.org/gpu/gl for OpenGL). It also allows programs that embed Gio (such as gioui.org/example/glfw) to freely choose a backend, not just OpenGL. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -109,6 +109,10 @@ type SwapChain struct {
|
||||
fbo *Framebuffer
|
||||
}
|
||||
|
||||
func init() {
|
||||
backend.NewDirect3D11Device = newDirect3D11Device
|
||||
}
|
||||
|
||||
func NewDevice() (*Device, error) {
|
||||
var flags uint32
|
||||
if debug {
|
||||
@@ -237,7 +241,8 @@ func (s *SwapChain) Present() error {
|
||||
return s.swchain.Present(1, 0)
|
||||
}
|
||||
|
||||
func NewBackend(dev *_ID3D11Device) (*Backend, error) {
|
||||
func newDirect3D11Device(api backend.Direct3D11) (backend.Device, error) {
|
||||
dev := (*_ID3D11Device)(api.Device)
|
||||
b := &Backend{
|
||||
dev: dev,
|
||||
ctx: dev.GetImmediateContext(),
|
||||
|
||||
Reference in New Issue
Block a user