Commit fe2b0d97 authored by Sam Lantinga's avatar Sam Lantinga

Simplified and improved the process of creating a texture from a surface.

parent 31b3ad24
......@@ -172,19 +172,16 @@ extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer,
/**
* \brief Create a texture from an existing surface.
*
* \param format The format of the texture, or 0 to pick an appropriate format.
* \param surface The surface containing pixel data used to fill the texture.
*
* \return The created texture is returned, or 0 if no rendering context was
* active, the format was unsupported, or the surface width or height
* were out of range.
* \return The created texture is returned, or 0 on error.
*
* \note The surface is not modified or freed by this function.
*
* \sa SDL_QueryTexture()
* \sa SDL_DestroyTexture()
*/
extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, Uint32 format, SDL_Surface * surface);
extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface);
/**
* \brief Query the attributes of a texture
......
This diff is collapsed.
......@@ -118,7 +118,7 @@ int main(int argc,char** argv)
for(i=0;i<num_pictures;i++)
pictures[i].texture = NULL;
for(i=0;i<num_pictures;i++) {
pictures[i].texture = SDL_CreateTextureFromSurface(renderer,0,pictures[i].surface);
pictures[i].texture = SDL_CreateTextureFromSurface(renderer,pictures[i].surface);
if(pictures[i].texture == NULL) {
j = 0;
for(j=0;j<num_pictures;i++)
......
......@@ -77,11 +77,7 @@ LoadSprite(char *file)
/* Create textures from the image */
for (i = 0; i < state->num_windows; ++i) {
SDL_Renderer *renderer = state->renderers[i];
sprites[i] = SDL_CreateTextureFromSurface(renderer, 0, temp);
if (!sprites[i]) {
SDL_SetColorKey(temp, 0, 0);
sprites[i] = SDL_CreateTextureFromSurface(renderer, 0, temp);
}
sprites[i] = SDL_CreateTextureFromSurface(renderer, temp);
if (!sprites[i]) {
fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
SDL_FreeSurface(temp);
......
......@@ -60,11 +60,7 @@ LoadSprite(char *file, SDL_Renderer *renderer)
}
/* Create textures from the image */
sprite = SDL_CreateTextureFromSurface(renderer, 0, temp);
if (!sprite) {
SDL_SetColorKey(temp, 0, 0);
sprite = SDL_CreateTextureFromSurface(renderer, 0, temp);
}
sprite = SDL_CreateTextureFromSurface(renderer, temp);
if (!sprite) {
fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
SDL_FreeSurface(temp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment