Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
fe2b0d97
Commit
fe2b0d97
authored
Feb 03, 2011
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplified and improved the process of creating a texture from a surface.
parent
31b3ad24
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
248 deletions
+40
-248
SDL_render.h
include/SDL_render.h
+2
-5
SDL_render.c
src/render/SDL_render.c
+35
-232
testshape.c
test/testshape.c
+1
-1
testsprite2.c
test/testsprite2.c
+1
-5
testspriteminimal.c
test/testspriteminimal.c
+1
-5
No files found.
include/SDL_render.h
View file @
fe2b0d97
...
...
@@ -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
...
...
src/render/SDL_render.c
View file @
fe2b0d97
This diff is collapsed.
Click to expand it.
test/testshape.c
View file @
fe2b0d97
...
...
@@ -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
++
)
...
...
test/testsprite2.c
View file @
fe2b0d97
...
...
@@ -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
);
...
...
test/testspriteminimal.c
View file @
fe2b0d97
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment