mirror of https://github.com/encounter/SDL.git
Fixed bug 4264 - SDL_CreateTextureFromSurface generates error message but returns ok
Anthony @ POW Games SDL_CreateTextureFromSurface makes an internal call to SDL_GetColorKey which can return an error and spams the error log with "Surface doesn't have a colorkey" even though the original function didn't return an error.
This commit is contained in:
parent
cd90e2ca58
commit
ef34704875
|
@ -248,6 +248,13 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
|
||||||
extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
|
extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
|
||||||
int flag, Uint32 key);
|
int flag, Uint32 key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Returns whether the surface has a color key
|
||||||
|
*
|
||||||
|
* \return SDL_TRUE if the surface has a color key, or SDL_FALSE if the surface is NULL or has no color key
|
||||||
|
*/
|
||||||
|
extern DECLSPEC SDL_bool SDLCALL SDL_HasColorKey(SDL_Surface * surface);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Gets the color key (transparent pixel) in a blittable surface.
|
* \brief Gets the color key (transparent pixel) in a blittable surface.
|
||||||
*
|
*
|
||||||
|
|
|
@ -696,3 +696,4 @@
|
||||||
#define SDL_SensorUpdate SDL_SensorUpdate_REAL
|
#define SDL_SensorUpdate SDL_SensorUpdate_REAL
|
||||||
#define SDL_IsTablet SDL_IsTablet_REAL
|
#define SDL_IsTablet SDL_IsTablet_REAL
|
||||||
#define SDL_GetDisplayOrientation SDL_GetDisplayOrientation_REAL
|
#define SDL_GetDisplayOrientation SDL_GetDisplayOrientation_REAL
|
||||||
|
#define SDL_HasColorKey SDL_HasColorKey_REAL
|
||||||
|
|
|
@ -738,3 +738,4 @@ SDL_DYNAPI_PROC(void,SDL_SensorClose,(SDL_Sensor *a),(a),)
|
||||||
SDL_DYNAPI_PROC(void,SDL_SensorUpdate,(void),(),)
|
SDL_DYNAPI_PROC(void,SDL_SensorUpdate,(void),(),)
|
||||||
SDL_DYNAPI_PROC(SDL_bool,SDL_IsTablet,(void),(),return)
|
SDL_DYNAPI_PROC(SDL_bool,SDL_IsTablet,(void),(),return)
|
||||||
SDL_DYNAPI_PROC(SDL_DisplayOrientation,SDL_GetDisplayOrientation,(int a),(a),return)
|
SDL_DYNAPI_PROC(SDL_DisplayOrientation,SDL_GetDisplayOrientation,(int a),(a),return)
|
||||||
|
SDL_DYNAPI_PROC(SDL_bool,SDL_HasColorKey,(SDL_Surface *a),(a),return)
|
||||||
|
|
|
@ -649,7 +649,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface)
|
||||||
|
|
||||||
/* See what the best texture format is */
|
/* See what the best texture format is */
|
||||||
fmt = surface->format;
|
fmt = surface->format;
|
||||||
if (fmt->Amask || SDL_GetColorKey(surface, NULL) == 0) {
|
if (fmt->Amask || (SDL_HasColorKey(surface) && SDL_GetColorKey(surface, NULL) == 0)) {
|
||||||
needAlpha = SDL_TRUE;
|
needAlpha = SDL_TRUE;
|
||||||
} else {
|
} else {
|
||||||
needAlpha = SDL_FALSE;
|
needAlpha = SDL_FALSE;
|
||||||
|
|
|
@ -292,6 +292,20 @@ SDL_SetColorKey(SDL_Surface * surface, int flag, Uint32 key)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_bool
|
||||||
|
SDL_HasColorKey(SDL_Surface * surface)
|
||||||
|
{
|
||||||
|
if (!surface) {
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(surface->map->info.flags & SDL_COPY_COLORKEY)) {
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SDL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
SDL_GetColorKey(SDL_Surface * surface, Uint32 * key)
|
SDL_GetColorKey(SDL_Surface * surface, Uint32 * key)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue