forked from gonutz/d3d9
/
IDirect3DPixelShader9_windows.go
64 lines (56 loc) · 1.53 KB
/
IDirect3DPixelShader9_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
package d3d9
/*
#include "d3d9wrapper.h"
HRESULT IDirect3DPixelShader9GetDevice(
IDirect3DPixelShader9* obj,
IDirect3DDevice9** ppDevice) {
return obj->lpVtbl->GetDevice(obj, ppDevice);
}
HRESULT IDirect3DPixelShader9GetFunction(
IDirect3DPixelShader9* obj,
void* pData,
UINT* pSizeOfData) {
return obj->lpVtbl->GetFunction(obj, pData, pSizeOfData);
}
void IDirect3DPixelShader9Release(IDirect3DPixelShader9* obj) {
obj->lpVtbl->Release(obj);
}
*/
import "C"
import "unsafe"
// PixelShader and its methods are used to manipulate a pixel shader resource.
type PixelShader struct {
handle *C.IDirect3DPixelShader9
}
// Release has to be called when finished using the object to free its
// associated resources.
func (obj PixelShader) Release() {
C.IDirect3DPixelShader9Release(obj.handle)
}
// GetDevice returns the device.
func (obj PixelShader) GetDevice() (ppDevice Device, err Error) {
var cppDevice *C.IDirect3DDevice9
err = toErr(C.IDirect3DPixelShader9GetDevice(obj.handle, &cppDevice))
ppDevice = Device{cppDevice}
return
}
// GetFunction returns the shader data.
func (obj PixelShader) GetFunction() (pData []byte, err Error) {
// first get the needed buffer size, pass nil as the data pointer
var cpSizeOfDataInBytes C.UINT
err = toErr(C.IDirect3DPixelShader9GetFunction(
obj.handle,
nil,
&cpSizeOfDataInBytes,
))
if err != nil {
return
}
pData = make([]byte, cpSizeOfDataInBytes)
err = toErr(C.IDirect3DPixelShader9GetFunction(
obj.handle,
unsafe.Pointer(&pData[0]),
&cpSizeOfDataInBytes,
))
return
}