annotate src/video/photon/SDL_photon_render.c @ 3383:90935231e9b6

Continue working on 2D support in Photon
author Mike Gorchak <lestat@i.com.ua>
date Sun, 11 Oct 2009 18:45:39 +0000
parents dd105b317335
children 04af265172f9
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
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
37 static SDL_Renderer *photon_createrenderer(SDL_Window * window, Uint32 flags);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
38 static int photon_displaymodechanged(SDL_Renderer * renderer);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
39 static int photon_activaterenderer(SDL_Renderer * renderer);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
40 static int photon_createtexture(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
41 SDL_Texture * texture);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
42 static int photon_querytexturepixels(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
43 SDL_Texture * texture, void **pixels,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
44 int *pitch);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
45 static int photon_settexturepalette(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
46 SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
47 const SDL_Color * colors, int firstcolor,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
48 int ncolors);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
49 static int photon_gettexturepalette(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
50 SDL_Texture * texture, SDL_Color * colors,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
51 int firstcolor, int ncolors);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
52 static int photon_settexturecolormod(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
53 SDL_Texture * texture);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
54 static int photon_settexturealphamod(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
55 SDL_Texture * texture);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
56 static int photon_settextureblendmode(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
57 SDL_Texture * texture);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
58 static int photon_settexturescalemode(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
59 SDL_Texture * texture);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
60 static int photon_updatetexture(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
61 SDL_Texture * texture, const SDL_Rect * rect,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
62 const void *pixels, int pitch);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
63 static int photon_locktexture(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
64 const SDL_Rect * rect, int markDirty,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
65 void **pixels, int *pitch);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
66 static void photon_unlocktexture(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
67 SDL_Texture * texture);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
68 static void photon_dirtytexture(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
69 SDL_Texture * texture, int numrects,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
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
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
73 static int photon_renderpoint(SDL_Renderer * renderer, int x, int y);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
74 static int photon_renderline(SDL_Renderer * renderer, int x1, int y1, int x2,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
75 int y2);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
76 static int photon_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
77 static int photon_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
78 const SDL_Rect * srcrect,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
79 const SDL_Rect * dstrect);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
80 static void photon_renderpresent(SDL_Renderer * renderer);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
81 static void photon_destroytexture(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
82 SDL_Texture * texture);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
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
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
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
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
90 "photon",
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
91 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
92 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
93 SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD |
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
94 SDL_RENDERER_ACCELERATED),
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
95 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
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 |
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
99 SDL_TEXTURESCALEMODE_FAST | SDL_TEXTURESCALEMODE_BEST),
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
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
102 SDL_PIXELFORMAT_RGB555,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
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
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
105 SDL_PIXELFORMAT_RGB888,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
106 SDL_PIXELFORMAT_ARGB8888,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
107 SDL_PIXELFORMAT_YV12,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
108 SDL_PIXELFORMAT_YUY2,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
109 SDL_PIXELFORMAT_UYVY,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
110 SDL_PIXELFORMAT_YVYU},
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
111 0,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
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
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
115 static SDL_Renderer *
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
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
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
118 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
119 SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
120 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
121 SDL_Renderer *renderer = NULL;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
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
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
124 /* Allocate new renderer structure */
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
125 renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(SDL_Renderer));
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
126 if (renderer == NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
127 SDL_OutOfMemory();
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
128 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
129 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
131 /* Allocate renderer data */
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
132 rdata = (SDL_RenderData *) SDL_calloc(1, sizeof(SDL_RenderData));
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
133 if (rdata == NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
134 SDL_free(renderer);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
135 SDL_OutOfMemory();
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
136 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
137 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
139 renderer->DisplayModeChanged = photon_displaymodechanged;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
140 renderer->ActivateRenderer = photon_activaterenderer;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
141 renderer->CreateTexture = photon_createtexture;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
142 renderer->QueryTexturePixels = photon_querytexturepixels;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
143 renderer->SetTexturePalette = photon_settexturepalette;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
144 renderer->GetTexturePalette = photon_gettexturepalette;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
145 renderer->SetTextureAlphaMod = photon_settexturealphamod;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
146 renderer->SetTextureColorMod = photon_settexturecolormod;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
147 renderer->SetTextureBlendMode = photon_settextureblendmode;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
148 renderer->SetTextureScaleMode = photon_settexturescalemode;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
149 renderer->UpdateTexture = photon_updatetexture;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
150 renderer->LockTexture = photon_locktexture;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
151 renderer->UnlockTexture = photon_unlocktexture;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
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
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
155 renderer->RenderPoint = photon_renderpoint;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
156 renderer->RenderLine = photon_renderline;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
157 renderer->RenderFill = photon_renderfill;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
158 renderer->RenderCopy = photon_rendercopy;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
159 renderer->RenderPresent = photon_renderpresent;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
160 renderer->DestroyTexture = photon_destroytexture;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
161 renderer->DestroyRenderer = photon_destroyrenderer;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
162 renderer->info = photon_renderdriver.info;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
163 renderer->window = window->id;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
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
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
166 /* Set render acceleration flag in case it is accelerated */
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
167 if ((didata->caps & SDL_PHOTON_ACCELERATED) == SDL_PHOTON_ACCELERATED) {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
168 renderer->info.flags = SDL_RENDERER_ACCELERATED;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
169 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
170 renderer->info.flags &= ~(SDL_RENDERER_ACCELERATED);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
171 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
173 /* Check if upper level requested synchronization on vsync signal */
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
174 if ((flags & SDL_RENDERER_PRESENTVSYNC) == SDL_RENDERER_PRESENTVSYNC) {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
175 rdata->enable_vsync = SDL_TRUE;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
176 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
177 rdata->enable_vsync = SDL_FALSE;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
178 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
180 /* Check what buffer copy/flip scheme is requested */
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
181 rdata->surfaces_count = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
182 if ((flags & SDL_RENDERER_SINGLEBUFFER) == SDL_RENDERER_SINGLEBUFFER) {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
183 if ((flags & SDL_RENDERER_PRESENTDISCARD) ==
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
184 SDL_RENDERER_PRESENTDISCARD) {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
185 renderer->info.flags |=
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
186 SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
187 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
188 renderer->info.flags |=
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
189 SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
190 }
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
191 rdata->surfaces_count = 1;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
192 rdata->surface_visible_idx = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
193 rdata->surface_render_idx = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
194 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
195 if ((flags & SDL_RENDERER_PRESENTFLIP2) == SDL_RENDERER_PRESENTFLIP2) {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
196 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
197 rdata->surfaces_count = 2;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
198 rdata->surface_visible_idx = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
199 rdata->surface_render_idx = 1;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
200 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
201 if ((flags & SDL_RENDERER_PRESENTFLIP3) ==
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
202 SDL_RENDERER_PRESENTFLIP3) {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
203 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
204 rdata->surfaces_count = 3;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
205 rdata->surface_visible_idx = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
206 rdata->surface_render_idx = 1;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
207 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
208 renderer->info.flags |=
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
209 SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
210 rdata->surfaces_count = 1;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
211 rdata->surface_visible_idx = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
212 rdata->surface_render_idx = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
213 }
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
214 }
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
215 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
217 /* Create new graphics context */
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
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
228 return renderer;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
231 void
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
232 photon_addrenderdriver(_THIS)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
234 uint32_t it;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
236 for (it = 0; it < _this->num_displays; it++) {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
237 SDL_AddRenderDriver(it, &photon_renderdriver);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
238 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 /****************************************************************************/
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
242 /* Render helper functions */
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 /****************************************************************************/
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
244
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
245 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
246 {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
247 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
248 SDL_VideoDisplay *display = NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
249 SDL_DisplayData *didata = NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
250 SDL_Window *window = NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
251 SDL_WindowData *wdata = NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
252 SDL_VideoData *phdata = NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
253 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
254 int32_t status;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
256 /* Obtain window and display structures */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
257 window=SDL_GetWindowFromID(renderer->window);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
258 wdata=(SDL_WindowData*)window->driverdata;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
259 display=SDL_GetDisplayFromWindow(window);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
260 didata=(SDL_DisplayData *) display->driverdata;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
261 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
262
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
263 /* 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
264 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
265 /* 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
266 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
267 return 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
268 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
269
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
270 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
271 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
272 /* Try to allocate offscreen surfaces */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
273 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
274 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
275 else
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
276 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
277 uint32_t it;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
278
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
279 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
280 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
281 /* Create offscreen surfaces */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
282 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
283
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
284 /* Destroy current surfaces */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
285 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
286 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
287 if (rdata->osurfaces[it] != NULL)
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 PhDCRelease(rdata->osurfaces[it]);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
290 rdata->osurfaces[it] = NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
291 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
292 }
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 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
297 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
298 /* Create shared phimage surfaces */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
299 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
300
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
301 /* Destroy current surfaces */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
302 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
303 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
304 if (rdata->pcontexts[it]!=NULL)
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 PmMemReleaseMC(rdata->pcontexts[it]);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
307 rdata->pcontexts[it]=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
308 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
309 if (rdata->psurfaces[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 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
312 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
313 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
314 rdata->psurfaces[it]->palette=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
315 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
316 /* 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
317 PgShmemDestroy(rdata->psurfaces[it]->image);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
318 rdata->psurfaces[it]->image=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
319 SDL_free(rdata->psurfaces[it]);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
320 rdata->psurfaces[it]=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
321 }
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 }
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 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
326
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
327 /* 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
328 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
329 /* 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
330 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
331 if (status != 0) {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
332 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
333 return -1;
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 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
336 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
337
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
338 switch (allocate_task)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
339 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
340 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
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 int32_t it;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
343 int32_t jt;
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 /* 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
346 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
347 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
348 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
349 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
350 /* in case if 2D acceleration is not available use CPU optimized surfaces */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
351 Pg_OSC_MEM_HINT_CPU_READ | Pg_OSC_MEM_HINT_CPU_WRITE |
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
352 /* 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
353 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
354
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
355 /* 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
356 if (rdata->osurfaces[it]==NULL)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
357 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
358 /* Destroy previously allocated surface(s) */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
359 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
360 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
361 PhDCRelease(rdata->osurfaces[jt]);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
362 rdata->osurfaces[jt] = NULL;
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 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
365 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
366 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
368 /* 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
369 if (rdata->osurfaces[0]!=NULL)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
370 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
371 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
372 /* 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
373 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
374 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
375 else
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 /* 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
378 }
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 /* fall through */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
381 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
382 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
383 int32_t it;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
384 int32_t jt;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
385 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
386
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
387 /* 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
388 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
389 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
390 /* 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
391 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
392 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
393 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
394 image_pfmt, NULL, 256, 1);
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 else
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
397 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
398 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
399 image_pfmt, NULL, 0, 1);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
400 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
401
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
402 if (rdata->psurfaces[it]!=NULL)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
403 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
404 PhPoint_t translation={0, 0};
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
405 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
406
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
407 /* 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
408 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
409 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
410
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
411 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
412 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
413 /* Destroy previously allocated surface(s) */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
414 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
415 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
416 if (rdata->pcontexts[jt]!=NULL)
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 PmMemReleaseMC(rdata->pcontexts[it]);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
419 rdata->pcontexts[jt]=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
420 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
421 if (rdata->psurfaces[jt]!=NULL)
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 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
424 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
425 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
426 rdata->psurfaces[jt]->palette=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
427 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
428 /* 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
429 PgShmemDestroy(rdata->psurfaces[jt]->image);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
430 rdata->psurfaces[jt]->image=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
431 SDL_free(rdata->psurfaces[jt]);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
432 rdata->psurfaces[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 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
435 break;
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 }
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 /* 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
440 if (rdata->psurfaces[0]!=NULL)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
441 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
442 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
443 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
444 else
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
445 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
446 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
447 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
448 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
449 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
450 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
451 default:
3375
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 /* do nothing with surface allocation */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
454 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
455 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
456 break;
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
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
459 /* 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
460 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
461 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
462 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
463 return -1;
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
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
466 /* Store current surface dimensions */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
467 rdata->window_width=window->w;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
468 rdata->window_height=window->h;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
469
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
470 /* 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
471 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
472 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
473 rdata->surface_visible_idx = 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
474 rdata->surface_render_idx = 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
475 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
476
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
477 /* 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
478 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
479 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
480 rdata->surface_visible_idx = 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
481 rdata->surface_render_idx = 1;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
482 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
483
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
484 /* 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
485 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
486 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
487 rdata->surface_visible_idx = 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
488 rdata->surface_render_idx = 1;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
489 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
490
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
491 switch (rdata->surfaces_type)
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 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
494 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
495 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
496 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
497 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
498 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
499 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
500 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
501 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
502 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
504 return 0;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
505 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
506
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
507 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
508 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
509 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
510 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
511 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
512 PhPoint_t src_point;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
513
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
514 /* 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
515 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
516 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
517 /* 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
518 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
519 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
520 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
521 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
522 PgWaitHWIdle();
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
523 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
524 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
525 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
526 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
527 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
528 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
529 return;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
530 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
531 }
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 PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window));
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
534
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
535 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
536 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
537
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
538 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
539 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
540 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
541 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
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_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
544 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
545 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
546 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
547 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
548 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
549 }
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
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
552 /****************************************************************************/
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
553 /* SDL render interface */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
554 /****************************************************************************/
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
555
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
556 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
557 photon_activaterenderer(SDL_Renderer * renderer)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
558 {
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
559 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
560 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
561 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
562
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
563 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
564 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
565 return _photon_recreate_surfaces(renderer);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
566 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
567
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
568 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
569 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
570 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
571 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
572 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
573 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
574 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
575 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
576 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
577 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
578 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
579 }
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 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
582 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
583
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
584 static int
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
585 photon_displaymodechanged(SDL_Renderer * renderer)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
586 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
587 return _photon_recreate_surfaces(renderer);
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
588 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
589
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
590 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
591 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
592 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
593 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
594 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
595 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
596 SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
597 SDL_TextureData *tdata = NULL;
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
598 uint32_t it;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
599
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
600 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
601 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
602 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
603 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
604 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
605 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
606
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
607 /* 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
608 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
609 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
610 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
611 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
612 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
613 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
614 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
615 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
616 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
617 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
618 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
619 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
620
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
621 /* Allocate texture driver data */
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
622 tdata = (SDL_TextureData *) SDL_calloc(1, sizeof(SDL_TextureData));
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
623 if (tdata == NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
624 SDL_OutOfMemory();
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
625 return -1;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
626 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
627
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
628 /* Set texture driver data */
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
629 texture->driverdata = tdata;
3383
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 /* 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
632 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
633 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
634 /* Try to allocate offscreen memory first */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
635 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
636 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
637 /* in case if 2D acceleration is not available use CPU optimized surfaces */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
638 Pg_OSC_MEM_HINT_CPU_READ | Pg_OSC_MEM_HINT_CPU_WRITE |
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
639 /* 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
640 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
641 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
642
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
643 /* Check if offscreen allocation has been failed */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
644 if (tdata->osurface==NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
645 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
646 PhPoint_t translation={0, 0};
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
647 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
648 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
649
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
650 /* Allocate photon image */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
651 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
652 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
653 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
654 image_pfmt, NULL, 256, 1);
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 else
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
657 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
658 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
659 image_pfmt, NULL, 0, 1);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
660 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
661
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
662 if (tdata->psurface==NULL)
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 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
665 }
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 /* Create memory context for PhImage_t */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
668 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
669 if (tdata->pcontext==NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
670 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
671 /* Destroy PhImage */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
672 if (tdata->psurface!=NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
673 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
674 if (tdata->psurface->palette!=NULL)
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 SDL_free(tdata->psurface->palette);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
677 tdata->psurface->palette=NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
678 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
679 /* Destroy shared memory for PhImage_t */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
680 PgShmemDestroy(tdata->psurface->image);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
681 tdata->psurface->image=NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
682 SDL_free(tdata->psurface);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
683 tdata->psurface=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 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
686 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
687 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
688 else
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 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
691 }
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 return 0;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
694 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
695
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
696 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
697 photon_querytexturepixels(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
698 void **pixels, int *pitch)
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
699 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
700 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
701 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
702
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
703 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
704 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
705 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
706 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
707 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
708 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
709
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
710 /* Clear outcoming parameters */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
711 *pixels=NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
712 *pitch=0;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
713
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
714 switch (tdata->surface_type)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
715 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
716 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
717 *pixels=(void*)PdGetOffscreenContextPtr(tdata->osurface);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
718 *pitch=tdata->osurface->pitch;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
719 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
720 case SDL_PHOTON_SURFTYPE_PHIMAGE:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
721 *pixels=(void*)tdata->psurface->image;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
722 *pitch=tdata->psurface->bpl;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
723 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
724 default:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
725 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
726 }
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 return 0;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
729 }
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
730
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
731 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
732 photon_settexturepalette(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
733 const SDL_Color * colors, int firstcolor,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
734 int ncolors)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
735 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
736 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
737 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
738
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
739 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
740 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
741 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
742 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
743 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
744 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
745
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
746 if (texture->format!=SDL_PIXELFORMAT_INDEX8)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
747 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
748 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
749 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
750 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
751
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
752 return -1;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
753 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
754
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
755 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
756 photon_gettexturepalette(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
757 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
758 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
759 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
760 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
761
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
762 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
763 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
764 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
765 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
766 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
767 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
768
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
769 if (texture->format!=SDL_PIXELFORMAT_INDEX8)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
770 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
771 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
772 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
773 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
774
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
775 return -1;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
776 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
777
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
778 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
779 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
780 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
781 /* TODO */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
782 return -1;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
783 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
784
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
785 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
786 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
787 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
788 /* TODO */
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
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
792 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
793 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
794 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
795 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
796
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
797 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
798 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
799 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
800 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
801 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
802 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
803
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
804 switch (texture->blendMode)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
805 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
806 case SDL_BLENDMODE_NONE:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
807 case SDL_BLENDMODE_MASK:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
808 case SDL_BLENDMODE_BLEND:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
809 return 0;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
810 case SDL_BLENDMODE_ADD:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
811 case SDL_BLENDMODE_MOD:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
812 default:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
813 SDL_Unsupported();
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
814 texture->blendMode = SDL_BLENDMODE_NONE;
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 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
817 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
818
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
819 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
820 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
821 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
822 /* TODO */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
823 return -1;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
824 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
825
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
826 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
827 photon_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
828 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
829 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
830 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
831 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
832
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
833 uint8_t* src=(uint8_t*)pixels;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
834 uint8_t* dst;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
835 uint32_t dst_pitch;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
836 uint32_t it;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
837 uint32_t copy_length;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
838
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
839 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
840 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
841 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
842 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
843 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
844 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
845
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
846 switch (tdata->surface_type)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
847 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
848 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
849 dst=(uint8_t*)PdGetOffscreenContextPtr(tdata->osurface);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
850 dst_pitch=tdata->osurface->pitch;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
851 if (dst==NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
852 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
853 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
854 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
855 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
856 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
857 case SDL_PHOTON_SURFTYPE_PHIMAGE:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
858 dst=(uint8_t*)tdata->psurface->image;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
859 dst_pitch=tdata->psurface->bpl;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
860 if (dst==NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
861 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
862 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
863 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
864 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
865 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
866 default:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
867 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
868 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
869 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
870
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
871 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
872 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
873 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
874 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
875 SDL_memcpy(dst, src, copy_length);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
876 src+=pitch;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
877 dst+=dst_pitch;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
878 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
879
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
880 return 0;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
881 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
882
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
883 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
884 photon_locktexture(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
885 const SDL_Rect * rect, int markDirty, void **pixels,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
886 int *pitch)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
887 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
888 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
889 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
890
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
891 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
892 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
893 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
894 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
895 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
896 }
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 /* Clear outcoming parameters */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
899 *pixels=NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
900 *pitch=0;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
901
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
902 switch (tdata->surface_type)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
903 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
904 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
905 *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
906 rect->y * tdata->osurface->pitch +
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
907 rect->x * SDL_BYTESPERPIXEL(texture->format));
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
908 *pitch=tdata->osurface->pitch;
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 *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
912 rect->y * tdata->osurface->pitch +
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
913 rect->x * SDL_BYTESPERPIXEL(texture->format));
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
914 *pitch=tdata->psurface->bpl;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
915 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
916 default:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
917 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
918 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
919
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
920 return 0;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
921 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
922
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
923 static void
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
924 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
925 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
926 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
927
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
928 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
929 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
930 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
931 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
932 return;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
933 }
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
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
936 static void
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
937 photon_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
938 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
939 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
940 /* TODO */
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
941 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
942
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
943 static int
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
944 photon_setdrawcolor(SDL_Renderer * renderer)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
945 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
946 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
947
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
948 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
949 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
950 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
951 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
952 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
953 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
954
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
955 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
956 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
957 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
958 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
959 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
960 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
961 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
962 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
963 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
964 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
965 }
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
966
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
967 return 0;
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
968 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
969
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
970 static int
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
971 photon_setdrawblendmode(SDL_Renderer * renderer)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
972 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
973 /* TODO */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
974 return -1;
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
975 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
976
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
977 static int
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
978 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
979 {
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
980 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
981
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
982 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
983 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
984 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
985 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
986 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
987 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
988
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
989 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
990 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
991 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
992 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
993 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
994 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
995 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
996 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
997 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
998 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
999 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1000 }
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1001
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1002 return 0;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1003 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1004
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1005 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1006 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
1007 {
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1008 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
1009
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1010 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1011 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
1012 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1013 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
1014 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1015 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1016
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1017 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1018 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1019 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1020 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
1021 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1022 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1023 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
1024 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1025 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1026 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1027 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1028 }
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1029
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1030 return 0;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1031 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1032
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1033 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1034 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
1035 {
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1036 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
1037
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1038 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1039 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
1040 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1041 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
1042 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1043 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1044
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1045 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1046 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1047 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1048 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
1049 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1050 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1051 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
1052 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1053 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1054 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1055 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1056 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1057 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1058
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1059 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1060 photon_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1061 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
1062 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1063 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
1064 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
1065
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1066 PhRect_t src_rect;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1067 PhRect_t dst_rect;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1068 PhPoint_t dst_point;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1069
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1070 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1071 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
1072 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1073 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
1074 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1075 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1076
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1077 /* Switch on requested graphics context modifiers */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1078 switch(texture->blendMode)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1079 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1080 case SDL_BLENDMODE_MASK:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1081 /* Enable and set chroma key */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1082 PgChromaOnCx(rdata->gc);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1083 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
1084 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1085 case SDL_BLENDMODE_BLEND:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1086 /* TODO */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1087 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1088 case SDL_BLENDMODE_NONE:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1089 default:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1090 /* Do nothing */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1091 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1092 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1093
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1094 /* Set source blit area */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1095 src_rect.ul.x = srcrect->x;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1096 src_rect.ul.y = srcrect->y;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1097 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
1098 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
1099
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1100 /* Set destination blit area */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1101 dst_rect.ul.x = dstrect->x;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1102 dst_rect.ul.y = dstrect->y;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1103 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
1104 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
1105
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1106 /* Set destination point */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1107 dst_point.x = dstrect->x;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1108 dst_point.y = dstrect->y;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1109
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1110 /* Do blit */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1111 switch (rdata->surfaces_type)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1112 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1113 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1114 /* two possible combinations */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1115 switch (tdata->surface_type)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1116 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1117 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1118 /* easiest full accelerated combination: offscreen->offscreen */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1119 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
1120 &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
1121 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1122 case SDL_PHOTON_SURFTYPE_PHIMAGE:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1123 /* not accelerated combination: PhImage->offscreen */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1124 /* 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
1125 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
1126 tdata->psurface, &src_rect, 0);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1127 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1128 default:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1129 break;
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 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1132 case SDL_PHOTON_SURFTYPE_PHIMAGE:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1133 /* two possible combinations */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1134 switch (tdata->surface_type)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1135 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1136 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1137 /* not supported combination: offscreen->PhImage */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1138 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1139 case SDL_PHOTON_SURFTYPE_PHIMAGE:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1140 /* 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
1141 /* 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
1142 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
1143 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1144 default:
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 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1147 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1148 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1149
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1150 /* Switch off graphics context modifiers */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1151 switch(texture->blendMode)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1152 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1153 case SDL_BLENDMODE_MASK:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1154 /* Disable chroma key */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1155 PgChromaOffCx(rdata->gc);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1156 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1157 case SDL_BLENDMODE_BLEND:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1158 /* TODO */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1159 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1160 case SDL_BLENDMODE_NONE:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1161 default:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1162 /* Do nothing */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1163 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1164 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1165
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1166 return 0;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1167 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1168
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1169 static void
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1170 photon_renderpresent(SDL_Renderer * renderer)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1171 {
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1172 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
1173 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
1174 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
1175 PhRect_t src_rect;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1176 PhPoint_t src_point;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1177
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1178 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1179 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
1180 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1181 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
1182 return;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1183 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1184
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1185 /* 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
1186 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1187 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1188 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1189 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
1190 PgWaitHWIdle();
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1191 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1192 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1193 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
1194 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1195 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1196 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1197 return;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1198 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1199
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1200 PgFFlush(Ph_START_DRAW);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1201 PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window));
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1202
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1203 /* Set blit area */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1204 src_rect.ul.x = 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1205 src_rect.ul.y = 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1206 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
1207 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
1208
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1209 src_point.x = 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1210 src_point.y = 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1211
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1212 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1213 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1214 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1215 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
1216 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1217 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1218 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
1219 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1220 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1221 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1222 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1223 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1224
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1225 /* finish blit */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1226 PgFFlush(Ph_DONE_DRAW);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1227 PgWaitHWIdle();
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1228 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1229
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1230 static void
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1231 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
1232 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1233 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
1234 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
1235
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1236 /* 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
1237 if (tdata==NULL)
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 return;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1240 }
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 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1243 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
1244 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1245 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
1246 return;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1247 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1248
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1249 switch (tdata->surface_type)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1250 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1251 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1252 if (tdata->osurface!=NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1253 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1254 PhDCRelease(tdata->osurface);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1255 tdata->osurface = NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1256 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1257 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1258 case SDL_PHOTON_SURFTYPE_PHIMAGE:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1259 if (tdata->pcontext!=NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1260 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1261 PmMemReleaseMC(tdata->pcontext);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1262 tdata->pcontext=NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1263 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1264
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1265 if (tdata->psurface!=NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1266 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1267 if (tdata->psurface->palette!=NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1268 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1269 SDL_free(tdata->psurface->palette);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1270 tdata->psurface->palette=NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1271 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1272 /* Destroy shared memory for PhImage_t */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1273 PgShmemDestroy(tdata->psurface->image);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1274 tdata->psurface->image=NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1275 SDL_free(tdata->psurface);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1276 tdata->psurface=NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1277 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1278 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1279 default:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1280 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1281 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1282 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1283
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1284 static void
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1285 photon_destroyrenderer(SDL_Renderer * renderer)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1286 {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1287 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
1288 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
1289 SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1290 uint32_t it;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1291
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1292 /* Destroy graphics context */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1293 if (rdata->gc!=NULL)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1294 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1295 PgDestroyGC(rdata->gc);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1296 rdata->gc=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1297 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1298
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1299 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1300 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1301 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1302 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1303 /* Destroy current surfaces */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1304 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
1305 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1306 if (rdata->osurfaces[it] != NULL)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1307 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1308 PhDCRelease(rdata->osurfaces[it]);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1309 rdata->osurfaces[it] = NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1310 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1311 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1312 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1313 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1314 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1315 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1316 /* Destroy current surfaces */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1317 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
1318 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1319 if (rdata->pcontexts[it]!=NULL)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1320 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1321 PmMemReleaseMC(rdata->pcontexts[it]);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1322 rdata->pcontexts[it]=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1323 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1324 if (rdata->psurfaces[it]!=NULL)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1325 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1326 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
1327 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1328 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
1329 rdata->psurfaces[it]->palette=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1330 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1331 /* 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
1332 PgShmemDestroy(rdata->psurfaces[it]->image);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1333 rdata->psurfaces[it]->image=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1334 SDL_free(rdata->psurfaces[it]);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1335 rdata->psurfaces[it]=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1336 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1337 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1338 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1339 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1340 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1341 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1342 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1343 /* nothing to do */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1344 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1345 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1346 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1347 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1348
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1349 /* vi: set ts=4 sw=4 expandtab: */