Mercurial > sdl-ios-xcode
comparison src/video/windows/SDL_d3drender.c @ 5141:da10636e5eca
Making the API simpler, scaling is always defined as linear interpolation and should be supported as much as possible on all renderers.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 31 Jan 2011 22:44:43 -0800 |
parents | e8916fe9cfc8 |
children | e743b9c3f6d6 |
comparison
equal
deleted
inserted
replaced
5140:e594f07297a9 | 5141:da10636e5eca |
---|---|
104 static int D3D_SetTextureColorMod(SDL_Renderer * renderer, | 104 static int D3D_SetTextureColorMod(SDL_Renderer * renderer, |
105 SDL_Texture * texture); | 105 SDL_Texture * texture); |
106 static int D3D_SetTextureAlphaMod(SDL_Renderer * renderer, | 106 static int D3D_SetTextureAlphaMod(SDL_Renderer * renderer, |
107 SDL_Texture * texture); | 107 SDL_Texture * texture); |
108 static int D3D_SetTextureBlendMode(SDL_Renderer * renderer, | 108 static int D3D_SetTextureBlendMode(SDL_Renderer * renderer, |
109 SDL_Texture * texture); | |
110 static int D3D_SetTextureScaleMode(SDL_Renderer * renderer, | |
111 SDL_Texture * texture); | 109 SDL_Texture * texture); |
112 static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, | 110 static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
113 const SDL_Rect * rect, const void *pixels, | 111 const SDL_Rect * rect, const void *pixels, |
114 int pitch); | 112 int pitch); |
115 static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, | 113 static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
148 SDL_RENDERER_ACCELERATED), | 146 SDL_RENDERER_ACCELERATED), |
149 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | | 147 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | |
150 SDL_TEXTUREMODULATE_ALPHA), | 148 SDL_TEXTUREMODULATE_ALPHA), |
151 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | | 149 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | |
152 SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), | 150 SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), |
153 (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST | | |
154 SDL_SCALEMODE_SLOW | SDL_SCALEMODE_BEST), | |
155 0, | 151 0, |
156 {0}, | 152 {0}, |
157 0, | 153 0, |
158 0} | 154 0} |
159 }; | 155 }; |
459 renderer->SetTexturePalette = D3D_SetTexturePalette; | 455 renderer->SetTexturePalette = D3D_SetTexturePalette; |
460 renderer->GetTexturePalette = D3D_GetTexturePalette; | 456 renderer->GetTexturePalette = D3D_GetTexturePalette; |
461 renderer->SetTextureColorMod = D3D_SetTextureColorMod; | 457 renderer->SetTextureColorMod = D3D_SetTextureColorMod; |
462 renderer->SetTextureAlphaMod = D3D_SetTextureAlphaMod; | 458 renderer->SetTextureAlphaMod = D3D_SetTextureAlphaMod; |
463 renderer->SetTextureBlendMode = D3D_SetTextureBlendMode; | 459 renderer->SetTextureBlendMode = D3D_SetTextureBlendMode; |
464 renderer->SetTextureScaleMode = D3D_SetTextureScaleMode; | |
465 renderer->UpdateTexture = D3D_UpdateTexture; | 460 renderer->UpdateTexture = D3D_UpdateTexture; |
466 renderer->LockTexture = D3D_LockTexture; | 461 renderer->LockTexture = D3D_LockTexture; |
467 renderer->UnlockTexture = D3D_UnlockTexture; | 462 renderer->UnlockTexture = D3D_UnlockTexture; |
468 renderer->DirtyTexture = D3D_DirtyTexture; | 463 renderer->DirtyTexture = D3D_DirtyTexture; |
469 renderer->RenderDrawPoints = D3D_RenderDrawPoints; | 464 renderer->RenderDrawPoints = D3D_RenderDrawPoints; |
802 return -1; | 797 return -1; |
803 } | 798 } |
804 } | 799 } |
805 | 800 |
806 static int | 801 static int |
807 D3D_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture) | |
808 { | |
809 switch (texture->scaleMode) { | |
810 case SDL_SCALEMODE_NONE: | |
811 case SDL_SCALEMODE_FAST: | |
812 case SDL_SCALEMODE_SLOW: | |
813 case SDL_SCALEMODE_BEST: | |
814 return 0; | |
815 default: | |
816 SDL_Unsupported(); | |
817 texture->scaleMode = SDL_SCALEMODE_NONE; | |
818 return -1; | |
819 } | |
820 return 0; | |
821 } | |
822 | |
823 static int | |
824 D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, | 802 D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
825 const SDL_Rect * rect, const void *pixels, int pitch) | 803 const SDL_Rect * rect, const void *pixels, int pitch) |
826 { | 804 { |
827 D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; | 805 D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; |
828 D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata; | 806 D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata; |
1340 | 1318 |
1341 if (texture->blendMode == SDL_BLENDMODE_MASK) { | 1319 if (texture->blendMode == SDL_BLENDMODE_MASK) { |
1342 shader = data->ps_mask; | 1320 shader = data->ps_mask; |
1343 } | 1321 } |
1344 | 1322 |
1345 switch (texture->scaleMode) { | 1323 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER, |
1346 case SDL_SCALEMODE_NONE: | 1324 D3DTEXF_LINEAR); |
1347 case SDL_SCALEMODE_FAST: | 1325 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER, |
1348 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER, | 1326 D3DTEXF_LINEAR); |
1349 D3DTEXF_POINT); | |
1350 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER, | |
1351 D3DTEXF_POINT); | |
1352 break; | |
1353 case SDL_SCALEMODE_SLOW: | |
1354 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER, | |
1355 D3DTEXF_LINEAR); | |
1356 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER, | |
1357 D3DTEXF_LINEAR); | |
1358 break; | |
1359 case SDL_SCALEMODE_BEST: | |
1360 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER, | |
1361 D3DTEXF_GAUSSIANQUAD); | |
1362 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER, | |
1363 D3DTEXF_GAUSSIANQUAD); | |
1364 break; | |
1365 } | |
1366 | 1327 |
1367 result = | 1328 result = |
1368 IDirect3DDevice9_SetTexture(data->device, 0, (IDirect3DBaseTexture9 *) | 1329 IDirect3DDevice9_SetTexture(data->device, 0, (IDirect3DBaseTexture9 *) |
1369 texturedata->texture); | 1330 texturedata->texture); |
1370 if (FAILED(result)) { | 1331 if (FAILED(result)) { |