Mercurial > sdl-ios-xcode
annotate src/video/photon/SDL_photon_render.c @ 3384:04af265172f9
Continue working on 2D support in Photon.
author | Mike Gorchak <lestat@i.com.ua> |
---|---|
date | Mon, 12 Oct 2009 08:21:43 +0000 |
parents | 90935231e9b6 |
children | fff074de9675 |
rev | line source |
---|---|
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2009 Sam Lantinga |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 QNX Photon GUI SDL driver |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 Copyright (C) 2009 Mike Gorchak |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 (mike@malva.ua, lestat@i.com.ua) |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 */ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 #include "SDL_config.h" |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include "../SDL_pixels_c.h" |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 #include "../SDL_yuv_sw_c.h" |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 #include "SDL_video.h" |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 #include "SDL_photon_render.h" |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 #include "SDL_photon.h" |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 |
3139 | 37 static SDL_Renderer *photon_createrenderer(SDL_Window * window, Uint32 flags); |
38 static int photon_displaymodechanged(SDL_Renderer * renderer); | |
39 static int photon_activaterenderer(SDL_Renderer * renderer); | |
40 static int photon_createtexture(SDL_Renderer * renderer, | |
41 SDL_Texture * texture); | |
42 static int photon_querytexturepixels(SDL_Renderer * renderer, | |
43 SDL_Texture * texture, void **pixels, | |
44 int *pitch); | |
45 static int photon_settexturepalette(SDL_Renderer * renderer, | |
46 SDL_Texture * texture, | |
47 const SDL_Color * colors, int firstcolor, | |
48 int ncolors); | |
49 static int photon_gettexturepalette(SDL_Renderer * renderer, | |
50 SDL_Texture * texture, SDL_Color * colors, | |
51 int firstcolor, int ncolors); | |
52 static int photon_settexturecolormod(SDL_Renderer * renderer, | |
53 SDL_Texture * texture); | |
54 static int photon_settexturealphamod(SDL_Renderer * renderer, | |
55 SDL_Texture * texture); | |
56 static int photon_settextureblendmode(SDL_Renderer * renderer, | |
57 SDL_Texture * texture); | |
58 static int photon_settexturescalemode(SDL_Renderer * renderer, | |
59 SDL_Texture * texture); | |
60 static int photon_updatetexture(SDL_Renderer * renderer, | |
61 SDL_Texture * texture, const SDL_Rect * rect, | |
62 const void *pixels, int pitch); | |
63 static int photon_locktexture(SDL_Renderer * renderer, SDL_Texture * texture, | |
64 const SDL_Rect * rect, int markDirty, | |
65 void **pixels, int *pitch); | |
66 static void photon_unlocktexture(SDL_Renderer * renderer, | |
67 SDL_Texture * texture); | |
68 static void photon_dirtytexture(SDL_Renderer * renderer, | |
69 SDL_Texture * texture, int numrects, | |
70 const SDL_Rect * rects); | |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
71 static int photon_setdrawcolor(SDL_Renderer * renderer); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
72 static int photon_setdrawblendmode(SDL_Renderer * renderer); |
3139 | 73 static int photon_renderpoint(SDL_Renderer * renderer, int x, int y); |
74 static int photon_renderline(SDL_Renderer * renderer, int x1, int y1, int x2, | |
75 int y2); | |
76 static int photon_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect); | |
77 static int photon_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture, | |
78 const SDL_Rect * srcrect, | |
79 const SDL_Rect * dstrect); | |
80 static void photon_renderpresent(SDL_Renderer * renderer); | |
81 static void photon_destroytexture(SDL_Renderer * renderer, | |
82 SDL_Texture * texture); | |
83 static void photon_destroyrenderer(SDL_Renderer * renderer); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
85 static int _photon_recreate_surfaces(SDL_Renderer * renderer); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
86 |
3139 | 87 SDL_RenderDriver photon_renderdriver = { |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 photon_createrenderer, |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 { |
3139 | 90 "photon", |
91 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | | |
92 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | | |
93 SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD | | |
94 SDL_RENDERER_ACCELERATED), | |
95 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | | |
96 SDL_TEXTUREMODULATE_ALPHA), | |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
97 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND), |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
98 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_SLOW | |
3384
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
99 SDL_TEXTURESCALEMODE_FAST), |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
100 10, |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
101 {SDL_PIXELFORMAT_INDEX8, |
3139 | 102 SDL_PIXELFORMAT_RGB555, |
103 SDL_PIXELFORMAT_RGB565, | |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
104 SDL_PIXELFORMAT_RGB24, |
3139 | 105 SDL_PIXELFORMAT_RGB888, |
106 SDL_PIXELFORMAT_ARGB8888, | |
107 SDL_PIXELFORMAT_YV12, | |
108 SDL_PIXELFORMAT_YUY2, | |
109 SDL_PIXELFORMAT_UYVY, | |
110 SDL_PIXELFORMAT_YVYU}, | |
111 0, | |
112 0} | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 }; |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 |
3139 | 115 static SDL_Renderer * |
116 photon_createrenderer(SDL_Window * window, Uint32 flags) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 { |
3139 | 118 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
119 SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; | |
120 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | |
121 SDL_Renderer *renderer = NULL; | |
122 SDL_RenderData *rdata = NULL; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 |
3139 | 124 /* Allocate new renderer structure */ |
125 renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(SDL_Renderer)); | |
126 if (renderer == NULL) { | |
127 SDL_OutOfMemory(); | |
128 return NULL; | |
129 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 |
3139 | 131 /* Allocate renderer data */ |
132 rdata = (SDL_RenderData *) SDL_calloc(1, sizeof(SDL_RenderData)); | |
133 if (rdata == NULL) { | |
134 SDL_free(renderer); | |
135 SDL_OutOfMemory(); | |
136 return NULL; | |
137 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 |
3139 | 139 renderer->DisplayModeChanged = photon_displaymodechanged; |
140 renderer->ActivateRenderer = photon_activaterenderer; | |
141 renderer->CreateTexture = photon_createtexture; | |
142 renderer->QueryTexturePixels = photon_querytexturepixels; | |
143 renderer->SetTexturePalette = photon_settexturepalette; | |
144 renderer->GetTexturePalette = photon_gettexturepalette; | |
145 renderer->SetTextureAlphaMod = photon_settexturealphamod; | |
146 renderer->SetTextureColorMod = photon_settexturecolormod; | |
147 renderer->SetTextureBlendMode = photon_settextureblendmode; | |
148 renderer->SetTextureScaleMode = photon_settexturescalemode; | |
149 renderer->UpdateTexture = photon_updatetexture; | |
150 renderer->LockTexture = photon_locktexture; | |
151 renderer->UnlockTexture = photon_unlocktexture; | |
152 renderer->DirtyTexture = photon_dirtytexture; | |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
153 renderer->SetDrawColor = photon_setdrawcolor; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
154 renderer->SetDrawBlendMode = photon_setdrawblendmode; |
3139 | 155 renderer->RenderPoint = photon_renderpoint; |
156 renderer->RenderLine = photon_renderline; | |
157 renderer->RenderFill = photon_renderfill; | |
158 renderer->RenderCopy = photon_rendercopy; | |
159 renderer->RenderPresent = photon_renderpresent; | |
160 renderer->DestroyTexture = photon_destroytexture; | |
161 renderer->DestroyRenderer = photon_destroyrenderer; | |
162 renderer->info = photon_renderdriver.info; | |
163 renderer->window = window->id; | |
164 renderer->driverdata = rdata; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 |
3139 | 166 /* Set render acceleration flag in case it is accelerated */ |
167 if ((didata->caps & SDL_PHOTON_ACCELERATED) == SDL_PHOTON_ACCELERATED) { | |
168 renderer->info.flags = SDL_RENDERER_ACCELERATED; | |
169 } else { | |
3384
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
170 renderer->info.flags = 0; |
3139 | 171 } |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 |
3139 | 173 /* Check if upper level requested synchronization on vsync signal */ |
174 if ((flags & SDL_RENDERER_PRESENTVSYNC) == SDL_RENDERER_PRESENTVSYNC) { | |
175 rdata->enable_vsync = SDL_TRUE; | |
176 } else { | |
177 rdata->enable_vsync = SDL_FALSE; | |
178 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 |
3139 | 180 /* Check what buffer copy/flip scheme is requested */ |
181 rdata->surfaces_count = 0; | |
182 if ((flags & SDL_RENDERER_SINGLEBUFFER) == SDL_RENDERER_SINGLEBUFFER) { | |
183 if ((flags & SDL_RENDERER_PRESENTDISCARD) == | |
184 SDL_RENDERER_PRESENTDISCARD) { | |
185 renderer->info.flags |= | |
186 SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD; | |
187 } else { | |
188 renderer->info.flags |= | |
189 SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY; | |
190 } | |
191 rdata->surfaces_count = 1; | |
192 rdata->surface_visible_idx = 0; | |
193 rdata->surface_render_idx = 0; | |
194 } else { | |
195 if ((flags & SDL_RENDERER_PRESENTFLIP2) == SDL_RENDERER_PRESENTFLIP2) { | |
196 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; | |
197 rdata->surfaces_count = 2; | |
198 rdata->surface_visible_idx = 0; | |
199 rdata->surface_render_idx = 1; | |
200 } else { | |
201 if ((flags & SDL_RENDERER_PRESENTFLIP3) == | |
202 SDL_RENDERER_PRESENTFLIP3) { | |
203 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3; | |
204 rdata->surfaces_count = 3; | |
205 rdata->surface_visible_idx = 0; | |
206 rdata->surface_render_idx = 1; | |
207 } else { | |
208 renderer->info.flags |= | |
209 SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY; | |
210 rdata->surfaces_count = 1; | |
211 rdata->surface_visible_idx = 0; | |
212 rdata->surface_render_idx = 0; | |
213 } | |
214 } | |
215 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 |
3384
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
217 /* Create new graphics context for the renderer */ |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
218 if (rdata->gc==NULL) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
219 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
220 rdata->gc=PgCreateGC(0); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
221 PgDefaultGC(rdata->gc); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
222 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
223 |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
224 /* Setup textures supported by current renderer instance */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
225 renderer->info.num_texture_formats=1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
226 renderer->info.texture_formats[0]=didata->current_mode.format; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
227 |
3384
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
228 /* Initialize surfaces */ |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
229 _photon_recreate_surfaces(renderer); |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
230 |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
231 /* Set current scale blitting capabilities */ |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
232 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_OFFSCREEN) |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
233 { |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
234 renderer->info.scale_modes=SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_SLOW; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
235 if ((didata->mode_2dcaps & SDL_VIDEO_CAP_SCALED_BLIT)==SDL_VIDEO_CAP_SCALED_BLIT) |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
236 { |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
237 /* This video mode supports hardware scaling */ |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
238 renderer->info.scale_modes|=SDL_TEXTURESCALEMODE_FAST; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
239 } |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
240 } |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
241 else |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
242 { |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
243 /* PhImage blit functions do not support scaling */ |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
244 renderer->info.scale_modes=SDL_TEXTURESCALEMODE_NONE; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
245 } |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
246 |
3139 | 247 return renderer; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 |
3139 | 250 void |
251 photon_addrenderdriver(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 { |
3139 | 253 uint32_t it; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 |
3139 | 255 for (it = 0; it < _this->num_displays; it++) { |
256 SDL_AddRenderDriver(it, &photon_renderdriver); | |
257 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 /****************************************************************************/ |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
261 /* Render helper functions */ |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 /****************************************************************************/ |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
263 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
264 static int _photon_recreate_surfaces(SDL_Renderer * renderer) |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 { |
3139 | 266 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
267 SDL_VideoDisplay *display = NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
268 SDL_DisplayData *didata = NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
269 SDL_Window *window = NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
270 SDL_WindowData *wdata = NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
271 SDL_VideoData *phdata = NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
272 uint32_t allocate_task=SDL_PHOTON_SURFTYPE_UNKNOWN; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
273 int32_t status; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
275 /* Obtain window and display structures */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
276 window=SDL_GetWindowFromID(renderer->window); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
277 wdata=(SDL_WindowData*)window->driverdata; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
278 display=SDL_GetDisplayFromWindow(window); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
279 didata=(SDL_DisplayData *) display->driverdata; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
280 phdata=(SDL_VideoData *) display->device->driverdata; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
281 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
282 /* Check if it is OpenGL ES window */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
283 if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
284 /* If so, do not waste surfaces */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
285 rdata->surfaces_type=SDL_PHOTON_SURFTYPE_UNKNOWN; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
286 return 0; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
287 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
288 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
289 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
290 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
291 /* Try to allocate offscreen surfaces */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
292 allocate_task=SDL_PHOTON_SURFTYPE_OFFSCREEN; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
293 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
294 else |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
295 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
296 uint32_t it; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
297 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
298 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_OFFSCREEN) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
299 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
300 /* Create offscreen surfaces */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
301 allocate_task=SDL_PHOTON_SURFTYPE_OFFSCREEN; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
302 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
303 /* Destroy current surfaces */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
304 for (it=0; it<SDL_PHOTON_MAX_SURFACES; it++) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
305 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
306 if (rdata->osurfaces[it] != NULL) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
307 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
308 PhDCRelease(rdata->osurfaces[it]); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
309 rdata->osurfaces[it] = NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
310 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
311 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
312 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
313 else |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
314 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
315 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_PHIMAGE) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
316 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
317 /* Create shared phimage surfaces */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
318 allocate_task=SDL_PHOTON_SURFTYPE_PHIMAGE; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
319 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
320 /* Destroy current surfaces */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
321 for (it=0; it<SDL_PHOTON_MAX_SURFACES; it++) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
322 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
323 if (rdata->pcontexts[it]!=NULL) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
324 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
325 PmMemReleaseMC(rdata->pcontexts[it]); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
326 rdata->pcontexts[it]=NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
327 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
328 if (rdata->psurfaces[it]!=NULL) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
329 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
330 if (rdata->psurfaces[it]->palette!=NULL) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
331 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
332 SDL_free(rdata->psurfaces[it]->palette); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
333 rdata->psurfaces[it]->palette=NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
334 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
335 /* Destroy shared memory for PhImage_t */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
336 PgShmemDestroy(rdata->psurfaces[it]->image); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
337 rdata->psurfaces[it]->image=NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
338 SDL_free(rdata->psurfaces[it]); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
339 rdata->psurfaces[it]=NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
340 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
341 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
342 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
343 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
344 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
345 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
346 /* Check if current device is not the same as target */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
347 if (phdata->current_device_id != didata->device_id) { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
348 /* Set target device as default for Pd and Pg functions */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
349 status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
350 if (status != 0) { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
351 SDL_SetError("Photon: Can't set default target device\n"); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
352 return -1; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
353 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
354 phdata->current_device_id = didata->device_id; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
355 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
356 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
357 switch (allocate_task) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
358 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
359 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
360 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
361 int32_t it; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
362 int32_t jt; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
363 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
364 /* Try the hardware accelerated offscreen surfaces first */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
365 for (it=0; it<rdata->surfaces_count; it++) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
366 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
367 rdata->osurfaces[it]=PdCreateOffscreenContext(0, window->w, window->h, |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
368 Pg_OSC_MEM_LINEAR_ACCESSIBLE | Pg_OSC_MEM_PAGE_ALIGN | |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
369 /* in case if 2D acceleration is available use it */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
370 Pg_OSC_MEM_2D_WRITABLE | Pg_OSC_MEM_2D_READABLE); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
371 /* If we can't create an offscreen surface, then fallback to software */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
372 if (rdata->osurfaces[it]==NULL) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
373 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
374 /* Destroy previously allocated surface(s) */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
375 for (jt = it - 1; jt > 0; jt--) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
376 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
377 PhDCRelease(rdata->osurfaces[jt]); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
378 rdata->osurfaces[jt] = NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
379 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
380 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
381 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
382 } |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
384 /* Check if all required surfaces have been created */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
385 if (rdata->osurfaces[0]!=NULL) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
386 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
387 rdata->surfaces_type=SDL_PHOTON_SURFTYPE_OFFSCREEN; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
388 /* exit from switch if surfaces have been created */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
389 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
390 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
391 else |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
392 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
393 /* else fall through to software phimage surface allocation */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
394 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
395 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
396 /* fall through */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
397 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
398 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
399 int32_t it; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
400 int32_t jt; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
401 uint32_t image_pfmt=photon_sdl_to_image_pixelformat(didata->current_mode.format); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
402 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
403 /* Try to allocate the software surfaces in shared memory */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
404 for (it=0; it<rdata->surfaces_count; it++) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
405 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
406 /* If this surface with palette, create a palette space */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
407 if (image_pfmt==Pg_IMAGE_PALETTE_BYTE) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
408 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
409 rdata->psurfaces[it]=PhCreateImage(NULL, window->w, window->h, |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
410 image_pfmt, NULL, 256, 1); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
411 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
412 else |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
413 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
414 rdata->psurfaces[it]=PhCreateImage(NULL, window->w, window->h, |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
415 image_pfmt, NULL, 0, 1); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
416 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
417 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
418 if (rdata->psurfaces[it]!=NULL) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
419 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
420 PhPoint_t translation={0, 0}; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
421 PhDim_t dimension={window->w, window->h}; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
422 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
423 /* Create memory context for PhImage_t */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
424 rdata->pcontexts[it]=PmMemCreateMC(rdata->psurfaces[it], &dimension, &translation); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
425 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
426 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
427 if ((rdata->psurfaces[it]==NULL) || (rdata->pcontexts[it]==NULL)) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
428 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
429 /* Destroy previously allocated surface(s) */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
430 for (jt = it - 1; jt > 0; jt--) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
431 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
432 if (rdata->pcontexts[jt]!=NULL) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
433 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
434 PmMemReleaseMC(rdata->pcontexts[it]); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
435 rdata->pcontexts[jt]=NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
436 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
437 if (rdata->psurfaces[jt]!=NULL) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
438 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
439 if (rdata->psurfaces[jt]->palette!=NULL) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
440 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
441 SDL_free(rdata->psurfaces[jt]->palette); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
442 rdata->psurfaces[jt]->palette=NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
443 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
444 /* Destroy shared memory for PhImage_t */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
445 PgShmemDestroy(rdata->psurfaces[jt]->image); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
446 rdata->psurfaces[jt]->image=NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
447 SDL_free(rdata->psurfaces[jt]); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
448 rdata->psurfaces[jt] = NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
449 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
450 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
451 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
452 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
453 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
454 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
455 /* Check if all required surfaces have been created */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
456 if (rdata->psurfaces[0]!=NULL) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
457 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
458 rdata->surfaces_type=SDL_PHOTON_SURFTYPE_PHIMAGE; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
459 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
460 else |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
461 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
462 rdata->surfaces_type=SDL_PHOTON_SURFTYPE_UNKNOWN; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
463 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
464 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
465 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
466 case SDL_PHOTON_SURFTYPE_UNKNOWN: |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
467 default: |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
468 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
469 /* do nothing with surface allocation */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
470 rdata->surfaces_type=SDL_PHOTON_SURFTYPE_UNKNOWN; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
471 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
472 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
473 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
474 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
475 /* Check if one of two allocation scheme was successful */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
476 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
477 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
478 SDL_SetError("Photon: primary surface(s) allocation failure"); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
479 return -1; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
480 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
481 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
482 /* Store current surface dimensions */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
483 rdata->window_width=window->w; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
484 rdata->window_height=window->h; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
485 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
486 /* If current copy/flip scheme is single buffer, then set initial parameters */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
487 if ((renderer->info.flags & SDL_RENDERER_SINGLEBUFFER)==SDL_RENDERER_SINGLEBUFFER) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
488 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
489 rdata->surface_visible_idx = 0; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
490 rdata->surface_render_idx = 0; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
491 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
492 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
493 /* If current copy/flip scheme is double buffer, then set initial parameters */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
494 if ((renderer->info.flags & SDL_RENDERER_PRESENTFLIP2)==SDL_RENDERER_PRESENTFLIP2) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
495 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
496 rdata->surface_visible_idx = 0; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
497 rdata->surface_render_idx = 1; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
498 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
499 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
500 /* If current copy/flip scheme is triple buffer, then set initial parameters */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
501 if ((renderer->info.flags & SDL_RENDERER_PRESENTFLIP3)==SDL_RENDERER_PRESENTFLIP3) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
502 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
503 rdata->surface_visible_idx = 0; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
504 rdata->surface_render_idx = 1; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
505 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
506 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
507 switch (rdata->surfaces_type) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
508 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
509 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
510 PgSetGCCx(rdata->osurfaces[rdata->surface_render_idx], rdata->gc); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
511 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
512 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
513 PgSetGCCx(rdata->pcontexts[rdata->surface_render_idx], rdata->gc); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
514 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
515 case SDL_PHOTON_SURFTYPE_UNKNOWN: |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
516 default: |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
517 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
518 } |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
519 |
3139 | 520 return 0; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
521 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
522 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
523 int _photon_update_rectangles(SDL_Renderer* renderer, PhRect_t* rect) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
524 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
525 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
526 SDL_Window *window = window=SDL_GetWindowFromID(renderer->window); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
527 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
528 PhPoint_t src_point; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
529 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
530 /* If currently single buffer is in use, we have to flush all data */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
531 if (rdata->surface_render_idx==rdata->surface_visible_idx) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
532 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
533 /* Flush all undrawn graphics data to surface */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
534 switch (rdata->surfaces_type) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
535 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
536 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
537 PgFlushCx(rdata->osurfaces[rdata->surface_visible_idx]); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
538 PgWaitHWIdle(); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
539 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
540 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
541 PmMemFlush(rdata->pcontexts[rdata->surface_visible_idx], rdata->psurfaces[rdata->surface_visible_idx]); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
542 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
543 case SDL_PHOTON_SURFTYPE_UNKNOWN: |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
544 default: |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
545 return; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
546 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
547 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
548 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
549 PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window)); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
550 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
551 src_point.x = rect->ul.x; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
552 src_point.y = rect->ul.y; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
553 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
554 switch (rdata->surfaces_type) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
555 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
556 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
557 PgContextBlit(rdata->osurfaces[rdata->surface_visible_idx], rect, NULL, rect); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
558 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
559 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
560 PgDrawPhImageRectv(&src_point, rdata->psurfaces[rdata->surface_visible_idx], rect, 0); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
561 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
562 case SDL_PHOTON_SURFTYPE_UNKNOWN: |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
563 default: |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
564 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
565 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
566 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
567 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
568 /****************************************************************************/ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
569 /* SDL render interface */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
570 /****************************************************************************/ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
571 |
3139 | 572 static int |
573 photon_activaterenderer(SDL_Renderer * renderer) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
574 { |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
575 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
576 SDL_Window *window = SDL_GetWindowFromID(renderer->window); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
577 SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
578 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
579 if ((rdata->window_width!=window->w) || (rdata->window_height!=window->h)) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
580 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
581 return _photon_recreate_surfaces(renderer); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
582 } |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
583 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
584 switch (rdata->surfaces_type) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
585 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
586 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
587 PgSetGCCx(rdata->osurfaces[rdata->surface_render_idx], rdata->gc); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
588 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
589 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
590 PgSetGCCx(rdata->pcontexts[rdata->surface_render_idx], rdata->gc); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
591 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
592 case SDL_PHOTON_SURFTYPE_UNKNOWN: |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
593 default: |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
594 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
595 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
596 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
597 return 0; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
598 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
599 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
600 static int |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
601 photon_displaymodechanged(SDL_Renderer * renderer) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
602 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
603 return _photon_recreate_surfaces(renderer); |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
604 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
605 |
3139 | 606 static int |
607 photon_createtexture(SDL_Renderer * renderer, SDL_Texture * texture) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
608 { |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
609 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
3139 | 610 SDL_Window *window = SDL_GetWindowFromID(renderer->window); |
611 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); | |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
612 SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; |
3139 | 613 SDL_TextureData *tdata = NULL; |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
614 uint32_t it; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
615 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
616 /* Check, if it is not initialized */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
617 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
618 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
619 SDL_SetError("Photon: can't create texture for OpenGL ES window"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
620 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
621 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
622 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
623 /* Check if requested texture format is supported */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
624 for (it=0; it<renderer->info.num_texture_formats; it++) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
625 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
626 if (renderer->info.texture_formats[it]==texture->format) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
627 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
628 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
629 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
630 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
631 if (it==renderer->info.num_texture_formats) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
632 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
633 SDL_SetError("Photon: requested texture format is not supported"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
634 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
635 } |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
636 |
3139 | 637 /* Allocate texture driver data */ |
638 tdata = (SDL_TextureData *) SDL_calloc(1, sizeof(SDL_TextureData)); | |
639 if (tdata == NULL) { | |
640 SDL_OutOfMemory(); | |
641 return -1; | |
642 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
643 |
3139 | 644 /* Set texture driver data */ |
645 texture->driverdata = tdata; | |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
646 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
647 /* Try offscreen allocation only in case if displayable buffers are also offscreen */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
648 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_OFFSCREEN) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
649 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
650 /* Try to allocate offscreen memory first */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
651 tdata->osurface=PdCreateOffscreenContext(0, texture->w, texture->h, |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
652 Pg_OSC_MEM_LINEAR_ACCESSIBLE | Pg_OSC_MEM_PAGE_ALIGN | |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
653 /* in case if 2D acceleration is available use it */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
654 Pg_OSC_MEM_2D_WRITABLE | Pg_OSC_MEM_2D_READABLE); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
655 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
656 |
3384
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
657 /* Check if offscreen allocation has been failed or not performed */ |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
658 if (tdata->osurface==NULL) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
659 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
660 PhPoint_t translation={0, 0}; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
661 PhDim_t dimension={texture->w, texture->h}; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
662 uint32_t image_pfmt=photon_sdl_to_image_pixelformat(didata->current_mode.format); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
663 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
664 /* Allocate photon image */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
665 if (image_pfmt==Pg_IMAGE_PALETTE_BYTE) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
666 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
667 tdata->psurface=PhCreateImage(NULL, texture->w, texture->h, |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
668 image_pfmt, NULL, 256, 1); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
669 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
670 else |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
671 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
672 tdata->psurface=PhCreateImage(NULL, texture->w, texture->h, |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
673 image_pfmt, NULL, 0, 1); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
674 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
675 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
676 if (tdata->psurface==NULL) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
677 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
678 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
679 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
680 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
681 /* Create memory context for PhImage_t */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
682 tdata->pcontext=PmMemCreateMC(tdata->psurface, &dimension, &translation); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
683 if (tdata->pcontext==NULL) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
684 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
685 /* Destroy PhImage */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
686 if (tdata->psurface!=NULL) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
687 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
688 if (tdata->psurface->palette!=NULL) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
689 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
690 SDL_free(tdata->psurface->palette); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
691 tdata->psurface->palette=NULL; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
692 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
693 /* Destroy shared memory for PhImage_t */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
694 PgShmemDestroy(tdata->psurface->image); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
695 tdata->psurface->image=NULL; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
696 SDL_free(tdata->psurface); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
697 tdata->psurface=NULL; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
698 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
699 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
700 tdata->surface_type=SDL_PHOTON_SURFTYPE_PHIMAGE; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
701 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
702 else |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
703 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
704 tdata->surface_type=SDL_PHOTON_SURFTYPE_OFFSCREEN; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
705 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
706 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
707 return 0; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
708 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
709 |
3139 | 710 static int |
711 photon_querytexturepixels(SDL_Renderer * renderer, SDL_Texture * texture, | |
712 void **pixels, int *pitch) | |
713 { | |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
714 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
715 SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
716 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
717 /* Check, if it is not initialized */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
718 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
719 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
720 SDL_SetError("Photon: can't query texture pixels for OpenGL ES window"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
721 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
722 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
723 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
724 /* Clear outcoming parameters */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
725 *pixels=NULL; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
726 *pitch=0; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
727 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
728 switch (tdata->surface_type) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
729 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
730 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
731 *pixels=(void*)PdGetOffscreenContextPtr(tdata->osurface); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
732 *pitch=tdata->osurface->pitch; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
733 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
734 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
735 *pixels=(void*)tdata->psurface->image; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
736 *pitch=tdata->psurface->bpl; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
737 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
738 default: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
739 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
740 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
741 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
742 return 0; |
3139 | 743 } |
744 | |
745 static int | |
746 photon_settexturepalette(SDL_Renderer * renderer, SDL_Texture * texture, | |
747 const SDL_Color * colors, int firstcolor, | |
748 int ncolors) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
749 { |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
750 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
751 SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
752 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
753 /* Check, if it is not initialized */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
754 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
755 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
756 SDL_SetError("Photon: can't set texture palette for OpenGL ES window"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
757 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
758 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
759 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
760 if (texture->format!=SDL_PIXELFORMAT_INDEX8) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
761 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
762 SDL_SetError("Photon: can't set palette for non-paletted texture"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
763 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
764 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
765 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
766 return -1; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
767 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
768 |
3139 | 769 static int |
770 photon_gettexturepalette(SDL_Renderer * renderer, SDL_Texture * texture, | |
771 SDL_Color * colors, int firstcolor, int ncolors) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
772 { |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
773 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
774 SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
775 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
776 /* Check, if it is not initialized */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
777 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
778 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
779 SDL_SetError("Photon: can't return texture palette for OpenGL ES window"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
780 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
781 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
782 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
783 if (texture->format!=SDL_PIXELFORMAT_INDEX8) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
784 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
785 SDL_SetError("Photon: can't return palette for non-paletted texture"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
786 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
787 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
788 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
789 return -1; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
790 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
791 |
3139 | 792 static int |
793 photon_settexturecolormod(SDL_Renderer * renderer, SDL_Texture * texture) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
794 { |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
795 /* TODO */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
796 return -1; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
797 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
798 |
3139 | 799 static int |
800 photon_settexturealphamod(SDL_Renderer * renderer, SDL_Texture * texture) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
801 { |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
802 /* TODO */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
803 return -1; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
804 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
805 |
3139 | 806 static int |
807 photon_settextureblendmode(SDL_Renderer * renderer, SDL_Texture * texture) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
808 { |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
809 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
810 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
811 /* Check, if it is not initialized */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
812 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
813 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
814 SDL_SetError("Photon: can't set texture blend mode for OpenGL ES window"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
815 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
816 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
817 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
818 switch (texture->blendMode) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
819 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
820 case SDL_BLENDMODE_NONE: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
821 case SDL_BLENDMODE_MASK: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
822 case SDL_BLENDMODE_BLEND: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
823 return 0; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
824 case SDL_BLENDMODE_ADD: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
825 case SDL_BLENDMODE_MOD: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
826 default: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
827 SDL_Unsupported(); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
828 texture->blendMode = SDL_BLENDMODE_NONE; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
829 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
830 } |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
831 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
832 |
3139 | 833 static int |
834 photon_settexturescalemode(SDL_Renderer * renderer, SDL_Texture * texture) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
835 { |
3384
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
836 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
837 |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
838 switch (texture->scaleMode) |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
839 { |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
840 case SDL_TEXTURESCALEMODE_NONE: |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
841 return 0; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
842 case SDL_TEXTURESCALEMODE_FAST: |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
843 if ((renderer->info.scale_modes & SDL_TEXTURESCALEMODE_FAST)==SDL_TEXTURESCALEMODE_FAST) |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
844 { |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
845 return 0; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
846 } |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
847 else |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
848 { |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
849 SDL_Unsupported(); |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
850 texture->scaleMode = SDL_TEXTURESCALEMODE_FAST; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
851 return -1; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
852 } |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
853 break; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
854 case SDL_TEXTURESCALEMODE_SLOW: |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
855 if ((renderer->info.scale_modes & SDL_TEXTURESCALEMODE_SLOW)==SDL_TEXTURESCALEMODE_SLOW) |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
856 { |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
857 return 0; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
858 } |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
859 else |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
860 { |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
861 SDL_Unsupported(); |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
862 texture->scaleMode = SDL_TEXTURESCALEMODE_SLOW; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
863 return -1; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
864 } |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
865 break; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
866 case SDL_TEXTURESCALEMODE_BEST: |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
867 SDL_Unsupported(); |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
868 texture->scaleMode = SDL_TEXTURESCALEMODE_SLOW; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
869 return -1; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
870 default: |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
871 SDL_Unsupported(); |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
872 texture->scaleMode = SDL_TEXTURESCALEMODE_NONE; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
873 return -1; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
874 } |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
875 |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
876 return -1; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
877 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
878 |
3139 | 879 static int |
880 photon_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture, | |
881 const SDL_Rect * rect, const void *pixels, int pitch) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
882 { |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
883 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
884 SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
885 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
886 uint8_t* src=(uint8_t*)pixels; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
887 uint8_t* dst; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
888 uint32_t dst_pitch; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
889 uint32_t it; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
890 uint32_t copy_length; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
891 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
892 /* Check, if it is not initialized */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
893 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
894 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
895 SDL_SetError("Photon: can't update texture for OpenGL ES window"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
896 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
897 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
898 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
899 switch (tdata->surface_type) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
900 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
901 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
902 dst=(uint8_t*)PdGetOffscreenContextPtr(tdata->osurface); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
903 dst_pitch=tdata->osurface->pitch; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
904 if (dst==NULL) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
905 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
906 SDL_SetError("Photon: can't get pointer to texture surface"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
907 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
908 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
909 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
910 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
911 dst=(uint8_t*)tdata->psurface->image; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
912 dst_pitch=tdata->psurface->bpl; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
913 if (dst==NULL) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
914 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
915 SDL_SetError("Photon: can't get pointer to texture surface"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
916 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
917 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
918 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
919 default: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
920 SDL_SetError("Photon: invalid internal surface type"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
921 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
922 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
923 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
924 dst+=rect->y * dst_pitch + rect->x * SDL_BYTESPERPIXEL(texture->format); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
925 copy_length=rect->w * SDL_BYTESPERPIXEL(texture->format); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
926 for (it = 0; it < rect->h; it++) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
927 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
928 SDL_memcpy(dst, src, copy_length); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
929 src+=pitch; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
930 dst+=dst_pitch; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
931 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
932 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
933 return 0; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
934 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
935 |
3139 | 936 static int |
937 photon_locktexture(SDL_Renderer * renderer, SDL_Texture * texture, | |
938 const SDL_Rect * rect, int markDirty, void **pixels, | |
939 int *pitch) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
940 { |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
941 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
942 SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
943 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
944 /* Check, if it is not initialized */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
945 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
946 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
947 SDL_SetError("Photon: can't lock texture for OpenGL ES window"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
948 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
949 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
950 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
951 /* Clear outcoming parameters */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
952 *pixels=NULL; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
953 *pitch=0; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
954 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
955 switch (tdata->surface_type) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
956 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
957 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
958 *pixels=(void*)((uint8_t*)PdGetOffscreenContextPtr(tdata->osurface) + |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
959 rect->y * tdata->osurface->pitch + |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
960 rect->x * SDL_BYTESPERPIXEL(texture->format)); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
961 *pitch=tdata->osurface->pitch; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
962 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
963 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
964 *pixels=(void*)((uint8_t*)tdata->psurface->image + |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
965 rect->y * tdata->osurface->pitch + |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
966 rect->x * SDL_BYTESPERPIXEL(texture->format)); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
967 *pitch=tdata->psurface->bpl; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
968 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
969 default: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
970 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
971 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
972 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
973 return 0; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
974 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
975 |
3139 | 976 static void |
977 photon_unlocktexture(SDL_Renderer * renderer, SDL_Texture * texture) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
978 { |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
979 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
980 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
981 /* Check, if it is not initialized */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
982 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
983 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
984 SDL_SetError("Photon: can't unlock texture for OpenGL ES window"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
985 return; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
986 } |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
987 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
988 |
3139 | 989 static void |
990 photon_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture, | |
991 int numrects, const SDL_Rect * rects) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
992 { |
3384
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
993 /* Check, if it is not initialized */ |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
994 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
995 { |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
996 SDL_SetError("Photon: can't update dirty texture for OpenGL ES window"); |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
997 return; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
998 } |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
999 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1000 |
3139 | 1001 static int |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1002 photon_setdrawcolor(SDL_Renderer * renderer) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1003 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1004 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1005 |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1006 /* Check, if it is not initialized */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1007 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1008 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1009 SDL_SetError("Photon: can't set draw color for OpenGL ES window"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1010 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1011 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1012 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1013 switch (rdata->surfaces_type) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1014 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1015 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1016 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1017 PgSetFillColorCx(rdata->gc, PgRGB(renderer->r, renderer->g, renderer->b)); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1018 PgSetStrokeColorCx(rdata->gc, PgRGB(renderer->r, renderer->g, renderer->b)); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1019 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1020 case SDL_PHOTON_SURFTYPE_UNKNOWN: |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1021 default: |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1022 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1023 } |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1024 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1025 return 0; |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1026 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1027 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1028 static int |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1029 photon_setdrawblendmode(SDL_Renderer * renderer) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1030 { |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1031 /* TODO */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1032 return -1; |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1033 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1034 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1035 static int |
3139 | 1036 photon_renderpoint(SDL_Renderer * renderer, int x, int y) |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1037 { |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1038 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1039 |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1040 /* Check, if it is not initialized */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1041 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1042 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1043 SDL_SetError("Photon: can't render point in OpenGL ES window"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1044 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1045 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1046 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1047 switch (rdata->surfaces_type) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1048 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1049 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1050 PgDrawIPixelCx(rdata->osurfaces[rdata->surface_render_idx], x, y); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1051 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1052 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1053 PgDrawIPixelCx(rdata->pcontexts[rdata->surface_render_idx], x, y); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1054 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1055 case SDL_PHOTON_SURFTYPE_UNKNOWN: |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1056 default: |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1057 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1058 } |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1059 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1060 return 0; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1061 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1062 |
3139 | 1063 static int |
1064 photon_renderline(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1065 { |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1066 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1067 |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1068 /* Check, if it is not initialized */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1069 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1070 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1071 SDL_SetError("Photon: can't render line in OpenGL ES window"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1072 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1073 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1074 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1075 switch (rdata->surfaces_type) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1076 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1077 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1078 PgDrawILineCx(rdata->osurfaces[rdata->surface_render_idx], x1, y1, x2, y2); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1079 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1080 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1081 PgDrawILineCx(rdata->pcontexts[rdata->surface_render_idx], x1, y1, x2, y2); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1082 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1083 case SDL_PHOTON_SURFTYPE_UNKNOWN: |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1084 default: |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1085 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1086 } |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1087 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1088 return 0; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1089 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1090 |
3139 | 1091 static int |
1092 photon_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1093 { |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1094 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1095 |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1096 /* Check, if it is not initialized */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1097 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1098 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1099 SDL_SetError("Photon: can't render filled box in OpenGL ES window"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1100 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1101 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1102 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1103 switch (rdata->surfaces_type) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1104 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1105 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1106 PgDrawIRectCx(rdata->osurfaces[rdata->surface_render_idx], rect->x, rect->y, rect->w+rect->x-1, rect->h+rect->y-1, Pg_DRAW_FILL); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1107 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1108 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1109 PgDrawIRectCx(rdata->pcontexts[rdata->surface_render_idx], rect->x, rect->y, rect->w+rect->x-1, rect->h+rect->y-1, Pg_DRAW_FILL); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1110 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1111 case SDL_PHOTON_SURFTYPE_UNKNOWN: |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1112 default: |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1113 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1114 } |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1115 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1116 |
3139 | 1117 static int |
1118 photon_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture, | |
1119 const SDL_Rect * srcrect, const SDL_Rect * dstrect) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1120 { |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1121 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1122 SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1123 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1124 PhRect_t src_rect; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1125 PhRect_t dst_rect; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1126 PhPoint_t dst_point; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1127 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1128 /* Check, if it is not initialized */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1129 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1130 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1131 SDL_SetError("Photon: can't blit textures in OpenGL ES window"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1132 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1133 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1134 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1135 /* Switch on requested graphics context modifiers */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1136 switch(texture->blendMode) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1137 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1138 case SDL_BLENDMODE_MASK: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1139 /* Enable and set chroma key */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1140 PgChromaOnCx(rdata->gc); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1141 PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1142 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1143 case SDL_BLENDMODE_BLEND: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1144 /* TODO */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1145 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1146 case SDL_BLENDMODE_NONE: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1147 default: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1148 /* Do nothing */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1149 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1150 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1151 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1152 /* Set source blit area */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1153 src_rect.ul.x = srcrect->x; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1154 src_rect.ul.y = srcrect->y; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1155 src_rect.lr.x = srcrect->x + srcrect->w - 1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1156 src_rect.lr.y = srcrect->y + srcrect->h - 1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1157 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1158 /* Set destination blit area */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1159 dst_rect.ul.x = dstrect->x; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1160 dst_rect.ul.y = dstrect->y; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1161 dst_rect.lr.x = dstrect->x + dstrect->w - 1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1162 dst_rect.lr.y = dstrect->y + dstrect->h - 1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1163 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1164 /* Set destination point */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1165 dst_point.x = dstrect->x; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1166 dst_point.y = dstrect->y; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1167 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1168 /* Do blit */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1169 switch (rdata->surfaces_type) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1170 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1171 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1172 /* two possible combinations */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1173 switch (tdata->surface_type) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1174 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1175 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1176 /* easiest full accelerated combination: offscreen->offscreen */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1177 PgContextBlitCx(rdata->osurfaces[rdata->surface_render_idx], tdata->osurface, |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1178 &src_rect, rdata->osurfaces[rdata->surface_render_idx], &dst_rect); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1179 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1180 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1181 /* not accelerated combination: PhImage->offscreen */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1182 /* scaling is not supported in this method */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1183 PgDrawPhImageRectCxv(rdata->osurfaces[rdata->surface_render_idx], &dst_point, |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1184 tdata->psurface, &src_rect, 0); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1185 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1186 default: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1187 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1188 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1189 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1190 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1191 /* two possible combinations */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1192 switch (tdata->surface_type) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1193 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1194 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1195 /* not supported combination: offscreen->PhImage */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1196 return -1; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1197 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1198 /* not accelerated combination, but fast: PhImage->PhImage */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1199 /* scaling is not supported in this method */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1200 PgDrawPhImageRectCxv(rdata->pcontexts[rdata->surface_render_idx], &dst_point, tdata->psurface, &src_rect, 0); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1201 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1202 default: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1203 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1204 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1205 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1206 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1207 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1208 /* Switch off graphics context modifiers */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1209 switch(texture->blendMode) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1210 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1211 case SDL_BLENDMODE_MASK: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1212 /* Disable chroma key */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1213 PgChromaOffCx(rdata->gc); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1214 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1215 case SDL_BLENDMODE_BLEND: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1216 /* TODO */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1217 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1218 case SDL_BLENDMODE_NONE: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1219 default: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1220 /* Do nothing */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1221 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1222 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1223 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1224 return 0; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1225 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1226 |
3139 | 1227 static void |
1228 photon_renderpresent(SDL_Renderer * renderer) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1229 { |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1230 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1231 SDL_Window *window = window=SDL_GetWindowFromID(renderer->window); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1232 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1233 PhRect_t src_rect; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1234 PhPoint_t src_point; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1235 |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1236 /* Check, if it is not initialized */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1237 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1238 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1239 SDL_SetError("Photon: can't render present for OpenGL ES window"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1240 return; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1241 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1242 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1243 /* Flush all undrawn graphics data to surface */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1244 switch (rdata->surfaces_type) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1245 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1246 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1247 PgFlushCx(rdata->osurfaces[rdata->surface_render_idx]); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1248 PgWaitHWIdle(); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1249 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1250 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1251 PmMemFlush(rdata->pcontexts[rdata->surface_render_idx], rdata->psurfaces[rdata->surface_render_idx]); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1252 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1253 case SDL_PHOTON_SURFTYPE_UNKNOWN: |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1254 default: |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1255 return; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1256 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1257 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1258 PgFFlush(Ph_START_DRAW); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1259 PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window)); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1260 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1261 /* Set blit area */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1262 src_rect.ul.x = 0; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1263 src_rect.ul.y = 0; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1264 src_rect.lr.x = rdata->window_width - 1; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1265 src_rect.lr.y = rdata->window_height - 1; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1266 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1267 src_point.x = 0; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1268 src_point.y = 0; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1269 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1270 switch (rdata->surfaces_type) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1271 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1272 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1273 PgContextBlit(rdata->osurfaces[rdata->surface_render_idx], &src_rect, NULL, &src_rect); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1274 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1275 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1276 PgDrawPhImagev(&src_point, rdata->psurfaces[rdata->surface_render_idx], 0); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1277 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1278 case SDL_PHOTON_SURFTYPE_UNKNOWN: |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1279 default: |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1280 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1281 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1282 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1283 /* finish blit */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1284 PgFFlush(Ph_DONE_DRAW); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1285 PgWaitHWIdle(); |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1286 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1287 |
3139 | 1288 static void |
1289 photon_destroytexture(SDL_Renderer * renderer, SDL_Texture * texture) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1290 { |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1291 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1292 SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1293 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1294 /* Check if partially created texture must be destroyed */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1295 if (tdata==NULL) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1296 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1297 return; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1298 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1299 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1300 /* Check, if it is not initialized */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1301 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1302 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1303 SDL_SetError("Photon: can't destroy texture for OpenGL ES window"); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1304 return; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1305 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1306 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1307 switch (tdata->surface_type) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1308 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1309 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1310 if (tdata->osurface!=NULL) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1311 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1312 PhDCRelease(tdata->osurface); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1313 tdata->osurface = NULL; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1314 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1315 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1316 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1317 if (tdata->pcontext!=NULL) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1318 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1319 PmMemReleaseMC(tdata->pcontext); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1320 tdata->pcontext=NULL; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1321 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1322 |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1323 if (tdata->psurface!=NULL) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1324 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1325 if (tdata->psurface->palette!=NULL) |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1326 { |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1327 SDL_free(tdata->psurface->palette); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1328 tdata->psurface->palette=NULL; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1329 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1330 /* Destroy shared memory for PhImage_t */ |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1331 PgShmemDestroy(tdata->psurface->image); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1332 tdata->psurface->image=NULL; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1333 SDL_free(tdata->psurface); |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1334 tdata->psurface=NULL; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1335 } |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1336 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1337 default: |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1338 break; |
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1339 } |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1340 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1341 |
3139 | 1342 static void |
1343 photon_destroyrenderer(SDL_Renderer * renderer) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1344 { |
3139 | 1345 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1346 SDL_Window *window = SDL_GetWindowFromID(renderer->window); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1347 SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata; |
3139 | 1348 uint32_t it; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1349 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1350 /* Destroy graphics context */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1351 if (rdata->gc!=NULL) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1352 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1353 PgDestroyGC(rdata->gc); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1354 rdata->gc=NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1355 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1356 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1357 switch (rdata->surfaces_type) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1358 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1359 case SDL_PHOTON_SURFTYPE_OFFSCREEN: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1360 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1361 /* Destroy current surfaces */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1362 for (it=0; it<SDL_PHOTON_MAX_SURFACES; it++) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1363 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1364 if (rdata->osurfaces[it] != NULL) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1365 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1366 PhDCRelease(rdata->osurfaces[it]); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1367 rdata->osurfaces[it] = NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1368 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1369 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1370 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1371 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1372 case SDL_PHOTON_SURFTYPE_PHIMAGE: |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1373 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1374 /* Destroy current surfaces */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1375 for (it=0; it<SDL_PHOTON_MAX_SURFACES; it++) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1376 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1377 if (rdata->pcontexts[it]!=NULL) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1378 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1379 PmMemReleaseMC(rdata->pcontexts[it]); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1380 rdata->pcontexts[it]=NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1381 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1382 if (rdata->psurfaces[it]!=NULL) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1383 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1384 if (rdata->psurfaces[it]->palette!=NULL) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1385 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1386 SDL_free(rdata->psurfaces[it]->palette); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1387 rdata->psurfaces[it]->palette=NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1388 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1389 /* Destroy shared memory for PhImage_t */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1390 PgShmemDestroy(rdata->psurfaces[it]->image); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1391 rdata->psurfaces[it]->image=NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1392 SDL_free(rdata->psurfaces[it]); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1393 rdata->psurfaces[it]=NULL; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1394 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1395 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1396 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1397 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1398 case SDL_PHOTON_SURFTYPE_UNKNOWN: |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
1399 default: |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1400 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1401 /* nothing to do */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1402 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1403 break; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1404 } |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1405 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1406 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1407 /* vi: set ts=4 sw=4 expandtab: */ |