annotate src/video/dummy/SDL_nullrender.c @ 3487:24d13328c44a

Eric Wing to Sam, hfutrell This one is quite puzzling. I found a partial workaround, but I don't fully understand the reasons yet. First, the console is complaining about not finding a nib for MainWindow. I tried removing the entry for this in the info.plist, and the message went away, but it didn't really change anything. Second, I stepped through this with the debugger and broke up some lines. It seems that the basic act of calling view = [SDL_uikitopenglview alloc]; or even view = [SDL_uikitview alloc] will crash the program. The debugger messages plus the stack trace make me think it's not finding the SDL_uikitview classes for some reason. But I don't understand why this would be. view = [UIView alloc] will not crash the program. For kicks, I added a new definition of a class called SDL_object which subclasses NSObject in the same files as SDL_uikitopenglview and then call view = [SDL_object alloc]; This does not crash the program. So, then I modified SDL_object to subclass UIView. No crash. Next, I made SDL_object subclass UIView<UITextFieldDelegate> . This crashes. So it is the act of conforming to the UITextFieldDelegate protocol that is crashing things. I don't understand why it would crash on alloc though. I'm guessing either a delegate needs to be set somewhere or one of the required methods needs to be implemented. But in the former case, I would not expect a crash, but a silent message to nil and something else doesn't work. And in the latter case, I would expect a compiler warning and an exception thrown instead of a crash. Anyway, my temporary workaround is to change the interface declaration for SDL_uikitview to look like: #if SDL_IPHONE_KEYBOARD @interface SDL_uikitview : UIView<UITextFieldDelegate> { #else @interface SDL_uikitview : UIView { #endif And then disable the keyboard support in the SDL_config_iphoneos.h file. /* enable iPhone keyboard support */ #define SDL_IPHONE_KEYBOARD 0 -Eric On Nov 23, 2009, at 1:43 AM, Sam Lantinga wrote: > I ran into a blocking startup crash with the Happy demo on iPhone OS 3.1.2 on my new iPhone: > > #0 0x323fea14 in _class_isInitialized > #1 0x323fea68 in _class_initialize > #2 0x32403e92 in prepareForMethodLookup > #3 0x32401244 in lookUpMethod > #4 0x323fea10 in _class_lookupMethodAndLoadCache > #5 0x323fe746 in objc_msgSend_uncached > #6 0x323feb26 in _class_initialize > #7 0x323fea58 in _class_initialize > #8 0x32403e92 in prepareForMethodLookup > #9 0x32401244 in lookUpMethod > #10 0x323fea10 in _class_lookupMethodAndLoadCache > #11 0x323fe746 in objc_msgSend_uncached > #12 0x000554dc in UIKit_GL_CreateContext at SDL_uikitopengles.m:103 > #13 0x0004f89e in SDL_GL_CreateContext at SDL_video.c:3155 > #14 0x000579e8 in GLES_CreateRenderer at SDL_renderer_gles.c:282 > #15 0x0004d7b8 in SDL_CreateRenderer at SDL_video.c:1509 > #16 0x00002bc2 in SDL_main at happy.c:156 > #17 0x000571b2 in -[SDLUIKitDelegate postFinishLaunch] at > SDL_uikitappdelegate.m:77 > #18 0x313f9ef2 in __NSFireDelayedPerform > #19 0x32567bb2 in CFRunLoopRunSpecific > #20 0x3256735c in CFRunLoopRunInMode > #21 0x32912cbe in GSEventRunModal > #22 0x32912d6a in GSEventRun > #23 0x32b6276e in -[UIApplication _run] > #24 0x32b61472 in UIApplicationMain > #25 0x00057088 in main at SDL_uikitappdelegate.m:50 > > Any ideas? > > See ya! > -- > -Sam Lantinga, Founder and President, Galaxy Gameworks LLC
author Sam Lantinga <slouken@libsdl.org>
date Tue, 24 Nov 2009 08:12:32 +0000
parents a65f7b3a2524
children 0267b8b1595c
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
2859
99210400e8b9 Updated copyright date
Sam Lantinga <slouken@libsdl.org>
parents: 2267
diff changeset
3 Copyright (C) 1997-2009 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);
2901
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
34 static int SDL_DUMMY_RenderPoint(SDL_Renderer * renderer, int x, int y);
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
35 static int SDL_DUMMY_RenderLine(SDL_Renderer * renderer, int x1, int y1,
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
36 int x2, int y2);
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
37 static int SDL_DUMMY_RenderFill(SDL_Renderer * renderer,
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
38 const SDL_Rect * rect);
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
39 static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
40 SDL_Texture * texture,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
41 const SDL_Rect * srcrect,
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
42 const SDL_Rect * dstrect);
3451
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
43 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
44 const SDL_Rect * rect,
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
45 Uint32 format,
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
46 void * pixels, int pitch);
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
47 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
48 const SDL_Rect * rect,
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
49 Uint32 format,
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
50 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
51 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
52 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
53
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
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 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
56 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
57 {
1906
0c49855a7a3e Changed the name of the dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
58 "dummy",
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
59 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
60 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
61 SDL_RENDERER_PRESENTDISCARD),
2227
b252359547ed Exported the software renderer texture functions to make easier to create
Sam Lantinga <slouken@libsdl.org>
parents: 1992
diff changeset
62 }
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
63 };
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 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
66 {
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
67 int current_screen;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
68 SDL_Surface *screens[3];
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 {
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
74 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
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;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
78 int i, n;
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
79 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
80 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
81
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 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
83 (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
84 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
85 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
86 }
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
87
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
88 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
89 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
90 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
91 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
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
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 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
95 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
96 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
97 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
98 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
99 }
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 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
101
2901
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
102 renderer->RenderPoint = SDL_DUMMY_RenderPoint;
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
103 renderer->RenderLine = SDL_DUMMY_RenderLine;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
104 renderer->RenderFill = SDL_DUMMY_RenderFill;
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;
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
112 renderer->window = window->id;
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
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
116 if (flags & SDL_RENDERER_PRESENTFLIP2) {
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
117 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
118 n = 2;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
119 } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
120 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
121 n = 3;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
122 } else {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
123 renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
124 n = 1;
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
125 }
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
126 for (i = 0; i < n; ++i) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
127 data->screens[i] =
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
128 SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask,
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
129 Bmask, Amask);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
130 if (!data->screens[i]) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
131 SDL_DUMMY_DestroyRenderer(renderer);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
132 return NULL;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
133 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
134 SDL_SetSurfacePalette(data->screens[i], display->palette);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
135 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
136 data->current_screen = 0;
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
137
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
138 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
139 }
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
140
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
141 static int
2901
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
142 SDL_DUMMY_RenderPoint(SDL_Renderer * renderer, int x, int y)
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
143 {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
144 SDL_DUMMY_RenderData *data =
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
145 (SDL_DUMMY_RenderData *) renderer->driverdata;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
146 SDL_Surface *target = data->screens[data->current_screen];
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
147 int status;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
148
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
149 if (renderer->blendMode == SDL_BLENDMODE_NONE ||
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
150 renderer->blendMode == SDL_BLENDMODE_MASK) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
151 Uint32 color =
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
152 SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
153 renderer->a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
154
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
155 status = SDL_DrawPoint(target, x, y, color);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
156 } else {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
157 status =
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
158 SDL_BlendPoint(target, x, y, renderer->blendMode, renderer->r,
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
159 renderer->g, renderer->b, renderer->a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
160 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
161 return status;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
162 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
163
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
164 static int
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
165 SDL_DUMMY_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
166 {
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
167 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
168 (SDL_DUMMY_RenderData *) renderer->driverdata;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
169 SDL_Surface *target = data->screens[data->current_screen];
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
170 int status;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
171
2901
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
172 if (renderer->blendMode == SDL_BLENDMODE_NONE ||
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
173 renderer->blendMode == SDL_BLENDMODE_MASK) {
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
174 Uint32 color =
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
175 SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
176 renderer->a);
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
177
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
178 status = SDL_DrawLine(target, x1, y1, x2, y2, color);
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
179 } else {
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
180 status =
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
181 SDL_BlendLine(target, x1, y1, x2, y2, renderer->blendMode,
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
182 renderer->r, renderer->g, renderer->b, renderer->a);
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
183 }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
184 return status;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
185 }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
186
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
187 static int
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
188 SDL_DUMMY_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
189 {
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
190 SDL_DUMMY_RenderData *data =
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
191 (SDL_DUMMY_RenderData *) renderer->driverdata;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
192 SDL_Surface *target = data->screens[data->current_screen];
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
193 SDL_Rect real_rect = *rect;
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
194 int status;
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
195
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
196 if (renderer->blendMode == SDL_BLENDMODE_NONE) {
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
197 Uint32 color =
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
198 SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
199 renderer->a);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
200
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
201 status = SDL_FillRect(target, &real_rect, color);
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
202 } else {
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
203 status =
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
204 SDL_BlendRect(target, &real_rect, renderer->blendMode,
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
205 renderer->r, renderer->g, renderer->b, renderer->a);
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
206 }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
207 return status;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
208 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
209
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
210 static int
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
211 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
212 const SDL_Rect * srcrect, const SDL_Rect * dstrect)
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
213 {
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
214 SDL_DUMMY_RenderData *data =
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
215 (SDL_DUMMY_RenderData *) renderer->driverdata;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
216 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
217 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
218
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
219 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
220 SDL_Surface *target = data->screens[data->current_screen];
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
221 void *pixels =
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
222 (Uint8 *) target->pixels + dstrect->y * target->pitch +
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
223 dstrect->x * target->format->BytesPerPixel;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
224 return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata,
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
225 srcrect, display->current_mode.format,
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
226 dstrect->w, dstrect->h, pixels,
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
227 target->pitch);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
228 } else {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
229 SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
230 SDL_Surface *target = data->screens[data->current_screen];
2267
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
231 SDL_Rect real_srcrect = *srcrect;
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
232 SDL_Rect real_dstrect = *dstrect;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
233
2267
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
234 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
235 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
236 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
237
3451
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
238 static int
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
239 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
240 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
241 {
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
242 SDL_DUMMY_RenderData *data =
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
243 (SDL_DUMMY_RenderData *) renderer->driverdata;
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
244 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
245 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
246 SDL_Surface *screen = data->screens[data->current_screen];
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
247 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
248 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
249 rect->y * screen->pitch +
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
250 rect->x * screen->format->BytesPerPixel;
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
251 int screen_pitch = screen->pitch;
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
252
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
253 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
254 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
255 format, pixels, 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
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
258 static int
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
259 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
260 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
261 {
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
262 SDL_DUMMY_RenderData *data =
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
263 (SDL_DUMMY_RenderData *) renderer->driverdata;
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
264 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
265 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
266 SDL_Surface *screen = data->screens[data->current_screen];
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
267 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
268 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
269 rect->y * screen->pitch +
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
270 rect->x * screen->format->BytesPerPixel;
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
271 int screen_pitch = screen->pitch;
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
272
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
273 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
274 format, pixels, pitch,
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
275 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
276 }
a65f7b3a2524 Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
277
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
278 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
279 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
280 {
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
281 static int frame_number;
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
282 SDL_DUMMY_RenderData *data =
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
283 (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
284
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
285 /* 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
286 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
287 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
288 SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
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
289 renderer->window, ++frame_number);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
290 SDL_SaveBMP(data->screens[data->current_screen], file);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
291 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
292
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
293 /* Update the flipping chain, if any */
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
294 if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
295 data->current_screen = (data->current_screen + 1) % 2;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
296 } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
297 data->current_screen = (data->current_screen + 1) % 3;
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
298 }
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 }
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
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
301 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
302 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
303 {
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
304 SDL_DUMMY_RenderData *data =
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
305 (SDL_DUMMY_RenderData *) renderer->driverdata;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
306 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
307
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 if (data) {
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
309 for (i = 0; i < SDL_arraysize(data->screens); ++i) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
310 if (data->screens[i]) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
311 SDL_FreeSurface(data->screens[i]);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
312 }
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
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 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
315 }
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
316 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
317 }
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
318
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
319 /* vi: set ts=4 sw=4 expandtab: */