Пример #1
1
Uint8 Image::GetAlpha() {
	Uint8 ret = 0;
	if (SDL_GetTextureAlphaMod(texture, &ret)) {
		std::ostringstream msg;
		msg << "Failed to get alpha; " << SDL_GetError();
		throw(std::runtime_error(msg.str()));
	}
	return ret;
}
Пример #2
0
/*
--------------------------------------------------------------------------------
                                   GET ALPHA
--------------------------------------------------------------------------------
 *  Get the alpha value from the texture and return it
*/
Uint8 Texture::get_alpha( void )
{
    Uint8 alpha;
    SDL_GetTextureAlphaMod( mTexture, &alpha );

    return( alpha );
}
Пример #3
0
/**
 * @brief Test to see if we can vary the alpha of the texture. Helper function.
 *
 * \sa
 *  http://wiki.libsdl.org/moin.cgi/SDL_SetTextureAlphaMod
 *  http://wiki.libsdl.org/moin.cgi/SDL_GetTextureAlphaMod
 *  http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture
 */
static int
_hasTexAlpha(void)
{
   int fail;
   int ret;
   SDL_Texture *tface;
   Uint8 a;

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

   /* See if supported. */
   fail = 0;
   ret = SDL_SetTextureAlphaMod( tface, 100 );
   if (!_isSupported(ret))
      fail = 1;
   ret = SDL_GetTextureAlphaMod( tface, &a );
   if (!_isSupported(ret))
      fail = 1;

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

   if (fail)
      return 0;
   else if (a != 100)
      return 0;
   return 1;
}
Пример #4
0
/*
--------------------------------------------------------------------------------
                                  RENDER FADE
--------------------------------------------------------------------------------
 *  This method is similar to render_self() except it also gets and modifies the
 *  alpha value of the texture instance, in effect, 'fading it out'.
*/
void Texture::render_fade( void )
{
    if( mFading )
    {
        /*  Get the alpha value */
        Uint8 a;
        SDL_GetTextureAlphaMod( mTexture, &a );

        /*  Decrease the alpha value or set it to zero */
        if( a >= 8 )
            a -= 8;
        else
            a = 0;

        /*  Apply the modified alpha to the texture */
        SDL_SetTextureAlphaMod( mTexture, a );

        /*  Create the draw rect and render the texture */
        SDL_Rect dRect = { mPos.x, mPos.y, mWidth, mHeight };
        SDL_RenderCopy( gRenderer, mTexture, NULL, &dRect );

        /*  If we've hit zero alpha, reset the texture and switch off fading */
        if( a == 0 )
        {
            mFading = false;
            SDL_SetTextureAlphaMod( mTexture, (Uint8)255 );
        }
    }
}
Пример #5
0
float image_get_alpha( void *image )
{
	Uint8 alpha;

	SDL_GetTextureAlphaMod( asset_image_handle(image), &alpha );
	return ( alpha / 255.0f );
}
Пример #6
0
int Texture::GetAlphaMod()
{
	Uint8 alpha;

	if(SDL_GetTextureAlphaMod(m_texture, &alpha) == -1)
		LOG_ERROR("Couldn't get alpha mod");

	return alpha;
}
Пример #7
0
double Sprite::getAlpha(){
	Uint8 alpha = 0;

	const int rc = SDL_GetTextureAlphaMod(this->sdlTexture, &alpha);
	if(rc != 0){
		Log(ERROR) << "Could not get alpha value from Sprite (" << this->path << "). " << SDL_GetError();
	}

	return ((double)alpha); // /255.0
}
Пример #8
0
double Sprite::Alpha() {
	Uint8 alpha = 0;

	const int rc = SDL_GetTextureAlphaMod(m_sdl_texture, &alpha);
	if(rc != 0) {
		log_error() << "Could not get alpha value from Sprite (" << m_path << "). " <<
			SDL_GetError();
	}

	return static_cast<double>(alpha);
}
Пример #9
0
CAMLprim value
caml_SDL_GetTextureAlphaMod(value texture)
{
    Uint8 alpha;
    int r =
        SDL_GetTextureAlphaMod(
            SDL_Texture_val(texture),
            &alpha);
    if (r)
        caml_failwith("Sdltexture.get_alpha_mod");
    return Val_uint8(alpha);
}
Пример #10
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);
	}
}
Пример #11
0
void SpaceScene::render_cursor()
{
	SDL_Point loc;
	SDL_GetMouseState(&(loc.x), &(loc.y));

	window->draw_absolute(cursor, loc);
	if (cursor_frames > 90) {
		Uint8 alpha;
		SDL_GetTextureAlphaMod(cursor->getTexture(), &alpha);
		if (alpha > 0) {
			SDL_SetTextureAlphaMod(cursor->getTexture(), alpha-2);
		}
	}
}
Пример #12
0
int gytexture_alpha(GyTexture * self, uint8_t *a) {
  return SDL_GetTextureAlphaMod(GY_TEXTURE_UNWRAP(self), a);
}
Пример #13
0
int Texture_GetAlpha(Texture* texture)
{
	Uint8 currentAlpha;
	int result = SDL_GetTextureAlphaMod(texture->texture, &currentAlpha);
	return (result == 0 ? currentAlpha : -1);
}