wintrust: Use a helper function to get a signer's cert info from a message.
[wine] / dlls / wined3d / basetexture.c
1 /*
2  * IWineD3DBaseTexture Implementation
3  *
4  * Copyright 2002-2004 Jason Edmeades
5  * Copyright 2002-2004 Raphael Junqueira
6  * Copyright 2005 Oliver Stieber
7  *
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.
12  *
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.
17  *
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22
23 #include "config.h"
24 #include "wined3d_private.h"
25
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
27 #define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
28
29 /* *******************************************
30    IWineD3DBaseTexture IUnknown parts follow
31    ******************************************* */
32 HRESULT WINAPI IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture *iface, REFIID riid, LPVOID *ppobj)
33 {
34     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
35     TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
36     if (IsEqualGUID(riid, &IID_IUnknown)
37         || IsEqualGUID(riid, &IID_IWineD3DBase)
38         || IsEqualGUID(riid, &IID_IWineD3DResource)
39         || IsEqualGUID(riid, &IID_IWineD3DBaseTexture)) {
40         IUnknown_AddRef(iface);
41         *ppobj = This;
42         return S_OK;
43     }
44     *ppobj = NULL;
45     return E_NOINTERFACE;
46 }
47
48 ULONG WINAPI IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture *iface) {
49     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
50     ULONG ref = InterlockedIncrement(&This->resource.ref);
51
52     TRACE("(%p) : AddRef increasing from %d\n", This,ref - 1);
53     return ref;
54 }
55
56 ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface) {
57     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
58     ULONG ref = InterlockedDecrement(&This->resource.ref);
59     TRACE("(%p) : Releasing from %d\n", This, ref + 1);
60     if (ref == 0) {
61         IWineD3DBaseTextureImpl_CleanUp(iface);
62         HeapFree(GetProcessHeap(), 0, This);
63     }
64     return ref;
65 }
66
67 /* class static */
68 void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface) {
69     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
70     IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
71
72     TRACE("(%p) : textureName(%d)\n", This, This->baseTexture.textureName);
73     if (This->baseTexture.textureName != 0) {
74         ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
75         ENTER_GL();
76         TRACE("(%p) : Deleting texture %d\n", This, This->baseTexture.textureName);
77         glDeleteTextures(1, &This->baseTexture.textureName);
78         LEAVE_GL();
79     }
80     IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
81 }
82
83 /* ****************************************************
84    IWineD3DBaseTexture IWineD3DResource parts follow
85    **************************************************** */
86 HRESULT WINAPI IWineD3DBaseTextureImpl_GetDevice(IWineD3DBaseTexture *iface, IWineD3DDevice** ppDevice) {
87     return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
88 }
89
90 HRESULT WINAPI IWineD3DBaseTextureImpl_SetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
91     return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
92 }
93
94 HRESULT WINAPI IWineD3DBaseTextureImpl_GetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
95     return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
96 }
97
98 HRESULT WINAPI IWineD3DBaseTextureImpl_FreePrivateData(IWineD3DBaseTexture *iface, REFGUID refguid) {
99     return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
100 }
101
102 DWORD    WINAPI        IWineD3DBaseTextureImpl_SetPriority(IWineD3DBaseTexture *iface, DWORD PriorityNew) {
103     return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
104 }
105
106 DWORD    WINAPI        IWineD3DBaseTextureImpl_GetPriority(IWineD3DBaseTexture *iface) {
107     return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
108 }
109
110 void     WINAPI        IWineD3DBaseTextureImpl_PreLoad(IWineD3DBaseTexture *iface) {
111     IWineD3DResourceImpl_PreLoad((IWineD3DResource *)iface);
112 }
113
114 WINED3DRESOURCETYPE WINAPI IWineD3DBaseTextureImpl_GetType(IWineD3DBaseTexture *iface) {
115     return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
116 }
117
118 HRESULT WINAPI IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture *iface, IUnknown **pParent) {
119     return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
120 }
121
122 /* ******************************************************
123    IWineD3DBaseTexture IWineD3DBaseTexture parts follow
124    ****************************************************** */
125
126 /* There is no OpenGL equivilent of setLOD, getLOD, all they do it priortise testure loading
127  * so just pretend that they work unless something really needs a failure. */
128 DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LODNew) {
129     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
130
131     if (This->resource.pool != WINED3DPOOL_MANAGED) {
132         return  WINED3DERR_INVALIDCALL;
133     }
134
135     if(LODNew >= This->baseTexture.levels)
136         LODNew = This->baseTexture.levels - 1;
137      This->baseTexture.LOD = LODNew;
138
139     TRACE("(%p) : set bogus LOD to %d\n", This, This->baseTexture.LOD);
140
141     return This->baseTexture.LOD;
142 }
143
144 DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface) {
145     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
146
147     if (This->resource.pool != WINED3DPOOL_MANAGED) {
148         return  WINED3DERR_INVALIDCALL;
149     }
150
151     TRACE("(%p) : returning %d\n", This, This->baseTexture.LOD);
152
153     return This->baseTexture.LOD;
154 }
155
156 DWORD WINAPI IWineD3DBaseTextureImpl_GetLevelCount(IWineD3DBaseTexture *iface) {
157     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
158     TRACE("(%p) : returning %d\n", This, This->baseTexture.levels);
159     return This->baseTexture.levels;
160 }
161
162 HRESULT WINAPI IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
163   IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
164
165   if (!(This->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP)) {
166       TRACE("(%p) : returning invalid call\n", This);
167       return WINED3DERR_INVALIDCALL;
168   }
169   This->baseTexture.filterType = FilterType;
170   TRACE("(%p) :\n", This);
171   return WINED3D_OK;
172 }
173
174 WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3DBaseTexture *iface) {
175   IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
176   FIXME("(%p) : stub\n", This);
177   if (!(This->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP)) {
178      return WINED3DTEXF_NONE;
179   }
180   return This->baseTexture.filterType;
181 }
182
183 void WINAPI IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture *iface) {
184   IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
185   /* TODO: implement filters using GL_SGI_generate_mipmaps http://oss.sgi.com/projects/ogl-sample/registry/SGIS/generate_mipmap.txt */
186   FIXME("(%p) : stub\n", This);
187   return ;
188 }
189
190 /* Internal function, No d3d mapping */
191 BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL dirty) {
192     BOOL old;
193     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
194     old = This->baseTexture.dirty;
195     This->baseTexture.dirty = dirty;
196     return old;
197 }
198
199 BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface) {
200     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
201     return This->baseTexture.dirty;
202 }
203
204 HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) {
205     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
206     HRESULT hr = WINED3D_OK;
207     UINT textureDimensions;
208     BOOL isNewTexture = FALSE;
209     TRACE("(%p) : About to bind texture\n", This);
210
211     textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
212     ENTER_GL();
213     /* Generate a texture name if we don't already have one */
214     if (This->baseTexture.textureName == 0) {
215         glGenTextures(1, &This->baseTexture.textureName);
216         checkGLcall("glGenTextures");
217         TRACE("Generated texture %d\n", This->baseTexture.textureName);
218         if (This->resource.pool == WINED3DPOOL_DEFAULT) {
219             /* Tell opengl to try and keep this texture in video ram (well mostly) */
220             GLclampf tmp;
221             tmp = 0.9f;
222             glPrioritizeTextures(1, &This->baseTexture.textureName, &tmp);
223
224         }
225         /* Initialise the state of the texture object
226         to the openGL defaults, not the directx defaults */
227         This->baseTexture.states[WINED3DTEXSTA_ADDRESSU]      = WINED3DTADDRESS_WRAP;
228         This->baseTexture.states[WINED3DTEXSTA_ADDRESSV]      = WINED3DTADDRESS_WRAP;
229         This->baseTexture.states[WINED3DTEXSTA_ADDRESSW]      = WINED3DTADDRESS_WRAP;
230         This->baseTexture.states[WINED3DTEXSTA_BORDERCOLOR]   = 0;
231         This->baseTexture.states[WINED3DTEXSTA_MAGFILTER]     = WINED3DTEXF_LINEAR;
232         This->baseTexture.states[WINED3DTEXSTA_MINFILTER]     = WINED3DTEXF_POINT; /* GL_NEAREST_MIPMAP_LINEAR */
233         This->baseTexture.states[WINED3DTEXSTA_MIPFILTER]     = WINED3DTEXF_LINEAR; /* GL_NEAREST_MIPMAP_LINEAR */
234         This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL]   = 0;
235         This->baseTexture.states[WINED3DTEXSTA_MAXANISOTROPY] = 0;
236         This->baseTexture.states[WINED3DTEXSTA_SRGBTEXTURE]   = 0;
237         This->baseTexture.states[WINED3DTEXSTA_ELEMENTINDEX]  = 0;
238         This->baseTexture.states[WINED3DTEXSTA_DMAPOFFSET]    = 0;
239         This->baseTexture.states[WINED3DTEXSTA_TSSADDRESSW]   = WINED3DTADDRESS_WRAP;
240         IWineD3DBaseTexture_SetDirty(iface, TRUE);
241         isNewTexture = TRUE;
242     }
243
244     /* Bind the texture */
245     if (This->baseTexture.textureName != 0) {
246         glBindTexture(textureDimensions, This->baseTexture.textureName);
247         checkGLcall("glBindTexture");
248         if (isNewTexture) {
249             /* For a new texture we have to set the textures levels after binding the texture.
250             * In theory this is all we should ever have to do, but because ATI's drivers are broken, we
251             * also need to set the texture dimensions before the texture is set */
252             TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->baseTexture.levels - 1);
253             glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels - 1);
254             checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels)");
255             if(textureDimensions==GL_TEXTURE_CUBE_MAP_ARB) {
256                 /* Cubemaps are always set to clamp, regardeless of the sampler state. */
257                 glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
258                 glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
259                 glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
260             }
261         }
262                 
263     } else { /* this only happened if we've run out of openGL textures */
264         WARN("This texture doesn't have an openGL texture assigned to it\n");
265         hr =  WINED3DERR_INVALIDCALL;
266     }
267
268     LEAVE_GL();
269     return hr;
270 }
271
272 HRESULT WINAPI IWineD3DBaseTextureImpl_UnBindTexture(IWineD3DBaseTexture *iface) {
273     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
274     UINT textureDimensions;
275
276     TRACE("(%p) : About to bind texture\n", This);
277     textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
278
279     ENTER_GL();
280
281     glBindTexture(textureDimensions, 0);
282 #if 0 /* TODO: context manager support */
283      IWineD3DContextManager_PopState(This->contextManager, textureDimensions, ENABLED, NOW /* make sure the state is applied now */);
284 #else
285     glDisable(textureDimensions);
286 #endif
287
288     LEAVE_GL();
289     return WINED3D_OK;
290 }
291
292 UINT WINAPI IWineD3DBaseTextureImpl_GetTextureDimensions(IWineD3DBaseTexture *iface){
293     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
294     FIXME("(%p) : This shouldn't be called\n", This);
295     return WINED3D_OK;
296 }
297
298 static inline GLenum warpLookupType(WINED3DSAMPLERSTATETYPE Type) {
299     switch(Type) {
300     case WINED3DSAMP_ADDRESSU:
301         return GL_TEXTURE_WRAP_S;
302     case WINED3DSAMP_ADDRESSV:
303         return GL_TEXTURE_WRAP_T;
304     case WINED3DSAMP_ADDRESSW:
305         return GL_TEXTURE_WRAP_R;
306     default:
307         FIXME("Unexpected warp type %d\n", Type);
308         return 0;
309     }
310 }
311
312 static inline void apply_wrap(const GLint textureDimensions, const DWORD state, const GLint type) {
313     GLint wrapParm;
314
315     if (state < minLookup[WINELOOKUP_WARPPARAM] || state > maxLookup[WINELOOKUP_WARPPARAM]) {
316         FIXME("Unrecognized or unsupported WINED3DTADDRESS_U value %d\n", state);
317     } else {
318         if(textureDimensions==GL_TEXTURE_CUBE_MAP_ARB) {
319             /* Cubemaps are always set to clamp, regardeless of the sampler state. */
320             wrapParm = GL_CLAMP_TO_EDGE;
321         } else {
322             wrapParm = stateLookup[WINELOOKUP_WARPPARAM][state - minLookup[WINELOOKUP_WARPPARAM]];
323         }
324         TRACE("Setting WRAP_S to %d for %x\n", wrapParm, textureDimensions);
325         glTexParameteri(textureDimensions, type, wrapParm);
326         checkGLcall("glTexParameteri(..., type, wrapParm)");
327     }
328 }
329
330 void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface,
331                                     const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
332                                     const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) {
333     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
334     DWORD state;
335     GLint textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
336
337     IWineD3DBaseTexture_PreLoad(iface);
338
339     if(samplerStates[WINED3DSAMP_ADDRESSU]      != This->baseTexture.states[WINED3DTEXSTA_ADDRESSU]) {
340         state = samplerStates[WINED3DSAMP_ADDRESSU];
341         apply_wrap(textureDimensions, state, GL_TEXTURE_WRAP_S);
342         This->baseTexture.states[WINED3DTEXSTA_ADDRESSU] = state;
343     }
344
345     if(samplerStates[WINED3DSAMP_ADDRESSV]      != This->baseTexture.states[WINED3DTEXSTA_ADDRESSV]) {
346         state = samplerStates[WINED3DSAMP_ADDRESSV];
347         apply_wrap(textureDimensions, state, GL_TEXTURE_WRAP_T);
348         This->baseTexture.states[WINED3DTEXSTA_ADDRESSV] = state;
349     }
350
351     if(samplerStates[WINED3DSAMP_ADDRESSW]      != This->baseTexture.states[WINED3DTEXSTA_ADDRESSW]) {
352         state = samplerStates[WINED3DSAMP_ADDRESSW];
353         apply_wrap(textureDimensions, state, GL_TEXTURE_WRAP_R);
354         This->baseTexture.states[WINED3DTEXSTA_ADDRESSW] = state;
355     }
356
357     if(samplerStates[WINED3DSAMP_BORDERCOLOR]   != This->baseTexture.states[WINED3DTEXSTA_BORDERCOLOR]) {
358         float col[4];
359
360         state = samplerStates[WINED3DSAMP_BORDERCOLOR];
361         D3DCOLORTOGLFLOAT4(state, col);
362         TRACE("Setting border color for %u to %x\n", textureDimensions, state);
363         glTexParameterfv(textureDimensions, GL_TEXTURE_BORDER_COLOR, &col[0]);
364         checkGLcall("glTexParameteri(..., GL_TEXTURE_BORDER_COLOR, ...)");
365         This->baseTexture.states[WINED3DTEXSTA_BORDERCOLOR] = state;
366     }
367
368     if(samplerStates[WINED3DSAMP_MAGFILTER]     != This->baseTexture.states[WINED3DTEXSTA_MAGFILTER]) {
369         GLint glValue;
370         state = samplerStates[WINED3DSAMP_MAGFILTER];
371         if (state < minLookup[WINELOOKUP_MAGFILTER] || state > maxLookup[WINELOOKUP_MAGFILTER]) {
372             FIXME("Unrecognized or unsupported MAGFILTER* value %d\n", state);
373         }
374         glValue = stateLookup[WINELOOKUP_MAGFILTER][state - minLookup[WINELOOKUP_MAGFILTER]];
375         TRACE("ValueMAG=%d setting MAGFILTER to %x\n", state, glValue);
376         glTexParameteri(textureDimensions, GL_TEXTURE_MAG_FILTER, glValue);
377         /* We need to reset the Aniotropic filtering state when we change the mag filter to WINED3DTEXF_ANISOTROPIC (this seems a bit weird, check the documentataion to see how it should be switched off. */
378         if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC) && WINED3DTEXF_ANISOTROPIC == state) {
379             glTexParameteri(textureDimensions, GL_TEXTURE_MAX_ANISOTROPY_EXT, samplerStates[WINED3DSAMP_MAXANISOTROPY]);
380         }
381         This->baseTexture.states[WINED3DTEXSTA_MAGFILTER] = state;
382     }
383
384     if(samplerStates[WINED3DSAMP_MINFILTER]     != This->baseTexture.states[WINED3DTEXSTA_MINFILTER] ||
385        samplerStates[WINED3DSAMP_MIPFILTER]     != This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] ||
386        samplerStates[WINED3DSAMP_MAXMIPLEVEL]   != This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL]) {
387         GLint glValue;
388
389         This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] = samplerStates[WINED3DSAMP_MIPFILTER];
390         This->baseTexture.states[WINED3DTEXSTA_MINFILTER] = samplerStates[WINED3DSAMP_MINFILTER];
391         This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL] = samplerStates[WINED3DSAMP_MAXMIPLEVEL];
392
393         if (This->baseTexture.states[WINED3DTEXSTA_MINFILTER] < WINED3DTEXF_NONE ||
394             This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] < WINED3DTEXF_NONE ||
395             This->baseTexture.states[WINED3DTEXSTA_MINFILTER] > WINED3DTEXF_ANISOTROPIC ||
396             This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] > WINED3DTEXF_LINEAR)
397         {
398
399             FIXME("Unrecognized or unsupported D3DSAMP_MINFILTER value %d D3DSAMP_MIPFILTER value %d\n",
400                   This->baseTexture.states[WINED3DTEXSTA_MINFILTER],
401                   This->baseTexture.states[WINED3DTEXSTA_MIPFILTER]);
402         }
403         glValue = minMipLookup[min(max(samplerStates[WINED3DSAMP_MINFILTER],WINED3DTEXF_NONE), WINED3DTEXF_ANISOTROPIC)]
404                 [min(max(samplerStates[WINED3DSAMP_MIPFILTER],WINED3DTEXF_NONE), WINED3DTEXF_LINEAR)];
405
406         TRACE("ValueMIN=%d, ValueMIP=%d, setting MINFILTER to %x\n",
407               samplerStates[WINED3DSAMP_MINFILTER],
408               samplerStates[WINED3DSAMP_MIPFILTER], glValue);
409         glTexParameteri(textureDimensions, GL_TEXTURE_MIN_FILTER, glValue);
410         checkGLcall("glTexParameter GL_TEXTURE_MIN_FILTER, ...");
411
412         if(This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] == WINED3DTEXF_NONE) {
413             glValue = 0;
414         } else if(This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL] >= This->baseTexture.levels) {
415             glValue = This->baseTexture.levels - 1;
416         } else {
417             glValue = This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL];
418         }
419         glTexParameteri(textureDimensions, GL_TEXTURE_BASE_LEVEL, glValue);
420     }
421
422     if(samplerStates[WINED3DSAMP_MAXANISOTROPY] != This->baseTexture.states[WINED3DTEXSTA_MAXANISOTROPY]) {
423         if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
424             glTexParameteri(textureDimensions, GL_TEXTURE_MAX_ANISOTROPY_EXT, samplerStates[WINED3DSAMP_MAXANISOTROPY]);
425             checkGLcall("glTexParameteri GL_TEXTURE_MAX_ANISOTROPY_EXT ...");
426         } else {
427             WARN("Unsupported in local OpenGL implementation: glTexParameteri GL_TEXTURE_MAX_ANISOTROPY_EXT\n");
428         }
429         This->baseTexture.states[WINED3DTEXSTA_MAXANISOTROPY] = samplerStates[WINED3DSAMP_MAXANISOTROPY];
430     }
431 }
432
433
434 static const IWineD3DBaseTextureVtbl IWineD3DBaseTexture_Vtbl =
435 {
436     /* IUnknown */
437     IWineD3DBaseTextureImpl_QueryInterface,
438     IWineD3DBaseTextureImpl_AddRef,
439     IWineD3DBaseTextureImpl_Release,
440     /* IWineD3DResource */
441     IWineD3DBaseTextureImpl_GetParent,
442     IWineD3DBaseTextureImpl_GetDevice,
443     IWineD3DBaseTextureImpl_SetPrivateData,
444     IWineD3DBaseTextureImpl_GetPrivateData,
445     IWineD3DBaseTextureImpl_FreePrivateData,
446     IWineD3DBaseTextureImpl_SetPriority,
447     IWineD3DBaseTextureImpl_GetPriority,
448     IWineD3DBaseTextureImpl_PreLoad,
449     IWineD3DBaseTextureImpl_GetType,
450     /*IWineD3DBaseTexture*/
451     IWineD3DBaseTextureImpl_SetLOD,
452     IWineD3DBaseTextureImpl_GetLOD,
453     IWineD3DBaseTextureImpl_GetLevelCount,
454     IWineD3DBaseTextureImpl_SetAutoGenFilterType,
455     IWineD3DBaseTextureImpl_GetAutoGenFilterType,
456     IWineD3DBaseTextureImpl_GenerateMipSubLevels,
457     IWineD3DBaseTextureImpl_SetDirty,
458     IWineD3DBaseTextureImpl_GetDirty,
459     /* internal */
460     IWineD3DBaseTextureImpl_BindTexture,
461     IWineD3DBaseTextureImpl_UnBindTexture,
462     IWineD3DBaseTextureImpl_GetTextureDimensions,
463     IWineD3DBaseTextureImpl_ApplyStateChanges
464
465 };