2 * Utility functions for the WineD3D Library
4 * Copyright 2002-2004 Jason Edmeades
5 * Copyright 2003-2004 Raphael Junqueira
6 * Copyright 2004 Christian Costa
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "wined3d_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
28 /*****************************************************************************
29 * Trace formatting of useful values
31 const char* debug_d3dformat(D3DFORMAT fmt
) {
33 #define FMT_TO_STR(fmt) case fmt: return #fmt
34 FMT_TO_STR(WINED3DFMT_UNKNOWN
);
35 FMT_TO_STR(WINED3DFMT_R8G8B8
);
36 FMT_TO_STR(WINED3DFMT_A8R8G8B8
);
37 FMT_TO_STR(WINED3DFMT_X8R8G8B8
);
38 FMT_TO_STR(WINED3DFMT_R5G6B5
);
39 FMT_TO_STR(WINED3DFMT_X1R5G5B5
);
40 FMT_TO_STR(WINED3DFMT_A1R5G5B5
);
41 FMT_TO_STR(WINED3DFMT_A4R4G4B4
);
42 FMT_TO_STR(WINED3DFMT_R3G3B2
);
43 FMT_TO_STR(WINED3DFMT_A8
);
44 FMT_TO_STR(WINED3DFMT_A8R3G3B2
);
45 FMT_TO_STR(WINED3DFMT_X4R4G4B4
);
46 FMT_TO_STR(WINED3DFMT_G16R16
);
47 FMT_TO_STR(WINED3DFMT_A2R10G10B10
);
48 FMT_TO_STR(WINED3DFMT_A16B16G16R16
);
49 FMT_TO_STR(WINED3DFMT_A8P8
);
50 FMT_TO_STR(WINED3DFMT_P8
);
51 FMT_TO_STR(WINED3DFMT_L8
);
52 FMT_TO_STR(WINED3DFMT_A8L8
);
53 FMT_TO_STR(WINED3DFMT_A4L4
);
54 FMT_TO_STR(WINED3DFMT_V8U8
);
55 FMT_TO_STR(WINED3DFMT_L6V5U5
);
56 FMT_TO_STR(WINED3DFMT_X8L8V8U8
);
57 FMT_TO_STR(WINED3DFMT_Q8W8V8U8
);
58 FMT_TO_STR(WINED3DFMT_V16U16
);
59 FMT_TO_STR(WINED3DFMT_W11V11U10
);
60 FMT_TO_STR(WINED3DFMT_A2W10V10U10
);
61 FMT_TO_STR(WINED3DFMT_UYVY
);
62 FMT_TO_STR(WINED3DFMT_YUY2
);
63 FMT_TO_STR(WINED3DFMT_DXT1
);
64 FMT_TO_STR(WINED3DFMT_DXT2
);
65 FMT_TO_STR(WINED3DFMT_DXT3
);
66 FMT_TO_STR(WINED3DFMT_DXT4
);
67 FMT_TO_STR(WINED3DFMT_DXT5
);
68 FMT_TO_STR(WINED3DFMT_MULTI2_ARGB
);
69 FMT_TO_STR(WINED3DFMT_G8R8_G8B8
);
70 FMT_TO_STR(WINED3DFMT_R8G8_B8G8
);
71 FMT_TO_STR(WINED3DFMT_D16_LOCKABLE
);
72 FMT_TO_STR(WINED3DFMT_D32
);
73 FMT_TO_STR(WINED3DFMT_D15S1
);
74 FMT_TO_STR(WINED3DFMT_D24S8
);
75 FMT_TO_STR(WINED3DFMT_D24X8
);
76 FMT_TO_STR(WINED3DFMT_D24X4S4
);
77 FMT_TO_STR(WINED3DFMT_D16
);
78 FMT_TO_STR(WINED3DFMT_D32F_LOCKABLE
);
79 FMT_TO_STR(WINED3DFMT_VERTEXDATA
);
80 FMT_TO_STR(WINED3DFMT_INDEX16
);
81 FMT_TO_STR(WINED3DFMT_INDEX32
);
82 FMT_TO_STR(WINED3DFMT_Q16W16V16U16
);
83 FMT_TO_STR(WINED3DFMT_R16F
);
84 FMT_TO_STR(WINED3DFMT_G16R16F
);
85 FMT_TO_STR(WINED3DFMT_A16B16G16R16F
);
88 FIXME("Unrecognized %u D3DFORMAT!\n", fmt
);
89 return "unrecognized";
93 const char* debug_d3ddevicetype(D3DDEVTYPE devtype
) {
95 #define DEVTYPE_TO_STR(dev) case dev: return #dev
96 DEVTYPE_TO_STR(D3DDEVTYPE_HAL
);
97 DEVTYPE_TO_STR(D3DDEVTYPE_REF
);
98 DEVTYPE_TO_STR(D3DDEVTYPE_SW
);
101 FIXME("Unrecognized %u D3DDEVTYPE!\n", devtype
);
102 return "unrecognized";
106 const char* debug_d3dusage(DWORD usage
) {
108 #define D3DUSAGE_TO_STR(u) case u: return #u
109 D3DUSAGE_TO_STR(D3DUSAGE_RENDERTARGET
);
110 D3DUSAGE_TO_STR(D3DUSAGE_DEPTHSTENCIL
);
111 D3DUSAGE_TO_STR(D3DUSAGE_WRITEONLY
);
112 D3DUSAGE_TO_STR(D3DUSAGE_SOFTWAREPROCESSING
);
113 D3DUSAGE_TO_STR(D3DUSAGE_DONOTCLIP
);
114 D3DUSAGE_TO_STR(D3DUSAGE_POINTS
);
115 D3DUSAGE_TO_STR(D3DUSAGE_RTPATCHES
);
116 D3DUSAGE_TO_STR(D3DUSAGE_NPATCHES
);
117 D3DUSAGE_TO_STR(D3DUSAGE_DYNAMIC
);
118 #undef D3DUSAGE_TO_STR
119 case 0: return "none";
121 FIXME("Unrecognized %lu Usage!\n", usage
);
122 return "unrecognized";
126 const char* debug_d3dresourcetype(D3DRESOURCETYPE res
) {
128 #define RES_TO_STR(res) case res: return #res;
129 RES_TO_STR(D3DRTYPE_SURFACE
);
130 RES_TO_STR(D3DRTYPE_VOLUME
);
131 RES_TO_STR(D3DRTYPE_TEXTURE
);
132 RES_TO_STR(D3DRTYPE_VOLUMETEXTURE
);
133 RES_TO_STR(D3DRTYPE_CUBETEXTURE
);
134 RES_TO_STR(D3DRTYPE_VERTEXBUFFER
);
135 RES_TO_STR(D3DRTYPE_INDEXBUFFER
);
138 FIXME("Unrecognized %u D3DRESOURCETYPE!\n", res
);
139 return "unrecognized";
143 const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType
) {
144 switch (PrimitiveType
) {
145 #define PRIM_TO_STR(prim) case prim: return #prim;
146 PRIM_TO_STR(D3DPT_POINTLIST
);
147 PRIM_TO_STR(D3DPT_LINELIST
);
148 PRIM_TO_STR(D3DPT_LINESTRIP
);
149 PRIM_TO_STR(D3DPT_TRIANGLELIST
);
150 PRIM_TO_STR(D3DPT_TRIANGLESTRIP
);
151 PRIM_TO_STR(D3DPT_TRIANGLEFAN
);
154 FIXME("Unrecognized %u D3DPRIMITIVETYPE!\n", PrimitiveType
);
155 return "unrecognized";
159 const char* debug_d3drenderstate(DWORD state
) {
161 #define D3DSTATE_TO_STR(u) case u: return #u
162 D3DSTATE_TO_STR(WINED3DRS_ZENABLE
);
163 D3DSTATE_TO_STR(WINED3DRS_FILLMODE
);
164 D3DSTATE_TO_STR(WINED3DRS_SHADEMODE
);
165 D3DSTATE_TO_STR(WINED3DRS_LINEPATTERN
);
166 D3DSTATE_TO_STR(WINED3DRS_ZWRITEENABLE
);
167 D3DSTATE_TO_STR(WINED3DRS_ALPHATESTENABLE
);
168 D3DSTATE_TO_STR(WINED3DRS_LASTPIXEL
);
169 D3DSTATE_TO_STR(WINED3DRS_SRCBLEND
);
170 D3DSTATE_TO_STR(WINED3DRS_DESTBLEND
);
171 D3DSTATE_TO_STR(WINED3DRS_CULLMODE
);
172 D3DSTATE_TO_STR(WINED3DRS_ZFUNC
);
173 D3DSTATE_TO_STR(WINED3DRS_ALPHAREF
);
174 D3DSTATE_TO_STR(WINED3DRS_ALPHAFUNC
);
175 D3DSTATE_TO_STR(WINED3DRS_DITHERENABLE
);
176 D3DSTATE_TO_STR(WINED3DRS_ALPHABLENDENABLE
);
177 D3DSTATE_TO_STR(WINED3DRS_FOGENABLE
);
178 D3DSTATE_TO_STR(WINED3DRS_SPECULARENABLE
);
179 D3DSTATE_TO_STR(WINED3DRS_ZVISIBLE
);
180 D3DSTATE_TO_STR(WINED3DRS_FOGCOLOR
);
181 D3DSTATE_TO_STR(WINED3DRS_FOGTABLEMODE
);
182 D3DSTATE_TO_STR(WINED3DRS_FOGSTART
);
183 D3DSTATE_TO_STR(WINED3DRS_FOGEND
);
184 D3DSTATE_TO_STR(WINED3DRS_FOGDENSITY
);
185 D3DSTATE_TO_STR(WINED3DRS_EDGEANTIALIAS
);
186 D3DSTATE_TO_STR(WINED3DRS_ZBIAS
);
187 D3DSTATE_TO_STR(WINED3DRS_RANGEFOGENABLE
);
188 D3DSTATE_TO_STR(WINED3DRS_STENCILENABLE
);
189 D3DSTATE_TO_STR(WINED3DRS_STENCILFAIL
);
190 D3DSTATE_TO_STR(WINED3DRS_STENCILZFAIL
);
191 D3DSTATE_TO_STR(WINED3DRS_STENCILPASS
);
192 D3DSTATE_TO_STR(WINED3DRS_STENCILFUNC
);
193 D3DSTATE_TO_STR(WINED3DRS_STENCILREF
);
194 D3DSTATE_TO_STR(WINED3DRS_STENCILMASK
);
195 D3DSTATE_TO_STR(WINED3DRS_STENCILWRITEMASK
);
196 D3DSTATE_TO_STR(WINED3DRS_TEXTUREFACTOR
);
197 D3DSTATE_TO_STR(WINED3DRS_WRAP0
);
198 D3DSTATE_TO_STR(WINED3DRS_WRAP1
);
199 D3DSTATE_TO_STR(WINED3DRS_WRAP2
);
200 D3DSTATE_TO_STR(WINED3DRS_WRAP3
);
201 D3DSTATE_TO_STR(WINED3DRS_WRAP4
);
202 D3DSTATE_TO_STR(WINED3DRS_WRAP5
);
203 D3DSTATE_TO_STR(WINED3DRS_WRAP6
);
204 D3DSTATE_TO_STR(WINED3DRS_WRAP7
);
205 D3DSTATE_TO_STR(WINED3DRS_CLIPPING
);
206 D3DSTATE_TO_STR(WINED3DRS_LIGHTING
);
207 D3DSTATE_TO_STR(WINED3DRS_AMBIENT
);
208 D3DSTATE_TO_STR(WINED3DRS_FOGVERTEXMODE
);
209 D3DSTATE_TO_STR(WINED3DRS_COLORVERTEX
);
210 D3DSTATE_TO_STR(WINED3DRS_LOCALVIEWER
);
211 D3DSTATE_TO_STR(WINED3DRS_NORMALIZENORMALS
);
212 D3DSTATE_TO_STR(WINED3DRS_DIFFUSEMATERIALSOURCE
);
213 D3DSTATE_TO_STR(WINED3DRS_SPECULARMATERIALSOURCE
);
214 D3DSTATE_TO_STR(WINED3DRS_AMBIENTMATERIALSOURCE
);
215 D3DSTATE_TO_STR(WINED3DRS_EMISSIVEMATERIALSOURCE
);
216 D3DSTATE_TO_STR(WINED3DRS_VERTEXBLEND
);
217 D3DSTATE_TO_STR(WINED3DRS_CLIPPLANEENABLE
);
218 D3DSTATE_TO_STR(WINED3DRS_SOFTWAREVERTEXPROCESSING
);
219 D3DSTATE_TO_STR(WINED3DRS_POINTSIZE
);
220 D3DSTATE_TO_STR(WINED3DRS_POINTSIZE_MIN
);
221 D3DSTATE_TO_STR(WINED3DRS_POINTSPRITEENABLE
);
222 D3DSTATE_TO_STR(WINED3DRS_POINTSCALEENABLE
);
223 D3DSTATE_TO_STR(WINED3DRS_POINTSCALE_A
);
224 D3DSTATE_TO_STR(WINED3DRS_POINTSCALE_B
);
225 D3DSTATE_TO_STR(WINED3DRS_POINTSCALE_C
);
226 D3DSTATE_TO_STR(WINED3DRS_MULTISAMPLEANTIALIAS
);
227 D3DSTATE_TO_STR(WINED3DRS_MULTISAMPLEMASK
);
228 D3DSTATE_TO_STR(WINED3DRS_PATCHEDGESTYLE
);
229 D3DSTATE_TO_STR(WINED3DRS_PATCHSEGMENTS
);
230 D3DSTATE_TO_STR(WINED3DRS_DEBUGMONITORTOKEN
);
231 D3DSTATE_TO_STR(WINED3DRS_POINTSIZE_MAX
);
232 D3DSTATE_TO_STR(WINED3DRS_INDEXEDVERTEXBLENDENABLE
);
233 D3DSTATE_TO_STR(WINED3DRS_COLORWRITEENABLE
);
234 D3DSTATE_TO_STR(WINED3DRS_TWEENFACTOR
);
235 D3DSTATE_TO_STR(WINED3DRS_BLENDOP
);
236 D3DSTATE_TO_STR(WINED3DRS_POSITIONORDER
);
237 D3DSTATE_TO_STR(WINED3DRS_NORMALORDER
);
238 #undef D3DSTATE_TO_STR
240 FIXME("Unrecognized %lu render state!\n", state
);
241 return "unrecognized";
245 const char* debug_d3dtexturestate(DWORD state
) {
247 #define D3DSTATE_TO_STR(u) case u: return #u
248 D3DSTATE_TO_STR(D3DTSS_COLOROP
);
249 D3DSTATE_TO_STR(D3DTSS_COLORARG1
);
250 D3DSTATE_TO_STR(D3DTSS_COLORARG2
);
251 D3DSTATE_TO_STR(D3DTSS_ALPHAOP
);
252 D3DSTATE_TO_STR(D3DTSS_ALPHAARG1
);
253 D3DSTATE_TO_STR(D3DTSS_ALPHAARG2
);
254 D3DSTATE_TO_STR(D3DTSS_BUMPENVMAT00
);
255 D3DSTATE_TO_STR(D3DTSS_BUMPENVMAT01
);
256 D3DSTATE_TO_STR(D3DTSS_BUMPENVMAT10
);
257 D3DSTATE_TO_STR(D3DTSS_BUMPENVMAT11
);
258 D3DSTATE_TO_STR(D3DTSS_TEXCOORDINDEX
);
259 D3DSTATE_TO_STR(D3DTSS_ADDRESSU
);
260 D3DSTATE_TO_STR(D3DTSS_ADDRESSV
);
261 D3DSTATE_TO_STR(D3DTSS_BORDERCOLOR
);
262 D3DSTATE_TO_STR(D3DTSS_MAGFILTER
);
263 D3DSTATE_TO_STR(D3DTSS_MINFILTER
);
264 D3DSTATE_TO_STR(D3DTSS_MIPFILTER
);
265 D3DSTATE_TO_STR(D3DTSS_MIPMAPLODBIAS
);
266 D3DSTATE_TO_STR(D3DTSS_MAXMIPLEVEL
);
267 D3DSTATE_TO_STR(D3DTSS_MAXANISOTROPY
);
268 D3DSTATE_TO_STR(D3DTSS_BUMPENVLSCALE
);
269 D3DSTATE_TO_STR(D3DTSS_BUMPENVLOFFSET
);
270 D3DSTATE_TO_STR(D3DTSS_TEXTURETRANSFORMFLAGS
);
271 D3DSTATE_TO_STR(D3DTSS_ADDRESSW
);
272 D3DSTATE_TO_STR(D3DTSS_COLORARG0
);
273 D3DSTATE_TO_STR(D3DTSS_ALPHAARG0
);
274 D3DSTATE_TO_STR(D3DTSS_RESULTARG
);
275 #undef D3DSTATE_TO_STR
277 /* Note D3DTSS are not consecutive, so skip these */
281 FIXME("Unrecognized %lu texture state!\n", state
);
282 return "unrecognized";
286 const char* debug_d3dpool(D3DPOOL Pool
) {
288 #define POOL_TO_STR(p) case p: return #p;
289 POOL_TO_STR(D3DPOOL_DEFAULT
);
290 POOL_TO_STR(D3DPOOL_MANAGED
);
291 POOL_TO_STR(D3DPOOL_SYSTEMMEM
);
292 POOL_TO_STR(D3DPOOL_SCRATCH
);
295 FIXME("Unrecognized %u D3DPOOL!\n", Pool
);
296 return "unrecognized";
299 /*****************************************************************************
300 * Useful functions mapping GL <-> D3D values
302 GLenum
StencilOp(DWORD op
) {
304 case D3DSTENCILOP_KEEP
: return GL_KEEP
;
305 case D3DSTENCILOP_ZERO
: return GL_ZERO
;
306 case D3DSTENCILOP_REPLACE
: return GL_REPLACE
;
307 case D3DSTENCILOP_INCRSAT
: return GL_INCR
;
308 case D3DSTENCILOP_DECRSAT
: return GL_DECR
;
309 case D3DSTENCILOP_INVERT
: return GL_INVERT
;
310 case D3DSTENCILOP_INCR
: return GL_INCR_WRAP_EXT
;
311 case D3DSTENCILOP_DECR
: return GL_DECR_WRAP_EXT
;
313 FIXME("Invalid stencil op %ld\n", op
);
318 /* Set texture operations up - The following avoids lots of ifdefs in this routine!*/
319 #if defined (GL_VERSION_1_3)
321 # define combine_ext 1
322 #elif defined (GL_EXT_texture_env_combine)
323 # define useext(A) A##_EXT
324 # define combine_ext 1
325 #elif defined (GL_ARB_texture_env_combine)
326 # define useext(A) A##_ARB
327 # define combine_ext 1
332 #if !defined(combine_ext)
333 void set_tex_op(LPDIRECT3DDEVICE8 iface
, BOOL isAlpha
, int Stage
, D3DTEXTUREOP op
, DWORD arg1
, DWORD arg2
, DWORD arg3
)
335 FIXME("Requires opengl combine extensions to work\n");
339 /* Setup the texture operations texture stage states */
340 void set_tex_op(IWineD3DDevice
*iface
, BOOL isAlpha
, int Stage
, D3DTEXTUREOP op
, DWORD arg1
, DWORD arg2
, DWORD arg3
)
342 #define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info
343 GLenum src1
, src2
, src3
;
344 GLenum opr1
, opr2
, opr3
;
346 GLenum src0_target
, src1_target
, src2_target
;
347 GLenum opr0_target
, opr1_target
, opr2_target
;
349 GLenum opr
=0, invopr
, src3_target
, opr3_target
;
350 BOOL Handled
= FALSE
;
351 IWineD3DDeviceImpl
*This
= (IWineD3DDeviceImpl
*)iface
;
353 TRACE("Alpha?(%d), Stage:%d Op(%d), a1(%ld), a2(%ld), a3(%ld)\n", isAlpha
, Stage
, op
, arg1
, arg2
, arg3
);
357 /* Note: Operations usually involve two ars, src0 and src1 and are operations of
358 the form (a1 <operation> a2). However, some of the more complex operations
359 take 3 parameters. Instead of the (sensible) addition of a3, Microsoft added
360 in a third parameter called a0. Therefore these are operations of the form
361 a0 <operation> a1 <operation> a2, ie the new parameter goes to the front.
363 However, below we treat the new (a0) parameter as src2/opr2, so in the actual
364 functions below, expect their syntax to differ slightly to those listed in the
365 manuals, ie replace arg1 with arg3, arg2 with arg1 and arg3 with arg2
366 This affects D3DTOP_MULTIPLYADD and D3DTOP_LERP */
369 comb_target
= useext(GL_COMBINE_ALPHA
);
370 src0_target
= useext(GL_SOURCE0_ALPHA
);
371 src1_target
= useext(GL_SOURCE1_ALPHA
);
372 src2_target
= useext(GL_SOURCE2_ALPHA
);
373 opr0_target
= useext(GL_OPERAND0_ALPHA
);
374 opr1_target
= useext(GL_OPERAND1_ALPHA
);
375 opr2_target
= useext(GL_OPERAND2_ALPHA
);
376 scal_target
= GL_ALPHA_SCALE
;
379 comb_target
= useext(GL_COMBINE_RGB
);
380 src0_target
= useext(GL_SOURCE0_RGB
);
381 src1_target
= useext(GL_SOURCE1_RGB
);
382 src2_target
= useext(GL_SOURCE2_RGB
);
383 opr0_target
= useext(GL_OPERAND0_RGB
);
384 opr1_target
= useext(GL_OPERAND1_RGB
);
385 opr2_target
= useext(GL_OPERAND2_RGB
);
386 scal_target
= useext(GL_RGB_SCALE
);
389 /* From MSDN (D3DTSS_ALPHAARG1) :
390 The default argument is D3DTA_TEXTURE. If no texture is set for this stage,
391 then the default argument is D3DTA_DIFFUSE.
392 FIXME? If texture added/removed, may need to reset back as well? */
393 if (isAlpha
&& This
->stateBlock
->textures
[Stage
] == NULL
&& arg1
== D3DTA_TEXTURE
) {
394 GetSrcAndOpFromValue(D3DTA_DIFFUSE
, isAlpha
, &src1
, &opr1
);
396 GetSrcAndOpFromValue(arg1
, isAlpha
, &src1
, &opr1
);
398 GetSrcAndOpFromValue(arg2
, isAlpha
, &src2
, &opr2
);
399 GetSrcAndOpFromValue(arg3
, isAlpha
, &src3
, &opr3
);
401 TRACE("ct(%x), 1:(%x,%x), 2:(%x,%x), 3:(%x,%x)\n", comb_target
, src1
, opr1
, src2
, opr2
, src3
, opr3
);
403 Handled
= TRUE
; /* Assume will be handled */
405 /* Other texture operations require special extensions: */
406 if (GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4
)) {
409 invopr
= GL_ONE_MINUS_SRC_ALPHA
;
410 src3_target
= GL_SOURCE3_ALPHA_NV
;
411 opr3_target
= GL_OPERAND3_ALPHA_NV
;
414 invopr
= GL_ONE_MINUS_SRC_COLOR
;
415 src3_target
= GL_SOURCE3_RGB_NV
;
416 opr3_target
= GL_OPERAND3_RGB_NV
;
419 case D3DTOP_DISABLE
: /* Only for alpha */
420 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
421 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
422 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
423 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
424 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
425 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
426 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
427 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
428 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
429 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
430 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
431 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
432 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
433 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
434 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
435 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
436 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
437 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
439 case D3DTOP_SELECTARG1
: /* = a1 * 1 + 0 * 0 */
440 case D3DTOP_SELECTARG2
: /* = a2 * 1 + 0 * 0 */
441 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
442 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
443 if (op
== D3DTOP_SELECTARG1
) {
444 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
445 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
446 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
447 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
449 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
450 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
451 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
452 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
454 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
455 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
456 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
457 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
458 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
459 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
460 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
461 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
462 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
463 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
464 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
465 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
468 case D3DTOP_MODULATE
:
469 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
470 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
471 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
472 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
473 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
474 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
475 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
476 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
477 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
478 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
479 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
480 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
481 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
482 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
483 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
484 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
485 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
486 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
487 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
488 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
490 case D3DTOP_MODULATE2X
:
491 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
492 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
493 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
494 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
495 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
496 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
497 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
498 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
499 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
500 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
501 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
502 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
503 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
504 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
505 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
506 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
507 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
508 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
509 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
510 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
512 case D3DTOP_MODULATE4X
:
513 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
514 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
515 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
516 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
517 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
518 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
519 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
520 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
521 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
522 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
523 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
524 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
525 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
526 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
527 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
528 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
529 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
530 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
531 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
532 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
536 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
537 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
538 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
539 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
540 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
541 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
542 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
543 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
544 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
545 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
546 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
547 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
548 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
549 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
550 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
551 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
552 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
553 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
554 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
555 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
558 case D3DTOP_ADDSIGNED
:
559 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_ADD_SIGNED
));
560 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_ADD_SIGNED)");
561 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
562 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
563 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
564 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
565 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
566 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
567 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
568 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
569 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
570 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
571 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
572 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
573 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
574 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
575 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
576 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
577 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
578 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
581 case D3DTOP_ADDSIGNED2X
:
582 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_ADD_SIGNED
));
583 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_ADD_SIGNED)");
584 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
585 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
586 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
587 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
588 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
589 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
590 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
591 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
592 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
593 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
594 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
595 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
596 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
597 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
598 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
599 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
600 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
601 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
604 case D3DTOP_ADDSMOOTH
:
605 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
606 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
607 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
608 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
609 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
610 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
611 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
612 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
613 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
614 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
615 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
616 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
617 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
618 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
619 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
620 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
622 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
623 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
624 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
625 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
627 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
628 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
629 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
630 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
633 case D3DTOP_BLENDDIFFUSEALPHA
:
634 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
635 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
636 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
637 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
638 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
639 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
640 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, useext(GL_PRIMARY_COLOR
));
641 checkGLcall("GL_TEXTURE_ENV, src1_target, useext(GL_PRIMARY_COLOR)");
642 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
643 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
644 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
645 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
646 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
647 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
648 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, useext(GL_PRIMARY_COLOR
));
649 checkGLcall("GL_TEXTURE_ENV, src3_target, useext(GL_PRIMARY_COLOR)");
650 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
651 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
652 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
653 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
655 case D3DTOP_BLENDTEXTUREALPHA
:
656 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
657 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
658 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
659 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
660 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
661 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
662 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_TEXTURE
);
663 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_TEXTURE");
664 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
665 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
666 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
667 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
668 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
669 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
670 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
671 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
672 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
673 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
674 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
675 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
677 case D3DTOP_BLENDFACTORALPHA
:
678 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
679 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
680 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
681 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
682 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
683 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
684 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, useext(GL_CONSTANT
));
685 checkGLcall("GL_TEXTURE_ENV, src1_target, useext(GL_CONSTANT)");
686 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
687 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
688 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
689 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
690 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
691 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
692 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, useext(GL_CONSTANT
));
693 checkGLcall("GL_TEXTURE_ENV, src3_target, useext(GL_CONSTANT)");
694 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
695 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
696 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
697 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
699 case D3DTOP_BLENDTEXTUREALPHAPM
:
700 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
701 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
702 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
703 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
704 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
705 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
706 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
707 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
708 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
709 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
710 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
711 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
712 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
713 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
714 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
715 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
716 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
717 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
718 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
719 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
721 case D3DTOP_MODULATEALPHA_ADDCOLOR
:
722 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
723 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
724 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
); /* a0 = src1/opr1 */
725 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
726 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
727 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); /* a1 = 1 (see docs) */
728 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
729 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
730 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
731 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
732 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
); /* a2 = arg2 */
733 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
734 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
735 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2"); /* a3 = src1 alpha */
736 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
737 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
739 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
740 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
742 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
743 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
744 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
745 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
747 case D3DTOP_MODULATECOLOR_ADDALPHA
:
748 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
749 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
750 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
751 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
752 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
753 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
754 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
755 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
756 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
757 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
758 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
759 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
761 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
762 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
764 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
765 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
766 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
767 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
768 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
769 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
770 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
771 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
773 case D3DTOP_MODULATEINVALPHA_ADDCOLOR
:
774 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
775 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
776 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
777 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
778 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
779 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
780 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
781 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
782 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
783 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
784 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
785 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
786 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
787 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
788 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
789 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
791 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
792 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
793 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
794 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
796 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
797 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
798 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
799 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
801 case D3DTOP_MODULATEINVCOLOR_ADDALPHA
:
802 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
803 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
804 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
805 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
807 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
808 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
809 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
810 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
812 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
813 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
814 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
815 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
816 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
817 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
818 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
819 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
821 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
822 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
824 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
825 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
826 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
827 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
828 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
829 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
830 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
831 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
833 case D3DTOP_MULTIPLYADD
:
834 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
835 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
836 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src3
);
837 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
838 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr3
);
839 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
840 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
841 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
842 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
843 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
844 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
845 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
846 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr1
);
847 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
848 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src2
);
849 checkGLcall("GL_TEXTURE_ENV, src3_target, src3");
850 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr2
);
851 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr3");
852 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
853 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
856 case D3DTOP_BUMPENVMAP
:
858 if (GL_SUPPORT(NV_TEXTURE_SHADER
)) {
860 texture unit 0: GL_TEXTURE_2D
861 texture unit 1: GL_DOT_PRODUCT_NV
862 texture unit 2: GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV
863 texture unit 3: GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV
872 tmpvalue
.d
= This
->stateBlock
->textureState
[Stage
][D3DTSS_BUMPENVMAT00
];
873 m
[0][0] = tmpvalue
.f
;
874 tmpvalue
.d
= This
->stateBlock
->textureState
[Stage
][D3DTSS_BUMPENVMAT01
];
875 m
[0][1] = tmpvalue
.f
;
876 tmpvalue
.d
= This
->stateBlock
->textureState
[Stage
][D3DTSS_BUMPENVMAT10
];
877 m
[1][0] = tmpvalue
.f
;
878 tmpvalue
.d
= This
->stateBlock
->textureState
[Stage
][D3DTSS_BUMPENVMAT11
];
879 m
[1][1] = tmpvalue
.f
;
881 /*FIXME("Stage %d matrix is (%.2f,%.2f),(%.2f,%.2f)\n", Stage, m[0][0], m[0][1], m[1][0], m[1][0]);*/
883 if (FALSE
== This
->texture_shader_active
) {
884 This
->texture_shader_active
= TRUE
;
885 glEnable(GL_TEXTURE_SHADER_NV
);
889 glEnable(GL_REGISTER_COMBINERS_NV);
890 glCombinerParameteriNV (GL_NUM_GENERAL_COMBINERS_NV, 1);
891 glCombinerInputNV (GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE0_ARB, GL_SIGNED_IDENTITY_NV, GL_RGB);
892 glCombinerInputNV (GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_NONE, GL_UNSIGNED_INVERT_NV, GL_RGB);
893 glCombinerInputNV (GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV, GL_TEXTURE2_ARB, GL_SIGNED_IDENTITY_NV, GL_RGB);
894 glCombinerInputNV (GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV, GL_NONE, GL_UNSIGNED_INVERT_NV, GL_RGB);
895 glCombinerOutputNV (GL_COMBINER0_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_PRIMARY_COLOR_NV, 0, 0, 0, 0, 0);
896 glCombinerInputNV (GL_COMBINER0_NV, GL_ALPHA, GL_VARIABLE_A_NV, GL_TEXTURE0_ARB, GL_SIGNED_IDENTITY_NV, GL_ALPHA);
897 glCombinerInputNV (GL_COMBINER0_NV, GL_ALPHA, GL_VARIABLE_B_NV, GL_NONE, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
898 glCombinerInputNV (GL_COMBINER0_NV, GL_ALPHA, GL_VARIABLE_C_NV, GL_TEXTURE2_ARB, GL_SIGNED_IDENTITY_NV, GL_ALPHA);
899 glCombinerInputNV (GL_COMBINER0_NV, GL_ALPHA, GL_VARIABLE_D_NV, GL_NONE, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
900 glCombinerOutputNV (GL_COMBINER0_NV, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, GL_PRIMARY_COLOR_NV, 0, 0, 0, 0, 0);
901 glDisable (GL_PER_STAGE_CONSTANTS_NV);
902 glCombinerParameteriNV (GL_COLOR_SUM_CLAMP_NV, 0);
903 glFinalCombinerInputNV (GL_VARIABLE_A_NV, 0, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
904 glFinalCombinerInputNV (GL_VARIABLE_B_NV, 0, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
905 glFinalCombinerInputNV (GL_VARIABLE_C_NV, 0, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
906 glFinalCombinerInputNV (GL_VARIABLE_D_NV, GL_PRIMARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
907 glFinalCombinerInputNV (GL_VARIABLE_E_NV, 0, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
908 glFinalCombinerInputNV (GL_VARIABLE_F_NV, 0, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
909 glFinalCombinerInputNV (GL_VARIABLE_G_NV, GL_PRIMARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);
913 for (i = 0; i < Stage; i++) {
914 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
916 glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D);
917 checkGLcall("Activate texture..");
919 FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
924 GL_ACTIVETEXTURE(Stage - 1);
925 glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D);
928 GL_ACTIVETEXTURE(Stage);
929 checkGLcall("Activate texture.. to update const color");
930 glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_OFFSET_TEXTURE_2D_NV);
931 checkGLcall("glTexEnv");
932 glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + Stage - 1);
933 checkGLcall("glTexEnv");
934 glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, (float*)&m[0]);
935 checkGLcall("glTexEnv");
943 case D3DTOP_BUMPENVMAPLUMINANCE
:
949 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE4_NV
);
950 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV");
955 } /* GL_NV_texture_env_combine4 */
957 Handled
= TRUE
; /* Again, assume handled */
959 case D3DTOP_DISABLE
: /* Only for alpha */
960 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
961 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
962 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
963 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_PREVIOUS_EXT");
964 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
965 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA");
966 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
967 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
969 case D3DTOP_SELECTARG1
:
970 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
971 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
972 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
973 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
974 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
975 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
976 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
977 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
979 case D3DTOP_SELECTARG2
:
980 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
981 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
982 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
983 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
984 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
985 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
986 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
987 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
989 case D3DTOP_MODULATE
:
990 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
991 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
992 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
993 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
994 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
995 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
996 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
997 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
998 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
999 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
1000 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
1001 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
1003 case D3DTOP_MODULATE2X
:
1004 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
1005 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
1006 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1007 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1008 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
1009 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
1010 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
1011 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
1012 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
1013 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
1014 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
1015 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
1017 case D3DTOP_MODULATE4X
:
1018 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
1019 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
1020 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1021 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1022 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
1023 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
1024 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
1025 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
1026 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
1027 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
1028 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
1029 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
1032 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
1033 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
1034 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1035 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1036 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
1037 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
1038 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
1039 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
1040 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
1041 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
1042 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
1043 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
1045 case D3DTOP_ADDSIGNED
:
1046 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_ADD_SIGNED
));
1047 checkGLcall("GL_TEXTURE_ENV, comb_target, useext((GL_ADD_SIGNED)");
1048 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1049 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1050 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
1051 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
1052 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
1053 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
1054 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
1055 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
1056 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
1057 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
1059 case D3DTOP_ADDSIGNED2X
:
1060 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_ADD_SIGNED
));
1061 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_ADD_SIGNED)");
1062 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1063 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1064 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
1065 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
1066 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
1067 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
1068 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
1069 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
1070 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
1071 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
1073 case D3DTOP_SUBTRACT
:
1074 if (GL_SUPPORT(ARB_TEXTURE_ENV_COMBINE
)) {
1075 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_SUBTRACT
);
1076 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_SUBTRACT)");
1077 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1078 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1079 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
1080 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
1081 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
1082 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
1083 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
1084 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
1085 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
1086 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
1088 FIXME("This version of opengl does not support GL_SUBTRACT\n");
1092 case D3DTOP_BLENDDIFFUSEALPHA
:
1093 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
1094 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
1095 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1096 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1097 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
1098 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
1099 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
1100 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
1101 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
1102 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
1103 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, useext(GL_PRIMARY_COLOR
));
1104 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PRIMARY_COLOR");
1105 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
1106 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
1107 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
1108 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
1110 case D3DTOP_BLENDTEXTUREALPHA
:
1111 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
1112 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
1113 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1114 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1115 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
1116 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
1117 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
1118 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
1119 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
1120 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
1121 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_TEXTURE
);
1122 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_TEXTURE");
1123 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
1124 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
1125 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
1126 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
1128 case D3DTOP_BLENDFACTORALPHA
:
1129 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
1130 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
1131 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1132 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1133 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
1134 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
1135 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
1136 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
1137 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
1138 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
1139 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, useext(GL_CONSTANT
));
1140 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_CONSTANT");
1141 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
1142 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
1143 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
1144 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
1146 case D3DTOP_BLENDCURRENTALPHA
:
1147 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
1148 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
1149 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1150 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1151 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
1152 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
1153 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
1154 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
1155 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
1156 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
1157 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, useext(GL_PREVIOUS
));
1158 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PREVIOUS");
1159 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
1160 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
1161 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
1162 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
1164 case D3DTOP_DOTPRODUCT3
:
1165 if (GL_SUPPORT(ARB_TEXTURE_ENV_DOT3
)) {
1166 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_ARB
);
1167 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_ARB");
1168 } else if (GL_SUPPORT(EXT_TEXTURE_ENV_DOT3
)) {
1169 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_EXT
);
1170 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_EXT");
1172 FIXME("This version of opengl does not support GL_DOT3\n");
1174 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1175 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1176 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
1177 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
1178 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
1179 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
1180 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
1181 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
1182 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
1183 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
1186 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
1187 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
1188 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1189 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1190 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
1191 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
1192 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
1193 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
1194 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
1195 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
1196 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src3
);
1197 checkGLcall("GL_TEXTURE_ENV, src2_target, src3");
1198 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr3
);
1199 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr3");
1200 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
1201 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
1203 case D3DTOP_ADDSMOOTH
:
1204 if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3
)) {
1205 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
1206 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
1207 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1208 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1210 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
1211 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
1212 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
1213 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
1215 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
1216 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
1217 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
1218 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
1219 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
1220 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
1221 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
1222 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
1223 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
1224 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
1225 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
1226 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
1230 case D3DTOP_BLENDTEXTUREALPHAPM
:
1231 if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3
)) {
1232 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
1233 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
1234 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_TEXTURE
);
1235 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_TEXTURE");
1236 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_ONE_MINUS_SRC_ALPHA
);
1237 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_ONE_MINUS_SRC_APHA");
1238 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
1239 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
1240 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
1241 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
1242 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
1243 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
1244 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
1245 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
1246 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
1247 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
1251 case D3DTOP_MODULATEALPHA_ADDCOLOR
:
1252 if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3
)) {
1253 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
1254 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
1255 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1256 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1258 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
1259 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
1260 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
1261 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
1263 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
1264 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
1265 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
1266 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
1267 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
1268 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
1269 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
1270 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
1271 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
1272 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
1273 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
1274 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
1278 case D3DTOP_MODULATECOLOR_ADDALPHA
:
1279 if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3
)) {
1280 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
1281 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
1282 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1283 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1284 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
1285 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
1286 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
1287 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
1289 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
1290 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
1291 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
1292 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
1294 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
1295 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
1296 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
1297 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
1298 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
1299 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
1300 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
1301 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
1305 case D3DTOP_MODULATEINVALPHA_ADDCOLOR
:
1306 if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3
)) {
1307 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
1308 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
1309 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1310 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1312 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
1313 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
1314 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
1315 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
1317 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
1318 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
1319 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
1320 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
1321 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
1322 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
1323 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
1324 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
1325 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
1326 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
1327 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
1328 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
1332 case D3DTOP_MODULATEINVCOLOR_ADDALPHA
:
1333 if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3
)) {
1334 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
1335 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
1336 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1337 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1339 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
1340 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
1341 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
1342 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
1344 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
1345 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
1346 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
1347 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
1349 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
1350 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
1351 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
1352 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
1354 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
1355 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
1356 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
1357 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
1358 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
1359 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
1360 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
1361 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
1365 case D3DTOP_MULTIPLYADD
:
1366 if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3
)) {
1367 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
1368 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
1369 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src3
);
1370 checkGLcall("GL_TEXTURE_ENV, src0_target, src3");
1371 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr3
);
1372 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr3");
1373 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
1374 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
1375 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
1376 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
1377 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
1378 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
1379 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
1380 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
1381 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
1382 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
1391 BOOL combineOK
= TRUE
;
1392 if (GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4
)) {
1396 op2
= This
->stateBlock
->textureState
[Stage
][D3DTSS_COLOROP
];
1398 op2
= This
->stateBlock
->textureState
[Stage
][D3DTSS_ALPHAOP
];
1401 /* Note: If COMBINE4 in effect can't go back to combine! */
1403 case D3DTOP_ADDSMOOTH
:
1404 case D3DTOP_BLENDTEXTUREALPHAPM
:
1405 case D3DTOP_MODULATEALPHA_ADDCOLOR
:
1406 case D3DTOP_MODULATECOLOR_ADDALPHA
:
1407 case D3DTOP_MODULATEINVALPHA_ADDCOLOR
:
1408 case D3DTOP_MODULATEINVCOLOR_ADDALPHA
:
1409 case D3DTOP_MULTIPLYADD
:
1410 /* Ignore those implemented in both cases */
1412 case D3DTOP_SELECTARG1
:
1413 case D3DTOP_SELECTARG2
:
1418 FIXME("Can't use COMBINE4 and COMBINE together, thisop=%d, otherop=%ld, isAlpha(%d)\n", op
, op2
, isAlpha
);
1426 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, useext(GL_COMBINE
));
1427 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, useext(GL_COMBINE)");
1436 /* After all the extensions, if still unhandled, report fixme */
1437 FIXME("Unhandled texture operation %d\n", op
);
1438 #undef GLINFO_LOCATION
1442 /* Setup this textures matrix according to the texture flags*/
1443 void set_texture_matrix(const float *smat
, DWORD flags
)
1447 glMatrixMode(GL_TEXTURE
);
1449 if (flags
== D3DTTFF_DISABLE
) {
1451 checkGLcall("glLoadIdentity()");
1455 if (flags
== (D3DTTFF_COUNT1
|D3DTTFF_PROJECTED
)) {
1456 ERR("Invalid texture transform flags: D3DTTFF_COUNT1|D3DTTFF_PROJECTED\n");
1457 checkGLcall("glLoadIdentity()");
1461 memcpy(mat
, smat
, 16*sizeof(float));
1463 switch (flags
& ~D3DTTFF_PROJECTED
) {
1464 case D3DTTFF_COUNT1
: mat
[1] = mat
[5] = mat
[9] = mat
[13] = 0;
1465 case D3DTTFF_COUNT2
: mat
[2] = mat
[6] = mat
[10] = mat
[14] = 0;
1466 default: mat
[3] = mat
[7] = mat
[11] = 0, mat
[15] = 1;
1469 if (flags
& D3DTTFF_PROJECTED
) switch (flags
& ~D3DTTFF_PROJECTED
) {
1470 case D3DTTFF_COUNT2
:
1471 mat
[3] = mat
[1], mat
[7] = mat
[5], mat
[11] = mat
[9], mat
[15] = mat
[13];
1472 mat
[1] = mat
[5] = mat
[9] = mat
[13] = 0;
1474 case D3DTTFF_COUNT3
:
1475 mat
[3] = mat
[2], mat
[7] = mat
[6], mat
[11] = mat
[10], mat
[15] = mat
[14];
1476 mat
[2] = mat
[6] = mat
[10] = mat
[14] = 0;
1480 checkGLcall("glLoadMatrixf(mat)");
1483 void GetSrcAndOpFromValue(DWORD iValue
, BOOL isAlphaArg
, GLenum
* source
, GLenum
* operand
)
1485 BOOL isAlphaReplicate
= FALSE
;
1486 BOOL isComplement
= FALSE
;
1488 *operand
= GL_SRC_COLOR
;
1489 *source
= GL_TEXTURE
;
1491 /* Catch alpha replicate */
1492 if (iValue
& D3DTA_ALPHAREPLICATE
) {
1493 iValue
= iValue
& ~D3DTA_ALPHAREPLICATE
;
1494 isAlphaReplicate
= TRUE
;
1497 /* Catch Complement */
1498 if (iValue
& D3DTA_COMPLEMENT
) {
1499 iValue
= iValue
& ~D3DTA_COMPLEMENT
;
1500 isComplement
= TRUE
;
1503 /* Calculate the operand */
1504 if (isAlphaReplicate
&& !isComplement
) {
1505 *operand
= GL_SRC_ALPHA
;
1506 } else if (isAlphaReplicate
&& isComplement
) {
1507 *operand
= GL_ONE_MINUS_SRC_ALPHA
;
1508 } else if (isComplement
) {
1510 *operand
= GL_ONE_MINUS_SRC_ALPHA
;
1512 *operand
= GL_ONE_MINUS_SRC_COLOR
;
1516 *operand
= GL_SRC_ALPHA
;
1518 *operand
= GL_SRC_COLOR
;
1522 /* Calculate the source */
1523 switch (iValue
& D3DTA_SELECTMASK
) {
1524 case D3DTA_CURRENT
: *source
= GL_PREVIOUS_EXT
;
1526 case D3DTA_DIFFUSE
: *source
= GL_PRIMARY_COLOR_EXT
;
1528 case D3DTA_TEXTURE
: *source
= GL_TEXTURE
;
1530 case D3DTA_TFACTOR
: *source
= GL_CONSTANT_EXT
;
1532 case D3DTA_SPECULAR
:
1534 * According to the GL_ARB_texture_env_combine specs, SPECULAR is
1535 * 'Secondary color' and isn't supported until base GL supports it
1536 * There is no concept of temp registers as far as I can tell
1538 FIXME("Unhandled texture arg D3DTA_SPECULAR\n");
1539 *source
= GL_TEXTURE
;
1543 FIXME("Unrecognized texture arg %ld\n", iValue
);
1544 *source
= GL_TEXTURE
;
1549 #define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info
1550 GLint
D3DFmt2GLIntFmt(IWineD3DDeviceImpl
* This
, D3DFORMAT fmt
) {
1553 if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC
)) {
1555 case WINED3DFMT_DXT1
: retVal
= GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
; break;
1556 case WINED3DFMT_DXT3
: retVal
= GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
; break;
1557 case WINED3DFMT_DXT5
: retVal
= GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
; break;
1559 /* stupid compiler */
1567 case WINED3DFMT_P8
: retVal
= GL_COLOR_INDEX8_EXT
; break;
1568 case WINED3DFMT_A8P8
: retVal
= GL_COLOR_INDEX8_EXT
; break;
1570 case WINED3DFMT_L8
: retVal
= GL_LUMINANCE8
; break;
1571 case WINED3DFMT_A8L8
: retVal
= GL_LUMINANCE8_ALPHA8
; break;
1572 case WINED3DFMT_A4L4
: retVal
= GL_LUMINANCE4_ALPHA4
; break;
1574 case WINED3DFMT_V8U8
: retVal
= GL_COLOR_INDEX8_EXT
; break;
1575 case WINED3DFMT_V16U16
: retVal
= GL_COLOR_INDEX
; break;
1576 case WINED3DFMT_L6V5U5
: retVal
= GL_COLOR_INDEX8_EXT
; break;
1577 case WINED3DFMT_X8L8V8U8
: retVal
= GL_COLOR_INDEX
; break;
1579 case WINED3DFMT_R3G3B2
: retVal
= GL_R3_G3_B2
; break;
1580 case WINED3DFMT_R5G6B5
: retVal
= GL_RGB5
; break; /* fixme: internal format 6 for g? */
1581 case WINED3DFMT_R8G8B8
: retVal
= GL_RGB8
; break;
1582 case WINED3DFMT_A1R5G5B5
: retVal
= GL_RGB5_A1
; break;
1583 case WINED3DFMT_X1R5G5B5
: retVal
= GL_RGB5_A1
; break;
1584 case WINED3DFMT_A4R4G4B4
: retVal
= GL_RGBA4
; break;
1585 case WINED3DFMT_X4R4G4B4
: retVal
= GL_RGBA4
; break;
1586 case WINED3DFMT_A8R8G8B8
: retVal
= GL_RGBA8
; break;
1587 case WINED3DFMT_X8R8G8B8
: retVal
= GL_RGBA8
; break;
1589 case WINED3DFMT_A8
: retVal
= GL_ALPHA8
; break;
1591 FIXME("Unhandled fmt(%u,%s)\n", fmt
, debug_d3dformat(fmt
));
1595 TRACE("fmt2glintFmt for fmt(%u,%s) = %x\n", fmt
, debug_d3dformat(fmt
), retVal
);
1599 GLenum
D3DFmt2GLFmt(IWineD3DDeviceImpl
* This
, D3DFORMAT fmt
) {
1602 if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC
)) {
1604 case WINED3DFMT_DXT1
: retVal
= GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
; break;
1605 case WINED3DFMT_DXT3
: retVal
= GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
; break;
1606 case WINED3DFMT_DXT5
: retVal
= GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
; break;
1608 /* stupid compiler */
1616 case WINED3DFMT_P8
: retVal
= GL_COLOR_INDEX
; break;
1617 case WINED3DFMT_A8P8
: retVal
= GL_COLOR_INDEX
; break;
1619 case WINED3DFMT_L8
: retVal
= GL_LUMINANCE
; break;
1620 case WINED3DFMT_A8L8
: retVal
= GL_LUMINANCE_ALPHA
; break;
1621 case WINED3DFMT_A4L4
: retVal
= GL_LUMINANCE_ALPHA
; break;
1623 case WINED3DFMT_V8U8
: retVal
= GL_COLOR_INDEX
; break;
1624 case WINED3DFMT_V16U16
: retVal
= GL_COLOR_INDEX
; break;
1625 case WINED3DFMT_L6V5U5
: retVal
= GL_COLOR_INDEX
; break;
1626 case WINED3DFMT_X8L8V8U8
: retVal
= GL_COLOR_INDEX
; break;
1628 case WINED3DFMT_R3G3B2
: retVal
= GL_BGR
; break;
1629 case WINED3DFMT_R5G6B5
: retVal
= GL_RGB
; break;
1630 case WINED3DFMT_R8G8B8
: retVal
= GL_RGB
; break;
1631 case WINED3DFMT_A1R5G5B5
: retVal
= GL_BGRA
; break;
1632 case WINED3DFMT_X1R5G5B5
: retVal
= GL_BGRA
; break;
1633 case WINED3DFMT_A4R4G4B4
: retVal
= GL_BGRA
; break;
1634 case WINED3DFMT_X4R4G4B4
: retVal
= GL_BGRA
; break;
1635 case WINED3DFMT_A8R8G8B8
: retVal
= GL_BGRA
; break;
1636 case WINED3DFMT_X8R8G8B8
: retVal
= GL_BGRA
; break;
1638 case WINED3DFMT_A8
: retVal
= GL_ALPHA
; break;
1640 FIXME("Unhandled fmt(%u,%s)\n", fmt
, debug_d3dformat(fmt
));
1645 TRACE("fmt2glFmt for fmt(%u,%s) = %x\n", fmt
, debug_d3dformat(fmt
), retVal
);
1649 GLenum
D3DFmt2GLType(IWineD3DDeviceImpl
* This
, D3DFORMAT fmt
) {
1652 if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC
)) {
1654 case WINED3DFMT_DXT1
: retVal
= 0; break;
1655 case WINED3DFMT_DXT3
: retVal
= 0; break;
1656 case WINED3DFMT_DXT5
: retVal
= 0; break;
1658 /* stupid compiler */
1666 case WINED3DFMT_P8
: retVal
= GL_UNSIGNED_BYTE
; break;
1667 case WINED3DFMT_A8P8
: retVal
= GL_UNSIGNED_BYTE
; break;
1669 case WINED3DFMT_L8
: retVal
= GL_UNSIGNED_BYTE
; break;
1670 case WINED3DFMT_A8L8
: retVal
= GL_UNSIGNED_BYTE
; break;
1671 case WINED3DFMT_A4L4
: retVal
= GL_UNSIGNED_BYTE
; break;
1673 case WINED3DFMT_V8U8
: retVal
= GL_UNSIGNED_BYTE
; break;
1674 case WINED3DFMT_V16U16
: retVal
= GL_UNSIGNED_SHORT
; break;
1675 case WINED3DFMT_L6V5U5
: retVal
= GL_UNSIGNED_SHORT_5_5_5_1
; break;
1676 case WINED3DFMT_X8L8V8U8
: retVal
= GL_UNSIGNED_BYTE
; break;
1678 case WINED3DFMT_R3G3B2
: retVal
= GL_UNSIGNED_BYTE_2_3_3_REV
; break;
1679 case WINED3DFMT_R5G6B5
: retVal
= GL_UNSIGNED_SHORT_5_6_5
; break;
1680 case WINED3DFMT_R8G8B8
: retVal
= GL_UNSIGNED_BYTE
; break;
1681 case WINED3DFMT_A1R5G5B5
: retVal
= GL_UNSIGNED_SHORT_1_5_5_5_REV
; break;
1682 case WINED3DFMT_X1R5G5B5
: retVal
= GL_UNSIGNED_SHORT_1_5_5_5_REV
; break;
1683 case WINED3DFMT_A4R4G4B4
: retVal
= GL_UNSIGNED_SHORT_4_4_4_4_REV
; break;
1684 case WINED3DFMT_X4R4G4B4
: retVal
= GL_UNSIGNED_SHORT_4_4_4_4_REV
; break;
1685 case WINED3DFMT_A8R8G8B8
: retVal
= GL_UNSIGNED_INT_8_8_8_8_REV
; break;
1686 case WINED3DFMT_X8R8G8B8
: retVal
= GL_UNSIGNED_INT_8_8_8_8_REV
; break;
1688 case WINED3DFMT_A8
: retVal
= GL_ALPHA
; break;
1690 FIXME("Unhandled fmt(%u,%s)\n", fmt
, debug_d3dformat(fmt
));
1691 retVal
= GL_UNSIGNED_BYTE
;
1695 TRACE("fmt2glType for fmt(%u,%s) = %x\n", fmt
, debug_d3dformat(fmt
), retVal
);
1699 SHORT
D3DFmtGetBpp(IWineD3DDeviceImpl
* This
, D3DFORMAT fmt
) {
1704 case WINED3DFMT_R3G3B2
: retVal
= 1; break;
1705 case WINED3DFMT_R5G6B5
: retVal
= 2; break;
1706 case WINED3DFMT_R8G8B8
: retVal
= 3; break;
1707 case WINED3DFMT_A1R5G5B5
: retVal
= 2; break;
1708 case WINED3DFMT_X1R5G5B5
: retVal
= 2; break;
1709 case WINED3DFMT_A4R4G4B4
: retVal
= 2; break;
1710 case WINED3DFMT_X4R4G4B4
: retVal
= 2; break;
1711 case WINED3DFMT_A8R8G8B8
: retVal
= 4; break;
1712 case WINED3DFMT_X8R8G8B8
: retVal
= 4; break;
1714 case WINED3DFMT_P8
: retVal
= 1; break;
1715 case WINED3DFMT_A8P8
: retVal
= 2; break;
1716 /* depth/stencil buffer */
1717 case WINED3DFMT_D16_LOCKABLE
: retVal
= 2; break;
1718 case WINED3DFMT_D16
: retVal
= 2; break;
1719 case WINED3DFMT_D32
: retVal
= 4; break;
1720 case WINED3DFMT_D15S1
: retVal
= 2; break;
1721 case WINED3DFMT_D24X4S4
: retVal
= 4; break;
1722 case WINED3DFMT_D24S8
: retVal
= 4; break;
1723 case WINED3DFMT_D24X8
: retVal
= 4; break;
1725 case WINED3DFMT_L8
: retVal
= 1; break;
1726 case WINED3DFMT_A4L4
: retVal
= 1; break;
1727 case WINED3DFMT_A8L8
: retVal
= 2; break;
1729 case WINED3DFMT_V8U8
: retVal
= 2; break;
1730 case WINED3DFMT_L6V5U5
: retVal
= 2; break;
1731 case WINED3DFMT_V16U16
: retVal
= 4; break;
1732 case WINED3DFMT_X8L8V8U8
: retVal
= 4; break;
1734 case WINED3DFMT_DXT1
: retVal
= 1; break; /* Actually 8 bytes per 16 pixels - Special cased later */
1735 case WINED3DFMT_DXT3
: retVal
= 1; break; /* Actually 16 bytes per 16 pixels */
1736 case WINED3DFMT_DXT5
: retVal
= 1; break; /* Actually 16 bytes per 16 pixels */
1738 case WINED3DFMT_A8
: retVal
= 1; break;
1740 case WINED3DFMT_UNKNOWN
:
1741 /* Guess at the highest value of the above */
1742 TRACE("WINED3DFMT_UNKNOWN - Guessing at 4 bytes/pixel %u\n", fmt
);
1747 FIXME("Unhandled fmt(%u,%s)\n", fmt
, debug_d3dformat(fmt
));
1750 TRACE("bytes/Pxl for fmt(%u,%s) = %d\n", fmt
, debug_d3dformat(fmt
), retVal
);
1753 #undef GLINFO_LOCATION