yagl_gles_ogl_macros.h: use APIENTRY wit function type prototypes
[sdk/emulator/qemu.git] / hw / yagl_drivers / gles_ogl / yagl_gles_ogl_macros.h
1 #ifndef _QEMU_YAGL_GLES_OGL_MACROS_H
2 #define _QEMU_YAGL_GLES_OGL_MACROS_H
3
4 #include <GL/gl.h>
5
6 /*
7  * GLES OpenGL prototyping macros.
8  * @{
9  */
10
11 #define YAGL_GLES_OGL_PROC0(func) \
12 void (APIENTRY *func)(void);
13
14 #define YAGL_GLES_OGL_PROC_RET0(ret_type, func) \
15 ret_type (APIENTRY *func)(void);
16
17 #define YAGL_GLES_OGL_PROC1(func, arg0_type, arg0) \
18 void (APIENTRY *func)(arg0_type arg0);
19
20 #define YAGL_GLES_OGL_PROC_RET1(ret_type, func, arg0_type, arg0) \
21 ret_type (APIENTRY *func)(arg0_type arg0);
22
23 #define YAGL_GLES_OGL_PROC2(func, arg0_type, arg1_type, arg0, arg1) \
24 void (APIENTRY *func)(arg0_type arg0, arg1_type arg1);
25
26 #define YAGL_GLES_OGL_PROC_RET2(ret_type, func, arg0_type, arg1_type, arg0, arg1) \
27 ret_type (APIENTRY *func)(arg0_type arg0, arg1_type arg1);
28
29 #define YAGL_GLES_OGL_PROC3(func, arg0_type, arg1_type, arg2_type, arg0, arg1, arg2) \
30 void (APIENTRY *func)(arg0_type arg0, arg1_type arg1, arg2_type arg2);
31
32 #define YAGL_GLES_OGL_PROC4(func, arg0_type, arg1_type, arg2_type, arg3_type, arg0, arg1, arg2, arg3) \
33 void (APIENTRY *func)(arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg3);
34
35 #define YAGL_GLES_OGL_PROC5(func, arg0_type, arg1_type, arg2_type, arg3_type, arg4_type, arg0, arg1, arg2, arg3, arg4) \
36 void (APIENTRY *func)(arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4);
37
38 #define YAGL_GLES_OGL_PROC6(func, arg0_type, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg0, arg1, arg2, arg3, arg4, arg5) \
39 void (APIENTRY *func)(arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg3, \
40      arg4_type arg4, arg5_type arg5);
41
42 #define YAGL_GLES_OGL_PROC7(func, arg0_type, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg0, arg1, arg2, arg3, arg4, arg5, arg6) \
43 void (APIENTRY *func)(arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg3, \
44      arg4_type arg4, arg5_type arg5, arg6_type arg6);
45
46 #define YAGL_GLES_OGL_PROC8(func, arg0_type, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
47 void (APIENTRY *func)(arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg3, \
48      arg4_type arg4, arg5_type arg5, arg6_type arg6, arg7_type arg7);
49
50 #define YAGL_GLES_OGL_PROC9(func, arg0_type, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
51 void (APIENTRY *func)(arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg3, \
52      arg4_type arg4, arg5_type arg5, arg6_type arg6, arg7_type arg7, \
53      arg8_type arg8);
54
55 /*
56  * @}
57  */
58
59 /*
60  * GLES OpenGL basic implementation macros.
61  * @{
62  */
63
64 #define YAGL_GLES_OGL_PROC_IMPL0(obj_type, ps_type, driver_type, func) \
65 static void driver_type##_##func(struct obj_type *driver_ps) \
66 { \
67     struct driver_type *d = (struct driver_type*)(((struct ps_type*)driver_ps)->driver); \
68     d->gl##func(); \
69 }
70
71 #define YAGL_GLES_OGL_PROC_IMPL_RET0(obj_type, ps_type, driver_type, ret_type, func) \
72 static ret_type driver_type##_##func(struct obj_type *driver_ps) \
73 { \
74     struct driver_type *d = (struct driver_type*)(((struct ps_type*)driver_ps)->driver); \
75     return d->gl##func(); \
76 }
77
78 #define YAGL_GLES_OGL_PROC_IMPL1(obj_type, ps_type, driver_type, func, arg0_type, arg0) \
79 static void driver_type##_##func(struct obj_type *driver_ps, arg0_type arg0) \
80 { \
81     struct driver_type *d = (struct driver_type*)(((struct ps_type*)driver_ps)->driver); \
82     d->gl##func(arg0); \
83 }
84
85 #define YAGL_GLES_OGL_PROC_IMPL_RET1(obj_type, ps_type, driver_type, ret_type, func, arg0_type, arg0) \
86 static ret_type driver_type##_##func(struct obj_type *driver_ps, arg0_type arg0) \
87 { \
88     struct driver_type *d = (struct driver_type*)(((struct ps_type*)driver_ps)->driver); \
89     return d->gl##func(arg0); \
90 }
91
92 #define YAGL_GLES_OGL_PROC_IMPL2(obj_type, ps_type, driver_type, func, arg0_type, arg1_type, arg0, arg1) \
93 static void driver_type##_##func(struct obj_type *driver_ps, arg0_type arg0, arg1_type arg1) \
94 { \
95     struct driver_type *d = (struct driver_type*)(((struct ps_type*)driver_ps)->driver); \
96     d->gl##func(arg0, arg1); \
97 }
98
99 #define YAGL_GLES_OGL_PROC_IMPL_RET2(obj_type, ps_type, driver_type, ret_type, func, arg0_type, arg1_type, arg0, arg1) \
100 static ret_type driver_type##_##func(struct obj_type *driver_ps, arg0_type arg0, arg1_type arg1) \
101 { \
102     struct driver_type *d = (struct driver_type*)(((struct ps_type*)driver_ps)->driver); \
103     return d->gl##func(arg0, arg1); \
104 }
105
106 #define YAGL_GLES_OGL_PROC_IMPL3(obj_type, ps_type, driver_type, func, arg0_type, arg1_type, arg2_type, arg0, arg1, arg2) \
107 static void driver_type##_##func(struct obj_type *driver_ps, arg0_type arg0, arg1_type arg1, arg2_type arg2) \
108 { \
109     struct driver_type *d = (struct driver_type*)(((struct ps_type*)driver_ps)->driver); \
110     d->gl##func(arg0, arg1, arg2); \
111 }
112
113 #define YAGL_GLES_OGL_PROC_IMPL4(obj_type, ps_type, driver_type, func, arg0_type, arg1_type, arg2_type, arg3_type, arg0, arg1, arg2, arg3) \
114 static void driver_type##_##func(struct obj_type *driver_ps, arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg3) \
115 { \
116     struct driver_type *d = (struct driver_type*)(((struct ps_type*)driver_ps)->driver); \
117     d->gl##func(arg0, arg1, arg2, arg3); \
118 }
119
120 #define YAGL_GLES_OGL_PROC_IMPL5(obj_type, ps_type, driver_type, func, arg0_type, arg1_type, arg2_type, arg3_type, arg4_type, arg0, arg1, arg2, arg3, arg4) \
121 static void driver_type##_##func(struct obj_type *driver_ps, arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4) \
122 { \
123     struct driver_type *d = (struct driver_type*)(((struct ps_type*)driver_ps)->driver); \
124     d->gl##func(arg0, arg1, arg2, arg3, arg4); \
125 }
126
127 #define YAGL_GLES_OGL_PROC_IMPL6(obj_type, ps_type, driver_type, func, arg0_type, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg0, arg1, arg2, arg3, arg4, arg5) \
128 static void driver_type##_##func(struct obj_type *driver_ps, arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, arg5_type arg5) \
129 { \
130     struct driver_type *d = (struct driver_type*)(((struct ps_type*)driver_ps)->driver); \
131     d->gl##func(arg0, arg1, arg2, arg3, arg4, arg5); \
132 }
133
134 #define YAGL_GLES_OGL_PROC_IMPL7(obj_type, ps_type, driver_type, func, arg0_type, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg0, arg1, arg2, arg3, arg4, arg5, arg6) \
135 static void driver_type##_##func(struct obj_type *driver_ps, arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, arg5_type arg5, arg6_type arg6) \
136 { \
137     struct driver_type *d = (struct driver_type*)(((struct ps_type*)driver_ps)->driver); \
138     d->gl##func(arg0, arg1, arg2, arg3, arg4, arg5, arg6); \
139 }
140
141 #define YAGL_GLES_OGL_PROC_IMPL8(obj_type, ps_type, driver_type, func, arg0_type, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
142 static void driver_type##_##func(struct obj_type *driver_ps, arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, arg5_type arg5, arg6_type arg6, arg7_type arg7) \
143 { \
144     struct driver_type *d = (struct driver_type*)(((struct ps_type*)driver_ps)->driver); \
145     d->gl##func(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); \
146 }
147
148 #define YAGL_GLES_OGL_PROC_IMPL9(obj_type, ps_type, driver_type, func, arg0_type, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
149 static void driver_type##_##func(struct obj_type *driver_ps, arg0_type arg0, arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8) \
150 { \
151     struct driver_type *d = (struct driver_type*)(((struct ps_type*)driver_ps)->driver); \
152     d->gl##func(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); \
153 }
154
155 /*
156  * @}
157  */
158
159 /*
160  * GLES OpenGL function loading/assigning macros.
161  * @{
162  */
163
164 #define YAGL_GLES_OGL_GET_PROC(driver, func) \
165     do { \
166         *(void**)(&driver->func) = yagl_dyn_lib_procaddr_get(dyn_lib, #func); \
167         if (!driver->func) { \
168             YAGL_LOG_ERROR("Unable to get symbol: %s", \
169                            yagl_dyn_lib_get_error(dyn_lib)); \
170             goto fail; \
171         } \
172     } while (0)
173
174 #define YAGL_GLES_OGL_ASSIGN_PROC(driver_type, driver_ps, func) \
175     driver_ps->base.func = &driver_type##_##func
176
177 /*
178  * @}
179  */
180
181 #endif