2 * Copyright (C) 2011 David Hoyt <dhoyt@hoytsoft.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef __DIRECTX_D3D_H__
21 #define __DIRECTX_D3D_H__
29 #define WM_DIRECTX_D3D_INIT_DEVICE WM_DIRECTX + 1
30 #define WM_DIRECTX_D3D_INIT_DEVICELOST WM_DIRECTX + 2
31 #define WM_DIRECTX_D3D_DEVICELOST WM_DIRECTX + 3
32 #define WM_DIRECTX_D3D_END_DEVICELOST WM_DIRECTX + 4
33 #define WM_DIRECTX_D3D_RESIZE WM_DIRECTX + 5
35 #define DIRECTX_D3D_API(version, dispatch_table, init_function, create_function, resize_function, device_lost_function, notify_device_reset_function, release_function) \
36 static gpointer DIRECTX_API_COMPONENT_D3D_ ## version ## _DISPATCH_TABLE = &dispatch_table; \
37 static DirectXAPIComponentD3D DIRECTX_API_COMPONENT_D3D_ ## version ## _INIT = { \
38 create_function /*create_function*/ \
39 , resize_function /*resize_function*/ \
40 , device_lost_function /*device_lost_function*/ \
41 , notify_device_reset_function /*notify_device_reset_function*/ \
42 , release_function /*release_function*/ \
43 , NULL /*private_data*/ \
45 static void init_directx_api_component_d3d_ ## version ## _(const DirectXAPI* api) { \
46 gpointer private_data = &DIRECTX_API_COMPONENT_D3D_ ## version ## _INIT; \
47 gpointer vtable = DIRECTX_API_COMPONENT_D3D_ ## version ## _DISPATCH_TABLE; \
48 DIRECTX_SET_COMPONENT_INIT(DIRECTX_D3D(api), init_function); \
49 DIRECTX_SET_COMPONENT_DATA(DIRECTX_D3D(api), private_data); \
50 DIRECTX_SET_COMPONENT_DISPATCH_TABLE(DIRECTX_D3D(api), vtable); \
53 #define INITIALIZE_DIRECTX_D3D_API(version, api) \
54 init_directx_api_component_d3d_ ## version ## _(api);
56 #define DIRECTX_D3D_FUNCTIONS(d3d) ((DirectXAPIComponentD3D*)d3d->d3d_component)
57 #define DIRECTX_D3D_API_FUNCTIONS(api) ((DirectXAPIComponentD3D*)DIRECTX_D3D_COMPONENT_DATA(api))
58 #define DIRECTX_D3D_CALL_FUNCTION(d3d, func_name, ...) (DIRECTX_D3D_FUNCTIONS(d3d)->func_name(__VA_ARGS__))
59 #define DIRECTX_D3D_CALL_API_FUNCTION(api, func_name, ...) (DIRECTX_D3D_API_FUNCTIONS(api)->func_name(__VA_ARGS__))
61 typedef struct _DirectXD3D DirectXD3D;
62 typedef struct _DirectXAPIComponentD3D DirectXAPIComponentD3D;
64 /* Function pointers */
65 typedef DirectXD3D* (*DirectXD3DCreateFunction) (const DirectXAPI* api);
66 typedef gboolean (*DirectXD3DResizeFunction) (const DirectXD3D* d3d);
67 typedef gboolean (*DirectXD3DDeviceLostFunction) (const DirectXD3D* d3d);
68 typedef gboolean (*DirectXD3DNotifyDeviceResetFunction) (const DirectXD3D* d3d);
69 typedef gboolean (*DirectXD3DReleaseFunction) (const DirectXD3D* d3d);
71 struct _DirectXAPIComponentD3D
73 DirectXD3DCreateFunction create;
74 DirectXD3DResizeFunction resize;
75 DirectXD3DDeviceLostFunction device_lost;
76 DirectXD3DNotifyDeviceResetFunction notify_device_reset;
77 DirectXD3DReleaseFunction release;
79 gpointer private_data;
85 DirectXAPIComponent* api_component;
86 DirectXAPIComponentD3D* d3d_component;
88 gpointer private_data;
91 const DirectXD3D* directx_d3d_create(const DirectXAPI* api);
92 gboolean directx_d3d_resize(const DirectXD3D* d3d);
93 gboolean directx_d3d_device_lost(const DirectXD3D* d3d);
94 gboolean directx_d3d_notify_device_reset(const DirectXD3D* d3d);
95 gboolean directx_d3d_release(const DirectXD3D* d3d);
99 #endif /* __DIRECTX_D3D_H__ */