mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
internal/d3d11: extract Direct3D API to separate package
We're about the merge the Direct3D backend into package gpu. Extract the raw Direct3D API to its own package, just like package glimpl. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -6,7 +6,9 @@ import (
|
||||
"unsafe"
|
||||
|
||||
"gioui.org/gpu"
|
||||
"gioui.org/app/internal/d3d11"
|
||||
"gioui.org/internal/d3d11"
|
||||
|
||||
_ "gioui.org/app/internal/d3d11"
|
||||
)
|
||||
|
||||
type d3d11Context struct {
|
||||
@@ -14,15 +16,20 @@ type d3d11Context struct {
|
||||
}
|
||||
|
||||
func newContext() (context, error) {
|
||||
dev, err := d3d11.NewDevice()
|
||||
dev, ctx, _, err := d3d11.CreateDevice(
|
||||
d3d11.DRIVER_TYPE_HARDWARE,
|
||||
0,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Don't need it.
|
||||
d3d11.IUnknownRelease(unsafe.Pointer(ctx), ctx.Vtbl.Release)
|
||||
return &d3d11Context{dev: dev}, nil
|
||||
}
|
||||
|
||||
func (c *d3d11Context) API() gpu.API {
|
||||
return gpu.Direct3D11{Device: unsafe.Pointer(c.dev.Handle)}
|
||||
return gpu.Direct3D11{Device: unsafe.Pointer(c.dev)}
|
||||
}
|
||||
|
||||
func (c *d3d11Context) MakeCurrent() error {
|
||||
@@ -33,6 +40,6 @@ func (c *d3d11Context) ReleaseCurrent() {
|
||||
}
|
||||
|
||||
func (c *d3d11Context) Release() {
|
||||
c.dev.Release()
|
||||
d3d11.IUnknownRelease(unsafe.Pointer(c.dev), c.dev.Vtbl.Release)
|
||||
c.dev = nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user