Mercurial > sdl-ios-xcode
annotate src/video/dummy/SDL_nullrender.c @ 5147:a1345acf7b3d
The renderers always support texture modulation and blend modes.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 01 Feb 2011 12:54:27 -0800 |
parents | c8e049de174c |
children | 5429daf5e3f9 |
rev | line source |
---|---|
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
3697 | 3 Copyright (C) 1997-2010 Sam Lantinga |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #include "SDL_video.h" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 #include "../SDL_sysvideo.h" |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
26 #include "../SDL_yuv_sw_c.h" |
2228
bb67fd5ccfdb
Fixed compile warnings with Visual C++
Sam Lantinga <slouken@libsdl.org>
parents:
2227
diff
changeset
|
27 #include "../SDL_renderer_sw.h" |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 /* SDL surface based renderer implementation */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
32 static SDL_Renderer *SDL_DUMMY_CreateRenderer(SDL_Window * window, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
33 Uint32 flags); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
34 static int SDL_DUMMY_RenderDrawPoints(SDL_Renderer * renderer, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
35 const SDL_Point * points, int count); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
36 static int SDL_DUMMY_RenderDrawLines(SDL_Renderer * renderer, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
37 const SDL_Point * points, int count); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
38 static int SDL_DUMMY_RenderDrawRects(SDL_Renderer * renderer, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
39 const SDL_Rect ** rects, int count); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
40 static int SDL_DUMMY_RenderFillRects(SDL_Renderer * renderer, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
41 const SDL_Rect ** rects, int count); |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
42 static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
43 SDL_Texture * texture, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
44 const SDL_Rect * srcrect, |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
45 const SDL_Rect * dstrect); |
3451
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
46 static int SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer, |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
47 const SDL_Rect * rect, |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
48 Uint32 format, |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
49 void * pixels, int pitch); |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
50 static int SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer, |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
51 const SDL_Rect * rect, |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
52 Uint32 format, |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
53 const void * pixels, int pitch); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 static void SDL_DUMMY_RenderPresent(SDL_Renderer * renderer); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 static void SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 SDL_RenderDriver SDL_DUMMY_RenderDriver = { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 SDL_DUMMY_CreateRenderer, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 { |
1906
0c49855a7a3e
Changed the name of the dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
61 "dummy", |
5145
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
62 (0), |
2227
b252359547ed
Exported the software renderer texture functions to make easier to create
Sam Lantinga <slouken@libsdl.org>
parents:
1992
diff
changeset
|
63 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 }; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 typedef struct |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 { |
5145
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
68 SDL_Surface *screen; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 } SDL_DUMMY_RenderData; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 SDL_Renderer * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 SDL_DUMMY_CreateRenderer(SDL_Window * window, Uint32 flags) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 { |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
74 SDL_VideoDisplay *display = window->display; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 SDL_DisplayMode *displayMode = &display->current_mode; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 SDL_Renderer *renderer; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 SDL_DUMMY_RenderData *data; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 int bpp; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 Uint32 Rmask, Gmask, Bmask, Amask; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 if (!SDL_PixelFormatEnumToMasks |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 SDL_SetError("Unknown display format"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
87 renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 if (!renderer) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 SDL_OutOfMemory(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 data = (SDL_DUMMY_RenderData *) SDL_malloc(sizeof(*data)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 if (!data) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 SDL_DUMMY_DestroyRenderer(renderer); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 SDL_OutOfMemory(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 SDL_zerop(data); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
101 renderer->RenderDrawPoints = SDL_DUMMY_RenderDrawPoints; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
102 renderer->RenderDrawLines = SDL_DUMMY_RenderDrawLines; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
103 renderer->RenderDrawRects = SDL_DUMMY_RenderDrawRects; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
104 renderer->RenderFillRects = SDL_DUMMY_RenderFillRects; |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
105 renderer->RenderCopy = SDL_DUMMY_RenderCopy; |
3451
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
106 renderer->RenderReadPixels = SDL_DUMMY_RenderReadPixels; |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
107 renderer->RenderWritePixels = SDL_DUMMY_RenderWritePixels; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 renderer->RenderPresent = SDL_DUMMY_RenderPresent; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 renderer->DestroyRenderer = SDL_DUMMY_DestroyRenderer; |
2227
b252359547ed
Exported the software renderer texture functions to make easier to create
Sam Lantinga <slouken@libsdl.org>
parents:
1992
diff
changeset
|
110 renderer->info.name = SDL_DUMMY_RenderDriver.info.name; |
b252359547ed
Exported the software renderer texture functions to make easier to create
Sam Lantinga <slouken@libsdl.org>
parents:
1992
diff
changeset
|
111 renderer->info.flags = 0; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
112 renderer->window = window; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 renderer->driverdata = data; |
2227
b252359547ed
Exported the software renderer texture functions to make easier to create
Sam Lantinga <slouken@libsdl.org>
parents:
1992
diff
changeset
|
114 Setup_SoftwareRenderer(renderer); |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
115 |
5145
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
116 data->screen = |
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
117 SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask, |
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
118 Bmask, Amask); |
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
119 if (!data->screen) { |
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
120 SDL_DUMMY_DestroyRenderer(renderer); |
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
121 return NULL; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 } |
5145
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
123 SDL_SetSurfacePalette(data->screen, display->palette); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 return renderer; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
128 static int |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
129 SDL_DUMMY_RenderDrawPoints(SDL_Renderer * renderer, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
130 const SDL_Point * points, int count) |
2901 | 131 { |
132 SDL_DUMMY_RenderData *data = | |
133 (SDL_DUMMY_RenderData *) renderer->driverdata; | |
5145
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
134 SDL_Surface *target = data->screen; |
2901 | 135 |
5143
e743b9c3f6d6
Making the API simpler, the blend modes are "none, blend, add" and are supported by all renderers.
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
136 if (renderer->blendMode == SDL_BLENDMODE_NONE) { |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3451
diff
changeset
|
137 Uint32 color = SDL_MapRGBA(target->format, |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3451
diff
changeset
|
138 renderer->r, renderer->g, renderer->b, |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3451
diff
changeset
|
139 renderer->a); |
2901 | 140 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3451
diff
changeset
|
141 return SDL_DrawPoints(target, points, count, color); |
2901 | 142 } else { |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3451
diff
changeset
|
143 return SDL_BlendPoints(target, points, count, renderer->blendMode, |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3451
diff
changeset
|
144 renderer->r, renderer->g, renderer->b, |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3451
diff
changeset
|
145 renderer->a); |
2901 | 146 } |
147 } | |
148 | |
149 static int | |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
150 SDL_DUMMY_RenderDrawLines(SDL_Renderer * renderer, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
151 const SDL_Point * points, int count) |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
152 { |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
153 SDL_DUMMY_RenderData *data = |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
154 (SDL_DUMMY_RenderData *) renderer->driverdata; |
5145
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
155 SDL_Surface *target = data->screen; |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
156 |
5143
e743b9c3f6d6
Making the API simpler, the blend modes are "none, blend, add" and are supported by all renderers.
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
157 if (renderer->blendMode == SDL_BLENDMODE_NONE) { |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3451
diff
changeset
|
158 Uint32 color = SDL_MapRGBA(target->format, |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3451
diff
changeset
|
159 renderer->r, renderer->g, renderer->b, |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3451
diff
changeset
|
160 renderer->a); |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
161 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3451
diff
changeset
|
162 return SDL_DrawLines(target, points, count, color); |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
163 } else { |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3451
diff
changeset
|
164 return SDL_BlendLines(target, points, count, renderer->blendMode, |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3451
diff
changeset
|
165 renderer->r, renderer->g, renderer->b, |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3451
diff
changeset
|
166 renderer->a); |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
167 } |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
168 } |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
169 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
170 static int |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
171 SDL_DUMMY_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
172 int count) |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
173 { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
174 SDL_DUMMY_RenderData *data = |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
175 (SDL_DUMMY_RenderData *) renderer->driverdata; |
5145
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
176 SDL_Surface *target = data->screen; |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
177 |
5143
e743b9c3f6d6
Making the API simpler, the blend modes are "none, blend, add" and are supported by all renderers.
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
178 if (renderer->blendMode == SDL_BLENDMODE_NONE) { |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
179 Uint32 color = SDL_MapRGBA(target->format, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
180 renderer->r, renderer->g, renderer->b, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
181 renderer->a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
182 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
183 return SDL_DrawRects(target, rects, count, color); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
184 } else { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
185 return SDL_BlendRects(target, rects, count, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
186 renderer->blendMode, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
187 renderer->r, renderer->g, renderer->b, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
188 renderer->a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
189 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
190 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
191 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
192 static int |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
193 SDL_DUMMY_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
194 int count) |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
195 { |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
196 SDL_DUMMY_RenderData *data = |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
197 (SDL_DUMMY_RenderData *) renderer->driverdata; |
5145
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
198 SDL_Surface *target = data->screen; |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
199 |
5143
e743b9c3f6d6
Making the API simpler, the blend modes are "none, blend, add" and are supported by all renderers.
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
200 if (renderer->blendMode == SDL_BLENDMODE_NONE) { |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3451
diff
changeset
|
201 Uint32 color = SDL_MapRGBA(target->format, |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3451
diff
changeset
|
202 renderer->r, renderer->g, renderer->b, |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3451
diff
changeset
|
203 renderer->a); |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
204 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3451
diff
changeset
|
205 return SDL_FillRects(target, rects, count, color); |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
206 } else { |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
207 return SDL_BlendFillRects(target, rects, count, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
208 renderer->blendMode, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
209 renderer->r, renderer->g, renderer->b, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
210 renderer->a); |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
211 } |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
212 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
213 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
214 static int |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
215 SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
216 const SDL_Rect * srcrect, const SDL_Rect * dstrect) |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
217 { |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
218 SDL_DUMMY_RenderData *data = |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
219 (SDL_DUMMY_RenderData *) renderer->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
220 SDL_Window *window = renderer->window; |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
221 SDL_VideoDisplay *display = window->display; |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
222 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
223 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
5145
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
224 SDL_Surface *target = data->screen; |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
225 void *pixels = |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
226 (Uint8 *) target->pixels + dstrect->y * target->pitch + |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
227 dstrect->x * target->format->BytesPerPixel; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
228 return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata, |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
229 srcrect, display->current_mode.format, |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
230 dstrect->w, dstrect->h, pixels, |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
231 target->pitch); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
232 } else { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
233 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; |
5145
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
234 SDL_Surface *target = data->screen; |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
235 SDL_Rect real_srcrect = *srcrect; |
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
236 SDL_Rect real_dstrect = *dstrect; |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
237 |
2267
c785543d1843
Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents:
2262
diff
changeset
|
238 return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect); |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
239 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
240 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
241 |
3451
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
242 static int |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
243 SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
244 Uint32 format, void * pixels, int pitch) |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
245 { |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
246 SDL_DUMMY_RenderData *data = |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
247 (SDL_DUMMY_RenderData *) renderer->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
248 SDL_Window *window = renderer->window; |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
249 SDL_VideoDisplay *display = window->display; |
5145
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
250 SDL_Surface *screen = data->screen; |
3451
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
251 Uint32 screen_format = display->current_mode.format; |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
252 Uint8 *screen_pixels = (Uint8 *) screen->pixels + |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
253 rect->y * screen->pitch + |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
254 rect->x * screen->format->BytesPerPixel; |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
255 int screen_pitch = screen->pitch; |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
256 |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
257 return SDL_ConvertPixels(rect->w, rect->h, |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
258 screen_format, screen_pixels, screen_pitch, |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
259 format, pixels, pitch); |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
260 } |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
261 |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
262 static int |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
263 SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
264 Uint32 format, const void * pixels, int pitch) |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
265 { |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
266 SDL_DUMMY_RenderData *data = |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
267 (SDL_DUMMY_RenderData *) renderer->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
268 SDL_Window *window = renderer->window; |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
269 SDL_VideoDisplay *display = window->display; |
5145
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
270 SDL_Surface *screen = data->screen; |
3451
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
271 Uint32 screen_format = display->current_mode.format; |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
272 Uint8 *screen_pixels = (Uint8 *) screen->pixels + |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
273 rect->y * screen->pitch + |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
274 rect->x * screen->format->BytesPerPixel; |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
275 int screen_pitch = screen->pitch; |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
276 |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
277 return SDL_ConvertPixels(rect->w, rect->h, |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
278 format, pixels, pitch, |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
279 screen_format, screen_pixels, screen_pitch); |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
280 } |
a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
2927
diff
changeset
|
281 |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
282 static void |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 SDL_DUMMY_RenderPresent(SDL_Renderer * renderer) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 static int frame_number; |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
286 SDL_DUMMY_RenderData *data = |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
287 (SDL_DUMMY_RenderData *) renderer->driverdata; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
289 /* Send the data to the display */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 char file[128]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp", |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3596
diff
changeset
|
293 renderer->window->id, ++frame_number); |
5145
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
294 SDL_SaveBMP(data->screen, file); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
298 static void |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 { |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
301 SDL_DUMMY_RenderData *data = |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
302 (SDL_DUMMY_RenderData *) renderer->driverdata; |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
303 int i; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 if (data) { |
5145
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
306 if (data->screen) { |
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
307 SDL_FreeSurface(data->screen); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 SDL_free(data); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 SDL_free(renderer); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 /* vi: set ts=4 sw=4 expandtab: */ |