annotate src/render/SDL_render.c @ 5205:1f2b17f42fd0

Removed extra unneeded pixel formats, added support for VSYNC on other platforms besides Zune HD.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 06 Feb 2011 00:48:16 -0800
parents 523409574510
children 115fff0641ee
rev   line source
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 /*
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Copyright (C) 1997-2010 Sam Lantinga
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 version 2.1 of the License, or (at your option) any later version.
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 slouken@libsdl.org
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 */
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 #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
23
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 /* 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
25
5195
ef5a61ea3202 Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents: 5183
diff changeset
26 #include "SDL_hints.h"
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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"
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 #include "../video/SDL_pixels_c.h"
5198
bb45ecd958d8 Renamed files for consistency
Sam Lantinga <slouken@libsdl.org>
parents: 5195
diff changeset
30 #include "software/SDL_render_sw_c.h"
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 #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
34 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
35 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
36 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
37 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 #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
40 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
41 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
42 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
43 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 static const SDL_RenderDriver *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
47 #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
48 &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
49 #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
50 #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
51 &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
52 #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
53 #if SDL_VIDEO_RENDER_OGL_ES
5204
523409574510 Added an OpenGL ES 2.0 renderer, contributed by itsnotabigtruck
Sam Lantinga <slouken@libsdl.org>
parents: 5202
diff changeset
54 &GLES_RenderDriver,
523409574510 Added an OpenGL ES 2.0 renderer, contributed by itsnotabigtruck
Sam Lantinga <slouken@libsdl.org>
parents: 5202
diff changeset
55 #endif
523409574510 Added an OpenGL ES 2.0 renderer, contributed by itsnotabigtruck
Sam Lantinga <slouken@libsdl.org>
parents: 5202
diff changeset
56 #if SDL_VIDEO_RENDER_OGL_ES2
523409574510 Added an OpenGL ES 2.0 renderer, contributed by itsnotabigtruck
Sam Lantinga <slouken@libsdl.org>
parents: 5202
diff changeset
57 &GLES2_RenderDriver,
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 #endif
5202
164f20ba08eb Updated the DirectFB support, from Couriersud
Sam Lantinga <slouken@libsdl.org>
parents: 5198
diff changeset
59 #if SDL_VIDEO_RENDER_DIRECTFB
164f20ba08eb Updated the DirectFB support, from Couriersud
Sam Lantinga <slouken@libsdl.org>
parents: 5198
diff changeset
60 &DirectFB_RenderDriver,
164f20ba08eb Updated the DirectFB support, from Couriersud
Sam Lantinga <slouken@libsdl.org>
parents: 5198
diff changeset
61 #endif
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 &SW_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
63 };
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 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
65 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
66
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
68 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
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 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
71 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 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
74 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
75 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
77 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
78 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
79 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
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 *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
82 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
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
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
86 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
87 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
89
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 if (event->type == SDL_WINDOWEVENT && renderer->WindowEvent) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
92 if (window == renderer->window) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 renderer->WindowEvent(renderer, &event->window);
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
97 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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_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
100 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
101 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 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
103 int n = SDL_GetNumRenderDrivers();
5195
ef5a61ea3202 Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents: 5183
diff changeset
104 const char *hint;
ef5a61ea3202 Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents: 5183
diff changeset
105
ef5a61ea3202 Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents: 5183
diff changeset
106 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: 5183
diff changeset
107 if (hint) {
ef5a61ea3202 Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents: 5183
diff changeset
108 if (*hint == '0') {
ef5a61ea3202 Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents: 5183
diff changeset
109 flags &= ~SDL_RENDERER_PRESENTVSYNC;
ef5a61ea3202 Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents: 5183
diff changeset
110 } else {
ef5a61ea3202 Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents: 5183
diff changeset
111 flags |= SDL_RENDERER_PRESENTVSYNC;
ef5a61ea3202 Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents: 5183
diff changeset
112 }
ef5a61ea3202 Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents: 5183
diff changeset
113 }
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 if (index < 0) {
5195
ef5a61ea3202 Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents: 5183
diff changeset
116 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: 5183
diff changeset
117 if (hint) {
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 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
119 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
120
5195
ef5a61ea3202 Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents: 5183
diff changeset
121 if (SDL_strcasecmp(hint, driver->info.name) == 0) {
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 /* 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
123 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
124 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
125 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 }
5195
ef5a61ea3202 Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents: 5183
diff changeset
127 }
ef5a61ea3202 Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents: 5183
diff changeset
128
ef5a61ea3202 Added the SDL_HINT_RENDER_DRIVER and SDL_HINT_RENDER_VSYNC hints.
Sam Lantinga <slouken@libsdl.org>
parents: 5183
diff changeset
129 if (!renderer) {
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 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
131 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
132
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 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
134 /* 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
135 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
136 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
137 /* 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
138 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
139 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 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
144 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
145 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
146 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 } 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
148 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
149 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
150 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
151 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
152 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 /* 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
154 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
155 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 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
158 renderer->magic = &renderer_magic;
5169
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: 5161
diff changeset
159 renderer->window = window;
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 SDL_AddEventWatch(SDL_RendererEventWatch, 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
162 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 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
164 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165
5169
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: 5161
diff changeset
166 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: 5161
diff changeset
167 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: 5161
diff changeset
168 {
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: 5161
diff changeset
169 return SW_CreateRendererForSurface(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: 5161
diff changeset
170 }
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: 5161
diff changeset
171
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 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
173 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
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 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
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 *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
178 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
179 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180
5159
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
181 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: 5157
diff changeset
182 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: 5157
diff changeset
183 {
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
184 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: 5157
diff changeset
185
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
186 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: 5157
diff changeset
187 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: 5157
diff changeset
188 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: 5157
diff changeset
189 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
190 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
191 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: 5157
diff changeset
192 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
193
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
194 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: 5157
diff changeset
195 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: 5157
diff changeset
196 {
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
197 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: 5157
diff changeset
198 SDL_bool hasAlpha = SDL_ISPIXELFORMAT_ALPHA(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: 5157
diff changeset
199
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
200 /* We just want to match the first format that has the same channels */
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
201 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: 5157
diff changeset
202 if (SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == hasAlpha) {
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
203 return renderer->info.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: 5157
diff changeset
204 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
205 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
206 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: 5157
diff changeset
207 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
208
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 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
210 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
211 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 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
213
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 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
215
5159
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
216 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: 5157
diff changeset
217 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: 5157
diff changeset
218 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: 5157
diff changeset
219 }
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 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
221 SDL_SetError("Texture dimensions can't be 0");
5159
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
222 return NULL;
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
225 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
226 SDL_OutOfMemory();
5159
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
227 return NULL;
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
230 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
231 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
232 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
233 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
234 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
235 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
236 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
237 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
238 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
239 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
240 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
241 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
242 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
244
5159
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
245 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: 5157
diff changeset
246 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: 5157
diff changeset
247 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: 5157
diff changeset
248 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: 5157
diff changeset
249 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
250 } 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: 5157
diff changeset
251 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: 5157
diff changeset
252 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: 5157
diff changeset
253 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: 5157
diff changeset
254 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: 5157
diff changeset
255 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: 5157
diff changeset
256 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: 5157
diff changeset
257 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
258
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
259 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: 5157
diff changeset
260 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: 5157
diff changeset
261 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: 5157
diff changeset
262 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: 5157
diff changeset
263 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: 5157
diff changeset
264 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
265 } 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: 5157
diff changeset
266 /* 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: 5157
diff changeset
267 texture->pitch = (((w * SDL_BYTESPERPIXEL(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: 5157
diff changeset
268 texture->pixels = SDL_malloc(texture->pitch * 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: 5157
diff changeset
269 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: 5157
diff changeset
270 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: 5157
diff changeset
271 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: 5157
diff changeset
272 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
273 }
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 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
276 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 SDL_Texture *
5161
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
279 SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface)
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 {
5161
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
281 const SDL_PixelFormat *fmt;
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
282 SDL_bool needAlpha;
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
283 Uint32 i;
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
284 Uint32 format;
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 int bpp;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 Uint32 Rmask, Gmask, Bmask, Amask;
5161
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
287 SDL_Texture *texture;
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
290
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 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
292 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
293 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
294 }
5161
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
295
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
296 /* See what the best texture format is */
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 fmt = surface->format;
5161
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
298 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: 5160
diff changeset
299 needAlpha = SDL_TRUE;
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 } else {
5161
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
301 needAlpha = SDL_FALSE;
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
302 }
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
303 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: 5160
diff changeset
304 for (i = 0; i < renderer->info.num_texture_formats; ++i) {
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
305 if (SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == needAlpha) {
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
306 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: 5160
diff changeset
307 break;
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310
5161
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
311 if (!SDL_PixelFormatEnumToMasks(format, &bpp,
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
312 &Rmask, &Gmask, &Bmask, &Amask)) {
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
313 SDL_SetError("Unknown pixel format");
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
314 return NULL;
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315 }
5161
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
316
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
317 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: 5160
diff changeset
318 surface->w, surface->h);
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 if (!texture) {
5161
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
320 return NULL;
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 }
5161
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
322
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 if (bpp == fmt->BitsPerPixel && Rmask == fmt->Rmask && Gmask == fmt->Gmask
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 && Bmask == fmt->Bmask && Amask == fmt->Amask) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
326 SDL_LockSurface(surface);
5161
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
327 SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch);
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 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
329 } else {
5161
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
330 SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch);
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 } 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
333 SDL_PixelFormat dst_fmt;
5161
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
334 SDL_Surface *temp = NULL;
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 /* Set up a destination surface for the texture update */
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 SDL_InitFormat(&dst_fmt, bpp, Rmask, Gmask, Bmask, Amask);
5161
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
338 temp = SDL_ConvertSurface(surface, &dst_fmt, 0);
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
339 if (temp) {
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
340 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: 5160
diff changeset
341 SDL_FreeSurface(temp);
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
342 } else {
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 SDL_DestroyTexture(texture);
5161
b3ccd1947786 Simplified and improved the process of creating a texture from a surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5160
diff changeset
344 return NULL;
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 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
350 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
351
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 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
353 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
354
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 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
356 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
357
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 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
359 /* 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
360 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
361 } 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
362 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
363 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
364 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
367 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
370 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
371 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
372 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 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
374
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 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
376 *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
377 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 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
379 *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
380 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
382 *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
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 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
385 *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
386 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387 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
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
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
391 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
392 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
394
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
396
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
398 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
399 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
400 } 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
401 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
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 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
404 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
405 texture->b = b;
5159
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
406 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: 5157
diff changeset
407 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: 5157
diff changeset
408 } else if (renderer->SetTextureColorMod) {
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409 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
410 } 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
411 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
412 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 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
416 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
417 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
418 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419 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
420
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 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
422
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 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
424 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
425 *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
426 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427 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
428 *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
429 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 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
431 *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
432 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433 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
434 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
435
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436 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
437 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
438 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439 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
440
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
442
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
444 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
445 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
446 } 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
447 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
448 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449 texture->a = alpha;
5159
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
450 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: 5157
diff changeset
451 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: 5157
diff changeset
452 } else if (renderer->SetTextureAlphaMod) {
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
454 } 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
455 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
456 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
460 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
461 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
463
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
464 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
465 *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
466 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
467 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
468 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
469
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
470 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
471 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
472 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
473 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
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 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
476
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
477 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
478 texture->blendMode = blendMode;
5159
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
479 if (texture->native) {
5183
4d098d286794 SDL_SetTextureBlendMode broken, caught by Kai Sterker - Thanks!
Sam Lantinga <slouken@libsdl.org>
parents: 5169
diff changeset
480 return SDL_SetTextureBlendMode(texture->native, blendMode);
5159
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
481 } else if (renderer->SetTextureBlendMode) {
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482 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
483 } 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
484 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
485 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
486 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
489 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
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 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
492
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
493 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
494 *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
495 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
496 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
497 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
498
5159
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
499 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: 5157
diff changeset
500 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: 5157
diff changeset
501 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: 5157
diff changeset
502 {
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
503 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: 5157
diff changeset
504 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: 5157
diff changeset
505
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
506 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: 5157
diff changeset
507 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: 5157
diff changeset
508 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
509
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
510 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: 5157
diff changeset
511 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: 5157
diff changeset
512 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: 5157
diff changeset
513 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: 5157
diff changeset
514 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: 5157
diff changeset
515
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
516 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: 5157
diff changeset
517 /* 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: 5157
diff changeset
518 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: 5157
diff changeset
519 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: 5157
diff changeset
520
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
521 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: 5157
diff changeset
522 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: 5157
diff changeset
523 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
524 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: 5157
diff changeset
525 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: 5157
diff changeset
526 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: 5157
diff changeset
527 } 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: 5157
diff changeset
528 /* 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: 5157
diff changeset
529 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: 5157
diff changeset
530 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: 5157
diff changeset
531
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
532 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: 5157
diff changeset
533 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: 5157
diff changeset
534 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: 5157
diff changeset
535 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: 5157
diff changeset
536 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: 5157
diff changeset
537 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
538 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: 5157
diff changeset
539 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: 5157
diff changeset
540 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: 5157
diff changeset
541 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: 5157
diff changeset
542 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
543 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: 5157
diff changeset
544 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
545
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
546 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: 5157
diff changeset
547 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: 5157
diff changeset
548 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: 5157
diff changeset
549 {
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
550 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: 5157
diff changeset
551
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
552 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: 5157
diff changeset
553 /* 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: 5157
diff changeset
554 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: 5157
diff changeset
555 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: 5157
diff changeset
556
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
557 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: 5157
diff changeset
558 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: 5157
diff changeset
559 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
560 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: 5157
diff changeset
561 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: 5157
diff changeset
562 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: 5157
diff changeset
563 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: 5157
diff changeset
564 } 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: 5157
diff changeset
565 /* 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: 5157
diff changeset
566 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: 5157
diff changeset
567 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: 5157
diff changeset
568
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
569 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: 5157
diff changeset
570 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: 5157
diff changeset
571 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: 5157
diff changeset
572 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: 5157
diff changeset
573 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: 5157
diff changeset
574 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
575 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: 5157
diff changeset
576 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: 5157
diff changeset
577 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: 5157
diff changeset
578 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: 5157
diff changeset
579 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: 5157
diff changeset
580 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
581 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: 5157
diff changeset
582 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
583
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
585 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
586 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
587 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
589 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
590
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
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 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
594 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
595 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
596 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
597 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
598 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
599 }
5159
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
600
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
601 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: 5157
diff changeset
602 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: 5157
diff changeset
603 } 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: 5157
diff changeset
604 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: 5157
diff changeset
605 } 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: 5157
diff changeset
606 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: 5157
diff changeset
607 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: 5157
diff changeset
608 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
609 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
610
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
611 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: 5157
diff changeset
612 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: 5157
diff changeset
613 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: 5157
diff changeset
614 {
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
615 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: 5157
diff changeset
616 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
617
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
618 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: 5157
diff changeset
619 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: 5157
diff changeset
620 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: 5157
diff changeset
621 {
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
622 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: 5157
diff changeset
623 *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: 5157
diff changeset
624 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: 5157
diff changeset
625 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: 5157
diff changeset
626 *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: 5157
diff changeset
627 return 0;
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 int
5159
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
631 SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect,
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
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 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
635 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
636
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
637 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
638
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
640 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
641 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
642 }
5159
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
643
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
645 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
646 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
647 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
648 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
649 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
650 }
5159
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
651
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
652 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: 5157
diff changeset
653 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: 5157
diff changeset
654 } 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: 5157
diff changeset
655 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: 5157
diff changeset
656 } 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: 5157
diff changeset
657 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: 5157
diff changeset
658 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: 5157
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: 5157
diff changeset
660 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
661
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
662 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: 5157
diff changeset
663 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: 5157
diff changeset
664 {
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
665 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: 5157
diff changeset
666 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: 5157
diff changeset
667 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: 5157
diff changeset
668 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: 5157
diff changeset
669
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
670 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: 5157
diff changeset
671 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: 5157
diff changeset
672 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: 5157
diff changeset
673 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: 5157
diff changeset
674
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
675 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: 5157
diff changeset
676 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: 5157
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: 5157
diff changeset
678 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: 5157
diff changeset
679 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: 5157
diff changeset
680 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: 5157
diff changeset
681 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
682
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
683 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: 5157
diff changeset
684 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: 5157
diff changeset
685 {
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
686 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: 5157
diff changeset
687 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: 5157
diff changeset
688 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: 5157
diff changeset
689 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: 5157
diff changeset
690 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: 5157
diff changeset
691 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: 5157
diff changeset
692 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: 5157
diff changeset
693 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: 5157
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: 5157
diff changeset
695 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: 5157
diff changeset
696 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: 5157
diff changeset
697 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
698 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: 5157
diff changeset
699 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: 5157
diff changeset
700 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: 5157
diff changeset
701 SDL_UnlockTexture(native);
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
702 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
703
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
704 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
705 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
706 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
707 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
708
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
709 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
710
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
711 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
712 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
713 }
5159
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
714 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: 5157
diff changeset
715 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: 5157
diff changeset
716 } 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: 5157
diff changeset
717 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: 5157
diff changeset
718 } 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: 5157
diff changeset
719 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: 5157
diff changeset
720 renderer->UnlockTexture(renderer, texture);
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
721 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
722 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
723
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
724 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
725 SDL_SetRenderDrawColor(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
726 Uint8 r, Uint8 g, Uint8 b, Uint8 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
727 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
728 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
729
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
730 renderer->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
731 renderer->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
732 renderer->b = 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
733 renderer->a = 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
734 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
735 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
736
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
737 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
738 SDL_GetRenderDrawColor(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
739 Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * 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
740 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
742
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
744 *r = renderer->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
745 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
747 *g = renderer->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
748 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
750 *b = renderer->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
751 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 if (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
753 *a = renderer->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
754 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
756 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
757
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
758 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
759 SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, 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
760 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
761 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
762
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
763 renderer->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
764 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
765 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
766
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
767 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
768 SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, 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
769 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
770 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
771
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
772 *blendMode = renderer->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
773 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
774 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
775
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
776 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
777 SDL_RenderClear(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
778 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
779 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
780
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
781 if (!renderer->RenderClear) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
782 SDL_BlendMode blendMode = renderer->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
783 int status;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
784
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 if (blendMode >= 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
786 SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
788
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 status = SDL_RenderFillRect(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
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 if (blendMode >= 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
792 SDL_SetRenderDrawBlendMode(renderer, 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
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 return status;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 return renderer->RenderClear(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
797 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
800 SDL_RenderDrawPoint(SDL_Renderer * renderer, int x, int y)
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 SDL_Point point;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 point.x = x;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 point.y = y;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 return SDL_RenderDrawPoints(renderer, &point, 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
807 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
808
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
809 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
810 SDL_RenderDrawPoints(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
811 const SDL_Point * points, int count)
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
812 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
813 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
814
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
815 if (!points) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
816 SDL_SetError("SDL_RenderDrawPoints(): Passed NULL points");
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
817 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
818 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
819 if (count < 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
820 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
821 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
822 return renderer->RenderDrawPoints(renderer, points, count);
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
823 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
824
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
825 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
826 SDL_RenderDrawLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
827 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
828 SDL_Point points[2];
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
829
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
830 points[0].x = x1;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
831 points[0].y = y1;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
832 points[1].x = x2;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
833 points[1].y = y2;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
834 return SDL_RenderDrawLines(renderer, points, 2);
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
835 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
836
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
837 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
838 SDL_RenderDrawLines(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
839 const SDL_Point * points, int count)
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
840 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
841 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
842
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
843 if (!points) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
844 SDL_SetError("SDL_RenderDrawLines(): Passed NULL points");
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
845 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
846 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
847 if (count < 2) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
848 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
849 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
850 return renderer->RenderDrawLines(renderer, points, count);
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
851 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
852
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
853 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
854 SDL_RenderDrawRect(SDL_Renderer * renderer, 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
855 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
856 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
857 SDL_Point points[5];
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
858
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
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 /* If 'rect' == NULL, then outline the whole 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
862 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
863 SDL_Window *window = renderer->window;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 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
866 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
867 SDL_GetWindowSize(window, &full_rect.w, &full_rect.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
868 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
869 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
871 points[0].x = rect->x;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
872 points[0].y = rect->y;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
873 points[1].x = rect->x+rect->w-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
874 points[1].y = rect->y;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
875 points[2].x = rect->x+rect->w-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
876 points[2].y = rect->y+rect->h-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
877 points[3].x = rect->x;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 points[3].y = rect->y+rect->h-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
879 points[4].x = rect->x;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled 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 points[4].y = rect->y;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
881 return SDL_RenderDrawLines(renderer, points, 5);
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
882 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
883
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
884 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
885 SDL_RenderDrawRects(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
886 const SDL_Rect ** rects, int count)
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
887 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
888 int i;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
889
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
890 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
891
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
892 if (!rects) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
893 SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects");
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
894 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
895 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
896 if (count < 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
897 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
898 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
899
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
900 /* Check for NULL rect, which means fill entire window */
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
901 for (i = 0; i < count; ++i) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
902 if (SDL_RenderDrawRect(renderer, rects[i]) < 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
903 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
904 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
905 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
906 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
907 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
908
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
909 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
910 SDL_RenderFillRect(SDL_Renderer * renderer, 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
911 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
912 return SDL_RenderFillRects(renderer, &rect, 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
913 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
914
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
915 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
916 SDL_RenderFillRects(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
917 const SDL_Rect ** rects, int count)
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
918 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
919 int i;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
920
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
921 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
922
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
923 if (!rects) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
924 SDL_SetError("SDL_RenderFillRects(): Passed NULL rects");
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
925 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
926 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
927 if (count < 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
928 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
929 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
930
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
931 /* Check for NULL rect, which means fill entire window */
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
932 for (i = 0; i < count; ++i) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
933 if (rects[i] == 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
934 SDL_Window *window = renderer->window;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
935 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
936 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
937
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
938 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
939 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
940 SDL_GetWindowSize(window, &full_rect.w, &full_rect.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
941 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
942 return renderer->RenderFillRects(renderer, &rect, 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
943 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
944 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
945 return renderer->RenderFillRects(renderer, rects, count);
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
946 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
947
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
948 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
949 SDL_RenderCopy(SDL_Renderer * renderer, 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
950 const SDL_Rect * srcrect, const SDL_Rect * dstrect)
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
951 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
952 SDL_Window *window;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
953 SDL_Rect real_srcrect;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
954 SDL_Rect real_dstrect;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
955
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
956 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
957 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
958
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
959 if (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
960 SDL_SetError("Texture was not created with this 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
961 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
962 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
963 window = renderer->window;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
964
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
965 real_srcrect.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
966 real_srcrect.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
967 real_srcrect.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
968 real_srcrect.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
969 if (srcrect) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
970 if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
971 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
972 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
973 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
974
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
975 real_dstrect.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
976 real_dstrect.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
977 SDL_GetWindowSize(window, &real_dstrect.w, &real_dstrect.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
978 if (dstrect) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
979 if (!SDL_IntersectRect(dstrect, &real_dstrect, &real_dstrect)) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
980 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
981 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
982 /* Clip srcrect by the same amount as dstrect was clipped */
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
983 if (dstrect->w != real_dstrect.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
984 int deltax = (real_dstrect.x - dstrect->x);
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
985 int deltaw = (real_dstrect.w - dstrect->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
986 real_srcrect.x += (deltax * real_srcrect.w) / dstrect->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
987 real_srcrect.w += (deltaw * real_srcrect.w) / dstrect->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
988 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
989 if (dstrect->h != real_dstrect.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
990 int deltay = (real_dstrect.y - dstrect->y);
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
991 int deltah = (real_dstrect.h - dstrect->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
992 real_srcrect.y += (deltay * real_srcrect.h) / dstrect->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
993 real_srcrect.h += (deltah * real_srcrect.h) / dstrect->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
994 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
995 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
996
5159
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
997 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: 5157
diff changeset
998 texture = 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: 5157
diff changeset
999 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
1000
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1001 return renderer->RenderCopy(renderer, texture, &real_srcrect,
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1002 &real_dstrect);
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1003 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1004
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1005 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
1006 SDL_RenderReadPixels(SDL_Renderer * renderer, 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
1007 Uint32 format, 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
1008 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1009 SDL_Window *window;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1010 SDL_Rect real_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
1011
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1012 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
1013
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1014 if (!renderer->RenderReadPixels) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1015 SDL_Unsupported();
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1016 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
1017 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1018 window = renderer->window;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1019
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1020 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
1021 format = SDL_GetWindowPixelFormat(window);
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1022 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1023
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1024 real_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
1025 real_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
1026 SDL_GetWindowSize(window, &real_rect.w, &real_rect.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
1027 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
1028 if (!SDL_IntersectRect(rect, &real_rect, &real_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
1029 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
1030 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1031 if (real_rect.y > rect->y) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1032 pixels = (Uint8 *)pixels + pitch * (real_rect.y - rect->y);
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1033 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1034 if (real_rect.x > rect->x) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1035 int bpp = SDL_BYTESPERPIXEL(SDL_GetWindowPixelFormat(window));
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1036 pixels = (Uint8 *)pixels + bpp * (real_rect.x - rect->x);
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1037 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1038 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1039
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1040 return renderer->RenderReadPixels(renderer, &real_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
1041 format, pixels, 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
1042 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1043
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1044 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
1045 SDL_RenderPresent(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
1046 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1047 CHECK_RENDERER_MAGIC(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
1048
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1049 renderer->RenderPresent(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
1050 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1051
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1052 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
1053 SDL_DestroyTexture(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
1054 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1055 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
1056
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1057 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
1058 texture->magic = 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
1059
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1060 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
1061 if (texture->next) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1062 texture->next->prev = texture->prev;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1063 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1064 if (texture->prev) {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1065 texture->prev->next = texture->next;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1066 } 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
1067 renderer->textures = texture->next;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1068 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1069
5159
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
1070 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: 5157
diff changeset
1071 SDL_DestroyTexture(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: 5157
diff changeset
1072 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
1073 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: 5157
diff changeset
1074 SDL_SW_DestroyYUVTexture(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: 5157
diff changeset
1075 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
1076 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: 5157
diff changeset
1077 SDL_free(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: 5157
diff changeset
1078 }
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5157
diff changeset
1079
5157
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1080 renderer->DestroyTexture(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
1081 SDL_free(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
1082 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1083
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1084 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
1085 SDL_DestroyRenderer(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
1086 {
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1087 CHECK_RENDERER_MAGIC(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
1088
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1089 SDL_DelEventWatch(SDL_RendererEventWatch, 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
1090
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1091 /* Free existing textures for this 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
1092 while (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
1093 SDL_DestroyTexture(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
1094 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1095
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1096 /* It's no longer magical... */
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1097 renderer->magic = 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
1098
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1099 /* Free the 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
1100 renderer->DestroyRenderer(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
1101 }
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1102
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1103 /* vi: set ts=4 sw=4 expandtab: */