comparison src/video/SDL_video.c @ 5144:31e7f523ab3d

Making the API simpler, texture color and alpha modulation are supported by all renderers.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 31 Jan 2011 23:37:30 -0800
parents e743b9c3f6d6
children a1345acf7b3d
comparison
equal deleted inserted replaced
5143:e743b9c3f6d6 5144:31e7f523ab3d
2072 texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR; 2072 texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR;
2073 } 2073 }
2074 texture->r = r; 2074 texture->r = r;
2075 texture->g = g; 2075 texture->g = g;
2076 texture->b = b; 2076 texture->b = b;
2077 return renderer->SetTextureColorMod(renderer, texture); 2077 if (renderer->SetTextureColorMod) {
2078 return renderer->SetTextureColorMod(renderer, texture);
2079 } else {
2080 return 0;
2081 }
2078 } 2082 }
2079 2083
2080 int 2084 int
2081 SDL_GetTextureColorMod(SDL_Texture * texture, Uint8 * r, Uint8 * g, 2085 SDL_GetTextureColorMod(SDL_Texture * texture, Uint8 * r, Uint8 * g,
2082 Uint8 * b) 2086 Uint8 * b)
2114 texture->modMode |= SDL_TEXTUREMODULATE_ALPHA; 2118 texture->modMode |= SDL_TEXTUREMODULATE_ALPHA;
2115 } else { 2119 } else {
2116 texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA; 2120 texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA;
2117 } 2121 }
2118 texture->a = alpha; 2122 texture->a = alpha;
2119 return renderer->SetTextureAlphaMod(renderer, texture); 2123 if (renderer->SetTextureAlphaMod) {
2124 return renderer->SetTextureAlphaMod(renderer, texture);
2125 } else {
2126 return 0;
2127 }
2120 } 2128 }
2121 2129
2122 int 2130 int
2123 SDL_GetTextureAlphaMod(SDL_Texture * texture, Uint8 * alpha) 2131 SDL_GetTextureAlphaMod(SDL_Texture * texture, Uint8 * alpha)
2124 { 2132 {
2141 if (!renderer->SetTextureBlendMode) { 2149 if (!renderer->SetTextureBlendMode) {
2142 SDL_Unsupported(); 2150 SDL_Unsupported();
2143 return -1; 2151 return -1;
2144 } 2152 }
2145 texture->blendMode = blendMode; 2153 texture->blendMode = blendMode;
2146 return renderer->SetTextureBlendMode(renderer, texture); 2154 if (renderer->SetTextureBlendMode) {
2155 return renderer->SetTextureBlendMode(renderer, texture);
2156 } else {
2157 return 0;
2158 }
2147 } 2159 }
2148 2160
2149 int 2161 int
2150 SDL_GetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode *blendMode) 2162 SDL_GetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode *blendMode)
2151 { 2163 {
2256 } 2268 }
2257 renderer->r = r; 2269 renderer->r = r;
2258 renderer->g = g; 2270 renderer->g = g;
2259 renderer->b = b; 2271 renderer->b = b;
2260 renderer->a = a; 2272 renderer->a = a;
2261 if (renderer->SetDrawColor) { 2273 return 0;
2262 return renderer->SetDrawColor(renderer);
2263 } else {
2264 return 0;
2265 }
2266 } 2274 }
2267 2275
2268 int 2276 int
2269 SDL_GetRenderDrawColor(Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a) 2277 SDL_GetRenderDrawColor(Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a)
2270 { 2278 {
2297 renderer = SDL_GetCurrentRenderer(SDL_TRUE); 2305 renderer = SDL_GetCurrentRenderer(SDL_TRUE);
2298 if (!renderer) { 2306 if (!renderer) {
2299 return -1; 2307 return -1;
2300 } 2308 }
2301 renderer->blendMode = blendMode; 2309 renderer->blendMode = blendMode;
2302 if (renderer->SetDrawBlendMode) { 2310 return 0;
2303 return renderer->SetDrawBlendMode(renderer);
2304 } else {
2305 return 0;
2306 }
2307 } 2311 }
2308 2312
2309 int 2313 int
2310 SDL_GetRenderDrawBlendMode(SDL_BlendMode *blendMode) 2314 SDL_GetRenderDrawBlendMode(SDL_BlendMode *blendMode)
2311 { 2315 {