1 | /*
|
---|
2 | * Compatibility functions for older GL implementations
|
---|
3 | *
|
---|
4 | * Copyright 2008 Stefan Dösinger for CodeWeavers
|
---|
5 | *
|
---|
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.
|
---|
10 | *
|
---|
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.
|
---|
15 | *
|
---|
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
---|
19 | */
|
---|
20 |
|
---|
21 | /*
|
---|
22 | * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
23 | * other than GPL or LGPL is available it will apply instead, Sun elects to use only
|
---|
24 | * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
25 | * a choice of LGPL license versions is made available with the language indicating
|
---|
26 | * that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
27 | * of the LGPL is applied is otherwise unspecified.
|
---|
28 | */
|
---|
29 |
|
---|
30 | #include "config.h"
|
---|
31 | #include <stdio.h>
|
---|
32 | #ifdef HAVE_FLOAT_H
|
---|
33 | # include <float.h>
|
---|
34 | #endif
|
---|
35 | #include "wined3d_private.h"
|
---|
36 |
|
---|
37 | WINE_DEFAULT_DEBUG_CHANNEL(gl_compat);
|
---|
38 |
|
---|
39 | /* Start GL_ARB_multitexture emulation */
|
---|
40 | static void WINE_GLAPI wine_glMultiTexCoord1fARB(GLenum target, GLfloat s) {
|
---|
41 | if(target != GL_TEXTURE0) {
|
---|
42 | ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
|
---|
43 | return;
|
---|
44 | }
|
---|
45 | glTexCoord1f(s);
|
---|
46 | }
|
---|
47 |
|
---|
48 | static void WINE_GLAPI wine_glMultiTexCoord1fvARB(GLenum target, const GLfloat *v) {
|
---|
49 | if(target != GL_TEXTURE0) {
|
---|
50 | ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
|
---|
51 | return;
|
---|
52 | }
|
---|
53 | glTexCoord1fv(v);
|
---|
54 | }
|
---|
55 |
|
---|
56 | static void WINE_GLAPI wine_glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t) {
|
---|
57 | if(target != GL_TEXTURE0) {
|
---|
58 | ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
|
---|
59 | return;
|
---|
60 | }
|
---|
61 | glTexCoord2f(s, t);
|
---|
62 | }
|
---|
63 |
|
---|
64 | static void WINE_GLAPI wine_glMultiTexCoord2fvARB(GLenum target, const GLfloat *v) {
|
---|
65 | if(target != GL_TEXTURE0) {
|
---|
66 | ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
|
---|
67 | return;
|
---|
68 | }
|
---|
69 | glTexCoord2fv(v);
|
---|
70 | }
|
---|
71 |
|
---|
72 | static void WINE_GLAPI wine_glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r) {
|
---|
73 | if(target != GL_TEXTURE0) {
|
---|
74 | ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
|
---|
75 | return;
|
---|
76 | }
|
---|
77 | glTexCoord3f(s, t, r);
|
---|
78 | }
|
---|
79 |
|
---|
80 | static void WINE_GLAPI wine_glMultiTexCoord3fvARB(GLenum target, const GLfloat *v) {
|
---|
81 | if(target != GL_TEXTURE0) {
|
---|
82 | ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
|
---|
83 | return;
|
---|
84 | }
|
---|
85 | glTexCoord3fv(v);
|
---|
86 | }
|
---|
87 |
|
---|
88 | static void WINE_GLAPI wine_glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
|
---|
89 | if(target != GL_TEXTURE0) {
|
---|
90 | ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
|
---|
91 | return;
|
---|
92 | }
|
---|
93 | glTexCoord4f(s, t, r, q);
|
---|
94 | }
|
---|
95 |
|
---|
96 | static void WINE_GLAPI wine_glMultiTexCoord4fvARB(GLenum target, const GLfloat *v) {
|
---|
97 | if(target != GL_TEXTURE0) {
|
---|
98 | ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
|
---|
99 | return;
|
---|
100 | }
|
---|
101 | glTexCoord4fv(v);
|
---|
102 | }
|
---|
103 |
|
---|
104 | static void WINE_GLAPI wine_glMultiTexCoord2svARB(GLenum target, const GLshort *v) {
|
---|
105 | if(target != GL_TEXTURE0) {
|
---|
106 | ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
|
---|
107 | return;
|
---|
108 | }
|
---|
109 | glTexCoord2sv(v);
|
---|
110 | }
|
---|
111 |
|
---|
112 | static void WINE_GLAPI wine_glMultiTexCoord4svARB(GLenum target, const GLshort *v) {
|
---|
113 | if(target != GL_TEXTURE0) {
|
---|
114 | ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
|
---|
115 | return;
|
---|
116 | }
|
---|
117 | glTexCoord4sv(v);
|
---|
118 | }
|
---|
119 |
|
---|
120 | static void WINE_GLAPI wine_glActiveTextureARB(GLenum texture) {
|
---|
121 | if(texture != GL_TEXTURE0) {
|
---|
122 | ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
|
---|
123 | return;
|
---|
124 | }
|
---|
125 | }
|
---|
126 |
|
---|
127 | static void WINE_GLAPI wine_glClientActiveTextureARB(GLenum texture) {
|
---|
128 | if(texture != GL_TEXTURE0) {
|
---|
129 | ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
|
---|
130 | return;
|
---|
131 | }
|
---|
132 | }
|
---|
133 |
|
---|
134 | static void (WINE_GLAPI *old_multitex_glGetIntegerv) (GLenum pname, GLint* params) = NULL;
|
---|
135 | static void WINE_GLAPI wine_glGetIntegerv(GLenum pname, GLint* params) {
|
---|
136 | switch(pname) {
|
---|
137 | case GL_ACTIVE_TEXTURE: *params = 0; break;
|
---|
138 | case GL_MAX_TEXTURE_UNITS_ARB: *params = 1; break;
|
---|
139 | default: old_multitex_glGetIntegerv(pname, params);
|
---|
140 | }
|
---|
141 | }
|
---|
142 |
|
---|
143 | static void (WINE_GLAPI *old_multitex_glGetFloatv) (GLenum pname, GLfloat* params) = NULL;
|
---|
144 | static void WINE_GLAPI wine_glGetFloatv(GLenum pname, GLfloat* params) {
|
---|
145 | if (pname == GL_ACTIVE_TEXTURE) *params = 0.0f;
|
---|
146 | else old_multitex_glGetFloatv(pname, params);
|
---|
147 | }
|
---|
148 |
|
---|
149 | static void (WINE_GLAPI *old_multitex_glGetDoublev) (GLenum pname, GLdouble* params) = NULL;
|
---|
150 | static void WINE_GLAPI wine_glGetDoublev(GLenum pname, GLdouble* params) {
|
---|
151 | if(pname == GL_ACTIVE_TEXTURE) *params = 0.0;
|
---|
152 | else old_multitex_glGetDoublev(pname, params);
|
---|
153 | }
|
---|
154 |
|
---|
155 | /* Start GL_EXT_fogcoord emulation */
|
---|
156 | static void (WINE_GLAPI *old_fogcoord_glEnable) (GLenum cap) = NULL;
|
---|
157 | static void WINE_GLAPI wine_glEnable(GLenum cap) {
|
---|
158 | if(cap == GL_FOG) {
|
---|
159 | struct wined3d_context *ctx = context_get_current();
|
---|
160 | ctx->fog_enabled = 1;
|
---|
161 | if(ctx->gl_fog_source != GL_FRAGMENT_DEPTH_EXT) return;
|
---|
162 | }
|
---|
163 | old_fogcoord_glEnable(cap);
|
---|
164 | }
|
---|
165 |
|
---|
166 | static void (WINE_GLAPI *old_fogcoord_glDisable) (GLenum cap) = NULL;
|
---|
167 | static void WINE_GLAPI wine_glDisable(GLenum cap) {
|
---|
168 | if(cap == GL_FOG) {
|
---|
169 | struct wined3d_context *ctx = context_get_current();
|
---|
170 | ctx->fog_enabled = 0;
|
---|
171 | if(ctx->gl_fog_source != GL_FRAGMENT_DEPTH_EXT) return;
|
---|
172 | }
|
---|
173 | old_fogcoord_glDisable(cap);
|
---|
174 | }
|
---|
175 |
|
---|
176 | static void (WINE_GLAPI *old_fogcoord_glFogi) (GLenum pname, GLint param) = NULL;
|
---|
177 | static void WINE_GLAPI wine_glFogi(GLenum pname, GLint param) {
|
---|
178 | struct wined3d_context *ctx = context_get_current();
|
---|
179 |
|
---|
180 | if(pname == GL_FOG_COORDINATE_SOURCE_EXT) {
|
---|
181 | ctx->gl_fog_source = param;
|
---|
182 | if(param == GL_FRAGMENT_DEPTH_EXT) {
|
---|
183 | if(ctx->fog_enabled) old_fogcoord_glEnable(GL_FOG);
|
---|
184 | } else {
|
---|
185 | WARN("Fog coords activated, but not supported. Using slow emulation\n");
|
---|
186 | old_fogcoord_glDisable(GL_FOG);
|
---|
187 | }
|
---|
188 | } else {
|
---|
189 | if(pname == GL_FOG_START) {
|
---|
190 | ctx->fogstart = param;
|
---|
191 | } else if(pname == GL_FOG_END) {
|
---|
192 | ctx->fogend = param;
|
---|
193 | }
|
---|
194 | old_fogcoord_glFogi(pname, param);
|
---|
195 | }
|
---|
196 | }
|
---|
197 |
|
---|
198 | static void (WINE_GLAPI *old_fogcoord_glFogiv) (GLenum pname, const GLint *param) = NULL;
|
---|
199 | static void WINE_GLAPI wine_glFogiv(GLenum pname, const GLint *param) {
|
---|
200 | struct wined3d_context *ctx = context_get_current();
|
---|
201 | if(pname == GL_FOG_COORDINATE_SOURCE_EXT) {
|
---|
202 | ctx->gl_fog_source = *param;
|
---|
203 | if(*param == GL_FRAGMENT_DEPTH_EXT) {
|
---|
204 | if(ctx->fog_enabled) old_fogcoord_glEnable(GL_FOG);
|
---|
205 | } else {
|
---|
206 | WARN("Fog coords activated, but not supported. Using slow emulation\n");
|
---|
207 | old_fogcoord_glDisable(GL_FOG);
|
---|
208 | }
|
---|
209 | } else {
|
---|
210 | if(pname == GL_FOG_START) {
|
---|
211 | ctx->fogstart = *param;
|
---|
212 | } else if(pname == GL_FOG_END) {
|
---|
213 | ctx->fogend = *param;
|
---|
214 | }
|
---|
215 | old_fogcoord_glFogiv(pname, param);
|
---|
216 | }
|
---|
217 | }
|
---|
218 |
|
---|
219 | static void (WINE_GLAPI *old_fogcoord_glFogf) (GLenum pname, GLfloat param) = NULL;
|
---|
220 | static void WINE_GLAPI wine_glFogf(GLenum pname, GLfloat param) {
|
---|
221 | struct wined3d_context *ctx = context_get_current();
|
---|
222 | if(pname == GL_FOG_COORDINATE_SOURCE_EXT) {
|
---|
223 | ctx->gl_fog_source = (GLint) param;
|
---|
224 | if(param == GL_FRAGMENT_DEPTH_EXT) {
|
---|
225 | if(ctx->fog_enabled) old_fogcoord_glEnable(GL_FOG);
|
---|
226 | } else {
|
---|
227 | WARN("Fog coords activated, but not supported. Using slow emulation\n");
|
---|
228 | old_fogcoord_glDisable(GL_FOG);
|
---|
229 | }
|
---|
230 | } else {
|
---|
231 | if(pname == GL_FOG_START) {
|
---|
232 | ctx->fogstart = param;
|
---|
233 | } else if(pname == GL_FOG_END) {
|
---|
234 | ctx->fogend = param;
|
---|
235 | }
|
---|
236 | old_fogcoord_glFogf(pname, param);
|
---|
237 | }
|
---|
238 | }
|
---|
239 |
|
---|
240 | static void (WINE_GLAPI *old_fogcoord_glFogfv) (GLenum pname, const GLfloat *param) = NULL;
|
---|
241 | static void WINE_GLAPI wine_glFogfv(GLenum pname, const GLfloat *param) {
|
---|
242 | struct wined3d_context *ctx = context_get_current();
|
---|
243 | if(pname == GL_FOG_COORDINATE_SOURCE_EXT) {
|
---|
244 | ctx->gl_fog_source = (GLint) *param;
|
---|
245 | if(*param == GL_FRAGMENT_DEPTH_EXT) {
|
---|
246 | if(ctx->fog_enabled) old_fogcoord_glEnable(GL_FOG);
|
---|
247 | } else {
|
---|
248 | WARN("Fog coords activated, but not supported. Using slow emulation\n");
|
---|
249 | old_fogcoord_glDisable(GL_FOG);
|
---|
250 | }
|
---|
251 | } else {
|
---|
252 | if(pname == GL_FOG_COLOR) {
|
---|
253 | ctx->fogcolor[0] = param[0];
|
---|
254 | ctx->fogcolor[1] = param[1];
|
---|
255 | ctx->fogcolor[2] = param[2];
|
---|
256 | ctx->fogcolor[3] = param[3];
|
---|
257 | } else if(pname == GL_FOG_START) {
|
---|
258 | ctx->fogstart = *param;
|
---|
259 | } else if(pname == GL_FOG_END) {
|
---|
260 | ctx->fogend = *param;
|
---|
261 | }
|
---|
262 | old_fogcoord_glFogfv(pname, param);
|
---|
263 | }
|
---|
264 | }
|
---|
265 |
|
---|
266 | static void (WINE_GLAPI *old_fogcoord_glVertex4f) (GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL;
|
---|
267 | static void (WINE_GLAPI *old_fogcoord_glVertex4fv) (const GLfloat *pos) = NULL;
|
---|
268 | static void (WINE_GLAPI *old_fogcoord_glVertex3f) (GLfloat x, GLfloat y, GLfloat z) = NULL;
|
---|
269 | static void (WINE_GLAPI *old_fogcoord_glVertex3fv) (const GLfloat *pos) = NULL;
|
---|
270 | static void (WINE_GLAPI *old_fogcoord_glColor4f) (GLfloat r, GLfloat g, GLfloat b, GLfloat a) = NULL;
|
---|
271 | static void (WINE_GLAPI *old_fogcoord_glColor4fv) (const GLfloat *color) = NULL;
|
---|
272 | static void (WINE_GLAPI *old_fogcoord_glColor3f) (GLfloat r, GLfloat g, GLfloat b) = NULL;
|
---|
273 | static void (WINE_GLAPI *old_fogcoord_glColor3fv) (const GLfloat *color) = NULL;
|
---|
274 | static void (WINE_GLAPI *old_fogcoord_glColor4ub) (GLubyte r, GLubyte g, GLubyte b, GLubyte a) = NULL;
|
---|
275 | static void (WINE_GLAPI *old_fogcoord_glFogCoordfEXT) (GLfloat f) = NULL;
|
---|
276 | static void (WINE_GLAPI *old_fogcoord_glFogCoorddEXT) (GLdouble f) = NULL;
|
---|
277 | static void (WINE_GLAPI *old_fogcoord_glFogCoordfvEXT) (const GLfloat *f) = NULL;
|
---|
278 | static void (WINE_GLAPI *old_fogcoord_glFogCoorddvEXT) (const GLdouble *f) = NULL;
|
---|
279 |
|
---|
280 | static void WINE_GLAPI wine_glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
|
---|
281 | struct wined3d_context *ctx = context_get_current();
|
---|
282 | if(ctx->gl_fog_source == GL_FOG_COORDINATE_EXT && ctx->fog_enabled) {
|
---|
283 | GLfloat c[4] = {ctx->color[0], ctx->color[1], ctx->color[2], ctx->color[3]};
|
---|
284 | GLfloat i;
|
---|
285 |
|
---|
286 | i = (ctx->fogend - ctx->fog_coord_value) / (ctx->fogend - ctx->fogstart);
|
---|
287 | c[0] = i * c[0] + (1.0f - i) * ctx->fogcolor[0];
|
---|
288 | c[1] = i * c[1] + (1.0f - i) * ctx->fogcolor[1];
|
---|
289 | c[2] = i * c[2] + (1.0f - i) * ctx->fogcolor[2];
|
---|
290 |
|
---|
291 | old_fogcoord_glColor4f(c[0], c[1], c[2], c[3]);
|
---|
292 | old_fogcoord_glVertex4f(x, y, z, w);
|
---|
293 | } else {
|
---|
294 | old_fogcoord_glVertex4f(x, y, z, w);
|
---|
295 | }
|
---|
296 | }
|
---|
297 |
|
---|
298 | static void WINE_GLAPI wine_glVertex4fv(const GLfloat *pos) {
|
---|
299 | wine_glVertex4f(pos[0], pos[1], pos[2], pos[3]);
|
---|
300 | }
|
---|
301 |
|
---|
302 | static void WINE_GLAPI wine_glVertex3f(GLfloat x, GLfloat y, GLfloat z) {
|
---|
303 | wine_glVertex4f(x, y, z, 1.0f);
|
---|
304 | }
|
---|
305 |
|
---|
306 | static void WINE_GLAPI wine_glVertex3fv(const GLfloat *pos) {
|
---|
307 | wine_glVertex4f(pos[0], pos[1], pos[2], 1.0f);
|
---|
308 | }
|
---|
309 |
|
---|
310 | static void WINE_GLAPI wine_glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
|
---|
311 | struct wined3d_context *ctx = context_get_current();
|
---|
312 | ctx->color[0] = r;
|
---|
313 | ctx->color[1] = g;
|
---|
314 | ctx->color[2] = b;
|
---|
315 | ctx->color[3] = a;
|
---|
316 | old_fogcoord_glColor4f(r, g, b, a);
|
---|
317 | }
|
---|
318 |
|
---|
319 | static void WINE_GLAPI wine_glColor4fv(const GLfloat *c) {
|
---|
320 | wine_glColor4f(c[0], c[1], c[2], c[3]);
|
---|
321 | }
|
---|
322 |
|
---|
323 | static void WINE_GLAPI wine_glColor3f(GLfloat r, GLfloat g, GLfloat b) {
|
---|
324 | wine_glColor4f(r, g, b, 1.0f);
|
---|
325 | }
|
---|
326 |
|
---|
327 | static void WINE_GLAPI wine_glColor3fv(const GLfloat *c) {
|
---|
328 | wine_glColor4f(c[0], c[1], c[2], 1.0f);
|
---|
329 | }
|
---|
330 |
|
---|
331 | static void WINE_GLAPI wine_glColor4ub(GLubyte r, GLubyte g, GLubyte b, GLubyte a) {
|
---|
332 | wine_glColor4f(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
|
---|
333 | }
|
---|
334 |
|
---|
335 | /* In D3D the fog coord is a UBYTE, so there's no problem with using the single
|
---|
336 | * precision function
|
---|
337 | */
|
---|
338 | static void WINE_GLAPI wine_glFogCoordfEXT(GLfloat f) {
|
---|
339 | struct wined3d_context *ctx = context_get_current();
|
---|
340 | ctx->fog_coord_value = f;
|
---|
341 | }
|
---|
342 | static void WINE_GLAPI wine_glFogCoorddEXT(GLdouble f) {
|
---|
343 | wine_glFogCoordfEXT(f);
|
---|
344 | }
|
---|
345 | static void WINE_GLAPI wine_glFogCoordfvEXT(const GLfloat *f) {
|
---|
346 | wine_glFogCoordfEXT(*f);
|
---|
347 | }
|
---|
348 | static void WINE_GLAPI wine_glFogCoorddvEXT(const GLdouble *f) {
|
---|
349 | wine_glFogCoordfEXT(*f);
|
---|
350 | }
|
---|
351 |
|
---|
352 | /* End GL_EXT_fog_coord emulation */
|
---|
353 |
|
---|
354 | void add_gl_compat_wrappers(struct wined3d_gl_info *gl_info)
|
---|
355 | {
|
---|
356 | if (!gl_info->supported[ARB_MULTITEXTURE])
|
---|
357 | {
|
---|
358 | TRACE("Applying GL_ARB_multitexture emulation hooks\n");
|
---|
359 | gl_info->glActiveTextureARB = wine_glActiveTextureARB;
|
---|
360 | gl_info->glClientActiveTextureARB = wine_glClientActiveTextureARB;
|
---|
361 | gl_info->glMultiTexCoord1fARB = wine_glMultiTexCoord1fARB;
|
---|
362 | gl_info->glMultiTexCoord1fvARB = wine_glMultiTexCoord1fvARB;
|
---|
363 | gl_info->glMultiTexCoord2fARB = wine_glMultiTexCoord2fARB;
|
---|
364 | gl_info->glMultiTexCoord2fvARB = wine_glMultiTexCoord2fvARB;
|
---|
365 | gl_info->glMultiTexCoord3fARB = wine_glMultiTexCoord3fARB;
|
---|
366 | gl_info->glMultiTexCoord3fvARB = wine_glMultiTexCoord3fvARB;
|
---|
367 | gl_info->glMultiTexCoord4fARB = wine_glMultiTexCoord4fARB;
|
---|
368 | gl_info->glMultiTexCoord4fvARB = wine_glMultiTexCoord4fvARB;
|
---|
369 | gl_info->glMultiTexCoord2svARB = wine_glMultiTexCoord2svARB;
|
---|
370 | gl_info->glMultiTexCoord4svARB = wine_glMultiTexCoord4svARB;
|
---|
371 | if(old_multitex_glGetIntegerv) {
|
---|
372 | FIXME("GL_ARB_multitexture glGetIntegerv hook already applied\n");
|
---|
373 | } else {
|
---|
374 | old_multitex_glGetIntegerv = glGetIntegerv;
|
---|
375 | glGetIntegerv = wine_glGetIntegerv;
|
---|
376 | }
|
---|
377 | if(old_multitex_glGetFloatv) {
|
---|
378 | FIXME("GL_ARB_multitexture glGetGloatv hook already applied\n");
|
---|
379 | } else {
|
---|
380 | old_multitex_glGetFloatv = glGetFloatv;
|
---|
381 | glGetFloatv = wine_glGetFloatv;
|
---|
382 | }
|
---|
383 | if(old_multitex_glGetDoublev) {
|
---|
384 | FIXME("GL_ARB_multitexture glGetDoublev hook already applied\n");
|
---|
385 | } else {
|
---|
386 | old_multitex_glGetDoublev = glGetDoublev;
|
---|
387 | glGetDoublev = wine_glGetDoublev;
|
---|
388 | }
|
---|
389 | gl_info->supported[ARB_MULTITEXTURE] = TRUE;
|
---|
390 | }
|
---|
391 |
|
---|
392 | if (!gl_info->supported[EXT_FOG_COORD])
|
---|
393 | {
|
---|
394 | /* This emulation isn't perfect. There are a number of potential problems, but they should
|
---|
395 | * not matter in practise:
|
---|
396 | *
|
---|
397 | * Fog vs fragment shader: If we are using GL_ARB_fragment_program with the fog option, the
|
---|
398 | * glDisable(GL_FOG) here won't matter. However, if we have GL_ARB_fragment_program, it is pretty
|
---|
399 | * unlikely that we don't have GL_EXT_fog_coord. Besides, we probably have GL_ARB_vertex_program
|
---|
400 | * too, which would allow fog coord emulation in a fixed function vertex pipeline replacement.
|
---|
401 | *
|
---|
402 | * Fog vs texture: We apply the fog in the vertex color. An app could set up texturing settings which
|
---|
403 | * ignore the vertex color, thus effectively disabing our fog. However, in D3D this type of fog is
|
---|
404 | * a per-vertex fog too, so the apps shouldn't do that.
|
---|
405 | *
|
---|
406 | * Fog vs lighting: The app could in theory use D3DFOG_NONE table and D3DFOG_NONE vertex fog with
|
---|
407 | * untransformed vertices. That enables lighting and fog coords at the same time, and the lighting
|
---|
408 | * calculations could affect the already blended in fog color. There's nothing we can do against that,
|
---|
409 | * but most apps using fog color do their own lighting too and often even use RHW vertices. So live
|
---|
410 | * with it.
|
---|
411 | */
|
---|
412 | TRACE("Applying GL_ARB_fog_coord emulation hooks\n");
|
---|
413 |
|
---|
414 | /* This probably means that the implementation doesn't advertise the extension, but implicitly supports
|
---|
415 | * it via the GL core version, or someone messed around in the extension table in directx.c. Add version-
|
---|
416 | * dependent loading for this extension if we ever hit this situation
|
---|
417 | */
|
---|
418 | if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
|
---|
419 | {
|
---|
420 | FIXME("GL implementation supports GL_ARB_fragment_program but not GL_EXT_fog_coord\n");
|
---|
421 | FIXME("The fog coord emulation will most likely fail\n");
|
---|
422 | }
|
---|
423 | else if (gl_info->supported[ARB_FRAGMENT_SHADER])
|
---|
424 | {
|
---|
425 | FIXME("GL implementation supports GL_ARB_fragment_shader but not GL_EXT_fog_coord\n");
|
---|
426 | FIXME("The fog coord emulation will most likely fail\n");
|
---|
427 | }
|
---|
428 |
|
---|
429 | if(old_fogcoord_glFogi) {
|
---|
430 | FIXME("GL_EXT_fogcoord glFogi hook already applied\n");
|
---|
431 | } else {
|
---|
432 | old_fogcoord_glFogi = glFogi;
|
---|
433 | glFogi = wine_glFogi;
|
---|
434 | }
|
---|
435 | if(old_fogcoord_glFogiv) {
|
---|
436 | FIXME("GL_EXT_fogcoord glFogiv hook already applied\n");
|
---|
437 | } else {
|
---|
438 | old_fogcoord_glFogiv = glFogiv;
|
---|
439 | glFogiv = wine_glFogiv;
|
---|
440 | }
|
---|
441 | if(old_fogcoord_glFogf) {
|
---|
442 | FIXME("GL_EXT_fogcoord glFogf hook already applied\n");
|
---|
443 | } else {
|
---|
444 | old_fogcoord_glFogf = glFogf;
|
---|
445 | glFogf = wine_glFogf;
|
---|
446 | }
|
---|
447 | if(old_fogcoord_glFogfv) {
|
---|
448 | FIXME("GL_EXT_fogcoord glFogfv hook already applied\n");
|
---|
449 | } else {
|
---|
450 | old_fogcoord_glFogfv = glFogfv;
|
---|
451 | glFogfv = wine_glFogfv;
|
---|
452 | }
|
---|
453 | if(old_fogcoord_glEnable) {
|
---|
454 | FIXME("GL_EXT_fogcoord glEnable hook already applied\n");
|
---|
455 | } else {
|
---|
456 | old_fogcoord_glEnable = glEnableWINE;
|
---|
457 | glEnableWINE = wine_glEnable;
|
---|
458 | }
|
---|
459 | if(old_fogcoord_glDisable) {
|
---|
460 | FIXME("GL_EXT_fogcoord glDisable hook already applied\n");
|
---|
461 | } else {
|
---|
462 | old_fogcoord_glDisable = glDisableWINE;
|
---|
463 | glDisableWINE = wine_glDisable;
|
---|
464 | }
|
---|
465 |
|
---|
466 | if(old_fogcoord_glVertex4f) {
|
---|
467 | FIXME("GL_EXT_fogcoord glVertex4f hook already applied\n");
|
---|
468 | } else {
|
---|
469 | old_fogcoord_glVertex4f = glVertex4f;
|
---|
470 | glVertex4f = wine_glVertex4f;
|
---|
471 | }
|
---|
472 | if(old_fogcoord_glVertex4fv) {
|
---|
473 | FIXME("GL_EXT_fogcoord glVertex4fv hook already applied\n");
|
---|
474 | } else {
|
---|
475 | old_fogcoord_glVertex4fv = glVertex4fv;
|
---|
476 | glVertex4fv = wine_glVertex4fv;
|
---|
477 | }
|
---|
478 | if(old_fogcoord_glVertex3f) {
|
---|
479 | FIXME("GL_EXT_fogcoord glVertex3f hook already applied\n");
|
---|
480 | } else {
|
---|
481 | old_fogcoord_glVertex3f = glVertex3f;
|
---|
482 | glVertex3f = wine_glVertex3f;
|
---|
483 | }
|
---|
484 | if(old_fogcoord_glVertex3fv) {
|
---|
485 | FIXME("GL_EXT_fogcoord glVertex3fv hook already applied\n");
|
---|
486 | } else {
|
---|
487 | old_fogcoord_glVertex3fv = glVertex3fv;
|
---|
488 | glVertex3fv = wine_glVertex3fv;
|
---|
489 | }
|
---|
490 |
|
---|
491 | if(old_fogcoord_glColor4f) {
|
---|
492 | FIXME("GL_EXT_fogcoord glColor4f hook already applied\n");
|
---|
493 | } else {
|
---|
494 | old_fogcoord_glColor4f = glColor4f;
|
---|
495 | glColor4f = wine_glColor4f;
|
---|
496 | }
|
---|
497 | if(old_fogcoord_glColor4fv) {
|
---|
498 | FIXME("GL_EXT_fogcoord glColor4fv hook already applied\n");
|
---|
499 | } else {
|
---|
500 | old_fogcoord_glColor4fv = glColor4fv;
|
---|
501 | glColor4fv = wine_glColor4fv;
|
---|
502 | }
|
---|
503 | if(old_fogcoord_glColor3f) {
|
---|
504 | FIXME("GL_EXT_fogcoord glColor3f hook already applied\n");
|
---|
505 | } else {
|
---|
506 | old_fogcoord_glColor3f = glColor3f;
|
---|
507 | glColor3f = wine_glColor3f;
|
---|
508 | }
|
---|
509 | if(old_fogcoord_glColor3fv) {
|
---|
510 | FIXME("GL_EXT_fogcoord glColor3fv hook already applied\n");
|
---|
511 | } else {
|
---|
512 | old_fogcoord_glColor3fv = glColor3fv;
|
---|
513 | glColor3fv = wine_glColor3fv;
|
---|
514 | }
|
---|
515 | if(old_fogcoord_glColor4ub) {
|
---|
516 | FIXME("GL_EXT_fogcoord glColor4ub hook already applied\n");
|
---|
517 | } else {
|
---|
518 | old_fogcoord_glColor4ub = glColor4ub;
|
---|
519 | glColor4ub = wine_glColor4ub;
|
---|
520 | }
|
---|
521 |
|
---|
522 | if(old_fogcoord_glFogCoordfEXT) {
|
---|
523 | FIXME("GL_EXT_fogcoord glFogCoordfEXT hook already applied\n");
|
---|
524 | } else {
|
---|
525 | old_fogcoord_glFogCoordfEXT = gl_info->glFogCoordfEXT;
|
---|
526 | gl_info->glFogCoordfEXT = wine_glFogCoordfEXT;
|
---|
527 | }
|
---|
528 | if(old_fogcoord_glFogCoordfvEXT) {
|
---|
529 | FIXME("GL_EXT_fogcoord glFogCoordfvEXT hook already applied\n");
|
---|
530 | } else {
|
---|
531 | old_fogcoord_glFogCoordfvEXT = gl_info->glFogCoordfvEXT;
|
---|
532 | gl_info->glFogCoordfvEXT = wine_glFogCoordfvEXT;
|
---|
533 | }
|
---|
534 | if(old_fogcoord_glFogCoorddEXT) {
|
---|
535 | FIXME("GL_EXT_fogcoord glFogCoorddEXT hook already applied\n");
|
---|
536 | } else {
|
---|
537 | old_fogcoord_glFogCoorddEXT = gl_info->glFogCoorddEXT;
|
---|
538 | gl_info->glFogCoorddEXT = wine_glFogCoorddEXT;
|
---|
539 | }
|
---|
540 | if(old_fogcoord_glFogCoorddvEXT) {
|
---|
541 | FIXME("GL_EXT_fogcoord glFogCoorddvEXT hook already applied\n");
|
---|
542 | } else {
|
---|
543 | old_fogcoord_glFogCoorddvEXT = gl_info->glFogCoorddvEXT;
|
---|
544 | gl_info->glFogCoorddvEXT = wine_glFogCoorddvEXT;
|
---|
545 | }
|
---|
546 | gl_info->supported[EXT_FOG_COORD] = TRUE;
|
---|
547 | }
|
---|
548 | }
|
---|