Mercurial > sdl-ios-xcode
comparison src/video/SDL_renderer_gles.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 | b5b42be9333c |
children | e743b9c3f6d6 |
comparison
equal
deleted
inserted
replaced
5140:e594f07297a9 | 5141:da10636e5eca |
---|---|
70 static int GLES_SetTextureColorMod(SDL_Renderer * renderer, | 70 static int GLES_SetTextureColorMod(SDL_Renderer * renderer, |
71 SDL_Texture * texture); | 71 SDL_Texture * texture); |
72 static int GLES_SetTextureAlphaMod(SDL_Renderer * renderer, | 72 static int GLES_SetTextureAlphaMod(SDL_Renderer * renderer, |
73 SDL_Texture * texture); | 73 SDL_Texture * texture); |
74 static int GLES_SetTextureBlendMode(SDL_Renderer * renderer, | 74 static int GLES_SetTextureBlendMode(SDL_Renderer * renderer, |
75 SDL_Texture * texture); | |
76 static int GLES_SetTextureScaleMode(SDL_Renderer * renderer, | |
77 SDL_Texture * texture); | 75 SDL_Texture * texture); |
78 static int GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, | 76 static int GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
79 const SDL_Rect * rect, const void *pixels, | 77 const SDL_Rect * rect, const void *pixels, |
80 int pitch); | 78 int pitch); |
81 static int GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, | 79 static int GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
110 SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED), | 108 SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED), |
111 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | | 109 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | |
112 SDL_TEXTUREMODULATE_ALPHA), | 110 SDL_TEXTUREMODULATE_ALPHA), |
113 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | | 111 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | |
114 SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), | 112 SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), |
115 (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST | SDL_SCALEMODE_SLOW), 6, | |
116 { | 113 { |
117 /* OpenGL ES 1.x supported formats list */ | 114 /* OpenGL ES 1.x supported formats list */ |
118 SDL_PIXELFORMAT_RGBA4444, | 115 SDL_PIXELFORMAT_RGBA4444, |
119 SDL_PIXELFORMAT_RGBA5551, | 116 SDL_PIXELFORMAT_RGBA5551, |
120 SDL_PIXELFORMAT_RGB565, | 117 SDL_PIXELFORMAT_RGB565, |
239 renderer->SetTexturePalette = GLES_SetTexturePalette; | 236 renderer->SetTexturePalette = GLES_SetTexturePalette; |
240 renderer->GetTexturePalette = GLES_GetTexturePalette; | 237 renderer->GetTexturePalette = GLES_GetTexturePalette; |
241 renderer->SetTextureColorMod = GLES_SetTextureColorMod; | 238 renderer->SetTextureColorMod = GLES_SetTextureColorMod; |
242 renderer->SetTextureAlphaMod = GLES_SetTextureAlphaMod; | 239 renderer->SetTextureAlphaMod = GLES_SetTextureAlphaMod; |
243 renderer->SetTextureBlendMode = GLES_SetTextureBlendMode; | 240 renderer->SetTextureBlendMode = GLES_SetTextureBlendMode; |
244 renderer->SetTextureScaleMode = GLES_SetTextureScaleMode; | |
245 renderer->UpdateTexture = GLES_UpdateTexture; | 241 renderer->UpdateTexture = GLES_UpdateTexture; |
246 renderer->LockTexture = GLES_LockTexture; | 242 renderer->LockTexture = GLES_LockTexture; |
247 renderer->UnlockTexture = GLES_UnlockTexture; | 243 renderer->UnlockTexture = GLES_UnlockTexture; |
248 renderer->DirtyTexture = GLES_DirtyTexture; | 244 renderer->DirtyTexture = GLES_DirtyTexture; |
249 renderer->RenderDrawPoints = GLES_RenderDrawPoints; | 245 renderer->RenderDrawPoints = GLES_RenderDrawPoints; |
447 | 443 |
448 data->format = format; | 444 data->format = format; |
449 data->formattype = type; | 445 data->formattype = type; |
450 renderdata->glBindTexture(data->type, data->texture); | 446 renderdata->glBindTexture(data->type, data->texture); |
451 renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, | 447 renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, |
452 GL_NEAREST); | 448 GL_LINEAR); |
453 renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, | 449 renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, |
454 GL_NEAREST); | 450 GL_LINEAR); |
455 renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S, | 451 renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S, |
456 GL_CLAMP_TO_EDGE); | 452 GL_CLAMP_TO_EDGE); |
457 renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T, | 453 renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T, |
458 GL_CLAMP_TO_EDGE); | 454 GL_CLAMP_TO_EDGE); |
459 | 455 |
528 case SDL_BLENDMODE_MOD: | 524 case SDL_BLENDMODE_MOD: |
529 return 0; | 525 return 0; |
530 default: | 526 default: |
531 SDL_Unsupported(); | 527 SDL_Unsupported(); |
532 texture->blendMode = SDL_BLENDMODE_NONE; | 528 texture->blendMode = SDL_BLENDMODE_NONE; |
533 return -1; | |
534 } | |
535 } | |
536 | |
537 static int | |
538 GLES_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture) | |
539 { | |
540 switch (texture->scaleMode) { | |
541 case SDL_SCALEMODE_NONE: | |
542 case SDL_SCALEMODE_FAST: | |
543 case SDL_SCALEMODE_SLOW: | |
544 return 0; | |
545 case SDL_SCALEMODE_BEST: | |
546 SDL_Unsupported(); | |
547 texture->scaleMode = SDL_SCALEMODE_SLOW; | |
548 return -1; | |
549 default: | |
550 SDL_Unsupported(); | |
551 texture->scaleMode = SDL_SCALEMODE_NONE; | |
552 return -1; | 529 return -1; |
553 } | 530 } |
554 } | 531 } |
555 | 532 |
556 static int | 533 static int |
876 data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | 853 data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f); |
877 } | 854 } |
878 | 855 |
879 GLES_SetBlendMode(data, texture->blendMode, 0); | 856 GLES_SetBlendMode(data, texture->blendMode, 0); |
880 | 857 |
881 switch (texture->scaleMode) { | |
882 case SDL_SCALEMODE_NONE: | |
883 case SDL_SCALEMODE_FAST: | |
884 data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER, | |
885 GL_NEAREST); | |
886 data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER, | |
887 GL_NEAREST); | |
888 break; | |
889 case SDL_SCALEMODE_SLOW: | |
890 case SDL_SCALEMODE_BEST: | |
891 data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER, | |
892 GL_LINEAR); | |
893 data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER, | |
894 GL_LINEAR); | |
895 break; | |
896 } | |
897 | |
898 if (data->GL_OES_draw_texture_supported && data->useDrawTexture) { | 858 if (data->GL_OES_draw_texture_supported && data->useDrawTexture) { |
899 /* this code is a little funny because the viewport is upside down vs SDL's coordinate system */ | 859 /* this code is a little funny because the viewport is upside down vs SDL's coordinate system */ |
900 SDL_Window *window = renderer->window; | 860 SDL_Window *window = renderer->window; |
901 GLint cropRect[4]; | 861 GLint cropRect[4]; |
902 cropRect[0] = srcrect->x; | 862 cropRect[0] = srcrect->x; |