/**
 * @brief Test to see if can set texture color mode. Helper function.
 *
 * \sa
 * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod
 * http://wiki.libsdl.org/moin.cgi/SDL_GetTextureColorMod
 * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
 */
static int
_hasTexColor (void)
{
   int fail;
   int ret;
   SDL_Texture *tface;
   Uint8 r, g, b;

   /* Get test face. */
   tface = _loadTestFace();
   if (tface == NULL)
      return 0;

   /* See if supported. */
   fail = 0;
   ret = SDL_SetTextureColorMod( tface, 100, 100, 100 );
   if (!_isSupported(ret))
      fail = 1;
   ret = SDL_GetTextureColorMod( tface, &r, &g, &b );
   if (!_isSupported(ret))
      fail = 1;

   /* Clean up. */
   SDL_DestroyTexture( tface );

   if (fail)
      return 0;
   else if ((r != 100) || (g != 100) || (b != 100))
      return 0;
   return 1;
}
Example #2
0
/*
--------------------------------------------------------------------------------
                                 SAVE COLOR MOD
--------------------------------------------------------------------------------
 *  This method saves a backup of the original color mod value
*/
void Texture::save_color_mod( void )
{
    /*  Get the color mod from the texture */
    Uint8 r, g, b;
    SDL_GetTextureColorMod( mTexture, &r, &g, &b );

    /*  Create a new color from it */
    SDL_Color orig = { r, g, b, 255 };
    
    /*  Store that color */
    mOriginalColorMod = orig;
}
Example #3
0
void Sprite::initTextureData()
{
	if(m_pTexture)
	{
		// Get texture width and height
		SDL_QueryTexture(m_pTexture, NULL, NULL, &m_width, &m_height);

		// Get color mod
		SDL_GetTextureColorMod(m_pTexture, &m_color.r, &m_color.g, &m_color.b);

		// Get alpha
		SDL_GetTextureAlphaMod(m_pTexture, &m_color.a);
	}
}
Example #4
0
CAMLprim value
caml_SDL_GetTextureColorMod(value texture)
{
    CAMLparam1(texture);
    CAMLlocal1(rgb);

    Uint8 r, g, b;
    int s =
        SDL_GetTextureColorMod(
            SDL_Texture_val(texture),
            &r, &g, &b);
    if (s)
        caml_failwith("Sdltexture.get_color_mod");

    rgb = caml_alloc(3, 0);
    Store_field(rgb, 0, Val_uint8(r));
    Store_field(rgb, 1, Val_uint8(g));
    Store_field(rgb, 2, Val_uint8(b));
    CAMLreturn(rgb);
}
Example #5
0
 TemporaryTextureColor(SDL_Texture * targ, Uint8 r, Uint8 g, Uint8 b)
 {
     texture = targ;
     SDL_GetTextureColorMod(texture, &oldr, &oldg, &oldb);
     SDL_SetTextureColorMod(texture, r, g, b);
 }
Example #6
0
 TemporaryTextureColor(bfont * farg, Uint8 r, Uint8 g, Uint8 b)
 {
     texture = farg->spritesheet;
     SDL_GetTextureColorMod(texture, &oldr, &oldg, &oldb);
     SDL_SetTextureColorMod(texture, r, g, b);
 }
Example #7
0
/*
--------------------------------------------------------------------------------
                              GET / SET COLOR MOD
--------------------------------------------------------------------------------
*/
void Texture::get_color_mod( Uint8 *r, Uint8 *g, Uint8 *b )
{
    SDL_GetTextureColorMod( mTexture, r, g, b );
}
Example #8
0
int gytexture_color(GyTexture * self, uint8_t *r, uint8_t *g, uint8_t *b) {
  return SDL_GetTextureColorMod(GY_TEXTURE_UNWRAP(self), r, g, b);
}  
Example #9
0
Color Texture::GetColorMod()
{
	SDL_Color temp;
	SDL_GetTextureColorMod(m_texture, &temp.r, &temp.g, &temp.b);
	return Color(temp.r, temp.g, temp.b);
}