annotate src/video/photon/SDL_photon_render.c @ 5013:9d6b527e0912

Fixed compiler errors
author Sam Lantinga <slouken@libsdl.org>
date Mon, 17 Jan 2011 13:54:13 -0800
parents aa8888658021
children da10636e5eca
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
3697
f7b03b6838cb Fixed bug #926
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
3 Copyright (C) 1997-2010 Sam Lantinga
3092
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
3411
d15a4daa4a58 Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents: 3396
diff changeset
37 #ifndef Pg_OSC_MEM_LINEAR_ACCESSIBLE
d15a4daa4a58 Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents: 3396
diff changeset
38 /* For QNX 6.3.2 compatibility */
d15a4daa4a58 Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents: 3396
diff changeset
39 #define Pg_OSC_MEM_LINEAR_ACCESSIBLE 0
d15a4daa4a58 Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents: 3396
diff changeset
40 #endif /* Pg_OSC_MEM_LINEAR_ACCESSIBLE */
d15a4daa4a58 Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents: 3396
diff changeset
41
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
42 static SDL_Renderer *photon_createrenderer(SDL_Window * window, Uint32 flags);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
43 static int photon_displaymodechanged(SDL_Renderer * renderer);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
44 static int photon_activaterenderer(SDL_Renderer * renderer);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
45 static int photon_createtexture(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 static int photon_querytexturepixels(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
48 SDL_Texture * texture, void **pixels,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
49 int *pitch);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
50 static int photon_settexturepalette(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
51 SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
52 const SDL_Color * colors, int firstcolor,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
53 int ncolors);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
54 static int photon_gettexturepalette(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
55 SDL_Texture * texture, SDL_Color * colors,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
56 int firstcolor, int ncolors);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
57 static int photon_settexturecolormod(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
58 SDL_Texture * texture);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
59 static int photon_settexturealphamod(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
60 SDL_Texture * texture);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
61 static int photon_settextureblendmode(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
62 SDL_Texture * texture);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
63 static int photon_settexturescalemode(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
64 SDL_Texture * texture);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
65 static int photon_updatetexture(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
66 SDL_Texture * texture, const SDL_Rect * rect,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
67 const void *pixels, int pitch);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
68 static int photon_locktexture(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
69 const SDL_Rect * rect, int markDirty,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
70 void **pixels, int *pitch);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
71 static void photon_unlocktexture(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
72 SDL_Texture * texture);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
73 static void photon_dirtytexture(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
74 SDL_Texture * texture, int numrects,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
75 const SDL_Rect * rects);
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
76 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
77 static int photon_setdrawblendmode(SDL_Renderer * renderer);
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
78 static int photon_renderpoint(SDL_Renderer * renderer, int x, int y);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
79 static int photon_renderline(SDL_Renderer * renderer, int x1, int y1, int x2,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
80 int y2);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
81 static int photon_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
82 static int photon_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
83 const SDL_Rect * srcrect,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
84 const SDL_Rect * dstrect);
3459
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
85 static int photon_renderreadpixels(SDL_Renderer * renderer, const SDL_Rect * rect,
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
86 Uint32 format, void * pixels, int pitch);
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
87 static int photon_renderwritepixels(SDL_Renderer * renderer, const SDL_Rect * rect,
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
88 Uint32 format, const void * pixels, int pitch);
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
89 static void photon_renderpresent(SDL_Renderer * renderer);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
90 static void photon_destroytexture(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
91 SDL_Texture * texture);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
92 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
93
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
94 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
95
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
96 SDL_RenderDriver photon_renderdriver = {
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 photon_createrenderer,
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
99 "photon",
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
100 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
101 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
102 SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD |
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
103 SDL_RENDERER_ACCELERATED),
3386
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
104 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_ALPHA),
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
105 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND |
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
106 SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
4929
aa8888658021 Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
107 (SDL_SCALEMODE_NONE | SDL_SCALEMODE_SLOW | SDL_SCALEMODE_FAST),
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
108 10,
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
109 {SDL_PIXELFORMAT_INDEX8,
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
110 SDL_PIXELFORMAT_RGB555,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
111 SDL_PIXELFORMAT_RGB565,
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
112 SDL_PIXELFORMAT_RGB24,
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
113 SDL_PIXELFORMAT_RGB888,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
114 SDL_PIXELFORMAT_ARGB8888,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
115 SDL_PIXELFORMAT_YV12,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
116 SDL_PIXELFORMAT_YUY2,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
117 SDL_PIXELFORMAT_UYVY,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
118 SDL_PIXELFORMAT_YVYU},
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
119 0,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
120 0}
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 };
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
123 static SDL_Renderer *
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
124 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
125 {
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
126 SDL_VideoDisplay *display = window->display;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
127 SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
128 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
129 SDL_Renderer *renderer = NULL;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
130 SDL_RenderData *rdata = NULL;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
132 /* Allocate new renderer structure */
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
133 renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(SDL_Renderer));
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
134 if (renderer == NULL) {
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 /* Allocate renderer data */
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
140 rdata = (SDL_RenderData *) SDL_calloc(1, sizeof(SDL_RenderData));
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
141 if (rdata == NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
142 SDL_free(renderer);
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
143 SDL_OutOfMemory();
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
144 return NULL;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
145 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
147 renderer->DisplayModeChanged = photon_displaymodechanged;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
148 renderer->ActivateRenderer = photon_activaterenderer;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
149 renderer->CreateTexture = photon_createtexture;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
150 renderer->QueryTexturePixels = photon_querytexturepixels;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
151 renderer->SetTexturePalette = photon_settexturepalette;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
152 renderer->GetTexturePalette = photon_gettexturepalette;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
153 renderer->SetTextureAlphaMod = photon_settexturealphamod;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
154 renderer->SetTextureColorMod = photon_settexturecolormod;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
155 renderer->SetTextureBlendMode = photon_settextureblendmode;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
156 renderer->SetTextureScaleMode = photon_settexturescalemode;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
157 renderer->UpdateTexture = photon_updatetexture;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
158 renderer->LockTexture = photon_locktexture;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
159 renderer->UnlockTexture = photon_unlocktexture;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
160 renderer->DirtyTexture = photon_dirtytexture;
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
161 renderer->SetDrawColor = photon_setdrawcolor;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
162 renderer->SetDrawBlendMode = photon_setdrawblendmode;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
163 renderer->RenderPoint = photon_renderpoint;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
164 renderer->RenderLine = photon_renderline;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
165 renderer->RenderFill = photon_renderfill;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
166 renderer->RenderCopy = photon_rendercopy;
3462
6265b67848e0 RenderReadPixels and RenderWritePixels now work properly.
Mike Gorchak <lestat@i.com.ua>
parents: 3459
diff changeset
167 renderer->RenderReadPixels = photon_renderreadpixels;
6265b67848e0 RenderReadPixels and RenderWritePixels now work properly.
Mike Gorchak <lestat@i.com.ua>
parents: 3459
diff changeset
168 renderer->RenderWritePixels = photon_renderwritepixels;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
169 renderer->RenderPresent = photon_renderpresent;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
170 renderer->DestroyTexture = photon_destroytexture;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
171 renderer->DestroyRenderer = photon_destroyrenderer;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
172 renderer->info = photon_renderdriver.info;
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
173 renderer->window = window;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
174 renderer->driverdata = rdata;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175
3387
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
176 /* Copy direct_mode status */
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
177 rdata->direct_mode=didata->direct_mode;
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
178
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
179 /* Set render acceleration flag in case it is accelerated */
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
180 if ((didata->caps & SDL_PHOTON_ACCELERATED) == SDL_PHOTON_ACCELERATED) {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
181 renderer->info.flags = SDL_RENDERER_ACCELERATED;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
182 } else {
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
183 renderer->info.flags = 0;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
184 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
186 /* Check if upper level requested synchronization on vsync signal */
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
187 if ((flags & SDL_RENDERER_PRESENTVSYNC) == SDL_RENDERER_PRESENTVSYNC) {
3387
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
188 if (rdata->direct_mode==SDL_TRUE)
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
189 {
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
190 /* We can control vsync only in direct mode */
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
191 rdata->enable_vsync = SDL_TRUE;
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
192 renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
193 }
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
194 else
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
195 {
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
196 rdata->enable_vsync = SDL_FALSE;
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
197 }
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
198 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
199 rdata->enable_vsync = SDL_FALSE;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
200 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
202 /* Check what buffer copy/flip scheme is requested */
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
203 rdata->surfaces_count = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
204 if ((flags & SDL_RENDERER_SINGLEBUFFER) == SDL_RENDERER_SINGLEBUFFER) {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
205 if ((flags & SDL_RENDERER_PRESENTDISCARD) ==
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
206 SDL_RENDERER_PRESENTDISCARD) {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
207 renderer->info.flags |=
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
208 SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
209 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
210 renderer->info.flags |=
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
211 SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
212 }
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
213 rdata->surfaces_count = 1;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
214 rdata->surface_visible_idx = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
215 rdata->surface_render_idx = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
216 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
217 if ((flags & SDL_RENDERER_PRESENTFLIP2) == SDL_RENDERER_PRESENTFLIP2) {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
218 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
219 rdata->surfaces_count = 2;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
220 rdata->surface_visible_idx = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
221 rdata->surface_render_idx = 1;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
222 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
223 if ((flags & SDL_RENDERER_PRESENTFLIP3) ==
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
224 SDL_RENDERER_PRESENTFLIP3) {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
225 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
226 rdata->surfaces_count = 3;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
227 rdata->surface_visible_idx = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
228 rdata->surface_render_idx = 1;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
229 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
230 renderer->info.flags |=
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
231 SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
232 rdata->surfaces_count = 1;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
233 rdata->surface_visible_idx = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
234 rdata->surface_render_idx = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
235 }
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
236 }
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
237 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
239 /* Create new graphics context for the renderer */
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
240 if (rdata->gc==NULL)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
241 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
242 rdata->gc=PgCreateGC(0);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
243 PgDefaultGC(rdata->gc);
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
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
246 /* 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
247 renderer->info.num_texture_formats=1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
248 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
249
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
250 /* Initialize surfaces */
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
251 _photon_recreate_surfaces(renderer);
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
252
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
253 /* Set current scale blitting capabilities */
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
254 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_OFFSCREEN)
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
255 {
4929
aa8888658021 Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
256 renderer->info.scale_modes=SDL_SCALEMODE_NONE | SDL_SCALEMODE_SLOW;
3386
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
257 if ((didata->mode_2dcaps & SDL_VIDEO_PHOTON_CAP_SCALED_BLIT)==SDL_VIDEO_PHOTON_CAP_SCALED_BLIT)
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
258 {
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
259 /* This video mode supports hardware scaling */
4929
aa8888658021 Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
260 renderer->info.scale_modes|=SDL_SCALEMODE_FAST;
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
261 }
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
262 }
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
263 else
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
264 {
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
265 /* PhImage blit functions do not support scaling */
4929
aa8888658021 Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
266 renderer->info.scale_modes=SDL_SCALEMODE_NONE;
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
267 }
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
268
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
269 return renderer;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
272 void
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
273 photon_addrenderdriver(_THIS)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
275 uint32_t it;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
277 for (it = 0; it < _this->num_displays; it++) {
3500
4b594623401b Work in progress on multi-display support:
Sam Lantinga <slouken@libsdl.org>
parents: 3469
diff changeset
278 SDL_AddRenderDriver(&_this->displays[it], &photon_renderdriver);
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
279 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 /****************************************************************************/
3396
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
283 /* Renderer helper functions */
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 /****************************************************************************/
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
285
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
286 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
287 {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
288 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
289 SDL_VideoDisplay *display = NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
290 SDL_DisplayData *didata = NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
291 SDL_Window *window = NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
292 SDL_WindowData *wdata = NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
293 SDL_VideoData *phdata = NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
294 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
295 int32_t status;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
297 /* Obtain window and display structures */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
298 window=SDL_GetWindowFromID(renderer->window);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
299 wdata=(SDL_WindowData*)window->driverdata;
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
300 display=window->display;
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
301 didata=(SDL_DisplayData *) display->driverdata;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
302 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
303
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
304 /* 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
305 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
306 /* 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
307 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
308 return 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
309 }
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->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
312 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
313 /* Try to allocate offscreen surfaces */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
314 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
315 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
316 else
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
317 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
318 uint32_t it;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
319
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
320 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
321 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
322 /* Create offscreen surfaces */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
323 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
324
3462
6265b67848e0 RenderReadPixels and RenderWritePixels now work properly.
Mike Gorchak <lestat@i.com.ua>
parents: 3459
diff changeset
325 /* Before destroying surfaces, be sure, that rendering was completed */
6265b67848e0 RenderReadPixels and RenderWritePixels now work properly.
Mike Gorchak <lestat@i.com.ua>
parents: 3459
diff changeset
326 PgFlush();
6265b67848e0 RenderReadPixels and RenderWritePixels now work properly.
Mike Gorchak <lestat@i.com.ua>
parents: 3459
diff changeset
327 PgWaitHWIdle();
6265b67848e0 RenderReadPixels and RenderWritePixels now work properly.
Mike Gorchak <lestat@i.com.ua>
parents: 3459
diff changeset
328
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
329 /* Destroy current surfaces */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
330 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
331 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
332 if (rdata->osurfaces[it] != NULL)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
333 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
334 PhDCRelease(rdata->osurfaces[it]);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
335 rdata->osurfaces[it] = NULL;
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 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
339 else
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
340 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
341 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
342 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
343 /* Create shared phimage surfaces */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
344 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
345
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
346 /* Destroy current surfaces */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
347 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
348 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
349 if (rdata->pcontexts[it]!=NULL)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
350 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
351 PmMemReleaseMC(rdata->pcontexts[it]);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
352 rdata->pcontexts[it]=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
353 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
354 if (rdata->psurfaces[it]!=NULL)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
355 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
356 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
357 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
358 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
359 rdata->psurfaces[it]->palette=NULL;
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 /* 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
362 PgShmemDestroy(rdata->psurfaces[it]->image);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
363 rdata->psurfaces[it]->image=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
364 SDL_free(rdata->psurfaces[it]);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
365 rdata->psurfaces[it]=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
366 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
367 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
368 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
369 }
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
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
372 /* 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
373 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
374 /* 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
375 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
376 if (status != 0) {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
377 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
378 return -1;
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 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
381 }
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 switch (allocate_task)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
384 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
385 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
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 int32_t it;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
388 int32_t jt;
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 /* 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
391 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
392 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
393 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
394 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
395 /* 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
396 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
397 /* 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
398 if (rdata->osurfaces[it]==NULL)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
399 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
400 /* Destroy previously allocated surface(s) */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
401 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
402 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
403 PhDCRelease(rdata->osurfaces[jt]);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
404 rdata->osurfaces[jt] = NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
405 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
406 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
407 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
408 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
410 /* 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
411 if (rdata->osurfaces[0]!=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 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
414 /* 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
415 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
416 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
417 else
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
418 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
419 /* 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
420 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
421 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
422 /* fall through */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
423 case SDL_PHOTON_SURFTYPE_PHIMAGE:
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 int32_t it;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
426 int32_t jt;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
427 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
428
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
429 /* 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
430 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
431 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
432 /* 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
433 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
434 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
435 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
436 image_pfmt, NULL, 256, 1);
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 else
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
439 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
440 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
441 image_pfmt, NULL, 0, 1);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
442 }
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 if (rdata->psurfaces[it]!=NULL)
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 PhPoint_t translation={0, 0};
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
447 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
448
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
449 /* 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
450 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
451 }
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 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
454 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
455 /* Destroy previously allocated surface(s) */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
456 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
457 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
458 if (rdata->pcontexts[jt]!=NULL)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
459 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
460 PmMemReleaseMC(rdata->pcontexts[it]);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
461 rdata->pcontexts[jt]=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
462 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
463 if (rdata->psurfaces[jt]!=NULL)
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 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
466 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
467 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
468 rdata->psurfaces[jt]->palette=NULL;
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 /* 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
471 PgShmemDestroy(rdata->psurfaces[jt]->image);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
472 rdata->psurfaces[jt]->image=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
473 SDL_free(rdata->psurfaces[jt]);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
474 rdata->psurfaces[jt] = NULL;
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 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
478 }
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
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
481 /* 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
482 if (rdata->psurfaces[0]!=NULL)
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 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
485 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
486 else
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
487 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
488 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
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 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
492 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
493 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
494 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
495 /* do nothing with surface allocation */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
496 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
497 }
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 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
500
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
501 /* 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
502 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
503 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
504 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
505 return -1;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
506 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
507
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
508 /* Store current surface dimensions */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
509 rdata->window_width=window->w;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
510 rdata->window_height=window->h;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
511
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
512 /* 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
513 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
514 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
515 rdata->surface_visible_idx = 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
516 rdata->surface_render_idx = 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
517 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
518
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
519 /* 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
520 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
521 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
522 rdata->surface_visible_idx = 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
523 rdata->surface_render_idx = 1;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
524 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
525
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
526 /* 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
527 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
528 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
529 rdata->surface_visible_idx = 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
530 rdata->surface_render_idx = 1;
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 switch (rdata->surfaces_type)
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 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
536 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
537 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
538 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
539 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
540 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
541 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
542 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
543 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
544 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
545
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
546 return 0;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
547 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
548
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
549 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
550 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
551 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
552 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
553 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
554 PhPoint_t src_point;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
555
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
556 /* 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
557 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
558 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
559 /* 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
560 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
561 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
562 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
563 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
564 PgWaitHWIdle();
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
565 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
566 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
567 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
568 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
569 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
570 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
571 return;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
572 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
573 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
574
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
575 PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window));
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
576
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
577 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
578 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
579
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
580 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
581 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
582 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
583 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
584 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
585 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
586 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
587 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
588 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
589 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
590 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
591 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
592 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
593
3396
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
594 int _photon_set_blending(SDL_Renderer* renderer, uint32_t blendmode, uint32_t globalalpha, uint32_t blendsource)
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
595 {
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
596 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
597
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
598 /* Switch on requested graphics context modifiers */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
599 switch (blendmode)
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
600 {
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
601 case SDL_BLENDMODE_MASK:
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
602 /* Enable and set chroma key */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
603 if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
604 {
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
605 PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
606 PgChromaOnCx(rdata->gc);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
607 }
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
608 break;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
609 case SDL_BLENDMODE_BLEND:
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
610 /* Enable and set chroma key and alpha blending */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
611 if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
612 {
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
613 PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
614 PgChromaOnCx(rdata->gc);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
615 }
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
616 PgSetAlphaCx(rdata->gc, Pg_ALPHA_OP_SRC_GLOBAL | Pg_BLEND_SRC_As | Pg_BLEND_DST_1mAs, NULL, NULL, globalalpha, 0);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
617 PgAlphaOnCx(rdata->gc);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
618 break;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
619 case SDL_BLENDMODE_ADD:
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
620 /* Enable and set chroma key and alpha blending */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
621 if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
622 {
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
623 PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
624 PgChromaOnCx(rdata->gc);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
625 }
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
626 PgSetAlphaCx(rdata->gc, Pg_ALPHA_OP_SRC_GLOBAL | Pg_BLEND_SRC_As | Pg_BLEND_DST_1, NULL, NULL, globalalpha, 0);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
627 PgAlphaOnCx(rdata->gc);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
628 break;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
629 case SDL_BLENDMODE_MOD:
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
630 /* Enable and set alpha blending */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
631 PgSetAlphaCx(rdata->gc, Pg_BLEND_SRC_0 | Pg_BLEND_DST_S, NULL, NULL, 0, 0);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
632 PgAlphaOnCx(rdata->gc);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
633 break;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
634 case SDL_BLENDMODE_NONE:
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
635 /* Do nothing */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
636 break;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
637 default:
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
638 return -1;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
639 }
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
640
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
641 return 0;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
642 }
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
643
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
644 int _photon_reset_blending(SDL_Renderer* renderer, uint32_t blendmode, uint32_t blendsource)
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
645 {
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
646 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
647
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
648 /* Switch off graphics context modifiers */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
649 switch (blendmode)
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
650 {
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
651 case SDL_BLENDMODE_MASK:
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
652 /* Disable chroma key */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
653 if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
654 {
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
655 PgChromaOffCx(rdata->gc);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
656 }
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
657 break;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
658 case SDL_BLENDMODE_BLEND:
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
659 /* Disable chroma key and alpha blending */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
660 if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
661 {
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
662 PgChromaOffCx(rdata->gc);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
663 }
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
664 PgAlphaOffCx(rdata->gc);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
665 break;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
666 case SDL_BLENDMODE_ADD:
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
667 /* Disable chroma key and alpha blending */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
668 if (blendsource==SDL_PHOTON_TEXTURE_BLEND)
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
669 {
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
670 PgChromaOffCx(rdata->gc);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
671 }
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
672 PgAlphaOffCx(rdata->gc);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
673 break;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
674 case SDL_BLENDMODE_MOD:
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
675 /* Disable chroma key and alpha blending */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
676 PgAlphaOffCx(rdata->gc);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
677 break;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
678 case SDL_BLENDMODE_NONE:
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
679 /* Do nothing */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
680 break;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
681 default:
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
682 return -1;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
683 }
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
684
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
685 return 0;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
686 }
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
687
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
688 /****************************************************************************/
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
689 /* SDL render interface */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
690 /****************************************************************************/
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
691
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
692 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
693 photon_activaterenderer(SDL_Renderer * renderer)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
694 {
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
695 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
696 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
697 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
698
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
699 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
700 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
701 return _photon_recreate_surfaces(renderer);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
702 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
703
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
704 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
705 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
706 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
707 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
708 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
709 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
710 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
711 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
712 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
713 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
714 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
715 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
716
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
717 return 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
718 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
719
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
720 static int
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
721 photon_displaymodechanged(SDL_Renderer * renderer)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
722 {
3387
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
723 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
724 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
725 SDL_VideoDisplay *display = window->display;
3387
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
726 SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
727
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
728 /* Copy direct_mode status */
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
729 rdata->direct_mode=didata->direct_mode;
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
730
05499ec8c022 Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents: 3386
diff changeset
731 /* Update the surfaces */
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
732 return _photon_recreate_surfaces(renderer);
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
733 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
734
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
735 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
736 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
737 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
738 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
739 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
740 SDL_VideoDisplay *display = window->display;
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
741 SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
742 SDL_TextureData *tdata = NULL;
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
743 uint32_t it;
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 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
746 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
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 create texture for OpenGL ES window");
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 /* 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
753 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
754 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
755 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
756 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
757 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
758 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
759 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
760 if (it==renderer->info.num_texture_formats)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
761 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
762 SDL_SetError("Photon: requested texture format is not supported");
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
763 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
764 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
765
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
766 /* Allocate texture driver data */
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
767 tdata = (SDL_TextureData *) SDL_calloc(1, sizeof(SDL_TextureData));
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
768 if (tdata == NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
769 SDL_OutOfMemory();
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
770 return -1;
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
771 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
772
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
773 /* Set texture driver data */
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
774 texture->driverdata = tdata;
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
775
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
776 /* 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
777 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
778 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
779 /* Try to allocate offscreen memory first */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
780 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
781 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
782 /* 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
783 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
784 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
785
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
786 /* Check if offscreen allocation has been failed or not performed */
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
787 if (tdata->osurface==NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
788 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
789 PhPoint_t translation={0, 0};
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
790 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
791 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
792
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
793 /* Allocate photon image */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
794 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
795 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
796 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
797 image_pfmt, NULL, 256, 1);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
798 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
799 else
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
800 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
801 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
802 image_pfmt, NULL, 0, 1);
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
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
805 if (tdata->psurface==NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
806 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
807 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
808 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
809
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
810 /* Create memory context for PhImage_t */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
811 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
812 if (tdata->pcontext==NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
813 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
814 /* Destroy PhImage */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
815 if (tdata->psurface!=NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
816 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
817 if (tdata->psurface->palette!=NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
818 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
819 SDL_free(tdata->psurface->palette);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
820 tdata->psurface->palette=NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
821 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
822 /* Destroy shared memory for PhImage_t */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
823 PgShmemDestroy(tdata->psurface->image);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
824 tdata->psurface->image=NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
825 SDL_free(tdata->psurface);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
826 tdata->psurface=NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
827 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
828 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
829 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
830 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
831 else
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 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
834 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
835
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
836 return 0;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
837 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
838
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
839 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
840 photon_querytexturepixels(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
841 void **pixels, int *pitch)
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
842 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
843 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
844 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
845
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
846 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
847 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
848 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
849 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
850 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
851 }
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 /* Clear outcoming parameters */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
854 *pixels=NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
855 *pitch=0;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
856
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
857 switch (tdata->surface_type)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
858 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
859 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
860 *pixels=(void*)PdGetOffscreenContextPtr(tdata->osurface);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
861 *pitch=tdata->osurface->pitch;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
862 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
863 case SDL_PHOTON_SURFTYPE_PHIMAGE:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
864 *pixels=(void*)tdata->psurface->image;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
865 *pitch=tdata->psurface->bpl;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
866 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
867 default:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
868 break;
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 return 0;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
872 }
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
873
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
874 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
875 photon_settexturepalette(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
876 const SDL_Color * colors, int firstcolor,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
877 int ncolors)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
878 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
879 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
880 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
881
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
882 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
883 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
884 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
885 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
886 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
887 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
888
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
889 if (texture->format!=SDL_PIXELFORMAT_INDEX8)
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 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
892 return -1;
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
3386
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
895 SDL_Unsupported();
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
896 return -1;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
897 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
898
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
899 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
900 photon_gettexturepalette(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
901 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
902 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
903 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
904 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
905
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
906 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
907 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
908 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
909 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
910 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
911 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
912
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
913 if (texture->format!=SDL_PIXELFORMAT_INDEX8)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
914 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
915 SDL_SetError("Photon: can't return palette for non-paletted texture");
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
916 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
917 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
918
3386
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
919 SDL_Unsupported();
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
920 return -1;
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 int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
924 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
925 {
3386
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
926 SDL_Unsupported();
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
927 return -1;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
928 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
929
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
930 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
931 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
932 {
3386
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
933 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
934
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
935 /* Check, if it is not initialized */
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
936 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
937 {
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
938 SDL_SetError("Photon: can't set texture blend mode for OpenGL ES window");
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
939 return -1;
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
940 }
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
941
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
942 /* Check if current renderer instance supports alpha modulation */
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
943 if ((renderer->info.mod_modes & SDL_TEXTUREMODULATE_ALPHA)!=SDL_TEXTUREMODULATE_ALPHA)
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
944 {
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
945 SDL_Unsupported();
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
946 return -1;
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
947 }
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
948
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
949 return 0;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
950 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
951
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
952 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
953 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
954 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
955 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
956
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
957 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
958 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
959 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
960 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
961 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
962 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
963
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
964 switch (texture->blendMode)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
965 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
966 case SDL_BLENDMODE_NONE:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
967 case SDL_BLENDMODE_MASK:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
968 case SDL_BLENDMODE_BLEND:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
969 case SDL_BLENDMODE_ADD:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
970 case SDL_BLENDMODE_MOD:
3386
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
971 return 0;
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
972 default:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
973 SDL_Unsupported();
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
974 texture->blendMode = SDL_BLENDMODE_NONE;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
975 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
976 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
977 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
978
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
979 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
980 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
981 {
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
982 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
983
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
984 switch (texture->scaleMode)
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
985 {
4929
aa8888658021 Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
986 case SDL_SCALEMODE_NONE:
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
987 return 0;
4929
aa8888658021 Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
988 case SDL_SCALEMODE_FAST:
aa8888658021 Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
989 if ((renderer->info.scale_modes & SDL_SCALEMODE_FAST)==SDL_SCALEMODE_FAST)
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
990 {
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
991 return 0;
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
992 }
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
993 else
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
994 {
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
995 SDL_Unsupported();
4929
aa8888658021 Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
996 texture->scaleMode = SDL_SCALEMODE_FAST;
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
997 return -1;
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
998 }
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
999 break;
4929
aa8888658021 Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1000 case SDL_SCALEMODE_SLOW:
aa8888658021 Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1001 if ((renderer->info.scale_modes & SDL_SCALEMODE_SLOW)==SDL_SCALEMODE_SLOW)
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1002 {
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1003 return 0;
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1004 }
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1005 else
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1006 {
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1007 SDL_Unsupported();
4929
aa8888658021 Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1008 texture->scaleMode = SDL_SCALEMODE_SLOW;
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1009 return -1;
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1010 }
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1011 break;
4929
aa8888658021 Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1012 case SDL_SCALEMODE_BEST:
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1013 SDL_Unsupported();
4929
aa8888658021 Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1014 texture->scaleMode = SDL_SCALEMODE_SLOW;
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1015 return -1;
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1016 default:
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1017 SDL_Unsupported();
4929
aa8888658021 Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
1018 texture->scaleMode = SDL_SCALEMODE_NONE;
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1019 return -1;
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1020 }
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1021
3386
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
1022 SDL_Unsupported();
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1023 return -1;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1024 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1025
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1026 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1027 photon_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1028 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
1029 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1030 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
1031 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
1032
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1033 uint8_t* src=(uint8_t*)pixels;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1034 uint8_t* dst;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1035 uint32_t dst_pitch;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1036 uint32_t it;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1037 uint32_t copy_length;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1038
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1039 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1040 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
1041 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1042 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
1043 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1044 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1045
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1046 switch (tdata->surface_type)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1047 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1048 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1049 dst=(uint8_t*)PdGetOffscreenContextPtr(tdata->osurface);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1050 dst_pitch=tdata->osurface->pitch;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1051 if (dst==NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1052 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1053 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
1054 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1055 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1056 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1057 case SDL_PHOTON_SURFTYPE_PHIMAGE:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1058 dst=(uint8_t*)tdata->psurface->image;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1059 dst_pitch=tdata->psurface->bpl;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1060 if (dst==NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1061 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1062 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
1063 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1064 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1065 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1066 default:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1067 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
1068 return -1;
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
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1071 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
1072 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
1073 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
1074 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1075 SDL_memcpy(dst, src, copy_length);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1076 src+=pitch;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1077 dst+=dst_pitch;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1078 }
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 return 0;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1081 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1082
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1083 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1084 photon_locktexture(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1085 const SDL_Rect * rect, int markDirty, void **pixels,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1086 int *pitch)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1087 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1088 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
1089 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
1090
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1091 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1092 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
1093 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1094 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
1095 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1096 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1097
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1098 /* Clear outcoming parameters */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1099 *pixels=NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1100 *pitch=0;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1101
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1102 switch (tdata->surface_type)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1103 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1104 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1105 *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
1106 rect->y * tdata->osurface->pitch +
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1107 rect->x * SDL_BYTESPERPIXEL(texture->format));
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1108 *pitch=tdata->osurface->pitch;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1109 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1110 case SDL_PHOTON_SURFTYPE_PHIMAGE:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1111 *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
1112 rect->y * tdata->osurface->pitch +
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1113 rect->x * SDL_BYTESPERPIXEL(texture->format));
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1114 *pitch=tdata->psurface->bpl;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1115 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1116 default:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1117 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1118 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1119
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1120 return 0;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1121 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1122
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1123 static void
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1124 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
1125 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1126 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
1127
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1128 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1129 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1130 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1131 SDL_SetError("Photon: can't unlock texture for OpenGL ES window");
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1132 return;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1133 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1134 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1135
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1136 static void
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1137 photon_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1138 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
1139 {
3386
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
1140 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
1141
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1142 /* Check, if it is not initialized */
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1143 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1144 {
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1145 SDL_SetError("Photon: can't update dirty texture for OpenGL ES window");
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1146 return;
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
1147 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1148 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1149
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1150 static int
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1151 photon_setdrawcolor(SDL_Renderer * renderer)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1152 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1153 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
1154
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1155 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1156 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
1157 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1158 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
1159 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1160 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1161
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1162 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1163 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1164 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1165 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1166 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
1167 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
1168 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1169 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1170 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1171 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1172 }
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1173
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1174 return 0;
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1175 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1176
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1177 static int
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1178 photon_setdrawblendmode(SDL_Renderer * renderer)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1179 {
3396
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1180 SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1181
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1182 /* Check, if it is not initialized */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1183 if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN)
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1184 {
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1185 SDL_SetError("Photon: can't set texture blend mode for OpenGL ES window");
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1186 return -1;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1187 }
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1188
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1189 switch (renderer->blendMode)
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1190 {
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1191 case SDL_BLENDMODE_NONE:
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1192 case SDL_BLENDMODE_MASK:
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1193 case SDL_BLENDMODE_BLEND:
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1194 case SDL_BLENDMODE_ADD:
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1195 case SDL_BLENDMODE_MOD:
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1196 return 0;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1197 default:
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1198 SDL_Unsupported();
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1199 renderer->blendMode = SDL_BLENDMODE_NONE;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1200 return -1;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1201 }
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1202
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1203 return 0;
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1204 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1205
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1206 static int
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1207 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
1208 {
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1209 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
1210
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1211 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1212 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
1213 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1214 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
1215 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1216 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1217
3396
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1218 /* Enable blending, if requested */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1219 _photon_set_blending(renderer, renderer->blendMode, renderer->a, SDL_PHOTON_DRAW_BLEND);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1220
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1221 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1222 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1223 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1224 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
1225 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1226 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1227 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
1228 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1229 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1230 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1231 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1232 }
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1233
3396
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1234 /* Disable blending, if it was enabled */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1235 _photon_reset_blending(renderer, renderer->blendMode, SDL_PHOTON_DRAW_BLEND);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1236
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1237 return 0;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1238 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1239
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1240 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1241 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
1242 {
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1243 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
1244
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1245 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1246 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
1247 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1248 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
1249 return -1;
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
3396
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1252 /* Enable blending, if requested */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1253 _photon_set_blending(renderer, renderer->blendMode, renderer->a, SDL_PHOTON_DRAW_BLEND);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1254
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1255 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1256 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1257 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1258 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
1259 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1260 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1261 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
1262 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1263 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1264 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1265 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1266 }
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1267
3396
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1268 /* Disable blending, if it was enabled */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1269 _photon_reset_blending(renderer, renderer->blendMode, SDL_PHOTON_DRAW_BLEND);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1270
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1271 return 0;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1272 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1273
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1274 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1275 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
1276 {
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1277 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
1278
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1279 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1280 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
1281 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1282 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
1283 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1284 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1285
3396
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1286 /* Enable blending, if requested */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1287 _photon_set_blending(renderer, renderer->blendMode, renderer->a, SDL_PHOTON_DRAW_BLEND);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1288
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1289 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1290 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1291 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1292 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
1293 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1294 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1295 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
1296 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1297 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1298 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1299 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1300 }
3396
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1301
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1302 /* Disable blending, if it was enabled */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1303 _photon_reset_blending(renderer, renderer->blendMode, SDL_PHOTON_DRAW_BLEND);
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1304
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1305 return 0;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1306 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1307
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1308 static int
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1309 photon_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1310 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
1311 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1312 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
1313 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
1314
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1315 PhRect_t src_rect;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1316 PhRect_t dst_rect;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1317 PhPoint_t dst_point;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1318
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1319 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1320 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
1321 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1322 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
1323 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1324 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1325
3396
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1326 _photon_set_blending(renderer, texture->blendMode, texture->a, SDL_PHOTON_TEXTURE_BLEND);
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1327
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1328 /* Set source blit area */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1329 src_rect.ul.x = srcrect->x;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1330 src_rect.ul.y = srcrect->y;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1331 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
1332 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
1333
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1334 /* Set destination blit area */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1335 dst_rect.ul.x = dstrect->x;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1336 dst_rect.ul.y = dstrect->y;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1337 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
1338 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
1339
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1340 /* Set destination point */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1341 dst_point.x = dstrect->x;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1342 dst_point.y = dstrect->y;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1343
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1344 /* Do blit */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1345 switch (rdata->surfaces_type)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1346 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1347 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1348 /* two possible combinations */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1349 switch (tdata->surface_type)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1350 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1351 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1352 /* easiest full accelerated combination: offscreen->offscreen */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1353 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
1354 &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
1355 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1356 case SDL_PHOTON_SURFTYPE_PHIMAGE:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1357 /* not accelerated combination: PhImage->offscreen */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1358 /* 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
1359 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
1360 tdata->psurface, &src_rect, 0);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1361 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1362 default:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1363 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1364 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1365 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1366 case SDL_PHOTON_SURFTYPE_PHIMAGE:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1367 /* two possible combinations */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1368 switch (tdata->surface_type)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1369 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1370 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1371 /* not supported combination: offscreen->PhImage */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1372 return -1;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1373 case SDL_PHOTON_SURFTYPE_PHIMAGE:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1374 /* 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
1375 /* 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
1376 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
1377 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1378 default:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1379 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1380 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1381 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1382 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1383
3396
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1384 _photon_reset_blending(renderer, texture->blendMode, SDL_PHOTON_TEXTURE_BLEND);
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1385
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1386 return 0;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1387 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1388
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1389 static void
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1390 photon_renderpresent(SDL_Renderer * renderer)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1391 {
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1392 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
1393 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
1394 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
1395 PhRect_t src_rect;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1396 PhPoint_t src_point;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1397
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1398 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1399 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
1400 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1401 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
1402 return;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1403 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1404
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1405 /* 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
1406 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1407 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1408 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1409 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
1410 PgWaitHWIdle();
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1411 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1412 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1413 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
1414 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1415 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1416 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1417 return;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1418 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1419
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1420 PgFFlush(Ph_START_DRAW);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1421 PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window));
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1422
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1423 /* Set blit area */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1424 src_rect.ul.x = 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1425 src_rect.ul.y = 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1426 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
1427 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
1428
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1429 src_point.x = 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1430 src_point.y = 0;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1431
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1432 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1433 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1434 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1435 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
1436 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1437 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1438 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
1439 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1440 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1441 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1442 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1443 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1444
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1445 /* finish blit */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1446 PgFFlush(Ph_DONE_DRAW);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1447 PgWaitHWIdle();
3396
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1448
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1449 /* Check if we are using double buffering */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1450 if ((renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) == SDL_RENDERER_PRESENTFLIP2)
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1451 {
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1452 rdata->surface_visible_idx=rdata->surface_render_idx;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1453 rdata->surface_render_idx=(rdata->surface_render_idx + 1) % 2;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1454 }
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1455
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1456 /* Check if we are using triple buffering */
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1457 if ((renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) == SDL_RENDERER_PRESENTFLIP3)
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1458 {
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1459 rdata->surface_visible_idx=rdata->surface_render_idx;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1460 rdata->surface_render_idx=(rdata->surface_render_idx + 1) % 3;
d6b79fc83362 All 2D operations in Photon driver have been finished. The driver is ready to use. There fullscreen modes and YUV textures are rest only.
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
1461 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1462 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1463
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1464 static void
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1465 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
1466 {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1467 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
1468 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
1469
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1470 /* 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
1471 if (tdata==NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1472 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1473 return;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1474 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1475
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1476 /* Check, if it is not initialized */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1477 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
1478 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1479 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
1480 return;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1481 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1482
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1483 switch (tdata->surface_type)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1484 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1485 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1486 if (tdata->osurface!=NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1487 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1488 PhDCRelease(tdata->osurface);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1489 tdata->osurface = NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1490 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1491 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1492 case SDL_PHOTON_SURFTYPE_PHIMAGE:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1493 if (tdata->pcontext!=NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1494 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1495 PmMemReleaseMC(tdata->pcontext);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1496 tdata->pcontext=NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1497 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1498
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1499 if (tdata->psurface!=NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1500 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1501 if (tdata->psurface->palette!=NULL)
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1502 {
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1503 SDL_free(tdata->psurface->palette);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1504 tdata->psurface->palette=NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1505 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1506 /* Destroy shared memory for PhImage_t */
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1507 PgShmemDestroy(tdata->psurface->image);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1508 tdata->psurface->image=NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1509 SDL_free(tdata->psurface);
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1510 tdata->psurface=NULL;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1511 }
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1512 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1513 default:
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1514 break;
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1515 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1516 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1517
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1518 static void
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1519 photon_destroyrenderer(SDL_Renderer * renderer)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1520 {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1521 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
1522 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
1523 SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3108
diff changeset
1524 uint32_t it;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1525
3462
6265b67848e0 RenderReadPixels and RenderWritePixels now work properly.
Mike Gorchak <lestat@i.com.ua>
parents: 3459
diff changeset
1526 /* Before destroying the renderer, be sure, that rendering was completed */
6265b67848e0 RenderReadPixels and RenderWritePixels now work properly.
Mike Gorchak <lestat@i.com.ua>
parents: 3459
diff changeset
1527 PgFlush();
6265b67848e0 RenderReadPixels and RenderWritePixels now work properly.
Mike Gorchak <lestat@i.com.ua>
parents: 3459
diff changeset
1528 PgWaitHWIdle();
6265b67848e0 RenderReadPixels and RenderWritePixels now work properly.
Mike Gorchak <lestat@i.com.ua>
parents: 3459
diff changeset
1529
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1530 /* Destroy graphics context */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1531 if (rdata->gc!=NULL)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1532 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1533 PgDestroyGC(rdata->gc);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1534 rdata->gc=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1535 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1536
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1537 switch (rdata->surfaces_type)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1538 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1539 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1540 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1541 /* Destroy current surfaces */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1542 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
1543 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1544 if (rdata->osurfaces[it] != NULL)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1545 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1546 PhDCRelease(rdata->osurfaces[it]);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1547 rdata->osurfaces[it] = NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1548 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1549 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1550 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1551 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1552 case SDL_PHOTON_SURFTYPE_PHIMAGE:
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1553 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1554 /* Destroy current surfaces */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1555 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
1556 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1557 if (rdata->pcontexts[it]!=NULL)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1558 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1559 PmMemReleaseMC(rdata->pcontexts[it]);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1560 rdata->pcontexts[it]=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1561 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1562 if (rdata->psurfaces[it]!=NULL)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1563 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1564 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
1565 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1566 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
1567 rdata->psurfaces[it]->palette=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1568 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1569 /* 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
1570 PgShmemDestroy(rdata->psurfaces[it]->image);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1571 rdata->psurfaces[it]->image=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1572 SDL_free(rdata->psurfaces[it]);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1573 rdata->psurfaces[it]=NULL;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1574 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1575 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1576 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1577 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1578 case SDL_PHOTON_SURFTYPE_UNKNOWN:
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
1579 default:
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1580 {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1581 /* nothing to do */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1582 }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1583 break;
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
1584 }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1585 }
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1586
3459
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1587 static int
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1588 photon_renderreadpixels(SDL_Renderer * renderer, const SDL_Rect * rect,
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1589 Uint32 format, void * pixels, int pitch)
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1590 {
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1591 SDL_RenderData *rdata = (SDL_RenderData *)renderer->driverdata;
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1592 Uint32 sformat=0;
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1593 uint8_t* spixels=NULL;
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1594 unsigned int spitch=0;
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1595
3469
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1596 /* Flush all undrawn graphics data to surface */
3459
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1597 switch (rdata->surfaces_type)
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1598 {
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1599 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
3469
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1600 PgFlushCx(rdata->osurfaces[rdata->surface_render_idx]);
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1601 PgWaitHWIdle();
3459
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1602 break;
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1603 case SDL_PHOTON_SURFTYPE_PHIMAGE:
3469
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1604 PmMemFlush(rdata->pcontexts[rdata->surface_render_idx], rdata->psurfaces[rdata->surface_render_idx]);
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1605 break;
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1606 case SDL_PHOTON_SURFTYPE_UNKNOWN:
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1607 default:
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1608 return;
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1609 }
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1610
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1611 switch (rdata->surfaces_type)
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1612 {
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1613 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1614 sformat=photon_image_to_sdl_pixelformat(rdata->osurfaces[rdata->surface_render_idx]->format);
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1615 spixels=(uint8_t*)PdGetOffscreenContextPtr(rdata->osurfaces[rdata->surface_render_idx]);
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1616 spitch=rdata->osurfaces[rdata->surface_render_idx]->pitch;
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1617 break;
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1618 case SDL_PHOTON_SURFTYPE_PHIMAGE:
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1619 sformat=photon_image_to_sdl_pixelformat(rdata->psurfaces[rdata->surface_render_idx]->type);
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1620 spixels=(uint8_t*)rdata->psurfaces[rdata->surface_render_idx]->image;
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1621 spitch=rdata->psurfaces[rdata->surface_render_idx]->bpl;
3459
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1622 break;
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1623 case SDL_PHOTON_SURFTYPE_UNKNOWN:
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1624 default:
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1625 SDL_SetError("Photon: surfaces are not initialized");
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1626 return -1;
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1627 }
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1628
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1629 /* Adjust surface pixels pointer to the rectangle coordinates */
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1630 spixels+=rect->y*spitch + rect->x*SDL_BYTESPERPIXEL(sformat);
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1631
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1632 SDL_ConvertPixels(rect->w, rect->h,
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1633 sformat, spixels, spitch,
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1634 format, pixels, pitch);
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1635
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1636 return 0;
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1637 }
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1638
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1639 static int
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1640 photon_renderwritepixels(SDL_Renderer * renderer, const SDL_Rect * rect,
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1641 Uint32 format, const void * pixels, int pitch)
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1642 {
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1643 SDL_RenderData *rdata = (SDL_RenderData *)renderer->driverdata;
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1644 Uint32 sformat=0;
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1645 uint8_t* spixels=NULL;
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1646 unsigned int spitch=0;
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1647
3469
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1648 /* Flush all undrawn graphics data to surface */
3459
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1649 switch (rdata->surfaces_type)
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1650 {
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1651 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
3469
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1652 PgFlushCx(rdata->osurfaces[rdata->surface_render_idx]);
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1653 PgWaitHWIdle();
3459
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1654 break;
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1655 case SDL_PHOTON_SURFTYPE_PHIMAGE:
3469
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1656 PmMemFlush(rdata->pcontexts[rdata->surface_render_idx], rdata->psurfaces[rdata->surface_render_idx]);
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1657 break;
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1658 case SDL_PHOTON_SURFTYPE_UNKNOWN:
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1659 default:
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1660 return;
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1661 }
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1662
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1663 switch (rdata->surfaces_type)
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1664 {
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1665 case SDL_PHOTON_SURFTYPE_OFFSCREEN:
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1666 sformat=photon_image_to_sdl_pixelformat(rdata->osurfaces[rdata->surface_render_idx]->format);
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1667 spixels=(uint8_t*)PdGetOffscreenContextPtr(rdata->osurfaces[rdata->surface_render_idx]);
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1668 spitch=rdata->osurfaces[rdata->surface_render_idx]->pitch;
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1669 break;
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1670 case SDL_PHOTON_SURFTYPE_PHIMAGE:
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1671 sformat=photon_image_to_sdl_pixelformat(rdata->psurfaces[rdata->surface_render_idx]->type);
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1672 spixels=(uint8_t*)rdata->psurfaces[rdata->surface_render_idx]->image;
8c5fb2a3b11d RenderReadPixels and RenderWritePixels functions work with back buffer now and all asynchronous operations are flushed before reading or writing to backbuffer. Thanks Sam for clarification of this.
Mike Gorchak <lestat@i.com.ua>
parents: 3462
diff changeset
1673 spitch=rdata->psurfaces[rdata->surface_render_idx]->bpl;
3459
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1674 break;
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1675 case SDL_PHOTON_SURFTYPE_UNKNOWN:
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1676 default:
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1677 SDL_SetError("Photon: surfaces are not initialized");
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1678 return -1;
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1679 }
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1680
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1681 /* Adjust surface pixels pointer to the rectangle coordinates */
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1682 spixels+=rect->y*spitch + rect->x*SDL_BYTESPERPIXEL(sformat);
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1683
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1684 SDL_ConvertPixels(rect->w, rect->h, format, pixels, pitch,
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1685 sformat, spixels, spitch);
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1686
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1687 return 0;
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1688 }
feea0def118d Support for RendererReadPixels and RendererWritePixels has been added to photon renderer.
Mike Gorchak <lestat@i.com.ua>
parents: 3411
diff changeset
1689
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1690 /* vi: set ts=4 sw=4 expandtab: */