2 * Direct3D gl definitions
4 * Copyright 2003 Raphael Junqueira
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __WINE_D3DCORE_GL_H
22 #define __WINE_D3DCORE_GL_H
24 #ifndef __WINE_CONFIG_H
25 # error You must include config.h to use this header
28 #define XMD_H /* This is to prevent the Xmd.h inclusion bug :-/ */
31 #ifdef HAVE_GL_GLEXT_H
32 # include <GL/glext.h>
39 /**********************************
40 * OpenGL Extensions (EXT and ARB)
41 * defines and functions pointer
44 /* GL_EXT_secondary_color */
45 #ifndef GL_EXT_secondary_color
46 #define GL_EXT_secondary_color 1
47 #define GL_COLOR_SUM_EXT 0x8458
48 #define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459
49 #define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A
50 #define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B
51 #define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C
52 #define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D
53 #define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E
55 typedef void (APIENTRY * PGLFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue);
56 typedef void (APIENTRY * PGLFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v);
57 typedef void (APIENTRY * PGLFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue);
58 typedef void (APIENTRY * PGLFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
59 /* GL_EXT_paletted_texture */
60 #ifndef GL_EXT_paletted_texture
61 #define GL_EXT_paletted_texture 1
62 #define GL_COLOR_INDEX1_EXT 0x80E2
63 #define GL_COLOR_INDEX2_EXT 0x80E3
64 #define GL_COLOR_INDEX4_EXT 0x80E4
65 #define GL_COLOR_INDEX8_EXT 0x80E5
66 #define GL_COLOR_INDEX12_EXT 0x80E6
67 #define GL_COLOR_INDEX16_EXT 0x80E7
68 #define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED
70 typedef void (APIENTRY * PGLFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
71 /* GL_EXT_point_parameters */
72 #ifndef GL_EXT_point_parameters
73 #define GL_EXT_point_parameters 1
74 #define GL_POINT_SIZE_MIN_EXT 0x8126
75 #define GL_POINT_SIZE_MAX_EXT 0x8127
76 #define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128
77 #define GL_DISTANCE_ATTENUATION_EXT 0x8129
79 typedef void (APIENTRY * PGLFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param);
80 typedef void (APIENTRY * PGLFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params);
81 #ifndef GL_EXT_texture_env_combine
82 #define GL_EXT_texture_env_combine 1
83 #define GL_COMBINE_EXT 0x8570
84 #define GL_COMBINE_RGB_EXT 0x8571
85 #define GL_COMBINE_ALPHA_EXT 0x8572
86 #define GL_RGB_SCALE_EXT 0x8573
87 #define GL_ADD_SIGNED_EXT 0x8574
88 #define GL_INTERPOLATE_EXT 0x8575
89 #define GL_SUBTRACT_EXT 0x84E7
90 #define GL_CONSTANT_EXT 0x8576
91 #define GL_PRIMARY_COLOR_EXT 0x8577
92 #define GL_PREVIOUS_EXT 0x8578
93 #define GL_SOURCE0_RGB_EXT 0x8580
94 #define GL_SOURCE1_RGB_EXT 0x8581
95 #define GL_SOURCE2_RGB_EXT 0x8582
96 #define GL_SOURCE3_RGB_EXT 0x8583
97 #define GL_SOURCE4_RGB_EXT 0x8584
98 #define GL_SOURCE5_RGB_EXT 0x8585
99 #define GL_SOURCE6_RGB_EXT 0x8586
100 #define GL_SOURCE7_RGB_EXT 0x8587
101 #define GL_SOURCE0_ALPHA_EXT 0x8588
102 #define GL_SOURCE1_ALPHA_EXT 0x8589
103 #define GL_SOURCE2_ALPHA_EXT 0x858A
104 #define GL_SOURCE3_ALPHA_EXT 0x858B
105 #define GL_SOURCE4_ALPHA_EXT 0x858C
106 #define GL_SOURCE5_ALPHA_EXT 0x858D
107 #define GL_SOURCE6_ALPHA_EXT 0x858E
108 #define GL_SOURCE7_ALPHA_EXT 0x858F
109 #define GL_OPERAND0_RGB_EXT 0x8590
110 #define GL_OPERAND1_RGB_EXT 0x8591
111 #define GL_OPERAND2_RGB_EXT 0x8592
112 #define GL_OPERAND3_RGB_EXT 0x8593
113 #define GL_OPERAND4_RGB_EXT 0x8594
114 #define GL_OPERAND5_RGB_EXT 0x8595
115 #define GL_OPERAND6_RGB_EXT 0x8596
116 #define GL_OPERAND7_RGB_EXT 0x8597
117 #define GL_OPERAND0_ALPHA_EXT 0x8598
118 #define GL_OPERAND1_ALPHA_EXT 0x8599
119 #define GL_OPERAND2_ALPHA_EXT 0x859A
120 #define GL_OPERAND3_ALPHA_EXT 0x859B
121 #define GL_OPERAND4_ALPHA_EXT 0x859C
122 #define GL_OPERAND5_ALPHA_EXT 0x859D
123 #define GL_OPERAND6_ALPHA_EXT 0x859E
124 #define GL_OPERAND7_ALPHA_EXT 0x859F
126 /* GL_EXT_texture_env_dot3 */
127 #ifndef GL_EXT_texture_env_dot3
128 #define GL_EXT_texture_env_dot3 1
129 #define GL_DOT3_RGB_EXT 0x8740
130 #define GL_DOT3_RGBA_EXT 0x8741
135 * OpenGL Official Version
140 #if !defined(GL_DOT3_RGBA)
141 # define GL_DOT3_RGBA 0x8741
143 #if !defined(GL_SUBTRACT)
144 # define GL_SUBTRACT 0x84E7
148 /*********************************
149 * OpenGL GLX Extensions
150 * defines and functions pointer
155 /*********************************
156 * OpenGL GLX Official Version
157 * defines and functions pointer
160 /* GLX_VERSION_1_3 */
161 typedef GLXFBConfig * (APIENTRY * PGLXFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements);
162 typedef GLXFBConfig * (APIENTRY * PGLXFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
163 typedef int (APIENTRY * PGLXFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value);
164 typedef XVisualInfo * (APIENTRY * PGLXFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);
165 typedef GLXWindow (APIENTRY * PGLXFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
166 typedef void (APIENTRY * PGLXFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win);
167 typedef GLXPixmap (APIENTRY * PGLXFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
168 typedef void (APIENTRY * PGLXFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap);
169 typedef GLXPbuffer (APIENTRY * PGLXFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list);
170 typedef void (APIENTRY * PGLXFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf);
171 typedef void (APIENTRY * PGLXFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
172 typedef GLXContext (APIENTRY * PGLXFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
173 typedef Bool (APIENTRY * PGLXFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
174 typedef GLXDrawable (APIENTRY * PGLXFNGLXGETCURRENTREADDRAWABLEPROC) (void);
175 typedef Display * (APIENTRY * PGLXFNGLXGETCURRENTDISPLAYPROC) (void);
176 typedef int (APIENTRY * PGLXFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);
177 typedef void (APIENTRY * PGLXFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask);
178 typedef void (APIENTRY * PGLXFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
181 /********************************************
182 * OpenGL Supported Extensions (ARB and EXT)
185 typedef enum _GL_SupportedExt {
187 ARB_FRAGMENT_PROGRAM,
190 ARB_POINT_PARAMETERS,
191 ARB_TEXTURE_COMPRESSION,
192 ARB_TEXTURE_CUBE_MAP,
193 ARB_TEXTURE_ENV_COMBINE,
194 ARB_TEXTURE_ENV_DOT3,
199 EXT_PALETTED_TEXTURE,
200 EXT_POINT_PARAMETERS,
202 EXT_TEXTURE_COMPRESSION_S3TC,
203 EXT_TEXTURE_FILTER_ANISOTROPIC,
205 EXT_TEXTURE_LOD_BIAS,
206 EXT_VERTEX_WEIGHTING,
213 OPENGL_SUPPORTED_EXT_END
216 typedef enum _GL_VSVersion {
217 VS_VERSION_NOT_SUPPORTED = 0x0,
218 VS_VERSION_10 = 0x10,
219 VS_VERSION_11 = 0x11,
220 VS_VERSION_20 = 0x20,
221 VS_VERSION_30 = 0x30,
223 VS_VERSION_FORCE_DWORD = 0x7FFFFFFF
226 typedef enum _GL_PSVersion {
227 PS_VERSION_NOT_SUPPORTED = 0x0,
228 PS_VERSION_10 = 0x10,
229 PS_VERSION_11 = 0x11,
230 PS_VERSION_12 = 0x12,
231 PS_VERSION_13 = 0x13,
232 PS_VERSION_14 = 0x14,
233 PS_VERSION_20 = 0x20,
234 PS_VERSION_30 = 0x30,
236 PS_VERSION_FORCE_DWORD = 0x7FFFFFFF
240 #define GL_EXT_FUNCS_GEN \
241 /** EXT Extensions **/ \
242 /* GL_EXT_fog_coord */ \
243 /* GL_EXT_paletted_texture */ \
244 USE_GL_FUNC(PGLFNGLCOLORTABLEEXTPROC, glColorTableEXT); \
245 /* GL_EXT_point_parameters */ \
246 USE_GL_FUNC(PGLFNGLPOINTPARAMETERFEXTPROC, glPointParameterfEXT); \
247 USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVEXTPROC, glPointParameterfvEXT); \
248 /* GL_EXT_secondary_color */ \
249 USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3UBEXTPROC, glSecondaryColor3ubEXT); \
250 USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3FEXTPROC, glSecondaryColor3fEXT); \
251 USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3FVEXTPROC, glSecondaryColor3fvEXT); \
252 USE_GL_FUNC(PGLFNGLSECONDARYCOLORPOINTEREXTPROC, glSecondaryColorPointerEXT); \
254 #define GLX_EXT_FUNCS_GEN \
255 /** GLX_VERSION_1_3 **/ \
256 USE_GL_FUNC(PGLXFNGLXCREATEPBUFFERPROC, glXCreatePbuffer); \
257 USE_GL_FUNC(PGLXFNGLXDESTROYPBUFFERPROC, glXDestroyPbuffer); \
258 USE_GL_FUNC(PGLXFNGLXCREATEPIXMAPPROC, glXCreatePixmap); \
259 USE_GL_FUNC(PGLXFNGLXDESTROYPIXMAPPROC, glXDestroyPixmap); \
260 USE_GL_FUNC(PGLXFNGLXCREATENEWCONTEXTPROC, glXCreateNewContext); \
261 USE_GL_FUNC(PGLXFNGLXMAKECONTEXTCURRENTPROC, glXMakeContextCurrent); \
262 USE_GL_FUNC(PGLXFNGLXCHOOSEFBCONFIGPROC, glXChooseFBConfig); \
268 /* Redefines the constants */
269 #define CALLBACK __stdcall
270 #define WINAPI __stdcall
271 #define APIENTRY WINAPI
273 /* Routine common to the draw primitive and draw indexed primitive routines */
274 void drawPrimitive(LPDIRECT3DDEVICE8 iface,
279 long StartVertexIndex,
286 /*****************************************
287 * Structures required to draw primitives
290 typedef struct Direct3DStridedData {
291 BYTE *lpData; /* Pointer to start of data */
292 DWORD dwStride; /* Stride between occurances of this data */
293 DWORD dwType; /* Type (as in D3DVSDT_TYPE) */
294 } Direct3DStridedData;
296 typedef struct Direct3DVertexStridedData {
299 Direct3DStridedData position;
300 Direct3DStridedData blendWeights;
301 Direct3DStridedData blendMatrixIndices;
302 Direct3DStridedData normal;
303 Direct3DStridedData pSize;
304 Direct3DStridedData diffuse;
305 Direct3DStridedData specular;
306 Direct3DStridedData texCoords[8];
308 Direct3DStridedData input[16]; /* Indexed by constants in D3DVSDE_REGISTER */
310 } Direct3DVertexStridedData;
312 #define USE_GL_FUNC(type, pfn) type pfn;
313 typedef struct _GL_Info {
321 GL_PSVersion ps_arb_version;
322 GL_PSVersion ps_nv_version;
324 GL_VSVersion vs_arb_version;
325 GL_VSVersion vs_nv_version;
326 GL_VSVersion vs_ati_version;
330 /** OpenGL EXT and ARB functions ptr */
332 /** OpenGL GLX functions ptr */
339 #endif /* __WINE_D3DCORE_GL_H */