~ubuntu-branches/ubuntu/quantal/mesa/quantal

« back to all changes in this revision

Viewing changes to src/mesa/drivers/windows/gldirect/dx7/gld_ext_dx7.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-02-21 12:44:07 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20070221124407-rgcacs32mycrtadl
ImportĀ upstreamĀ versionĀ 6.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
*
3
 
*                        Mesa 3-D graphics library
4
 
*                        Direct3D Driver Interface
5
 
*
6
 
*  ========================================================================
7
 
*
8
 
*   Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
9
 
*
10
 
*   Permission is hereby granted, free of charge, to any person obtaining a
11
 
*   copy of this software and associated documentation files (the "Software"),
12
 
*   to deal in the Software without restriction, including without limitation
13
 
*   the rights to use, copy, modify, merge, publish, distribute, sublicense,
14
 
*   and/or sell copies of the Software, and to permit persons to whom the
15
 
*   Software is furnished to do so, subject to the following conditions:
16
 
*
17
 
*   The above copyright notice and this permission notice shall be included
18
 
*   in all copies or substantial portions of the Software.
19
 
*
20
 
*   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21
 
*   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
 
*   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
23
 
*   SCITECH SOFTWARE INC BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24
 
*   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
25
 
*   OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
 
*   SOFTWARE.
27
 
*
28
 
*  ======================================================================
29
 
*
30
 
* Language:     ANSI C
31
 
* Environment:  Windows 9x/2000/XP/XBox (Win32)
32
 
*
33
 
* Description:  GL extensions
34
 
*
35
 
****************************************************************************/
36
 
 
37
 
//#include "../GLDirect.h"
38
 
//#include "../gld_log.h"
39
 
//#include "../gld_settings.h"
40
 
 
41
 
#include <windows.h>
42
 
#define GL_GLEXT_PROTOTYPES
43
 
#include <GL/gl.h>
44
 
#include <GL/glext.h>
45
 
 
46
 
//#include "ddlog.h"
47
 
//#include "gld_dx8.h"
48
 
 
49
 
#include "glheader.h"
50
 
#include "context.h"
51
 
#include "colormac.h"
52
 
#include "depth.h"
53
 
#include "extensions.h"
54
 
#include "macros.h"
55
 
#include "matrix.h"
56
 
// #include "mem.h"
57
 
//#include "mmath.h"
58
 
#include "mtypes.h"
59
 
#include "texformat.h"
60
 
#include "texstore.h"
61
 
#include "array_cache/acache.h"
62
 
#include "swrast_setup/swrast_setup.h"
63
 
#include "swrast_setup/ss_context.h"
64
 
#include "tnl/tnl.h"
65
 
#include "tnl/t_context.h"
66
 
#include "tnl/t_pipeline.h"
67
 
 
68
 
#include "dglcontext.h"
69
 
#include "extensions.h"
70
 
 
71
 
// For some reason this is not defined in an above header...
72
 
extern void _mesa_enable_imaging_extensions(GLcontext *ctx);
73
 
 
74
 
//---------------------------------------------------------------------------
75
 
// Hack for the SGIS_multitexture extension that was removed from Mesa
76
 
// NOTE: SGIS_multitexture enums also clash with GL_SGIX_async_pixel
77
 
 
78
 
        // NOTE: Quake2 ran *slower* with this enabled, so I've
79
 
        // disabled it for now.
80
 
        // To enable, uncomment:
81
 
        //  _mesa_add_extension(ctx, GL_TRUE, szGL_SGIS_multitexture, 0);
82
 
 
83
 
//---------------------------------------------------------------------------
84
 
 
85
 
enum {
86
 
        /* Quake2 GL_SGIS_multitexture */
87
 
        GL_SELECTED_TEXTURE_SGIS                        = 0x835B,
88
 
        GL_SELECTED_TEXTURE_COORD_SET_SGIS      = 0x835C,
89
 
        GL_MAX_TEXTURES_SGIS                            = 0x835D,
90
 
        GL_TEXTURE0_SGIS                                        = 0x835E,
91
 
        GL_TEXTURE1_SGIS                                        = 0x835F,
92
 
        GL_TEXTURE2_SGIS                                        = 0x8360,
93
 
        GL_TEXTURE3_SGIS                                        = 0x8361,
94
 
        GL_TEXTURE_COORD_SET_SOURCE_SGIS        = 0x8363,
95
 
};
96
 
 
97
 
//---------------------------------------------------------------------------
98
 
 
99
 
void APIENTRY gldSelectTextureSGIS(
100
 
        GLenum target)
101
 
{
102
 
        GLenum ARB_target = GL_TEXTURE0_ARB + (target - GL_TEXTURE0_SGIS);
103
 
        glActiveTextureARB(ARB_target);
104
 
}
105
 
 
106
 
//---------------------------------------------------------------------------
107
 
 
108
 
void APIENTRY gldMTexCoord2fSGIS(
109
 
        GLenum target,
110
 
        GLfloat s,
111
 
        GLfloat t)
112
 
{
113
 
        GLenum ARB_target = GL_TEXTURE0_ARB + (target - GL_TEXTURE0_SGIS);
114
 
        glMultiTexCoord2fARB(ARB_target, s, t);
115
 
}
116
 
 
117
 
//---------------------------------------------------------------------------
118
 
 
119
 
void APIENTRY gldMTexCoord2fvSGIS(
120
 
        GLenum target,
121
 
        const GLfloat *v)
122
 
{
123
 
        GLenum ARB_target = GL_TEXTURE0_ARB + (target - GL_TEXTURE0_SGIS);
124
 
        glMultiTexCoord2fvARB(ARB_target, v);
125
 
}
126
 
 
127
 
//---------------------------------------------------------------------------
128
 
// Extensions
129
 
//---------------------------------------------------------------------------
130
 
 
131
 
typedef struct {
132
 
        PROC proc;
133
 
        char *name;
134
 
}  GLD_extension;
135
 
 
136
 
GLD_extension GLD_extList[] = {
137
 
#ifdef GL_EXT_polygon_offset
138
 
    {   (PROC)glPolygonOffsetEXT,               "glPolygonOffsetEXT"            },
139
 
#endif
140
 
    {   (PROC)glBlendEquationEXT,               "glBlendEquationEXT"            },
141
 
    {   (PROC)glBlendColorEXT,                  "glBlendColorExt"                       },
142
 
    {   (PROC)glVertexPointerEXT,               "glVertexPointerEXT"            },
143
 
    {   (PROC)glNormalPointerEXT,               "glNormalPointerEXT"            },
144
 
    {   (PROC)glColorPointerEXT,                "glColorPointerEXT"                     },
145
 
    {   (PROC)glIndexPointerEXT,                "glIndexPointerEXT"                     },
146
 
    {   (PROC)glTexCoordPointerEXT,             "glTexCoordPointer"                     },
147
 
    {   (PROC)glEdgeFlagPointerEXT,             "glEdgeFlagPointerEXT"          },
148
 
    {   (PROC)glGetPointervEXT,                 "glGetPointervEXT"                      },
149
 
    {   (PROC)glArrayElementEXT,                "glArrayElementEXT"                     },
150
 
    {   (PROC)glDrawArraysEXT,                  "glDrawArrayEXT"                        },
151
 
    {   (PROC)glAreTexturesResidentEXT, "glAreTexturesResidentEXT"      },
152
 
    {   (PROC)glBindTextureEXT,                 "glBindTextureEXT"                      },
153
 
    {   (PROC)glDeleteTexturesEXT,              "glDeleteTexturesEXT"           },
154
 
    {   (PROC)glGenTexturesEXT,                 "glGenTexturesEXT"                      },
155
 
    {   (PROC)glIsTextureEXT,                   "glIsTextureEXT"                        },
156
 
    {   (PROC)glPrioritizeTexturesEXT,  "glPrioritizeTexturesEXT"       },
157
 
    {   (PROC)glCopyTexSubImage3DEXT,   "glCopyTexSubImage3DEXT"        },
158
 
    {   (PROC)glTexImage3DEXT,                  "glTexImage3DEXT"                       },
159
 
    {   (PROC)glTexSubImage3DEXT,               "glTexSubImage3DEXT"            },
160
 
    {   (PROC)glPointParameterfEXT,             "glPointParameterfEXT"          },
161
 
    {   (PROC)glPointParameterfvEXT,    "glPointParameterfvEXT"         },
162
 
 
163
 
    {   (PROC)glLockArraysEXT,                  "glLockArraysEXT"                       },
164
 
    {   (PROC)glUnlockArraysEXT,                "glUnlockArraysEXT"                     },
165
 
        {       NULL,                                                   "\0"                                            }
166
 
};
167
 
 
168
 
GLD_extension GLD_multitexList[] = {
169
 
/*
170
 
    {   (PROC)glMultiTexCoord1dSGIS,            "glMTexCoord1dSGIS"                     },
171
 
    {   (PROC)glMultiTexCoord1dvSGIS,           "glMTexCoord1dvSGIS"            },
172
 
    {   (PROC)glMultiTexCoord1fSGIS,            "glMTexCoord1fSGIS"                     },
173
 
    {   (PROC)glMultiTexCoord1fvSGIS,           "glMTexCoord1fvSGIS"            },
174
 
    {   (PROC)glMultiTexCoord1iSGIS,            "glMTexCoord1iSGIS"                     },
175
 
    {   (PROC)glMultiTexCoord1ivSGIS,           "glMTexCoord1ivSGIS"            },
176
 
    {   (PROC)glMultiTexCoord1sSGIS,            "glMTexCoord1sSGIS"                     },
177
 
    {   (PROC)glMultiTexCoord1svSGIS,           "glMTexCoord1svSGIS"            },
178
 
    {   (PROC)glMultiTexCoord2dSGIS,            "glMTexCoord2dSGIS"                     },
179
 
    {   (PROC)glMultiTexCoord2dvSGIS,           "glMTexCoord2dvSGIS"            },
180
 
    {   (PROC)glMultiTexCoord2fSGIS,            "glMTexCoord2fSGIS"                     },
181
 
    {   (PROC)glMultiTexCoord2fvSGIS,           "glMTexCoord2fvSGIS"            },
182
 
    {   (PROC)glMultiTexCoord2iSGIS,            "glMTexCoord2iSGIS"                     },
183
 
    {   (PROC)glMultiTexCoord2ivSGIS,           "glMTexCoord2ivSGIS"            },
184
 
    {   (PROC)glMultiTexCoord2sSGIS,            "glMTexCoord2sSGIS"                     },
185
 
    {   (PROC)glMultiTexCoord2svSGIS,           "glMTexCoord2svSGIS"            },
186
 
    {   (PROC)glMultiTexCoord3dSGIS,            "glMTexCoord3dSGIS"                     },
187
 
    {   (PROC)glMultiTexCoord3dvSGIS,           "glMTexCoord3dvSGIS"            },
188
 
    {   (PROC)glMultiTexCoord3fSGIS,            "glMTexCoord3fSGIS"                     },
189
 
    {   (PROC)glMultiTexCoord3fvSGIS,           "glMTexCoord3fvSGIS"            },
190
 
    {   (PROC)glMultiTexCoord3iSGIS,            "glMTexCoord3iSGIS"                     },
191
 
    {   (PROC)glMultiTexCoord3ivSGIS,           "glMTexCoord3ivSGIS"            },
192
 
    {   (PROC)glMultiTexCoord3sSGIS,            "glMTexCoord3sSGIS"                     },
193
 
    {   (PROC)glMultiTexCoord3svSGIS,           "glMTexCoord3svSGIS"            },
194
 
    {   (PROC)glMultiTexCoord4dSGIS,            "glMTexCoord4dSGIS"                     },
195
 
    {   (PROC)glMultiTexCoord4dvSGIS,           "glMTexCoord4dvSGIS"            },
196
 
    {   (PROC)glMultiTexCoord4fSGIS,            "glMTexCoord4fSGIS"                     },
197
 
    {   (PROC)glMultiTexCoord4fvSGIS,           "glMTexCoord4fvSGIS"            },
198
 
    {   (PROC)glMultiTexCoord4iSGIS,            "glMTexCoord4iSGIS"                     },
199
 
    {   (PROC)glMultiTexCoord4ivSGIS,           "glMTexCoord4ivSGIS"            },
200
 
    {   (PROC)glMultiTexCoord4sSGIS,            "glMTexCoord4sSGIS"                     },
201
 
    {   (PROC)glMultiTexCoord4svSGIS,           "glMTexCoord4svSGIS"            },
202
 
    {   (PROC)glMultiTexCoordPointerSGIS,       "glMTexCoordPointerSGIS"        },
203
 
    {   (PROC)glSelectTextureSGIS,                      "glSelectTextureSGIS"                   },
204
 
    {   (PROC)glSelectTextureCoordSetSGIS,      "glSelectTextureCoordSetSGIS"   },
205
 
*/
206
 
    {   (PROC)glActiveTextureARB,               "glActiveTextureARB"            },
207
 
    {   (PROC)glClientActiveTextureARB, "glClientActiveTextureARB"      },
208
 
    {   (PROC)glMultiTexCoord1dARB,             "glMultiTexCoord1dARB"          },
209
 
    {   (PROC)glMultiTexCoord1dvARB,    "glMultiTexCoord1dvARB"         },
210
 
    {   (PROC)glMultiTexCoord1fARB,             "glMultiTexCoord1fARB"          },
211
 
    {   (PROC)glMultiTexCoord1fvARB,    "glMultiTexCoord1fvARB"         },
212
 
    {   (PROC)glMultiTexCoord1iARB,             "glMultiTexCoord1iARB"          },
213
 
    {   (PROC)glMultiTexCoord1ivARB,    "glMultiTexCoord1ivARB"         },
214
 
    {   (PROC)glMultiTexCoord1sARB,             "glMultiTexCoord1sARB"          },
215
 
    {   (PROC)glMultiTexCoord1svARB,    "glMultiTexCoord1svARB"         },
216
 
    {   (PROC)glMultiTexCoord2dARB,             "glMultiTexCoord2dARB"          },
217
 
    {   (PROC)glMultiTexCoord2dvARB,    "glMultiTexCoord2dvARB"         },
218
 
    {   (PROC)glMultiTexCoord2fARB,             "glMultiTexCoord2fARB"          },
219
 
    {   (PROC)glMultiTexCoord2fvARB,    "glMultiTexCoord2fvARB"         },
220
 
    {   (PROC)glMultiTexCoord2iARB,             "glMultiTexCoord2iARB"          },
221
 
    {   (PROC)glMultiTexCoord2ivARB,    "glMultiTexCoord2ivARB"         },
222
 
    {   (PROC)glMultiTexCoord2sARB,             "glMultiTexCoord2sARB"          },
223
 
    {   (PROC)glMultiTexCoord2svARB,    "glMultiTexCoord2svARB"         },
224
 
    {   (PROC)glMultiTexCoord3dARB,             "glMultiTexCoord3dARB"          },
225
 
    {   (PROC)glMultiTexCoord3dvARB,    "glMultiTexCoord3dvARB"         },
226
 
    {   (PROC)glMultiTexCoord3fARB,             "glMultiTexCoord3fARB"          },
227
 
    {   (PROC)glMultiTexCoord3fvARB,    "glMultiTexCoord3fvARB"         },
228
 
    {   (PROC)glMultiTexCoord3iARB,             "glMultiTexCoord3iARB"          },
229
 
    {   (PROC)glMultiTexCoord3ivARB,    "glMultiTexCoord3ivARB"         },
230
 
    {   (PROC)glMultiTexCoord3sARB,             "glMultiTexCoord3sARB"          },
231
 
    {   (PROC)glMultiTexCoord3svARB,    "glMultiTexCoord3svARB"         },
232
 
    {   (PROC)glMultiTexCoord4dARB,             "glMultiTexCoord4dARB"          },
233
 
    {   (PROC)glMultiTexCoord4dvARB,    "glMultiTexCoord4dvARB"         },
234
 
    {   (PROC)glMultiTexCoord4fARB,             "glMultiTexCoord4fARB"          },
235
 
    {   (PROC)glMultiTexCoord4fvARB,    "glMultiTexCoord4fvARB"         },
236
 
    {   (PROC)glMultiTexCoord4iARB,             "glMultiTexCoord4iARB"          },
237
 
    {   (PROC)glMultiTexCoord4ivARB,    "glMultiTexCoord4ivARB"         },
238
 
    {   (PROC)glMultiTexCoord4sARB,             "glMultiTexCoord4sARB"          },
239
 
    {   (PROC)glMultiTexCoord4svARB,    "glMultiTexCoord4svARB"         },
240
 
 
241
 
        // Descent3 doesn't use correct string, hence this hack
242
 
    {   (PROC)glMultiTexCoord4fARB,             "glMultiTexCoord4f"                     },
243
 
 
244
 
        // Quake2 SGIS multitexture
245
 
    {   (PROC)gldSelectTextureSGIS,             "glSelectTextureSGIS"           },
246
 
    {   (PROC)gldMTexCoord2fSGIS,               "glMTexCoord2fSGIS"                     },
247
 
    {   (PROC)gldMTexCoord2fvSGIS,              "glMTexCoord2fvSGIS"            },
248
 
 
249
 
        {       NULL,                                                   "\0"                                            }
250
 
};
251
 
 
252
 
//---------------------------------------------------------------------------
253
 
 
254
 
PROC gldGetProcAddress_DX(
255
 
        LPCSTR a)
256
 
{
257
 
        int             i;
258
 
        PROC    proc = NULL;
259
 
 
260
 
        for (i=0; GLD_extList[i].proc; i++) {
261
 
                if (!strcmp(a, GLD_extList[i].name)) {
262
 
                        proc = GLD_extList[i].proc;
263
 
                        break;
264
 
                }
265
 
        }
266
 
 
267
 
        if (glb.bMultitexture) {
268
 
                for (i=0; GLD_multitexList[i].proc; i++) {
269
 
                        if (!strcmp(a, GLD_multitexList[i].name)) {
270
 
                                proc = GLD_multitexList[i].proc;
271
 
                                break;
272
 
                        }
273
 
                }
274
 
        }
275
 
 
276
 
        gldLogPrintf(GLDLOG_INFO, "GetProcAddress: %s (%s)", a, proc ? "OK" : "Failed");
277
 
 
278
 
        return proc;
279
 
}
280
 
 
281
 
//---------------------------------------------------------------------------
282
 
 
283
 
void gldEnableExtensions_DX7(
284
 
        GLcontext *ctx)
285
 
{
286
 
        GLuint i;
287
 
 
288
 
        // Mesa enables some extensions by default.
289
 
        // This table decides which ones we want to switch off again.
290
 
 
291
 
        // NOTE: GL_EXT_compiled_vertex_array appears broken.
292
 
 
293
 
        const char *gld_disable_extensions[] = {
294
 
//              "GL_ARB_transpose_matrix",
295
 
//              "GL_EXT_compiled_vertex_array",
296
 
//              "GL_EXT_polygon_offset",
297
 
//              "GL_EXT_rescale_normal",
298
 
                "GL_EXT_texture3D",
299
 
//              "GL_NV_texgen_reflection",
300
 
                "GL_EXT_abgr",
301
 
                "GL_EXT_bgra",
302
 
                NULL
303
 
        };
304
 
 
305
 
        const char *gld_multitex_extensions[] = {
306
 
                "GL_ARB_multitexture",          // Quake 3
307
 
                NULL
308
 
        };
309
 
 
310
 
        // Quake 2 engines
311
 
        const char *szGL_SGIS_multitexture = "GL_SGIS_multitexture";
312
 
 
313
 
        const char *gld_enable_extensions[] = {
314
 
                "GL_EXT_texture_env_add",       // Quake 3
315
 
                "GL_ARB_texture_env_add",       // Quake 3
316
 
                NULL
317
 
        };
318
 
        
319
 
        for (i=0; gld_disable_extensions[i]; i++) {
320
 
                _mesa_disable_extension(ctx, gld_disable_extensions[i]);
321
 
        }
322
 
        
323
 
        for (i=0; gld_enable_extensions[i]; i++) {
324
 
                _mesa_enable_extension(ctx, gld_enable_extensions[i]);
325
 
        }
326
 
 
327
 
        if (glb.bMultitexture) {        
328
 
                for (i=0; gld_multitex_extensions[i]; i++) {
329
 
                        _mesa_enable_extension(ctx, gld_multitex_extensions[i]);
330
 
                }
331
 
 
332
 
                // GL_SGIS_multitexture
333
 
                // NOTE: Quake2 ran *slower* with this enabled, so I've
334
 
                // disabled it for now.
335
 
                // Fair bit slower on GeForce256,
336
 
                // Much slower on 3dfx Voodoo5 5500.
337
 
//              _mesa_add_extension(ctx, GL_TRUE, szGL_SGIS_multitexture, 0);
338
 
 
339
 
        }
340
 
 
341
 
        _mesa_enable_imaging_extensions(ctx);
342
 
        _mesa_enable_1_3_extensions(ctx);
343
 
        _mesa_enable_1_4_extensions(ctx);
344
 
}
345
 
 
346
 
//---------------------------------------------------------------------------