author | Sam Lantinga <slouken@libsdl.org> |
Mon, 01 Oct 2012 23:28:19 -0700 | |
changeset 6532 | 58f726a2fc82 |
parent 6531 | 1ab2e34b90cc |
child 6533 | c784245304dd |
permissions | -rw-r--r-- |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 |
/* |
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5528
diff
changeset
|
2 |
Simple DirectMedia Layer |
6138 | 3 |
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org> |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5528
diff
changeset
|
5 |
This software is provided 'as-is', without any express or implied |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5528
diff
changeset
|
6 |
warranty. In no event will the authors be held liable for any damages |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5528
diff
changeset
|
7 |
arising from the use of this software. |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5528
diff
changeset
|
9 |
Permission is granted to anyone to use this software for any purpose, |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5528
diff
changeset
|
10 |
including commercial applications, and to alter it and redistribute it |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5528
diff
changeset
|
11 |
freely, subject to the following restrictions: |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5528
diff
changeset
|
13 |
1. The origin of this software must not be misrepresented; you must not |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5528
diff
changeset
|
14 |
claim that you wrote the original software. If you use this software |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5528
diff
changeset
|
15 |
in a product, an acknowledgment in the product documentation would be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5528
diff
changeset
|
16 |
appreciated but is not required. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5528
diff
changeset
|
17 |
2. Altered source versions must be plainly marked as such, and must not be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5528
diff
changeset
|
18 |
misrepresented as being the original software. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5528
diff
changeset
|
19 |
3. This notice may not be removed or altered from any source distribution. |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 |
*/ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 |
#include "SDL_config.h" |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
/* The SDL 2D rendering system */ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 |
|
5192
ef5a61ea3202
Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents:
5180
diff
changeset
|
25 |
#include "SDL_hints.h" |
5221
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
5209
diff
changeset
|
26 |
#include "SDL_log.h" |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
#include "SDL_render.h" |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
#include "SDL_sysrender.h" |
5195
bb45ecd958d8
Renamed files for consistency
Sam Lantinga <slouken@libsdl.org>
parents:
5192
diff
changeset
|
29 |
#include "software/SDL_render_sw_c.h" |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
|
5528 | 32 |
#define SDL_WINDOWRENDERDATA "_SDL_WindowRenderData" |
33 |
||
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 |
#define CHECK_RENDERER_MAGIC(renderer, retval) \ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 |
if (!renderer || renderer->magic != &renderer_magic) { \ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 |
SDL_SetError("Invalid renderer"); \ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 |
return retval; \ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 |
#define CHECK_TEXTURE_MAGIC(texture, retval) \ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 |
if (!texture || texture->magic != &texture_magic) { \ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 |
SDL_SetError("Invalid texture"); \ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 |
return retval; \ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 |
static const SDL_RenderDriver *render_drivers[] = { |
5226
710d00cb3a6a
Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents:
5224
diff
changeset
|
48 |
#if !SDL_RENDER_DISABLED |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 |
#if SDL_VIDEO_RENDER_D3D |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 |
&D3D_RenderDriver, |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 |
#endif |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 |
#if SDL_VIDEO_RENDER_OGL |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 |
&GL_RenderDriver, |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 |
#endif |
5209
115fff0641ee
Prefer the OpenGL ES 2.0 context when it's available, make it possible to create an OpenGL 2.0 context on iPhoneOS
Sam Lantinga <slouken@libsdl.org>
parents:
5201
diff
changeset
|
55 |
#if SDL_VIDEO_RENDER_OGL_ES2 |
115fff0641ee
Prefer the OpenGL ES 2.0 context when it's available, make it possible to create an OpenGL 2.0 context on iPhoneOS
Sam Lantinga <slouken@libsdl.org>
parents:
5201
diff
changeset
|
56 |
&GLES2_RenderDriver, |
115fff0641ee
Prefer the OpenGL ES 2.0 context when it's available, make it possible to create an OpenGL 2.0 context on iPhoneOS
Sam Lantinga <slouken@libsdl.org>
parents:
5201
diff
changeset
|
57 |
#endif |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 |
#if SDL_VIDEO_RENDER_OGL_ES |
5201
523409574510
Added an OpenGL ES 2.0 renderer, contributed by itsnotabigtruck
Sam Lantinga <slouken@libsdl.org>
parents:
5199
diff
changeset
|
59 |
&GLES_RenderDriver, |
523409574510
Added an OpenGL ES 2.0 renderer, contributed by itsnotabigtruck
Sam Lantinga <slouken@libsdl.org>
parents:
5199
diff
changeset
|
60 |
#endif |
5199
164f20ba08eb
Updated the DirectFB support, from Couriersud
Sam Lantinga <slouken@libsdl.org>
parents:
5195
diff
changeset
|
61 |
#if SDL_VIDEO_RENDER_DIRECTFB |
164f20ba08eb
Updated the DirectFB support, from Couriersud
Sam Lantinga <slouken@libsdl.org>
parents:
5195
diff
changeset
|
62 |
&DirectFB_RenderDriver, |
164f20ba08eb
Updated the DirectFB support, from Couriersud
Sam Lantinga <slouken@libsdl.org>
parents:
5195
diff
changeset
|
63 |
#endif |
5423 | 64 |
#if SDL_VIDEO_RENDER_NDS |
65 |
&NDS_RenderDriver, |
|
66 |
#endif |
|
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 |
&SW_RenderDriver |
5226
710d00cb3a6a
Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents:
5224
diff
changeset
|
68 |
#endif /* !SDL_RENDER_DISABLED */ |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 |
}; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 |
static char renderer_magic; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 |
static char texture_magic; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 |
|
6530
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
73 |
static int UpdateLogicalSize(SDL_Renderer *renderer); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
74 |
|
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 |
int |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 |
SDL_GetNumRenderDrivers(void) |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 |
{ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 |
return SDL_arraysize(render_drivers); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 |
int |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 |
SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info) |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 |
{ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 |
if (index < 0 || index >= SDL_GetNumRenderDrivers()) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 |
SDL_SetError("index must be in the range of 0 - %d", |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 |
SDL_GetNumRenderDrivers() - 1); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 |
return -1; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 |
*info = render_drivers[index]->info; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 |
return 0; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 |
static int |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 |
SDL_RendererEventWatch(void *userdata, SDL_Event *event) |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 |
{ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 |
SDL_Renderer *renderer = (SDL_Renderer *)userdata; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 |
|
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
98 |
if (event->type == SDL_WINDOWEVENT) { |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 |
SDL_Window *window = SDL_GetWindowFromID(event->window.windowID); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 |
if (window == renderer->window) { |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
101 |
if (renderer->WindowEvent) { |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
102 |
renderer->WindowEvent(renderer, &event->window); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
103 |
} |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
104 |
|
6260
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
105 |
if (event->window.event == SDL_WINDOWEVENT_RESIZED) { |
6530
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
106 |
if (renderer->logical_w) { |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
107 |
/* We'll update the renderer in the SIZE_CHANGED event */ |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
108 |
} else { |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
109 |
/* Try to keep the previous viewport centered */ |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
110 |
int w, h; |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
111 |
|
6530
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
112 |
SDL_GetWindowSize(window, &w, &h); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
113 |
if (renderer->target) { |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
114 |
renderer->viewport_backup.x = (w - renderer->viewport_backup.w) / 2; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
115 |
renderer->viewport_backup.y = (h - renderer->viewport_backup.h) / 2; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
116 |
} else { |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
117 |
renderer->viewport.x = (w - renderer->viewport.w) / 2; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
118 |
renderer->viewport.y = (h - renderer->viewport.h) / 2; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
119 |
renderer->UpdateViewport(renderer); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
120 |
} |
6246
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
121 |
} |
6260
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
122 |
renderer->resized = SDL_TRUE; |
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
123 |
} else if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) { |
6530
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
124 |
if (renderer->logical_w) { |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
125 |
UpdateLogicalSize(renderer); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
126 |
} else if (!renderer->resized) { |
6260
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
127 |
/* Window was programmatically resized, reset viewport */ |
6528
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
128 |
int w, h; |
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
129 |
|
6260
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
130 |
SDL_GetWindowSize(window, &w, &h); |
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
131 |
if (renderer->target) { |
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
132 |
renderer->viewport_backup.x = 0; |
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
133 |
renderer->viewport_backup.y = 0; |
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
134 |
renderer->viewport_backup.w = w; |
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
135 |
renderer->viewport_backup.h = h; |
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
136 |
} else { |
6528
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
137 |
renderer->viewport.x = 0; |
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
138 |
renderer->viewport.y = 0; |
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
139 |
renderer->viewport.w = w; |
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
140 |
renderer->viewport.h = h; |
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
141 |
renderer->UpdateViewport(renderer); |
6260
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
142 |
} |
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
143 |
} |
6528
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
144 |
renderer->resized = SDL_FALSE; |
6260
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
145 |
} else if (event->window.event == SDL_WINDOWEVENT_HIDDEN) { |
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
146 |
renderer->hidden = SDL_TRUE; |
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
147 |
} else if (event->window.event == SDL_WINDOWEVENT_SHOWN) { |
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
148 |
if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED)) { |
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
149 |
renderer->hidden = SDL_FALSE; |
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
150 |
} |
6060
59d398ac031e
Fixed SDL applications being killed immediately after being backgrounded, because they were trying to draw while minimized.
Sam Lantinga <slouken@libsdl.org>
parents:
6044
diff
changeset
|
151 |
} else if (event->window.event == SDL_WINDOWEVENT_MINIMIZED) { |
6260
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
152 |
renderer->hidden = SDL_TRUE; |
6060
59d398ac031e
Fixed SDL applications being killed immediately after being backgrounded, because they were trying to draw while minimized.
Sam Lantinga <slouken@libsdl.org>
parents:
6044
diff
changeset
|
153 |
} else if (event->window.event == SDL_WINDOWEVENT_RESTORED) { |
6260
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
154 |
if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_HIDDEN)) { |
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
155 |
renderer->hidden = SDL_FALSE; |
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
156 |
} |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
157 |
} |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 |
} |
6530
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
159 |
} else if (event->type == SDL_MOUSEMOTION) { |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
160 |
if (renderer->logical_w) { |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
161 |
event->motion.x -= renderer->viewport.x; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
162 |
event->motion.y -= renderer->viewport.y; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
163 |
event->motion.x = (int)(event->motion.x / renderer->scale.x); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
164 |
event->motion.y = (int)(event->motion.y / renderer->scale.y); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
165 |
} |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
166 |
} else if (event->type == SDL_MOUSEBUTTONDOWN || |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
167 |
event->type == SDL_MOUSEBUTTONUP) { |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
168 |
if (renderer->logical_w) { |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
169 |
event->button.x -= renderer->viewport.x; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
170 |
event->button.y -= renderer->viewport.y; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
171 |
event->button.x = (int)(event->button.x / renderer->scale.x); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
172 |
event->button.y = (int)(event->button.y / renderer->scale.y); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
173 |
} |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 |
return 0; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 |
|
6258
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
178 |
int |
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
179 |
SDL_CreateWindowAndRenderer(int width, int height, Uint32 window_flags, |
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
180 |
SDL_Window **window, SDL_Renderer **renderer) |
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
181 |
{ |
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
182 |
*window = SDL_CreateWindow(NULL, SDL_WINDOWPOS_UNDEFINED, |
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
183 |
SDL_WINDOWPOS_UNDEFINED, |
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
184 |
width, height, window_flags); |
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
185 |
if (!*window) { |
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
186 |
*renderer = NULL; |
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
187 |
return -1; |
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
188 |
} |
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
189 |
|
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
190 |
*renderer = SDL_CreateRenderer(*window, -1, 0); |
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
191 |
if (!*renderer) { |
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
192 |
return -1; |
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
193 |
} |
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
194 |
|
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
195 |
return 0; |
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
196 |
} |
fce7ce72677b
Added a convenience function SDL_CreateWindowAndRenderer()
Sam Lantinga <slouken@libsdl.org>
parents:
6247
diff
changeset
|
197 |
|
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 |
SDL_Renderer * |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 |
SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags) |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 |
{ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 |
SDL_Renderer *renderer = NULL; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 |
int n = SDL_GetNumRenderDrivers(); |
5192
ef5a61ea3202
Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents:
5180
diff
changeset
|
203 |
const char *hint; |
ef5a61ea3202
Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents:
5180
diff
changeset
|
204 |
|
5528 | 205 |
if (!window) { |
206 |
SDL_SetError("Invalid window"); |
|
207 |
return NULL; |
|
208 |
} |
|
209 |
||
210 |
if (SDL_GetRenderer(window)) { |
|
211 |
SDL_SetError("Renderer already associated with window"); |
|
212 |
return NULL; |
|
213 |
} |
|
214 |
||
5192
ef5a61ea3202
Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents:
5180
diff
changeset
|
215 |
hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC); |
ef5a61ea3202
Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents:
5180
diff
changeset
|
216 |
if (hint) { |
ef5a61ea3202
Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents:
5180
diff
changeset
|
217 |
if (*hint == '0') { |
ef5a61ea3202
Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents:
5180
diff
changeset
|
218 |
flags &= ~SDL_RENDERER_PRESENTVSYNC; |
ef5a61ea3202
Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents:
5180
diff
changeset
|
219 |
} else { |
ef5a61ea3202
Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents:
5180
diff
changeset
|
220 |
flags |= SDL_RENDERER_PRESENTVSYNC; |
ef5a61ea3202
Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents:
5180
diff
changeset
|
221 |
} |
ef5a61ea3202
Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents:
5180
diff
changeset
|
222 |
} |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 |
if (index < 0) { |
5192
ef5a61ea3202
Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents:
5180
diff
changeset
|
225 |
hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER); |
ef5a61ea3202
Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents:
5180
diff
changeset
|
226 |
if (hint) { |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 |
for (index = 0; index < n; ++index) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 |
const SDL_RenderDriver *driver = render_drivers[index]; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 |
|
5192
ef5a61ea3202
Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents:
5180
diff
changeset
|
230 |
if (SDL_strcasecmp(hint, driver->info.name) == 0) { |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 |
/* Create a new renderer instance */ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 |
renderer = driver->CreateRenderer(window, flags); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 |
break; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 |
} |
5192
ef5a61ea3202
Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents:
5180
diff
changeset
|
236 |
} |
ef5a61ea3202
Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents:
5180
diff
changeset
|
237 |
|
ef5a61ea3202
Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents:
5180
diff
changeset
|
238 |
if (!renderer) { |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 |
for (index = 0; index < n; ++index) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 |
const SDL_RenderDriver *driver = render_drivers[index]; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 |
if ((driver->info.flags & flags) == flags) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 |
/* Create a new renderer instance */ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 |
renderer = driver->CreateRenderer(window, flags); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 |
if (renderer) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 |
/* Yay, we got one! */ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 |
break; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 |
if (index == n) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 |
SDL_SetError("Couldn't find matching render driver"); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 |
return NULL; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 |
} else { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 |
if (index >= SDL_GetNumRenderDrivers()) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 |
SDL_SetError("index must be -1 or in the range of 0 - %d", |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 |
SDL_GetNumRenderDrivers() - 1); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 |
return NULL; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 |
/* Create a new renderer instance */ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 |
renderer = render_drivers[index]->CreateRenderer(window, flags); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 |
if (renderer) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 |
renderer->magic = &renderer_magic; |
5166
4d39eeaad00b
Added a way to get a framebuffer interface for a window, and also a way to create a software renderer for an arbitrary surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5158
diff
changeset
|
268 |
renderer->window = window; |
6528
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
269 |
renderer->scale.x = 1.0f; |
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
270 |
renderer->scale.y = 1.0f; |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 |
|
6260
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
272 |
if (SDL_GetWindowFlags(window) & (SDL_WINDOW_HIDDEN|SDL_WINDOW_MINIMIZED)) { |
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
273 |
renderer->hidden = SDL_TRUE; |
6060
59d398ac031e
Fixed SDL applications being killed immediately after being backgrounded, because they were trying to draw while minimized.
Sam Lantinga <slouken@libsdl.org>
parents:
6044
diff
changeset
|
274 |
} else { |
6260
fd494c5f305b
Fixed loading textures when the window starts hidden.
Sam Lantinga <slouken@libsdl.org>
parents:
6258
diff
changeset
|
275 |
renderer->hidden = SDL_FALSE; |
6060
59d398ac031e
Fixed SDL applications being killed immediately after being backgrounded, because they were trying to draw while minimized.
Sam Lantinga <slouken@libsdl.org>
parents:
6044
diff
changeset
|
276 |
} |
59d398ac031e
Fixed SDL applications being killed immediately after being backgrounded, because they were trying to draw while minimized.
Sam Lantinga <slouken@libsdl.org>
parents:
6044
diff
changeset
|
277 |
|
5528 | 278 |
SDL_SetWindowData(window, SDL_WINDOWRENDERDATA, renderer); |
279 |
||
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
280 |
SDL_RenderSetViewport(renderer, NULL); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
281 |
|
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 |
SDL_AddEventWatch(SDL_RendererEventWatch, renderer); |
5221
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
5209
diff
changeset
|
283 |
|
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
5209
diff
changeset
|
284 |
SDL_LogInfo(SDL_LOG_CATEGORY_RENDER, |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
5209
diff
changeset
|
285 |
"Created renderer: %s", renderer->info.name); |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 |
return renderer; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 |
|
5166
4d39eeaad00b
Added a way to get a framebuffer interface for a window, and also a way to create a software renderer for an arbitrary surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5158
diff
changeset
|
290 |
SDL_Renderer * |
4d39eeaad00b
Added a way to get a framebuffer interface for a window, and also a way to create a software renderer for an arbitrary surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5158
diff
changeset
|
291 |
SDL_CreateSoftwareRenderer(SDL_Surface * surface) |
4d39eeaad00b
Added a way to get a framebuffer interface for a window, and also a way to create a software renderer for an arbitrary surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5158
diff
changeset
|
292 |
{ |
5226
710d00cb3a6a
Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents:
5224
diff
changeset
|
293 |
#if !SDL_RENDER_DISABLED |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
294 |
SDL_Renderer *renderer; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
295 |
|
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
296 |
renderer = SW_CreateRendererForSurface(surface); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
297 |
|
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
298 |
if (renderer) { |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
299 |
renderer->magic = &renderer_magic; |
6532
58f726a2fc82
Initialized default scale for software renderer (thanks Marcus von Appen!)
Sam Lantinga <slouken@libsdl.org>
parents:
6531
diff
changeset
|
300 |
renderer->scale.x = 1.0f; |
58f726a2fc82
Initialized default scale for software renderer (thanks Marcus von Appen!)
Sam Lantinga <slouken@libsdl.org>
parents:
6531
diff
changeset
|
301 |
renderer->scale.y = 1.0f; |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
302 |
|
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
303 |
SDL_RenderSetViewport(renderer, NULL); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
304 |
} |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
305 |
return renderer; |
5226
710d00cb3a6a
Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents:
5224
diff
changeset
|
306 |
#else |
710d00cb3a6a
Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents:
5224
diff
changeset
|
307 |
SDL_SetError("SDL not built with rendering support"); |
710d00cb3a6a
Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents:
5224
diff
changeset
|
308 |
return NULL; |
710d00cb3a6a
Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents:
5224
diff
changeset
|
309 |
#endif /* !SDL_RENDER_DISABLED */ |
5166
4d39eeaad00b
Added a way to get a framebuffer interface for a window, and also a way to create a software renderer for an arbitrary surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5158
diff
changeset
|
310 |
} |
4d39eeaad00b
Added a way to get a framebuffer interface for a window, and also a way to create a software renderer for an arbitrary surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5158
diff
changeset
|
311 |
|
5528 | 312 |
SDL_Renderer * |
313 |
SDL_GetRenderer(SDL_Window * window) |
|
314 |
{ |
|
315 |
return (SDL_Renderer *)SDL_GetWindowData(window, SDL_WINDOWRENDERDATA); |
|
316 |
} |
|
317 |
||
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 |
int |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 |
SDL_GetRendererInfo(SDL_Renderer * renderer, SDL_RendererInfo * info) |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 |
{ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 |
CHECK_RENDERER_MAGIC(renderer, -1); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 |
*info = renderer->info; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 |
return 0; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 |
|
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
327 |
static SDL_bool |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
328 |
IsSupportedFormat(SDL_Renderer * renderer, Uint32 format) |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
329 |
{ |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
330 |
Uint32 i; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
331 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
332 |
for (i = 0; i < renderer->info.num_texture_formats; ++i) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
333 |
if (renderer->info.texture_formats[i] == format) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
334 |
return SDL_TRUE; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
335 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
336 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
337 |
return SDL_FALSE; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
338 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
339 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
340 |
static Uint32 |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
341 |
GetClosestSupportedFormat(SDL_Renderer * renderer, Uint32 format) |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
342 |
{ |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
343 |
Uint32 i; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
344 |
|
5268
c5a04f3c3908
Fixed a crash caused by the 1.2 code path getting a YV12 texture. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
345 |
if (SDL_ISPIXELFORMAT_FOURCC(format)) { |
c5a04f3c3908
Fixed a crash caused by the 1.2 code path getting a YV12 texture. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
346 |
/* Look for an exact match */ |
c5a04f3c3908
Fixed a crash caused by the 1.2 code path getting a YV12 texture. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
347 |
for (i = 0; i < renderer->info.num_texture_formats; ++i) { |
c5a04f3c3908
Fixed a crash caused by the 1.2 code path getting a YV12 texture. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
348 |
if (renderer->info.texture_formats[i] == format) { |
c5a04f3c3908
Fixed a crash caused by the 1.2 code path getting a YV12 texture. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
349 |
return renderer->info.texture_formats[i]; |
c5a04f3c3908
Fixed a crash caused by the 1.2 code path getting a YV12 texture. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
350 |
} |
c5a04f3c3908
Fixed a crash caused by the 1.2 code path getting a YV12 texture. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
351 |
} |
c5a04f3c3908
Fixed a crash caused by the 1.2 code path getting a YV12 texture. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
352 |
} else { |
c5a04f3c3908
Fixed a crash caused by the 1.2 code path getting a YV12 texture. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
353 |
SDL_bool hasAlpha = SDL_ISPIXELFORMAT_ALPHA(format); |
c5a04f3c3908
Fixed a crash caused by the 1.2 code path getting a YV12 texture. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
354 |
|
c5a04f3c3908
Fixed a crash caused by the 1.2 code path getting a YV12 texture. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
355 |
/* We just want to match the first format that has the same channels */ |
c5a04f3c3908
Fixed a crash caused by the 1.2 code path getting a YV12 texture. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
356 |
for (i = 0; i < renderer->info.num_texture_formats; ++i) { |
5300
3f825465a14a
Don't accidentally pick a YV12 format as the closest format.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
357 |
if (!SDL_ISPIXELFORMAT_FOURCC(renderer->info.texture_formats[i]) && |
3f825465a14a
Don't accidentally pick a YV12 format as the closest format.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
358 |
SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == hasAlpha) { |
5268
c5a04f3c3908
Fixed a crash caused by the 1.2 code path getting a YV12 texture. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
359 |
return renderer->info.texture_formats[i]; |
c5a04f3c3908
Fixed a crash caused by the 1.2 code path getting a YV12 texture. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
360 |
} |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
361 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
362 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
363 |
return renderer->info.texture_formats[0]; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
364 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
365 |
|
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 |
SDL_Texture * |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 |
SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int h) |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 |
{ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 |
SDL_Texture *texture; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 |
CHECK_RENDERER_MAGIC(renderer, NULL); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 |
|
5413
64c0e474c459
If you pass in texture format 0, it'll use the first supported texture format.
Sam Lantinga <slouken@libsdl.org>
parents:
5369
diff
changeset
|
373 |
if (!format) { |
64c0e474c459
If you pass in texture format 0, it'll use the first supported texture format.
Sam Lantinga <slouken@libsdl.org>
parents:
5369
diff
changeset
|
374 |
format = renderer->info.texture_formats[0]; |
64c0e474c459
If you pass in texture format 0, it'll use the first supported texture format.
Sam Lantinga <slouken@libsdl.org>
parents:
5369
diff
changeset
|
375 |
} |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
376 |
if (SDL_ISPIXELFORMAT_INDEXED(format)) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
377 |
SDL_SetError("Palettized textures are not supported"); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
378 |
return NULL; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
379 |
} |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 |
if (w <= 0 || h <= 0) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 |
SDL_SetError("Texture dimensions can't be 0"); |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
382 |
return NULL; |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 |
texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture)); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 |
if (!texture) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
386 |
SDL_OutOfMemory(); |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
387 |
return NULL; |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
388 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 |
texture->magic = &texture_magic; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 |
texture->format = format; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 |
texture->access = access; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 |
texture->w = w; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
393 |
texture->h = h; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 |
texture->r = 255; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 |
texture->g = 255; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 |
texture->b = 255; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 |
texture->a = 255; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 |
texture->renderer = renderer; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 |
texture->next = renderer->textures; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 |
if (renderer->textures) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
401 |
renderer->textures->prev = texture; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 |
renderer->textures = texture; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 |
|
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
405 |
if (IsSupportedFormat(renderer, format)) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
406 |
if (renderer->CreateTexture(renderer, texture) < 0) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
407 |
SDL_DestroyTexture(texture); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
408 |
return 0; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
409 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
410 |
} else { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
411 |
texture->native = SDL_CreateTexture(renderer, |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
412 |
GetClosestSupportedFormat(renderer, format), |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
413 |
access, w, h); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
414 |
if (!texture->native) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
415 |
SDL_DestroyTexture(texture); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
416 |
return NULL; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
417 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
418 |
|
6497
e844e2632149
Fixed bug 1579 - Creating a texture with unsupported format may cause double-destruction
Sam Lantinga <slouken@libsdl.org>
parents:
6417
diff
changeset
|
419 |
/* Swap textures to have texture before texture->native in the list */ |
e844e2632149
Fixed bug 1579 - Creating a texture with unsupported format may cause double-destruction
Sam Lantinga <slouken@libsdl.org>
parents:
6417
diff
changeset
|
420 |
texture->native->next = texture->next; |
e844e2632149
Fixed bug 1579 - Creating a texture with unsupported format may cause double-destruction
Sam Lantinga <slouken@libsdl.org>
parents:
6417
diff
changeset
|
421 |
texture->prev = texture->native->prev; |
e844e2632149
Fixed bug 1579 - Creating a texture with unsupported format may cause double-destruction
Sam Lantinga <slouken@libsdl.org>
parents:
6417
diff
changeset
|
422 |
texture->native->prev = texture; |
e844e2632149
Fixed bug 1579 - Creating a texture with unsupported format may cause double-destruction
Sam Lantinga <slouken@libsdl.org>
parents:
6417
diff
changeset
|
423 |
texture->next = texture->native; |
e844e2632149
Fixed bug 1579 - Creating a texture with unsupported format may cause double-destruction
Sam Lantinga <slouken@libsdl.org>
parents:
6417
diff
changeset
|
424 |
renderer->textures = texture; |
e844e2632149
Fixed bug 1579 - Creating a texture with unsupported format may cause double-destruction
Sam Lantinga <slouken@libsdl.org>
parents:
6417
diff
changeset
|
425 |
|
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
426 |
if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
427 |
texture->yuv = SDL_SW_CreateYUVTexture(format, w, h); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
428 |
if (!texture->yuv) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
429 |
SDL_DestroyTexture(texture); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
430 |
return NULL; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
431 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
432 |
} else if (access == SDL_TEXTUREACCESS_STREAMING) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
433 |
/* The pitch is 4 byte aligned */ |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
434 |
texture->pitch = (((w * SDL_BYTESPERPIXEL(format)) + 3) & ~3); |
5342
d4b691de3b8f
Zero streaming textures to reduce confusion.
Sam Lantinga <slouken@libsdl.org>
parents:
5333
diff
changeset
|
435 |
texture->pixels = SDL_calloc(1, texture->pitch * h); |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
436 |
if (!texture->pixels) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
437 |
SDL_DestroyTexture(texture); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
438 |
return NULL; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
439 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
440 |
} |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
441 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
442 |
return texture; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
443 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
444 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
445 |
SDL_Texture * |
5158
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
446 |
SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface) |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
447 |
{ |
5158
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
448 |
const SDL_PixelFormat *fmt; |
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
449 |
SDL_bool needAlpha; |
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
450 |
Uint32 i; |
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
451 |
Uint32 format; |
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
452 |
SDL_Texture *texture; |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
454 |
CHECK_RENDERER_MAGIC(renderer, NULL); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
455 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
456 |
if (!surface) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 |
SDL_SetError("SDL_CreateTextureFromSurface() passed NULL surface"); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
458 |
return NULL; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
459 |
} |
5158
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
460 |
|
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
461 |
/* See what the best texture format is */ |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 |
fmt = surface->format; |
5158
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
463 |
if (fmt->Amask || SDL_GetColorKey(surface, NULL) == 0) { |
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
464 |
needAlpha = SDL_TRUE; |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
465 |
} else { |
5158
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
466 |
needAlpha = SDL_FALSE; |
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
467 |
} |
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
468 |
format = renderer->info.texture_formats[0]; |
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
469 |
for (i = 0; i < renderer->info.num_texture_formats; ++i) { |
5268
c5a04f3c3908
Fixed a crash caused by the 1.2 code path getting a YV12 texture. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
470 |
if (!SDL_ISPIXELFORMAT_FOURCC(renderer->info.texture_formats[i]) && |
c5a04f3c3908
Fixed a crash caused by the 1.2 code path getting a YV12 texture. :)
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
471 |
SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == needAlpha) { |
5158
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
472 |
format = renderer->info.texture_formats[i]; |
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
473 |
break; |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
474 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
475 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
476 |
|
5158
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
477 |
texture = SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_STATIC, |
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
478 |
surface->w, surface->h); |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
479 |
if (!texture) { |
5158
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
480 |
return NULL; |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 |
} |
5158
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
482 |
|
5288 | 483 |
if (format == surface->format->format) { |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 |
if (SDL_MUSTLOCK(surface)) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
485 |
SDL_LockSurface(surface); |
5158
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
486 |
SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch); |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
487 |
SDL_UnlockSurface(surface); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
488 |
} else { |
5158
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
489 |
SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch); |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
491 |
} else { |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
492 |
SDL_PixelFormat *dst_fmt; |
5158
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
493 |
SDL_Surface *temp = NULL; |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
494 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
495 |
/* Set up a destination surface for the texture update */ |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
496 |
dst_fmt = SDL_AllocFormat(format); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
497 |
temp = SDL_ConvertSurface(surface, dst_fmt, 0); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5289
diff
changeset
|
498 |
SDL_FreeFormat(dst_fmt); |
5158
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
499 |
if (temp) { |
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
500 |
SDL_UpdateTexture(texture, NULL, temp->pixels, temp->pitch); |
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
501 |
SDL_FreeSurface(temp); |
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
502 |
} else { |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
503 |
SDL_DestroyTexture(texture); |
5158
b3ccd1947786
Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
504 |
return NULL; |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
505 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
506 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
507 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 |
{ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
509 |
Uint8 r, g, b, a; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
510 |
SDL_BlendMode blendMode; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
511 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
512 |
SDL_GetSurfaceColorMod(surface, &r, &g, &b); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
513 |
SDL_SetTextureColorMod(texture, r, g, b); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
514 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
515 |
SDL_GetSurfaceAlphaMod(surface, &a); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
516 |
SDL_SetTextureAlphaMod(texture, a); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
517 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
518 |
if (SDL_GetColorKey(surface, NULL) == 0) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
519 |
/* We converted to a texture with alpha format */ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
520 |
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
521 |
} else { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
522 |
SDL_GetSurfaceBlendMode(surface, &blendMode); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
523 |
SDL_SetTextureBlendMode(texture, blendMode); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
524 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
525 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
526 |
return texture; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
527 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
528 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
529 |
int |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
530 |
SDL_QueryTexture(SDL_Texture * texture, Uint32 * format, int *access, |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
531 |
int *w, int *h) |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
532 |
{ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
533 |
CHECK_TEXTURE_MAGIC(texture, -1); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
534 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
535 |
if (format) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
536 |
*format = texture->format; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
537 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
538 |
if (access) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
539 |
*access = texture->access; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
540 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
541 |
if (w) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
542 |
*w = texture->w; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
543 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
544 |
if (h) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
545 |
*h = texture->h; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
546 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
547 |
return 0; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
548 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
549 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
550 |
int |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
551 |
SDL_SetTextureColorMod(SDL_Texture * texture, Uint8 r, Uint8 g, Uint8 b) |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
552 |
{ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
553 |
SDL_Renderer *renderer; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
554 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
555 |
CHECK_TEXTURE_MAGIC(texture, -1); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
556 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
557 |
renderer = texture->renderer; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
558 |
if (r < 255 || g < 255 || b < 255) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
559 |
texture->modMode |= SDL_TEXTUREMODULATE_COLOR; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
560 |
} else { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
561 |
texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
562 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
563 |
texture->r = r; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
564 |
texture->g = g; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
565 |
texture->b = b; |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
566 |
if (texture->native) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
567 |
return SDL_SetTextureColorMod(texture->native, r, g, b); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
568 |
} else if (renderer->SetTextureColorMod) { |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
569 |
return renderer->SetTextureColorMod(renderer, texture); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
570 |
} else { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
571 |
return 0; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
572 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
573 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
574 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
575 |
int |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
576 |
SDL_GetTextureColorMod(SDL_Texture * texture, Uint8 * r, Uint8 * g, |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
577 |
Uint8 * b) |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
578 |
{ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
579 |
CHECK_TEXTURE_MAGIC(texture, -1); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
580 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
581 |
if (r) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
582 |
*r = texture->r; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
583 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
584 |
if (g) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
585 |
*g = texture->g; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
586 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
587 |
if (b) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
588 |
*b = texture->b; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
589 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
590 |
return 0; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
591 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
592 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
593 |
int |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
594 |
SDL_SetTextureAlphaMod(SDL_Texture * texture, Uint8 alpha) |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
595 |
{ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
596 |
SDL_Renderer *renderer; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
597 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
598 |
CHECK_TEXTURE_MAGIC(texture, -1); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
599 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
600 |
renderer = texture->renderer; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
601 |
if (alpha < 255) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
602 |
texture->modMode |= SDL_TEXTUREMODULATE_ALPHA; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
603 |
} else { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
604 |
texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
605 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
606 |
texture->a = alpha; |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
607 |
if (texture->native) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
608 |
return SDL_SetTextureAlphaMod(texture->native, alpha); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
609 |
} else if (renderer->SetTextureAlphaMod) { |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
610 |
return renderer->SetTextureAlphaMod(renderer, texture); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
611 |
} else { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
612 |
return 0; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
613 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
614 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
615 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
616 |
int |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
617 |
SDL_GetTextureAlphaMod(SDL_Texture * texture, Uint8 * alpha) |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
618 |
{ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
619 |
CHECK_TEXTURE_MAGIC(texture, -1); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
620 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
621 |
if (alpha) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
622 |
*alpha = texture->a; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
623 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
624 |
return 0; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
625 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
626 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
627 |
int |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
628 |
SDL_SetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode blendMode) |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
629 |
{ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
630 |
SDL_Renderer *renderer; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
631 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
632 |
CHECK_TEXTURE_MAGIC(texture, -1); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
633 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
634 |
renderer = texture->renderer; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
635 |
texture->blendMode = blendMode; |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
636 |
if (texture->native) { |
5180
4d098d286794
SDL_SetTextureBlendMode broken, caught by Kai Sterker - Thanks!
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
637 |
return SDL_SetTextureBlendMode(texture->native, blendMode); |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
638 |
} else if (renderer->SetTextureBlendMode) { |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
639 |
return renderer->SetTextureBlendMode(renderer, texture); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
640 |
} else { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
641 |
return 0; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
642 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
643 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
644 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
645 |
int |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
646 |
SDL_GetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode *blendMode) |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
647 |
{ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
648 |
CHECK_TEXTURE_MAGIC(texture, -1); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
649 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
650 |
if (blendMode) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
651 |
*blendMode = texture->blendMode; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
652 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
653 |
return 0; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
654 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
655 |
|
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
656 |
static int |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
657 |
SDL_UpdateTextureYUV(SDL_Texture * texture, const SDL_Rect * rect, |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
658 |
const void *pixels, int pitch) |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
659 |
{ |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
660 |
SDL_Texture *native = texture->native; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
661 |
SDL_Rect full_rect; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
662 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
663 |
if (SDL_SW_UpdateYUVTexture(texture->yuv, rect, pixels, pitch) < 0) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
664 |
return -1; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
665 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
666 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
667 |
full_rect.x = 0; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
668 |
full_rect.y = 0; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
669 |
full_rect.w = texture->w; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
670 |
full_rect.h = texture->h; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
671 |
rect = &full_rect; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
672 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
673 |
if (texture->access == SDL_TEXTUREACCESS_STREAMING) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
674 |
/* We can lock the texture and copy to it */ |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
675 |
void *native_pixels; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
676 |
int native_pitch; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
677 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
678 |
if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
679 |
return -1; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
680 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
681 |
SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
682 |
rect->w, rect->h, native_pixels, native_pitch); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
683 |
SDL_UnlockTexture(native); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
684 |
} else { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
685 |
/* Use a temporary buffer for updating */ |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
686 |
void *temp_pixels; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
687 |
int temp_pitch; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
688 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
689 |
temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
690 |
temp_pixels = SDL_malloc(rect->h * temp_pitch); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
691 |
if (!temp_pixels) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
692 |
SDL_OutOfMemory(); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
693 |
return -1; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
694 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
695 |
SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
696 |
rect->w, rect->h, temp_pixels, temp_pitch); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
697 |
SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
698 |
SDL_free(temp_pixels); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
699 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
700 |
return 0; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
701 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
702 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
703 |
static int |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
704 |
SDL_UpdateTextureNative(SDL_Texture * texture, const SDL_Rect * rect, |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
705 |
const void *pixels, int pitch) |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
706 |
{ |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
707 |
SDL_Texture *native = texture->native; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
708 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
709 |
if (texture->access == SDL_TEXTUREACCESS_STREAMING) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
710 |
/* We can lock the texture and copy to it */ |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
711 |
void *native_pixels; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
712 |
int native_pitch; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
713 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
714 |
if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
715 |
return -1; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
716 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
717 |
SDL_ConvertPixels(rect->w, rect->h, |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
718 |
texture->format, pixels, pitch, |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
719 |
native->format, native_pixels, native_pitch); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
720 |
SDL_UnlockTexture(native); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
721 |
} else { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
722 |
/* Use a temporary buffer for updating */ |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
723 |
void *temp_pixels; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
724 |
int temp_pitch; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
725 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
726 |
temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
727 |
temp_pixels = SDL_malloc(rect->h * temp_pitch); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
728 |
if (!temp_pixels) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
729 |
SDL_OutOfMemory(); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
730 |
return -1; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
731 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
732 |
SDL_ConvertPixels(rect->w, rect->h, |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
733 |
texture->format, pixels, pitch, |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
734 |
native->format, temp_pixels, temp_pitch); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
735 |
SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
736 |
SDL_free(temp_pixels); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
737 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
738 |
return 0; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
739 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
740 |
|
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
741 |
int |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
742 |
SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect, |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
743 |
const void *pixels, int pitch) |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
744 |
{ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
745 |
SDL_Renderer *renderer; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
746 |
SDL_Rect full_rect; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
747 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
748 |
CHECK_TEXTURE_MAGIC(texture, -1); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
749 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
750 |
if (!rect) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
751 |
full_rect.x = 0; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
752 |
full_rect.y = 0; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
753 |
full_rect.w = texture->w; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
754 |
full_rect.h = texture->h; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
755 |
rect = &full_rect; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
756 |
} |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
757 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
758 |
if (texture->yuv) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
759 |
return SDL_UpdateTextureYUV(texture, rect, pixels, pitch); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
760 |
} else if (texture->native) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
761 |
return SDL_UpdateTextureNative(texture, rect, pixels, pitch); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
762 |
} else { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
763 |
renderer = texture->renderer; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
764 |
return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
765 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
766 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
767 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
768 |
static int |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
769 |
SDL_LockTextureYUV(SDL_Texture * texture, const SDL_Rect * rect, |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
770 |
void **pixels, int *pitch) |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
771 |
{ |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
772 |
return SDL_SW_LockYUVTexture(texture->yuv, rect, pixels, pitch); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
773 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
774 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
775 |
static int |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
776 |
SDL_LockTextureNative(SDL_Texture * texture, const SDL_Rect * rect, |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
777 |
void **pixels, int *pitch) |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
778 |
{ |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
779 |
texture->locked_rect = *rect; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
780 |
*pixels = (void *) ((Uint8 *) texture->pixels + |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
781 |
rect->y * texture->pitch + |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
782 |
rect->x * SDL_BYTESPERPIXEL(texture->format)); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
783 |
*pitch = texture->pitch; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
784 |
return 0; |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
785 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
786 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
787 |
int |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
788 |
SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect, |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
789 |
void **pixels, int *pitch) |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
790 |
{ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
791 |
SDL_Renderer *renderer; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
792 |
SDL_Rect full_rect; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
793 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
794 |
CHECK_TEXTURE_MAGIC(texture, -1); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
795 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
796 |
if (texture->access != SDL_TEXTUREACCESS_STREAMING) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
797 |
SDL_SetError("SDL_LockTexture(): texture must be streaming"); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
798 |
return -1; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
799 |
} |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
800 |
|
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
801 |
if (!rect) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
802 |
full_rect.x = 0; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
803 |
full_rect.y = 0; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
804 |
full_rect.w = texture->w; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
805 |
full_rect.h = texture->h; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
806 |
rect = &full_rect; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
807 |
} |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
808 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
809 |
if (texture->yuv) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
810 |
return SDL_LockTextureYUV(texture, rect, pixels, pitch); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
811 |
} else if (texture->native) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
812 |
return SDL_LockTextureNative(texture, rect, pixels, pitch); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
813 |
} else { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
814 |
renderer = texture->renderer; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
815 |
return renderer->LockTexture(renderer, texture, rect, pixels, pitch); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
816 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
817 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
818 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
819 |
static void |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
820 |
SDL_UnlockTextureYUV(SDL_Texture * texture) |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
821 |
{ |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
822 |
SDL_Texture *native = texture->native; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
823 |
void *native_pixels; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
824 |
int native_pitch; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
825 |
SDL_Rect rect; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
826 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
827 |
rect.x = 0; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
828 |
rect.y = 0; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
829 |
rect.w = texture->w; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
830 |
rect.h = texture->h; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
831 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
832 |
if (SDL_LockTexture(native, &rect, &native_pixels, &native_pitch) < 0) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
833 |
return; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
834 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
835 |
SDL_SW_CopyYUVToRGB(texture->yuv, &rect, native->format, |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
836 |
rect.w, rect.h, native_pixels, native_pitch); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
837 |
SDL_UnlockTexture(native); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
838 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
839 |
|
6044
35448a5ea044
Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents:
5535
diff
changeset
|
840 |
static void |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
841 |
SDL_UnlockTextureNative(SDL_Texture * texture) |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
842 |
{ |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
843 |
SDL_Texture *native = texture->native; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
844 |
void *native_pixels; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
845 |
int native_pitch; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
846 |
const SDL_Rect *rect = &texture->locked_rect; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
847 |
const void* pixels = (void *) ((Uint8 *) texture->pixels + |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
848 |
rect->y * texture->pitch + |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
849 |
rect->x * SDL_BYTESPERPIXEL(texture->format)); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
850 |
int pitch = texture->pitch; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
851 |
|
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
852 |
if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
853 |
return; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
854 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
855 |
SDL_ConvertPixels(rect->w, rect->h, |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
856 |
texture->format, pixels, pitch, |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
857 |
native->format, native_pixels, native_pitch); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
858 |
SDL_UnlockTexture(native); |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
859 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
860 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
861 |
void |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
862 |
SDL_UnlockTexture(SDL_Texture * texture) |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
863 |
{ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
864 |
SDL_Renderer *renderer; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
865 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
866 |
CHECK_TEXTURE_MAGIC(texture, ); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
867 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
868 |
if (texture->access != SDL_TEXTUREACCESS_STREAMING) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
869 |
return; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
870 |
} |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
871 |
if (texture->yuv) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
872 |
SDL_UnlockTextureYUV(texture); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
873 |
} else if (texture->native) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
874 |
SDL_UnlockTextureNative(texture); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
875 |
} else { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
876 |
renderer = texture->renderer; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
877 |
renderer->UnlockTexture(renderer, texture); |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
878 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
879 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
880 |
|
6246
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
881 |
SDL_bool |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
882 |
SDL_RenderTargetSupported(SDL_Renderer *renderer) |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
883 |
{ |
6247
b6212690f78d
Renamed SetTargetTexture() to SetRenderTarget()
Sam Lantinga <slouken@libsdl.org>
parents:
6246
diff
changeset
|
884 |
if (!renderer || !renderer->SetRenderTarget) { |
6246
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
885 |
return SDL_FALSE; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
886 |
} |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
887 |
return (renderer->info.flags & SDL_RENDERER_TARGETTEXTURE) != 0; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
888 |
} |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
889 |
|
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
890 |
int |
6247
b6212690f78d
Renamed SetTargetTexture() to SetRenderTarget()
Sam Lantinga <slouken@libsdl.org>
parents:
6246
diff
changeset
|
891 |
SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) |
6246
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
892 |
{ |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
893 |
if (!SDL_RenderTargetSupported(renderer)) { |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
894 |
SDL_Unsupported(); |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
895 |
return -1; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
896 |
} |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
897 |
if (texture == renderer->target) { |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
898 |
/* Nothing to do! */ |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
899 |
return 0; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
900 |
} |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
901 |
|
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
902 |
/* texture == NULL is valid and means reset the target to the window */ |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
903 |
if (texture) { |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
904 |
CHECK_TEXTURE_MAGIC(texture, -1); |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
905 |
if (renderer != texture->renderer) { |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
906 |
SDL_SetError("Texture was not created with this renderer"); |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
907 |
return -1; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
908 |
} |
6337
3c91a153f398
Fixes #1523 by removing inconsistent use of texture->access
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6320
diff
changeset
|
909 |
if (texture->access != SDL_TEXTUREACCESS_TARGET) { |
6246
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
910 |
SDL_SetError("Texture not created with SDL_TEXTUREACCESS_TARGET"); |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
911 |
return -1; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
912 |
} |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
913 |
if (texture->native) { |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
914 |
/* Always render to the native texture */ |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
915 |
texture = texture->native; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
916 |
} |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
917 |
} |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
918 |
|
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
919 |
if (texture && !renderer->target) { |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
920 |
/* Make a backup of the viewport */ |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
921 |
renderer->viewport_backup = renderer->viewport; |
6528
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
922 |
renderer->scale_backup = renderer->scale; |
6246
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
923 |
} |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
924 |
renderer->target = texture; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
925 |
|
6247
b6212690f78d
Renamed SetTargetTexture() to SetRenderTarget()
Sam Lantinga <slouken@libsdl.org>
parents:
6246
diff
changeset
|
926 |
if (renderer->SetRenderTarget(renderer, texture) < 0) { |
6246
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
927 |
return -1; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
928 |
} |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
929 |
|
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
930 |
if (texture) { |
6528
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
931 |
renderer->viewport.x = 0; |
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
932 |
renderer->viewport.y = 0; |
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
933 |
renderer->viewport.w = texture->w; |
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
934 |
renderer->viewport.h = texture->h; |
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
935 |
renderer->scale.x = 1.0f; |
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
936 |
renderer->scale.y = 1.0f; |
6246
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
937 |
} else { |
6528
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
938 |
renderer->viewport = renderer->viewport_backup; |
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
939 |
renderer->scale = renderer->scale_backup; |
6246
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
940 |
} |
6528
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6497
diff
changeset
|
941 |
if (renderer->UpdateViewport(renderer) < 0) { |
6246
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
942 |
return -1; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
943 |
} |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
944 |
|
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
945 |
/* All set! */ |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
946 |
return 0; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
947 |
} |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6237
diff
changeset
|
948 |
|
6530
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
949 |
static int |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
950 |
UpdateLogicalSize(SDL_Renderer *renderer) |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
951 |
{ |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
952 |
int w, h; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
953 |
float want_aspect; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
954 |
float real_aspect; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
955 |
float scale; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
956 |
SDL_Rect viewport; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
957 |
|
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
958 |
if (renderer->window) { |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
959 |
SDL_GetWindowSize(renderer->window, &w, &h); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
960 |
} else { |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
961 |
/* FIXME */ |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
962 |
SDL_SetError("Internal error: No way to get output resolution"); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
963 |
return -1; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
964 |
} |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
965 |
|
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
966 |
want_aspect = (float)renderer->logical_w / renderer->logical_h; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
967 |
real_aspect = (float)w / h; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
968 |
|
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
969 |
/* Clear the scale because we're setting viewport in output coordinates */ |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
970 |
SDL_RenderSetScale(renderer, 1.0f, 1.0f); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
971 |
|
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
972 |
if (SDL_fabs(want_aspect-real_aspect) < 0.0001) { |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
973 |
/* The aspect ratios are the same, just scale appropriately */ |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
974 |
scale = (float)w / renderer->logical_w; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
975 |
SDL_RenderSetViewport(renderer, NULL); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
976 |
} else if (want_aspect > real_aspect) { |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
977 |
/* We want a wider aspect ratio than is available - letterbox it */ |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
978 |
scale = (float)w / renderer->logical_w; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
979 |
viewport.x = 0; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
980 |
viewport.w = w; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
981 |
viewport.h = (int)SDL_ceil(renderer->logical_h * scale); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
982 |
viewport.y = (h - viewport.h) / 2; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
983 |
SDL_RenderSetViewport(renderer, &viewport); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
984 |
} else { |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
985 |
/* We want a narrower aspect ratio than is available - use side-bars */ |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
986 |
scale = (float)h / renderer->logical_h; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
987 |
viewport.y = 0; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
988 |
viewport.h = h; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
989 |
viewport.w = (int)SDL_ceil(renderer->logical_w * scale); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
990 |
viewport.x = (w - viewport.w) / 2; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
991 |
SDL_RenderSetViewport(renderer, &viewport); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
992 |
} |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
993 |
|
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
994 |
/* Set the new scale */ |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
995 |
SDL_RenderSetScale(renderer, scale, scale); |
6531
1ab2e34b90cc
Fixed a compiler warning
Sam Lantinga <slouken@libsdl.org>
parents:
6530
diff
changeset
|
996 |
|
1ab2e34b90cc
Fixed a compiler warning
Sam Lantinga <slouken@libsdl.org>
parents:
6530
diff
changeset
|
997 |
return 0; |
6530
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
998 |
} |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
999 |
|
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1000 |
int |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1001 |
SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h) |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1002 |
{ |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1003 |
CHECK_RENDERER_MAGIC(renderer, -1); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1004 |
|
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1005 |
if (!w || !h) { |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1006 |
/* Clear any previous logical resolution */ |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1007 |
renderer->logical_w = 0; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1008 |
renderer->logical_h = 0; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1009 |
SDL_RenderSetViewport(renderer, NULL); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1010 |
SDL_RenderSetScale(renderer, 1.0f, 1.0f); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1011 |
return 0; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1012 |
} |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1013 |
|
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1014 |
renderer->logical_w = w; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1015 |
renderer->logical_h = h; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1016 |
|
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1017 |
return UpdateLogicalSize(renderer); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1018 |
} |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1019 |
|
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1020 |
void |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1021 |
SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h) |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1022 |
{ |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1023 |
CHECK_RENDERER_MAGIC(renderer, ); |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1024 |
|
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1025 |
if (w) { |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1026 |
*w = renderer->logical_w; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1027 |
} |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1028 |
if (h) { |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1029 |
*h = renderer->logical_h; |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize()
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
1030 |
} |
ba5de88eab60
Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogica |