Mercurial > sdl-ios-xcode
annotate src/video/SDL_renderer_sw.c @ 1680:9488fca10677 SDL-1.3
Dummy video driver works again in high color video modes. Yay!
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 14 Jun 2006 08:41:13 +0000 |
parents | 90bf530ced8e |
children | 80a5e6a4e1e2 |
rev | line source |
---|---|
1676
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #include "SDL_video.h" |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 #include "SDL_sysvideo.h" |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 /* SDL surface based renderer implementation */ |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 static SDL_Renderer *SDL_SW_CreateRenderer(SDL_Window * window, Uint32 flags); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 static int SDL_SW_CreateTexture(SDL_Renderer * renderer, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 SDL_Texture * texture); |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1676
diff
changeset
|
33 static int SDL_SW_QueryTexturePixels(SDL_Renderer * renderer, |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1676
diff
changeset
|
34 SDL_Texture * texture, void **pixels, |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1676
diff
changeset
|
35 int *pitch); |
1680
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
36 static int SDL_SW_SetTexturePalette(SDL_Renderer * renderer, |
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
37 SDL_Texture * texture, SDL_Color * colors, |
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
38 int firstcolor, int ncolors); |
1676
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 static int SDL_SW_UpdateTexture(SDL_Renderer * renderer, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 SDL_Texture * texture, SDL_Rect * rect, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 const void *pixels, int pitch); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 static int SDL_SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 SDL_Rect * rect, int markDirty, void **pixels, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 int *pitch); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 static void SDL_SW_UnlockTexture(SDL_Renderer * renderer, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 SDL_Texture * texture); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 static void SDL_SW_DirtyTexture(SDL_Renderer * renderer, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 SDL_Texture * texture, int numrects, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 SDL_Rect * rects); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 static void SDL_SW_SelectRenderTexture(SDL_Renderer * renderer, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 SDL_Texture * texture); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 static void SDL_SW_RenderFill(SDL_Renderer * renderer, SDL_Rect * rect, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 Uint32 color); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 static int SDL_SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 SDL_Rect * srcrect, SDL_Rect * dstrect, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 int blendMode, int scaleMode); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 static int SDL_SW_RenderReadPixels(SDL_Renderer * renderer, SDL_Rect * rect, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 void *pixels, int pitch); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 static int SDL_SW_RenderWritePixels(SDL_Renderer * renderer, SDL_Rect * rect, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 const void *pixels, int pitch); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 static void SDL_SW_RenderPresent(SDL_Renderer * renderer); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 static void SDL_SW_DestroyTexture(SDL_Renderer * renderer, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 SDL_Texture * texture); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 static void SDL_SW_DestroyRenderer(SDL_Renderer * renderer); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 SDL_RenderDriver SDL_SW_RenderDriver = { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 SDL_SW_CreateRenderer, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 "software", |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 (SDL_Renderer_PresentDiscard | |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 SDL_Renderer_PresentCopy | |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 SDL_Renderer_PresentFlip2 | |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 SDL_Renderer_PresentFlip3 | SDL_Renderer_RenderTarget), |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 (SDL_TextureBlendMode_None | |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 SDL_TextureBlendMode_Mask | SDL_TextureBlendMode_Blend), |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 (SDL_TextureScaleMode_None | SDL_TextureScaleMode_Fast), |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 11, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 SDL_PixelFormat_Index8, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 SDL_PixelFormat_RGB555, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 SDL_PixelFormat_RGB565, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 SDL_PixelFormat_RGB888, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 SDL_PixelFormat_BGR888, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 SDL_PixelFormat_ARGB8888, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 SDL_PixelFormat_RGBA8888, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 SDL_PixelFormat_ABGR8888, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 SDL_PixelFormat_BGRA8888, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 SDL_PixelFormat_YUY2, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 SDL_PixelFormat_UYVY}, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 32768, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 32768} |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 }; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 typedef struct |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 int current_screen; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 SDL_Surface *screens[3]; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 SDL_Surface *target; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 SDL_Renderer *renderer; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 } SDL_SW_RenderData; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 SDL_Renderer * |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 SDL_SW_CreateRenderer(SDL_Window * window, Uint32 flags) |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 SDL_DisplayMode *displayMode = &window->display->current_mode; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 SDL_Renderer *renderer; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 SDL_SW_RenderData *data; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 int i, n; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 int bpp; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 Uint32 Rmask, Gmask, Bmask, Amask; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 if (!SDL_PixelFormatEnumToMasks |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 SDL_SetError("Unknown display format"); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 return NULL; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 renderer = (SDL_Renderer *) SDL_malloc(sizeof(*renderer)); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 if (!renderer) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 SDL_OutOfMemory(); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 return NULL; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 SDL_zerop(renderer); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 data = (SDL_SW_RenderData *) SDL_malloc(sizeof(*data)); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 if (!data) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 SDL_SW_DestroyRenderer(renderer); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 SDL_OutOfMemory(); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 return NULL; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 SDL_zerop(data); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 renderer->CreateTexture = SDL_SW_CreateTexture; |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1676
diff
changeset
|
135 renderer->QueryTexturePixels = SDL_SW_QueryTexturePixels; |
1680
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
136 renderer->SetTexturePalette = SDL_SW_SetTexturePalette; |
1676
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 renderer->UpdateTexture = SDL_SW_UpdateTexture; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 renderer->LockTexture = SDL_SW_LockTexture; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 renderer->UnlockTexture = SDL_SW_UnlockTexture; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 renderer->DirtyTexture = SDL_SW_DirtyTexture; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 renderer->SelectRenderTexture = SDL_SW_SelectRenderTexture; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 renderer->RenderFill = SDL_SW_RenderFill; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 renderer->RenderCopy = SDL_SW_RenderCopy; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 renderer->RenderReadPixels = SDL_SW_RenderReadPixels; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 renderer->RenderWritePixels = SDL_SW_RenderWritePixels; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 renderer->RenderPresent = SDL_SW_RenderPresent; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 renderer->DestroyTexture = SDL_SW_DestroyTexture; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 renderer->DestroyRenderer = SDL_SW_DestroyRenderer; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 renderer->info = SDL_SW_RenderDriver.info; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 renderer->window = window; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 renderer->driverdata = data; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 renderer->info.flags = SDL_Renderer_RenderTarget; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 if (flags & SDL_Renderer_PresentFlip2) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 renderer->info.flags |= SDL_Renderer_PresentFlip2; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 n = 2; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 } else if (flags & SDL_Renderer_PresentFlip3) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 renderer->info.flags |= SDL_Renderer_PresentFlip3; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 n = 3; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 } else { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 renderer->info.flags |= SDL_Renderer_PresentCopy; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 n = 1; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 for (i = 0; i < n; ++i) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 data->screens[i] = |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 Bmask, Amask); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 if (!data->screens[i]) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 SDL_SW_DestroyRenderer(renderer); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 return NULL; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 data->current_screen = 0; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 data->target = data->screens[0]; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 /* Find a render driver that we can use to display data */ |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 for (i = 0; i < window->display->num_render_drivers; ++i) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 SDL_RenderDriver *driver = &window->display->render_drivers[i]; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 if (driver->info.name != SDL_SW_RenderDriver.info.name) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 data->renderer = |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 driver->CreateRenderer(window, SDL_Renderer_PresentDiscard); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 if (data->renderer) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 break; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 if (i == window->display->num_render_drivers) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 SDL_SW_DestroyRenderer(renderer); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 SDL_SetError("Couldn't find display render driver"); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 return NULL; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 return renderer; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 |
1680
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
196 static int |
1676
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 SDL_SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 SDL_Surface *surface; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 int bpp; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 Uint32 Rmask, Gmask, Bmask, Amask; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 /* FIXME: implement this */ |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 return -1; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 if (!SDL_PixelFormatEnumToMasks |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 SDL_SetError("Unknown texture format"); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 return -1; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 surface = |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, Gmask, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 Bmask, Amask); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 if (!surface) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 return -1; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 texture->driverdata = surface; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 return 0; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 |
1680
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
225 static int |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1676
diff
changeset
|
226 SDL_SW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1676
diff
changeset
|
227 void **pixels, int *pitch) |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1676
diff
changeset
|
228 { |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1676
diff
changeset
|
229 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1676
diff
changeset
|
230 |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1676
diff
changeset
|
231 *pixels = surface->pixels; |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1676
diff
changeset
|
232 *pitch = surface->pitch; |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1676
diff
changeset
|
233 return 0; |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1676
diff
changeset
|
234 } |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1676
diff
changeset
|
235 |
1680
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
236 static int |
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
237 SDL_SW_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, |
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
238 SDL_Color * colors, int firstcolor, int ncolors) |
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
239 { |
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
240 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; |
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
241 |
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
242 SDL_SetColors(surface, colors, firstcolor, ncolors); |
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
243 return 0; |
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
244 } |
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
245 |
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
246 static int |
1676
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 SDL_SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 SDL_Rect * rect, const void *pixels, int pitch) |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 Uint8 *src, *dst; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 int row; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 size_t length; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 src = (Uint8 *) pixels; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 dst = |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 (Uint8 *) surface->pixels + rect->y * surface->pitch + |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 rect->x * surface->format->BytesPerPixel; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 length = rect->w * surface->format->BytesPerPixel; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 for (row = 0; row < rect->h; ++row) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 SDL_memcpy(dst, src, length); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 src += pitch; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 dst += surface->pitch; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 return 0; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 |
1680
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
268 static int |
1676
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 SDL_SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 SDL_Rect * rect, int markDirty, void **pixels, int *pitch) |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 *pixels = |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 (void *) ((Uint8 *) surface->pixels + rect->y * surface->pitch + |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 rect->x * surface->format->BytesPerPixel); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 *pitch = surface->pitch; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 return 0; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 |
1680
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
281 static void |
1676
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 SDL_SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 |
1680
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
286 static void |
1676
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 SDL_SW_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 int numrects, SDL_Rect * rects) |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 |
1680
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
292 static void |
1676
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 SDL_SW_SelectRenderTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 data->target = (SDL_Surface *) texture->driverdata; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 |
1680
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
299 static void |
1676
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 SDL_SW_RenderFill(SDL_Renderer * renderer, SDL_Rect * rect, Uint32 color) |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 Uint8 r, g, b, a; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 a = (Uint8) ((color >> 24) & 0xFF); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 r = (Uint8) ((color >> 16) & 0xFF); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 g = (Uint8) ((color >> 8) & 0xFF); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 b = (Uint8) (color & 0xFF); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 color = SDL_MapRGBA(data->target->format, r, g, b, a); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 SDL_FillRect(data->target, rect, color); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 |
1680
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
314 static int |
1676
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 SDL_SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 SDL_Rect * srcrect, SDL_Rect * dstrect, int blendMode, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 int scaleMode) |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 if (blendMode & (SDL_TextureBlendMode_Mask | SDL_TextureBlendMode_Blend)) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 SDL_SetAlpha(surface, SDL_SRCALPHA, 0); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 } else { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 SDL_SetAlpha(surface, 0, 0); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 if (scaleMode != SDL_TextureScaleMode_None && |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 (srcrect->w != dstrect->w || srcrect->h != dstrect->h)) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 return SDL_SoftStretch(surface, srcrect, data->target, dstrect); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 } else { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 return SDL_LowerBlit(surface, srcrect, data->target, dstrect); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 |
1680
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
335 static int |
1676
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 SDL_SW_RenderReadPixels(SDL_Renderer * renderer, SDL_Rect * rect, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 void *pixels, int pitch) |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 SDL_Surface *surface = data->target; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 Uint8 *src, *dst; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 int row; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 size_t length; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 src = |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 (Uint8 *) surface->pixels + rect->y * surface->pitch + |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 rect->x * surface->format->BytesPerPixel; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 dst = (Uint8 *) pixels; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 length = rect->w * surface->format->BytesPerPixel; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 for (row = 0; row < rect->h; ++row) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 SDL_memcpy(dst, src, length); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 src += surface->pitch; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 dst += pitch; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 return 0; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 |
1680
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
358 static int |
1676
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 SDL_SW_RenderWritePixels(SDL_Renderer * renderer, SDL_Rect * rect, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 const void *pixels, int pitch) |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
362 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
363 SDL_Surface *surface = data->target; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
364 Uint8 *src, *dst; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 int row; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 size_t length; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 src = (Uint8 *) pixels; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 dst = |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 (Uint8 *) surface->pixels + rect->y * surface->pitch + |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 rect->x * surface->format->BytesPerPixel; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 length = rect->w * surface->format->BytesPerPixel; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 for (row = 0; row < rect->h; ++row) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
374 SDL_memcpy(dst, src, length); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 src += pitch; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
376 dst += surface->pitch; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
377 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
378 return 0; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 |
1680
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
381 static void |
1676
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 SDL_SW_RenderPresent(SDL_Renderer * renderer) |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 SDL_Surface *surface = data->screens[data->current_screen]; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
386 SDL_Rect rect; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
387 int new_screen; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
388 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 /* Send the data to the display */ |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 /* FIXME: implement dirty rect updates */ |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 rect.x = 0; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 rect.y = 0; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
393 rect.w = surface->w; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 rect.h = surface->h; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 data->renderer->RenderWritePixels(data->renderer, &rect, surface->pixels, |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 surface->pitch); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 data->renderer->RenderPresent(data->renderer); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 /* Update the flipping chain, if any */ |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 if (renderer->info.flags & SDL_Renderer_PresentFlip2) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
401 new_screen = (data->current_screen + 1) % 2; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 } else if (renderer->info.flags & SDL_Renderer_PresentFlip3) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 new_screen = (data->current_screen + 1) % 3; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 } else { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 new_screen = 0; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 if (data->target == data->screens[data->current_screen]) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
408 data->target = data->screens[new_screen]; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
410 data->current_screen = new_screen; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
411 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 |
1680
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
413 static void |
1676
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
414 SDL_SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 SDL_FreeSurface(surface); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
420 |
1680
9488fca10677
Dummy video driver works again in high color video modes. Yay!
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
421 static void |
1676
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
422 SDL_SW_DestroyRenderer(SDL_Renderer * renderer) |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
424 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
425 int i; |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
426 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 if (data) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 for (i = 0; i < SDL_arraysize(data->screens); ++i) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 if (data->screens[i]) { |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 SDL_FreeSurface(data->screens[i]); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
431 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
432 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 SDL_free(data); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
434 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
435 SDL_free(renderer); |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
436 } |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
437 |
e136f3ffdc1b
Adding software renderer implementation
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
438 /* vi: set ts=4 sw=4 expandtab: */ |