-
Notifications
You must be signed in to change notification settings - Fork 13
/
state_block_windows.go
87 lines (78 loc) · 1.69 KB
/
state_block_windows.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package d3d9
import (
"syscall"
"unsafe"
)
// StateBlock and its methods are used to encapsulate render states.
type StateBlock struct {
vtbl *stateBlockVtbl
}
type stateBlockVtbl struct {
QueryInterface uintptr
AddRef uintptr
Release uintptr
GetDevice uintptr
Capture uintptr
Apply uintptr
}
// AddRef increments the reference count for an interface on an object. This
// method should be called for every new copy of a pointer to an interface on an
// object.
func (obj *StateBlock) AddRef() uint32 {
ret, _, _ := syscall.Syscall(
obj.vtbl.AddRef,
1,
uintptr(unsafe.Pointer(obj)),
0,
0,
)
return uint32(ret)
}
// Release has to be called when finished using the object to free its
// associated resources.
func (obj *StateBlock) Release() uint32 {
ret, _, _ := syscall.Syscall(
obj.vtbl.Release,
1,
uintptr(unsafe.Pointer(obj)),
0,
0,
)
return uint32(ret)
}
// GetDevice retrieves the associated device.
// Call Release on the returned device when finished using it.
func (obj *StateBlock) GetDevice() (device *Device, err Error) {
ret, _, _ := syscall.Syscall(
obj.vtbl.GetDevice,
2,
uintptr(unsafe.Pointer(obj)),
uintptr(unsafe.Pointer(&device)),
0,
)
err = toErr(ret)
return
}
// Capture captures the current value of states that are included in a
// stateblock.
func (obj *StateBlock) Capture() Error {
ret, _, _ := syscall.Syscall(
obj.vtbl.Capture,
1,
uintptr(unsafe.Pointer(obj)),
0,
0,
)
return toErr(ret)
}
// Apply applies the state block to the current device state.
func (obj *StateBlock) Apply() Error {
ret, _, _ := syscall.Syscall(
obj.vtbl.Apply,
1,
uintptr(unsafe.Pointer(obj)),
0,
0,
)
return toErr(ret)
}