-
Notifications
You must be signed in to change notification settings - Fork 3
/
directx9-bindings.reds
425 lines (362 loc) · 13.7 KB
/
directx9-bindings.reds
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
Red/System []
#define directx9-wrapper "C:\Users\Ariel\Documents\Visual Studio 2015\Projects\directx9-wrapper\Debug\directx9-wrapper.dll"
; #define
#define calling cdecl
#define HWND! byte-ptr!
#define DWORD! float!
#define BOOL! integer!
#define D3D_SDK_VERSION 32
#define D3DADAPTER_DEFAULT 0
#define D3DCREATE_SOFTWARE_VERTEXPROCESSING 32.0
#define D3DCREATE_HARDWARE_VERTEXPROCESSING 64.0
#define ZERO-MEMORY(destination length) [mem-set destination 0 length]
#define MAKEFOURCC(ch0 ch1 ch2 ch3) [
(as-integer ch0) or
((as-integer ch1) << 8) or
((as-integer ch1) << 16) or
((as-integer ch3) << 24)
]
;directx enums
#enum D3DDEVTYPE! [
D3DDEVTYPE_HAL: 1
D3DDEVTYPE_REF: 2
D3DDEVTYPE_SW: 3
D3DDEVTYPE_NULLREF: 4
D3DDEVTYPE_FORCE_DWORD: 7FFFFFFFh
]
#enum D3DFORMAT! [
D3DFMT_UNKNOWN: 0
D3DFMT_R8G8B8: 20
D3DFMT_A8R8G8B8: 21
D3DFMT_X8R8G8B8: 22
D3DFMT_R5G6B5: 23
D3DFMT_X1R5G5B5: 24
D3DFMT_A1R5G5B5: 25
D3DFMT_A4R4G4B4: 26
D3DFMT_R3G3B2: 27
D3DFMT_A8: 28
D3DFMT_A8R3G3B2: 29
D3DFMT_X4R4G4B4: 30
D3DFMT_A2B10G10R10: 31
D3DFMT_A8B8G8R8: 32
D3DFMT_X8B8G8R8: 33
D3DFMT_G16R16: 34
D3DFMT_A2R10G10B10: 35
D3DFMT_A16B16G16R16: 36
D3DFMT_A8P8: 40
D3DFMT_P8: 41
D3DFMT_L8: 50
D3DFMT_A8L8: 51
D3DFMT_A4L4: 52
D3DFMT_V8U8: 60
D3DFMT_L6V5U5: 61
D3DFMT_X8L8V8U8: 62
D3DFMT_Q8W8V8U8: 63
D3DFMT_V16U16: 64
D3DFMT_A2W10V10U10: 67
D3DFMT_UYVY: 1498831189
D3DFMT_R8G8_B8G8: 1195525970
D3DFMT_YUY2: 844715353
D3DFMT_G8R8_G8B8: 1111970375
D3DFMT_DXT1: 827611204
D3DFMT_DXT2: 844388420
D3DFMT_DXT3: 861165636
D3DFMT_DXT4: 877942852
D3DFMT_DXT5: 894720068
D3DFMT_D16_LOCKABLE: 70
D3DFMT_D32: 71
D3DFMT_D15S1: 73
D3DFMT_D24S8: 75
D3DFMT_D24X8: 77
D3DFMT_D24X4S4: 79
D3DFMT_D16: 80
D3DFMT_D32F_LOCKABLE: 82
D3DFMT_D24FS8: 83
D3DFMT_D32_LOCKABLE: 84
D3DFMT_S8_LOCKABLE: 85
D3DFMT_L16: 81
D3DFMT_VERTEXDATA: 100
D3DFMT_INDEX16: 101
D3DFMT_INDEX32: 102
D3DFMT_Q16W16V16U16: 110
D3DFMT_MULTI2_ARGB8: 827606349
; Floating point surface formats
; s10e5 formats (16-bits per channel)
D3DFMT_R16F: 111
D3DFMT_G16R16F: 112
D3DFMT_A16B16G16R16F: 113
; IEEE s23e8 formats (32-bits per channel)
D3DFMT_R32F: 114
D3DFMT_G32R32F: 115
D3DFMT_A32B32G32R32F: 116
D3DFMT_CxV8U8: 117
; Monochrome 1 bit per pixel format
D3DFMT_A1: 118
; 2.8 biased fixed point
D3DFMT_A2B10G10R10_XR_BIAS: 119
; Binary format indicating that the data has no inherent type
D3DFMT_BINARYBUFFER: 199
D3DFMT_FORCE_DWORD: 7FFFFFFFh
]
#enum D3DMULTISAMPLE_TYPE! [
D3DMULTISAMPLE_NONE: 0
D3DMULTISAMPLE_NONMASKABLE: 1
D3DMULTISAMPLE_2_SAMPLES: 2
D3DMULTISAMPLE_3_SAMPLES: 3
D3DMULTISAMPLE_4_SAMPLES: 4
D3DMULTISAMPLE_5_SAMPLES: 5
D3DMULTISAMPLE_6_SAMPLES: 6
D3DMULTISAMPLE_7_SAMPLES: 7
D3DMULTISAMPLE_8_SAMPLES: 8
D3DMULTISAMPLE_9_SAMPLES: 9
D3DMULTISAMPLE_10_SAMPLES: 10
D3DMULTISAMPLE_11_SAMPLES: 11
D3DMULTISAMPLE_12_SAMPLES: 12
D3DMULTISAMPLE_13_SAMPLES: 13
D3DMULTISAMPLE_14_SAMPLES: 14
D3DMULTISAMPLE_15_SAMPLES: 15
D3DMULTISAMPLE_16_SAMPLES: 16
D3DMULTISAMPLE_FORCE_DWORD: 7FFFFFFFh
]
#enum D3DSWAPEFFECT! [
D3DSWAPEFFECT_DISCARD: 1
D3DSWAPEFFECT_FLIP: 2
D3DSWAPEFFECT_COPY: 3
D3DSWAPEFFECT_OVERLAY: 4
D3DSWAPEFFECT_FLIPEX: 5
D3DSWAPEFFECT_FORCE_DWORD: 7FFFFFFFh
]
;directx functions
query-interface!: alias function! [
pad1 [byte-ptr!]
pad2 [byte-ptr!]
return: [byte-ptr!]
]
d3d-presentation-parameters!: alias struct! [
back-buffer-width [integer!]
back-buffer-height [integer!]
back-buffer-format [D3DFORMAT!]
back-buffer-count [integer!]
multi-sample-type [D3DMULTISAMPLE_TYPE!]
multi-sample-quality [DWORD!]
swap-effect [D3DSWAPEFFECT!]
h-device-window [HWND!]
windowed [BOOL!]
enable-auto-depth-stencil [BOOL!]
auto-depth-stencil-format [D3DFORMAT!]
flags [DWORD!]
full-screen-refresh-rate-in-hz [integer!]
presentation-interval [integer!]
]
;directx structs
direct3d-device!: alias struct! [
query-interface [function! []]
add-ref [function! []]
release [function! []]
TestCooperativeLevel [function! []]
GetAvailableTextureMem [function! []]
EvictManagedResources [function! []]
GetDirect3D [function! []]
GetDeviceCaps [function! []]
GetDisplayMode [function! []]
GetCreationParameters [function! []]
SetCursorProperties [function! []]
SetCursorPosition [function! []]
ShowCursor [function! []]
CreateAdditionalSwapChain [function! []]
GetSwapChain [function! []]
GetNumberOfSwapChains [function! []]
Reset [function! []]
Present [function! []]
GetBackBuffer [function! []]
GetRasterStatus [function! []]
SetDialogBoxMode [function! []]
SetGammaRamp [function! []]
GetGammaRamp [function! []]
CreateTexture [function! []]
CreateVolumeTexture [function! []]
CreateCubeTexture [function! []]
CreateVertexBuffer [function! []]
CreateIndexBuffer [function! []]
CreateRenderTarget [function! []]
CreateDepthStencilSurface [function! []]
UpdateSurface [function! []]
UpdateTexture [function! []]
GetRenderTargetData [function! []]
GetFrontBufferData [function! []]
StretchRect [function! []]
ColorFill [function! []]
CreateOffscreenPlainSurface [function! []]
SetRenderTarget [function! []]
GetRenderTarget [function! []]
SetDepthStencilSurface [function! []]
GetDepthStencilSurface [function! []]
BeginScene [function! []]
EndScene [function! []]
Clear [function! []]
SetTransform [function! []]
GetTransform [function! []]
MultiplyTransform [function! []]
SetViewport [function! []]
GetViewport [function! []]
SetMaterial [function! []]
GetMaterial [function! []]
SetLight [function! []]
GetLight [function! []]
LightEnable [function! []]
GetLightEnable [function! []]
SetClipPlane [function! []]
GetClipPlane [function! []]
SetRenderState [function! []]
GetRenderState [function! []]
CreateStateBlock [function! []]
BeginStateBlock [function! []]
EndStateBlock [function! []]
SetClipStatus [function! []]
GetClipStatus [function! []]
GetTexture [function! []]
SetTexture [function! []]
GetTextureStageState [function! []]
SetTextureStageState [function! []]
GetSamplerState [function! []]
SetSamplerState [function! []]
ValidateDevice [function! []]
SetPaletteEntries [function! []]
GetPaletteEntries [function! []]
SetCurrentTexturePalette [function! []]
GetCurrentTexturePalette [function! []]
SetScissorRect [function! []]
GetScissorRect [function! []]
SetSoftwareVertexProcessing [function! []]
GetSoftwareVertexProcessing [function! []]
SetNPatchMode [function! []]
GetNPatchMode [function! []]
DrawPrimitive [function! []]
DrawIndexedPrimitive [function! []]
DrawPrimitiveUP [function! []]
DrawIndexedPrimitiveUP [function! []]
ProcessVertices [function! []]
CreateVertexDeclaration [function! []]
SetVertexDeclaration [function! []]
GetVertexDeclaration [function! []]
SetFVF [function! []]
GetFVF [function! []]
CreateVertexShader [function! []]
SetVertexShader [function! []]
GetVertexShader [function! []]
SetVertexShaderConstantF [function! []]
GetVertexShaderConstantF [function! []]
SetVertexShaderConstantI [function! []]
GetVertexShaderConstantI [function! []]
SetVertexShaderConstantB [function! []]
GetVertexShaderConstantB [function! []]
SetStreamSource [function! []]
GetStreamSource [function! []]
SetStreamSourceFreq [function! []]
GetStreamSourceFreq [function! []]
SetIndices [function! []]
GetIndices [function! []]
CreatePixelShader [function! []]
SetPixelShader [function! []]
GetPixelShader [function! []]
SetPixelShaderConstantF [function! []]
GetPixelShaderConstantF [function! []]
SetPixelShaderConstantI [function! []]
GetPixelShaderConstantI [function! []]
SetPixelShaderConstantB [function! []]
GetPixelShaderConstantB [function! []]
DrawRectPatch [function! []]
DrawTriPatch [function! []]
DeletePatch [function! []]
CreateQuery [function! []]
]
direct3d!: alias struct! [
query-interface [function! []]
add-ref [function! []]
release [function! []]
RegisterSoftwareDevice [function! []]
GetAdapterCount [function! []]
GetAdapterIdentifier [function! []]
GetAdapterModeCount [function! []]
EnumAdapterModes [function! []]
GetAdapterDisplayMode [function! []]
CheckDeviceType [function! []]
CheckDeviceFormat [function! []]
CheckDeviceMultiSampleType [function! []]
CheckDepthStencilMatch [function! []]
CheckDeviceFormatConversion [function! []]
GetDeviceCaps [function! []]
GetAdapterMonitor [function! []]
create-device [function! [
adapter [integer!]
device-type [D3DDEVTYPE!]
focus-window [HWND!]
behavior-flags [DWORD!]
presentation-parameters [d3d-presentation-parameters!]
returned-device-interface [direct3d-device!]
return: [float!]
]
]
]
#import [
directx9-wrapper calling [
directx-create: "directXCreate" [
return: [direct3d!]
]
directx-create-device: "directXCreateDevice" [
window [byte-ptr!]
adapter [integer!]
device-type [D3DDEVTYPE!]
behaviour [DWORD!]
]
directx-destroy: "destroy_directx" [
device [direct3d-device!]
directx [direct3d!]
]
set-presentation-parameters-is-windowed: "set_present_parameters_windowed" [
logic [logic!]
]
set-presentation-parameters-swap-effect: "set_present_parameters_swap_effect" [
swap-effect [D3DSWAPEFFECT!]
]
set-presentation-parameters-enable-auto-depth-stencil: "set_present_parameters_enable_auto_depth_stencil" [
logic [logic!]
]
set-presentation-parameters-auto-depth-stencil-format: "set_present_parameters_auto_depth_stencil_format" [
format [D3DFORMAT!]
]
set-presentation-parameters-back-buffer-width: "set_present_parameters_back_buffer_width" [
int [integer!]
]
set-presentation-parameters-back-buffer-height: "set_present_parameters_back_buffer_height" [
int [integer!]
]
set-presentation-parameters-back-buffer-format: "set_present_parameters_back_buffer_format" [
format [D3DFORMAT!]
]
set-presentation-parameters-multi-sample-type: "set_present_parameters_multi_sample_type" [
type [D3DMULTISAMPLE_TYPE!]
]
set-presentation-parameters-h-device-window: "set_present_parameters_h_device_window" [
window [HWND!]
]
get-presentation-parameters: "get_presentation_parameters" [
return: [d3d-presentation-parameters!]
]
get-direct-3d-device: "get_direct_3d_device" [
return: [direct3d-device!]
]
get-direct-3d: "get_direct_3d" [
return: [direct3d!]
]
;misc calls
init-presentation-parameters: "zero_memory" []
;windows sys calls
get-active-window: "get_active_window" [
return: [byte-ptr!]
]
;D3DCREATE_SOFTWARE_VERTEXPROCESSING: "d3dcreate_software_vertex_processing" [
; return: [float!]
;]
]
]