2 * IWineD3DBaseTexture Implementation
4 * Copyright 2002-2004 Jason Edmeades
5 * Copyright 2002-2004 Raphael Junqueira
6 * Copyright 2005 Oliver Stieber
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wined3d_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
27 #define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
29 /* *******************************************
30 IWineD3DBaseTexture IUnknown parts follow
31 ******************************************* */
32 HRESULT WINAPI IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture *iface, REFIID riid, LPVOID *ppobj)
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);
48 ULONG WINAPI IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture *iface) {
49 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
50 ULONG ref = InterlockedIncrement(&This->resource.ref);
52 TRACE("(%p) : AddRef increasing from %d\n", This,ref - 1);
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);
61 IWineD3DBaseTextureImpl_CleanUp(iface);
62 HeapFree(GetProcessHeap(), 0, This);
68 void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface) {
69 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
70 IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
72 TRACE("(%p) : textureName(%d)\n", This, This->baseTexture.textureName);
73 if (This->baseTexture.textureName != 0) {
74 ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
76 TRACE("(%p) : Deleting texture %d\n", This, This->baseTexture.textureName);
77 glDeleteTextures(1, &This->baseTexture.textureName);
80 IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
83 /* ****************************************************
84 IWineD3DBaseTexture IWineD3DResource parts follow
85 **************************************************** */
86 HRESULT WINAPI IWineD3DBaseTextureImpl_GetDevice(IWineD3DBaseTexture *iface, IWineD3DDevice** ppDevice) {
87 return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
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);
94 HRESULT WINAPI IWineD3DBaseTextureImpl_GetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
95 return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
98 HRESULT WINAPI IWineD3DBaseTextureImpl_FreePrivateData(IWineD3DBaseTexture *iface, REFGUID refguid) {
99 return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
102 DWORD WINAPI IWineD3DBaseTextureImpl_SetPriority(IWineD3DBaseTexture *iface, DWORD PriorityNew) {
103 return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
106 DWORD WINAPI IWineD3DBaseTextureImpl_GetPriority(IWineD3DBaseTexture *iface) {
107 return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
110 void WINAPI IWineD3DBaseTextureImpl_PreLoad(IWineD3DBaseTexture *iface) {
111 IWineD3DResourceImpl_PreLoad((IWineD3DResource *)iface);
114 WINED3DRESOURCETYPE WINAPI IWineD3DBaseTextureImpl_GetType(IWineD3DBaseTexture *iface) {
115 return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
118 HRESULT WINAPI IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture *iface, IUnknown **pParent) {
119 return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
122 /* ******************************************************
123 IWineD3DBaseTexture IWineD3DBaseTexture parts follow
124 ****************************************************** */
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;
131 if (This->resource.pool != WINED3DPOOL_MANAGED) {
132 return WINED3DERR_INVALIDCALL;
135 if(LODNew >= This->baseTexture.levels)
136 LODNew = This->baseTexture.levels - 1;
137 This->baseTexture.LOD = LODNew;
139 TRACE("(%p) : set bogus LOD to %d\n", This, This->baseTexture.LOD);
141 return This->baseTexture.LOD;
144 DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface) {
145 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
147 if (This->resource.pool != WINED3DPOOL_MANAGED) {
148 return WINED3DERR_INVALIDCALL;
151 TRACE("(%p) : returning %d\n", This, This->baseTexture.LOD);
153 return This->baseTexture.LOD;
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;
162 HRESULT WINAPI IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
163 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
164 IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
165 UINT textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
167 if (!(This->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP)) {
168 TRACE("(%p) : returning invalid call\n", This);
169 return WINED3DERR_INVALIDCALL;
171 if(This->baseTexture.filterType != FilterType) {
172 /* What about multithreading? Do we want all the context overhead just to set this value?
173 * Or should we delay the applying until the texture is used for drawing? For now, apply
176 ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
178 glBindTexture(textureDimensions, This->baseTexture.textureName);
179 checkGLcall("glBindTexture");
181 case WINED3DTEXF_NONE:
182 case WINED3DTEXF_POINT:
183 glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_FASTEST);
184 checkGLcall("glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_FASTEST)");
186 case WINED3DTEXF_LINEAR:
187 glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
188 checkGLcall("glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST)");
191 WARN("Unexpected filter type %d, setting to GL_NICEST\n", FilterType);
192 glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
193 checkGLcall("glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST)");
197 This->baseTexture.filterType = FilterType;
198 TRACE("(%p) :\n", This);
202 WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3DBaseTexture *iface) {
203 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
204 FIXME("(%p) : stub\n", This);
205 if (!(This->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP)) {
206 return WINED3DTEXF_NONE;
208 return This->baseTexture.filterType;
211 void WINAPI IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture *iface) {
212 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
213 /* TODO: implement filters using GL_SGI_generate_mipmaps http://oss.sgi.com/projects/ogl-sample/registry/SGIS/generate_mipmap.txt */
214 FIXME("(%p) : stub\n", This);
218 /* Internal function, No d3d mapping */
219 BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL dirty) {
221 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
222 old = This->baseTexture.dirty;
223 This->baseTexture.dirty = dirty;
227 BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface) {
228 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
229 return This->baseTexture.dirty;
232 HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) {
233 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
234 HRESULT hr = WINED3D_OK;
235 UINT textureDimensions;
236 BOOL isNewTexture = FALSE;
237 TRACE("(%p) : About to bind texture\n", This);
239 textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
241 /* Generate a texture name if we don't already have one */
242 if (This->baseTexture.textureName == 0) {
243 glGenTextures(1, &This->baseTexture.textureName);
244 checkGLcall("glGenTextures");
245 TRACE("Generated texture %d\n", This->baseTexture.textureName);
246 if (This->resource.pool == WINED3DPOOL_DEFAULT) {
247 /* Tell opengl to try and keep this texture in video ram (well mostly) */
250 glPrioritizeTextures(1, &This->baseTexture.textureName, &tmp);
253 /* Initialise the state of the texture object
254 to the openGL defaults, not the directx defaults */
255 This->baseTexture.states[WINED3DTEXSTA_ADDRESSU] = WINED3DTADDRESS_WRAP;
256 This->baseTexture.states[WINED3DTEXSTA_ADDRESSV] = WINED3DTADDRESS_WRAP;
257 This->baseTexture.states[WINED3DTEXSTA_ADDRESSW] = WINED3DTADDRESS_WRAP;
258 This->baseTexture.states[WINED3DTEXSTA_BORDERCOLOR] = 0;
259 This->baseTexture.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_LINEAR;
260 This->baseTexture.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT; /* GL_NEAREST_MIPMAP_LINEAR */
261 This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_LINEAR; /* GL_NEAREST_MIPMAP_LINEAR */
262 This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL] = 0;
263 This->baseTexture.states[WINED3DTEXSTA_MAXANISOTROPY] = 0;
264 This->baseTexture.states[WINED3DTEXSTA_SRGBTEXTURE] = 0;
265 This->baseTexture.states[WINED3DTEXSTA_ELEMENTINDEX] = 0;
266 This->baseTexture.states[WINED3DTEXSTA_DMAPOFFSET] = 0;
267 This->baseTexture.states[WINED3DTEXSTA_TSSADDRESSW] = WINED3DTADDRESS_WRAP;
268 IWineD3DBaseTexture_SetDirty(iface, TRUE);
271 if(This->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP) {
272 /* This means double binding the texture at creation, but keeps the code simpler all
273 * in all, and the run-time path free from additional checks
275 glBindTexture(textureDimensions, This->baseTexture.textureName);
276 checkGLcall("glBindTexture");
277 glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
278 checkGLcall("glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_SGIS, GL_TRUE)");
282 /* Bind the texture */
283 if (This->baseTexture.textureName != 0) {
284 glBindTexture(textureDimensions, This->baseTexture.textureName);
285 checkGLcall("glBindTexture");
287 /* For a new texture we have to set the textures levels after binding the texture.
288 * In theory this is all we should ever have to do, but because ATI's drivers are broken, we
289 * also need to set the texture dimensions before the texture is set */
290 TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->baseTexture.levels - 1);
291 glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels - 1);
292 checkGLcall("glTexParameteri(textureDimensions, GL_TEXTURE_MAX_LEVEL, This->baseTexture.levels)");
293 if(textureDimensions==GL_TEXTURE_CUBE_MAP_ARB) {
294 /* Cubemaps are always set to clamp, regardeless of the sampler state. */
295 glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
296 glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
297 glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
301 } else { /* this only happened if we've run out of openGL textures */
302 WARN("This texture doesn't have an openGL texture assigned to it\n");
303 hr = WINED3DERR_INVALIDCALL;
310 HRESULT WINAPI IWineD3DBaseTextureImpl_UnBindTexture(IWineD3DBaseTexture *iface) {
311 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
312 UINT textureDimensions;
314 TRACE("(%p) : About to bind texture\n", This);
315 textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
319 glBindTexture(textureDimensions, 0);
320 #if 0 /* TODO: context manager support */
321 IWineD3DContextManager_PopState(This->contextManager, textureDimensions, ENABLED, NOW /* make sure the state is applied now */);
323 glDisable(textureDimensions);
330 UINT WINAPI IWineD3DBaseTextureImpl_GetTextureDimensions(IWineD3DBaseTexture *iface){
331 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
332 FIXME("(%p) : This shouldn't be called\n", This);
336 static inline GLenum warpLookupType(WINED3DSAMPLERSTATETYPE Type) {
338 case WINED3DSAMP_ADDRESSU:
339 return GL_TEXTURE_WRAP_S;
340 case WINED3DSAMP_ADDRESSV:
341 return GL_TEXTURE_WRAP_T;
342 case WINED3DSAMP_ADDRESSW:
343 return GL_TEXTURE_WRAP_R;
345 FIXME("Unexpected warp type %d\n", Type);
350 static inline void apply_wrap(const GLint textureDimensions, const DWORD state, const GLint type) {
353 if (state < minLookup[WINELOOKUP_WARPPARAM] || state > maxLookup[WINELOOKUP_WARPPARAM]) {
354 FIXME("Unrecognized or unsupported WINED3DTADDRESS_U value %d\n", state);
356 if(textureDimensions==GL_TEXTURE_CUBE_MAP_ARB) {
357 /* Cubemaps are always set to clamp, regardeless of the sampler state. */
358 wrapParm = GL_CLAMP_TO_EDGE;
360 wrapParm = stateLookup[WINELOOKUP_WARPPARAM][state - minLookup[WINELOOKUP_WARPPARAM]];
362 TRACE("Setting WRAP_S to %d for %x\n", wrapParm, textureDimensions);
363 glTexParameteri(textureDimensions, type, wrapParm);
364 checkGLcall("glTexParameteri(..., type, wrapParm)");
368 void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface,
369 const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
370 const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) {
371 IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
373 GLint textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
375 IWineD3DBaseTexture_PreLoad(iface);
377 if(samplerStates[WINED3DSAMP_ADDRESSU] != This->baseTexture.states[WINED3DTEXSTA_ADDRESSU]) {
378 state = samplerStates[WINED3DSAMP_ADDRESSU];
379 apply_wrap(textureDimensions, state, GL_TEXTURE_WRAP_S);
380 This->baseTexture.states[WINED3DTEXSTA_ADDRESSU] = state;
383 if(samplerStates[WINED3DSAMP_ADDRESSV] != This->baseTexture.states[WINED3DTEXSTA_ADDRESSV]) {
384 state = samplerStates[WINED3DSAMP_ADDRESSV];
385 apply_wrap(textureDimensions, state, GL_TEXTURE_WRAP_T);
386 This->baseTexture.states[WINED3DTEXSTA_ADDRESSV] = state;
389 if(samplerStates[WINED3DSAMP_ADDRESSW] != This->baseTexture.states[WINED3DTEXSTA_ADDRESSW]) {
390 state = samplerStates[WINED3DSAMP_ADDRESSW];
391 apply_wrap(textureDimensions, state, GL_TEXTURE_WRAP_R);
392 This->baseTexture.states[WINED3DTEXSTA_ADDRESSW] = state;
395 if(samplerStates[WINED3DSAMP_BORDERCOLOR] != This->baseTexture.states[WINED3DTEXSTA_BORDERCOLOR]) {
398 state = samplerStates[WINED3DSAMP_BORDERCOLOR];
399 D3DCOLORTOGLFLOAT4(state, col);
400 TRACE("Setting border color for %u to %x\n", textureDimensions, state);
401 glTexParameterfv(textureDimensions, GL_TEXTURE_BORDER_COLOR, &col[0]);
402 checkGLcall("glTexParameteri(..., GL_TEXTURE_BORDER_COLOR, ...)");
403 This->baseTexture.states[WINED3DTEXSTA_BORDERCOLOR] = state;
406 if(samplerStates[WINED3DSAMP_MAGFILTER] != This->baseTexture.states[WINED3DTEXSTA_MAGFILTER]) {
408 state = samplerStates[WINED3DSAMP_MAGFILTER];
409 if (state < minLookup[WINELOOKUP_MAGFILTER] || state > maxLookup[WINELOOKUP_MAGFILTER]) {
410 FIXME("Unrecognized or unsupported MAGFILTER* value %d\n", state);
412 glValue = stateLookup[WINELOOKUP_MAGFILTER][state - minLookup[WINELOOKUP_MAGFILTER]];
413 TRACE("ValueMAG=%d setting MAGFILTER to %x\n", state, glValue);
414 glTexParameteri(textureDimensions, GL_TEXTURE_MAG_FILTER, glValue);
415 /* 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. */
416 if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC) && WINED3DTEXF_ANISOTROPIC == state) {
417 glTexParameteri(textureDimensions, GL_TEXTURE_MAX_ANISOTROPY_EXT, samplerStates[WINED3DSAMP_MAXANISOTROPY]);
419 This->baseTexture.states[WINED3DTEXSTA_MAGFILTER] = state;
422 if(samplerStates[WINED3DSAMP_MINFILTER] != This->baseTexture.states[WINED3DTEXSTA_MINFILTER] ||
423 samplerStates[WINED3DSAMP_MIPFILTER] != This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] ||
424 samplerStates[WINED3DSAMP_MAXMIPLEVEL] != This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL]) {
427 This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] = samplerStates[WINED3DSAMP_MIPFILTER];
428 This->baseTexture.states[WINED3DTEXSTA_MINFILTER] = samplerStates[WINED3DSAMP_MINFILTER];
429 This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL] = samplerStates[WINED3DSAMP_MAXMIPLEVEL];
431 if (This->baseTexture.states[WINED3DTEXSTA_MINFILTER] < WINED3DTEXF_NONE ||
432 This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] < WINED3DTEXF_NONE ||
433 This->baseTexture.states[WINED3DTEXSTA_MINFILTER] > WINED3DTEXF_ANISOTROPIC ||
434 This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] > WINED3DTEXF_LINEAR)
437 FIXME("Unrecognized or unsupported D3DSAMP_MINFILTER value %d D3DSAMP_MIPFILTER value %d\n",
438 This->baseTexture.states[WINED3DTEXSTA_MINFILTER],
439 This->baseTexture.states[WINED3DTEXSTA_MIPFILTER]);
441 glValue = minMipLookup[min(max(samplerStates[WINED3DSAMP_MINFILTER],WINED3DTEXF_NONE), WINED3DTEXF_ANISOTROPIC)]
442 [min(max(samplerStates[WINED3DSAMP_MIPFILTER],WINED3DTEXF_NONE), WINED3DTEXF_LINEAR)];
444 TRACE("ValueMIN=%d, ValueMIP=%d, setting MINFILTER to %x\n",
445 samplerStates[WINED3DSAMP_MINFILTER],
446 samplerStates[WINED3DSAMP_MIPFILTER], glValue);
447 glTexParameteri(textureDimensions, GL_TEXTURE_MIN_FILTER, glValue);
448 checkGLcall("glTexParameter GL_TEXTURE_MIN_FILTER, ...");
450 if(This->baseTexture.states[WINED3DTEXSTA_MIPFILTER] == WINED3DTEXF_NONE) {
452 } else if(This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL] >= This->baseTexture.levels) {
453 glValue = This->baseTexture.levels - 1;
455 glValue = This->baseTexture.states[WINED3DTEXSTA_MAXMIPLEVEL];
457 glTexParameteri(textureDimensions, GL_TEXTURE_BASE_LEVEL, glValue);
460 if(samplerStates[WINED3DSAMP_MAXANISOTROPY] != This->baseTexture.states[WINED3DTEXSTA_MAXANISOTROPY]) {
461 if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
462 glTexParameteri(textureDimensions, GL_TEXTURE_MAX_ANISOTROPY_EXT, samplerStates[WINED3DSAMP_MAXANISOTROPY]);
463 checkGLcall("glTexParameteri GL_TEXTURE_MAX_ANISOTROPY_EXT ...");
465 WARN("Unsupported in local OpenGL implementation: glTexParameteri GL_TEXTURE_MAX_ANISOTROPY_EXT\n");
467 This->baseTexture.states[WINED3DTEXSTA_MAXANISOTROPY] = samplerStates[WINED3DSAMP_MAXANISOTROPY];
472 static const IWineD3DBaseTextureVtbl IWineD3DBaseTexture_Vtbl =
475 IWineD3DBaseTextureImpl_QueryInterface,
476 IWineD3DBaseTextureImpl_AddRef,
477 IWineD3DBaseTextureImpl_Release,
478 /* IWineD3DResource */
479 IWineD3DBaseTextureImpl_GetParent,
480 IWineD3DBaseTextureImpl_GetDevice,
481 IWineD3DBaseTextureImpl_SetPrivateData,
482 IWineD3DBaseTextureImpl_GetPrivateData,
483 IWineD3DBaseTextureImpl_FreePrivateData,
484 IWineD3DBaseTextureImpl_SetPriority,
485 IWineD3DBaseTextureImpl_GetPriority,
486 IWineD3DBaseTextureImpl_PreLoad,
487 IWineD3DBaseTextureImpl_GetType,
488 /*IWineD3DBaseTexture*/
489 IWineD3DBaseTextureImpl_SetLOD,
490 IWineD3DBaseTextureImpl_GetLOD,
491 IWineD3DBaseTextureImpl_GetLevelCount,
492 IWineD3DBaseTextureImpl_SetAutoGenFilterType,
493 IWineD3DBaseTextureImpl_GetAutoGenFilterType,
494 IWineD3DBaseTextureImpl_GenerateMipSubLevels,
495 IWineD3DBaseTextureImpl_SetDirty,
496 IWineD3DBaseTextureImpl_GetDirty,
498 IWineD3DBaseTextureImpl_BindTexture,
499 IWineD3DBaseTextureImpl_UnBindTexture,
500 IWineD3DBaseTextureImpl_GetTextureDimensions,
501 IWineD3DBaseTextureImpl_ApplyStateChanges