src/video/SDL_video.c
changeset 1985 8055185ae4ed
parent 1981 3f21778e7433
child 2046 da8332c8f480
     1.1 --- a/src/video/SDL_video.c	Thu Aug 24 12:49:59 2006 +0000
     1.2 +++ b/src/video/SDL_video.c	Mon Aug 28 03:17:39 2006 +0000
     1.3 @@ -1510,6 +1510,10 @@
     1.4      texture->access = access;
     1.5      texture->w = w;
     1.6      texture->h = h;
     1.7 +    texture->r = 255;
     1.8 +    texture->g = 255;
     1.9 +    texture->b = 255;
    1.10 +    texture->a = 255;
    1.11      texture->renderer = renderer;
    1.12  
    1.13      if (renderer->CreateTexture(renderer, texture) < 0) {
    1.14 @@ -1772,6 +1776,162 @@
    1.15  }
    1.16  
    1.17  int
    1.18 +SDL_SetTextureColorMod(SDL_TextureID textureID, Uint8 r, Uint8 g, Uint8 b)
    1.19 +{
    1.20 +    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
    1.21 +    SDL_Renderer *renderer;
    1.22 +
    1.23 +    if (!texture) {
    1.24 +        return -1;
    1.25 +    }
    1.26 +
    1.27 +    renderer = texture->renderer;
    1.28 +    if (!renderer->SetTextureColorMod) {
    1.29 +        return -1;
    1.30 +    }
    1.31 +    if (r < 255 | g < 255 | b < 255) {
    1.32 +        texture->modMode |= SDL_TEXTUREMODULATE_COLOR;
    1.33 +    } else {
    1.34 +        texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR;
    1.35 +    }
    1.36 +    texture->r = r;
    1.37 +    texture->g = g;
    1.38 +    texture->b = b;
    1.39 +    return renderer->SetTextureColorMod(renderer, texture);
    1.40 +}
    1.41 +
    1.42 +int
    1.43 +SDL_GetTextureColorMod(SDL_TextureID textureID, Uint8 * r, Uint8 * g,
    1.44 +                       Uint8 * b)
    1.45 +{
    1.46 +    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
    1.47 +    SDL_Renderer *renderer;
    1.48 +
    1.49 +    if (!texture) {
    1.50 +        return -1;
    1.51 +    }
    1.52 +
    1.53 +    renderer = texture->renderer;
    1.54 +    if (r) {
    1.55 +        *r = texture->r;
    1.56 +    }
    1.57 +    if (g) {
    1.58 +        *g = texture->g;
    1.59 +    }
    1.60 +    if (b) {
    1.61 +        *b = texture->b;
    1.62 +    }
    1.63 +    return 0;
    1.64 +}
    1.65 +
    1.66 +int
    1.67 +SDL_SetTextureAlphaMod(SDL_TextureID textureID, Uint8 alpha)
    1.68 +{
    1.69 +    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
    1.70 +    SDL_Renderer *renderer;
    1.71 +
    1.72 +    if (!texture) {
    1.73 +        return -1;
    1.74 +    }
    1.75 +
    1.76 +    renderer = texture->renderer;
    1.77 +    if (!renderer->SetTextureAlphaMod) {
    1.78 +        return -1;
    1.79 +    }
    1.80 +    if (alpha < 255) {
    1.81 +        texture->modMode |= SDL_TEXTUREMODULATE_ALPHA;
    1.82 +    } else {
    1.83 +        texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA;
    1.84 +    }
    1.85 +    texture->a = alpha;
    1.86 +    return renderer->SetTextureAlphaMod(renderer, texture);
    1.87 +}
    1.88 +
    1.89 +int
    1.90 +SDL_GetTextureAlphaMod(SDL_TextureID textureID, Uint8 * alpha)
    1.91 +{
    1.92 +    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
    1.93 +    SDL_Renderer *renderer;
    1.94 +
    1.95 +    if (!texture) {
    1.96 +        return -1;
    1.97 +    }
    1.98 +
    1.99 +    if (alpha) {
   1.100 +        *alpha = texture->a;
   1.101 +    }
   1.102 +    return 0;
   1.103 +}
   1.104 +
   1.105 +int
   1.106 +SDL_SetTextureBlendMode(SDL_TextureID textureID, int blendMode)
   1.107 +{
   1.108 +    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
   1.109 +    SDL_Renderer *renderer;
   1.110 +
   1.111 +    if (!texture) {
   1.112 +        return -1;
   1.113 +    }
   1.114 +
   1.115 +    renderer = texture->renderer;
   1.116 +    if (!renderer->SetTextureBlendMode) {
   1.117 +        return -1;
   1.118 +    }
   1.119 +    texture->blendMode = blendMode;
   1.120 +    return renderer->SetTextureBlendMode(renderer, texture);
   1.121 +}
   1.122 +
   1.123 +int
   1.124 +SDL_GetTextureBlendMode(SDL_TextureID textureID, int *blendMode)
   1.125 +{
   1.126 +    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
   1.127 +    SDL_Renderer *renderer;
   1.128 +
   1.129 +    if (!texture) {
   1.130 +        return -1;
   1.131 +    }
   1.132 +
   1.133 +    if (blendMode) {
   1.134 +        *blendMode = texture->blendMode;
   1.135 +    }
   1.136 +    return 0;
   1.137 +}
   1.138 +
   1.139 +int
   1.140 +SDL_SetTextureScaleMode(SDL_TextureID textureID, int scaleMode)
   1.141 +{
   1.142 +    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
   1.143 +    SDL_Renderer *renderer;
   1.144 +
   1.145 +    if (!texture) {
   1.146 +        return -1;
   1.147 +    }
   1.148 +
   1.149 +    renderer = texture->renderer;
   1.150 +    if (!renderer->SetTextureScaleMode) {
   1.151 +        return -1;
   1.152 +    }
   1.153 +    texture->scaleMode = scaleMode;
   1.154 +    return renderer->SetTextureScaleMode(renderer, texture);
   1.155 +}
   1.156 +
   1.157 +int
   1.158 +SDL_GetTextureScaleMode(SDL_TextureID textureID, int *scaleMode)
   1.159 +{
   1.160 +    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
   1.161 +    SDL_Renderer *renderer;
   1.162 +
   1.163 +    if (!texture) {
   1.164 +        return -1;
   1.165 +    }
   1.166 +
   1.167 +    if (scaleMode) {
   1.168 +        *scaleMode = texture->scaleMode;
   1.169 +    }
   1.170 +    return 0;
   1.171 +}
   1.172 +
   1.173 +int
   1.174  SDL_UpdateTexture(SDL_TextureID textureID, const SDL_Rect * rect,
   1.175                    const void *pixels, int pitch)
   1.176  {
   1.177 @@ -1864,7 +2024,7 @@
   1.178  }
   1.179  
   1.180  int
   1.181 -SDL_RenderFill(const SDL_Rect * rect, Uint32 color)
   1.182 +SDL_RenderFill(Uint8 r, Uint8 g, Uint8 b, Uint8 a, const SDL_Rect * rect)
   1.183  {
   1.184      SDL_Renderer *renderer;
   1.185      SDL_Window *window;
   1.186 @@ -1891,12 +2051,12 @@
   1.187          }
   1.188      }
   1.189  
   1.190 -    return renderer->RenderFill(renderer, &real_rect, color);
   1.191 +    return renderer->RenderFill(renderer, r, g, b, a, &real_rect);
   1.192  }
   1.193  
   1.194  int
   1.195  SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect,
   1.196 -               const SDL_Rect * dstrect, int blendMode, int scaleMode)
   1.197 +               const SDL_Rect * dstrect)
   1.198  {
   1.199      SDL_Texture *texture = SDL_GetTextureFromID(textureID);
   1.200      SDL_Renderer *renderer;
   1.201 @@ -1932,7 +2092,7 @@
   1.202      }
   1.203  
   1.204      return renderer->RenderCopy(renderer, texture, &real_srcrect,
   1.205 -                                &real_dstrect, blendMode, scaleMode);
   1.206 +                                &real_dstrect);
   1.207  }
   1.208  
   1.209  void