Mercurial > sdl-ios-xcode
annotate src/video/photon/SDL_photon.c @ 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.
author | Mike Gorchak <lestat@i.com.ua> |
---|---|
date | Sat, 21 Nov 2009 06:17:50 +0000 |
parents | 0cbfec87e4f1 |
children | 4b594623401b |
rev | line source |
---|---|
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2009 Sam Lantinga |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
21 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
22 QNX Photon GUI SDL driver |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
23 Copyright (C) 2009 Mike Gorchak |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
24 (mike@malva.ua, lestat@i.com.ua) |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 */ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
27 /* SDL internals */ |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 #include "SDL_config.h" |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include "../SDL_sysvideo.h" |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
30 #include "SDL_version.h" |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
31 #include "SDL_syswm.h" |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
32 #include "SDL_loadso.h" |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
33 #include "SDL_events.h" |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
34 #include "../../events/SDL_mouse_c.h" |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
35 #include "../../events/SDL_keyboard_c.h" |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
36 |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
37 /* Photon declarations */ |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
38 #include "SDL_photon.h" |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
39 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
40 /* Pixel format conversion routines */ |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
41 #include "SDL_photon_pixelfmt.h" |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
42 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
43 /* Use GF's pixel format functions for OpenGL ES context creation */ |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
44 #if defined(SDL_VIDEO_OPENGL_ES) |
3139 | 45 #include "../qnxgf/SDL_gf_pixelfmt.h" |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
46 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
47 /* If GF driver is not compiled in, include some of usefull functions */ |
3139 | 48 #if !defined(SDL_VIDEO_DRIVER_QNXGF) |
49 #include "../qnxgf/SDL_gf_pixelfmt.c" | |
50 #endif /* SDL_VIDEO_DRIVER_QNXGF */ | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
51 #endif /* SDL_VIDEO_OPENGL_ES */ |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
52 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
53 /* Use GF's OpenGL ES 1.1 functions emulation */ |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
54 #if defined(SDL_VIDEO_OPENGL_ES) |
3139 | 55 #include "../qnxgf/SDL_gf_opengles.h" |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
56 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
57 /* If GF driver is not compiled in, include some of usefull functions */ |
3139 | 58 #if !defined(SDL_VIDEO_DRIVER_QNXGF) |
59 #include "../qnxgf/SDL_gf_opengles.c" | |
60 #endif /* SDL_VIDEO_DRIVER_QNXGF */ | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
61 #endif /* SDL_VIDEO_OPENGL_ES */ |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
62 |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
63 /* Low level device graphics driver names, which they are reporting */ |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
64 static const Photon_DeviceCaps photon_devicename[] = { |
3139 | 65 /* ATI Rage 128 graphics driver (devg-ati_rage128) */ |
66 {"ati_rage128", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
67 , | |
68 /* Fujitsu Carmine graphics driver (devg-carmine.so) */ | |
69 {"carmine", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} | |
70 , | |
71 /* C&T graphics driver (devg-chips.so) */ | |
72 {"chips", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
73 , | |
74 /* Fujitsu Coral graphics driver (devg-coral.so) */ | |
75 {"coral", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} | |
76 , | |
77 /* Intel integrated graphics driver (devg-extreme2.so) */ | |
78 {"extreme2", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} | |
79 , | |
80 /* Unaccelerated FB driver (devg-flat.so) */ | |
81 {"flat", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
82 , | |
83 /* NS Geode graphics driver (devg-geode.so) */ | |
84 {"geode", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
85 , | |
86 /* Geode LX graphics driver (devg-geodelx.so) */ | |
87 {"geodelx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
88 , | |
89 /* Intel integrated graphics driver (devg-gma9xx.so) */ | |
90 {"gma", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} | |
91 , | |
92 /* Intel integrated graphics driver (devg-i810.so) */ | |
93 {"i810", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
94 , | |
95 /* Intel integrated graphics driver (devg-i830.so) */ | |
96 {"i830", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
97 , | |
98 /* Geode LX graphics driver (devg-lx800.so) */ | |
99 {"lx800", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
100 , | |
101 /* Matrox Gxx graphics driver (devg-matroxg.so) */ | |
102 {"matroxg", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
103 , | |
104 /* Intel Poulsbo graphics driver (devg-poulsbo.so) */ | |
105 {"poulsbo", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} | |
106 , | |
107 /* ATI Radeon driver (devg-radeon.so) */ | |
108 {"radeon", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
109 , | |
110 /* ATI Rage driver (devg-rage.so) */ | |
111 {"rage", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
112 , | |
113 /* S3 Savage graphics driver (devg-s3_savage.so) */ | |
114 {"s3_savage", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
115 , | |
116 /* SiS630 integrated graphics driver (devg-sis630.so) */ | |
117 {"sis630", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
118 , | |
119 /* PowerVR SGX 535 graphics driver (devg-poulsbo.so) */ | |
120 {"sgx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} | |
121 , | |
122 /* SM Voyager GX graphics driver (devg-smi5xx.so) */ | |
123 {"smi5xx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
124 , | |
125 /* Silicon Motion graphics driver (devg-smi7xx.so) */ | |
126 {"smi7xx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
127 , | |
128 /* SVGA unaccelerated gfx driver (devg-svga.so) */ | |
129 {"svga", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
130 , | |
131 /* nVidia TNT graphics driver (devg-tnt.so) */ | |
132 {"tnt", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
133 , | |
134 /* VIA integrated graphics driver (devg-tvia.so) */ | |
135 {"tvia", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
136 , | |
137 /* VIA UniChrome graphics driver (devg-unichrome.so) */ | |
138 {"unichrome", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
139 , | |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
140 /* VESA unaccelerated gfx driver (devg-vesabios.so) */ |
3139 | 141 {"vesa", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D} |
142 , | |
143 /* VmWare graphics driver (devg-volari.so) */ | |
144 {"vmware", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
145 , | |
146 /* XGI XP10 graphics driver (devg-volari.so), OpenGL 1.5 */ | |
147 {"volari", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
148 , | |
149 /* End of list */ | |
150 {NULL, 0x00000000} | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
151 }; |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 |
3139 | 153 static SDL_bool photon_initialized = SDL_FALSE; |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 |
3139 | 155 static int |
156 photon_available(void) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 { |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
158 int32_t status; |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 |
3139 | 160 /* Check if Photon was initialized before */ |
161 if (photon_initialized == SDL_FALSE) { | |
162 /* Initialize Photon widget library and open channel to Photon */ | |
163 status = PtInit(NULL); | |
164 if (status == 0) { | |
165 photon_initialized = SDL_TRUE; | |
166 return 1; | |
167 } else { | |
168 photon_initialized = SDL_FALSE; | |
169 return 0; | |
170 } | |
171 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 |
3139 | 173 return 1; |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 |
3139 | 176 static void |
177 photon_destroy(SDL_VideoDevice * device) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 { |
3139 | 179 SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
180 |
3139 | 181 #if defined(SDL_VIDEO_OPENGL_ES) |
182 if (phdata->gfinitialized != SDL_FALSE) { | |
183 gf_dev_detach(phdata->gfdev); | |
184 } | |
185 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
186 |
3139 | 187 if (device->driverdata != NULL) { |
188 device->driverdata = NULL; | |
189 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 |
3139 | 192 static SDL_VideoDevice * |
193 photon_create(int devindex) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 { |
3139 | 195 SDL_VideoDevice *device; |
196 SDL_VideoData *phdata; | |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
197 int32_t status; |
3139 | 198 |
199 /* Check if photon could be initialized */ | |
200 status = photon_available(); | |
201 if (status == 0) { | |
202 /* Photon could not be used */ | |
203 return NULL; | |
204 } | |
205 | |
206 /* Photon agregates all video devices to one with multiple heads */ | |
207 if (devindex != 0) { | |
208 /* devindex could be zero only in Photon SDL driver */ | |
209 return NULL; | |
210 } | |
211 | |
212 /* Initialize SDL_VideoDevice structure */ | |
213 device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); | |
214 if (device == NULL) { | |
215 SDL_OutOfMemory(); | |
216 return NULL; | |
217 } | |
218 | |
219 /* Initialize internal photon specific data */ | |
220 phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); | |
221 if (phdata == NULL) { | |
222 SDL_OutOfMemory(); | |
223 SDL_free(device); | |
224 return NULL; | |
225 } | |
226 device->driverdata = phdata; | |
227 | |
228 /* Get all photon display devices */ | |
229 phdata->avail_rids = | |
230 PdGetDevices(&phdata->rid[0], SDL_VIDEO_PHOTON_MAX_RIDS); | |
231 if (phdata->avail_rids > SDL_VIDEO_PHOTON_MAX_RIDS) { | |
232 phdata->avail_rids = SDL_VIDEO_PHOTON_MAX_RIDS; | |
233 } | |
234 #if defined(SDL_VIDEO_OPENGL_ES) | |
235 /* TODO: add real device detection versus multiple heads */ | |
236 status = | |
237 gf_dev_attach(&phdata->gfdev, GF_DEVICE_INDEX(0), | |
238 &phdata->gfdev_info); | |
239 if (status != GF_ERR_OK) { | |
240 /* Do not fail right now, if GF can't be attached */ | |
241 phdata->gfinitialized = SDL_FALSE; | |
242 } else { | |
243 phdata->gfinitialized = SDL_TRUE; | |
244 } | |
245 #endif /* SDL_VIDEO_OPENGL_ES */ | |
246 | |
247 /* Set default target device */ | |
248 status = PdSetTargetDevice(NULL, phdata->rid[0]); | |
249 if (status == -1) { | |
250 SDL_SetError("Photon: Can't set default target device"); | |
251 #if defined(SDL_VIDEO_OPENGL_ES) | |
252 gf_dev_detach(phdata->gfdev); | |
253 #endif /* SDL_VIDEO_OPENGL_ES */ | |
254 SDL_free(phdata); | |
255 SDL_free(device); | |
256 return NULL; | |
257 } | |
258 phdata->current_device_id = 0; | |
259 | |
260 /* Setup amount of available displays and current display */ | |
261 device->num_displays = 0; | |
262 device->current_display = 0; | |
263 | |
264 /* Set device free function */ | |
265 device->free = photon_destroy; | |
266 | |
267 /* Setup all functions which we can handle */ | |
268 device->VideoInit = photon_videoinit; | |
269 device->VideoQuit = photon_videoquit; | |
270 device->GetDisplayModes = photon_getdisplaymodes; | |
271 device->SetDisplayMode = photon_setdisplaymode; | |
272 device->SetDisplayPalette = photon_setdisplaypalette; | |
273 device->GetDisplayPalette = photon_getdisplaypalette; | |
274 device->SetDisplayGammaRamp = photon_setdisplaygammaramp; | |
275 device->GetDisplayGammaRamp = photon_getdisplaygammaramp; | |
276 device->CreateWindow = photon_createwindow; | |
277 device->CreateWindowFrom = photon_createwindowfrom; | |
278 device->SetWindowTitle = photon_setwindowtitle; | |
279 device->SetWindowIcon = photon_setwindowicon; | |
280 device->SetWindowPosition = photon_setwindowposition; | |
281 device->SetWindowSize = photon_setwindowsize; | |
282 device->ShowWindow = photon_showwindow; | |
283 device->HideWindow = photon_hidewindow; | |
284 device->RaiseWindow = photon_raisewindow; | |
285 device->MaximizeWindow = photon_maximizewindow; | |
286 device->MinimizeWindow = photon_minimizewindow; | |
287 device->RestoreWindow = photon_restorewindow; | |
288 device->SetWindowGrab = photon_setwindowgrab; | |
289 device->DestroyWindow = photon_destroywindow; | |
290 device->GetWindowWMInfo = photon_getwindowwminfo; | |
291 device->GL_LoadLibrary = photon_gl_loadlibrary; | |
292 device->GL_GetProcAddress = photon_gl_getprocaddres; | |
293 device->GL_UnloadLibrary = photon_gl_unloadlibrary; | |
294 device->GL_CreateContext = photon_gl_createcontext; | |
295 device->GL_MakeCurrent = photon_gl_makecurrent; | |
296 device->GL_SetSwapInterval = photon_gl_setswapinterval; | |
297 device->GL_GetSwapInterval = photon_gl_getswapinterval; | |
298 device->GL_SwapWindow = photon_gl_swapwindow; | |
299 device->GL_DeleteContext = photon_gl_deletecontext; | |
300 device->PumpEvents = photon_pumpevents; | |
301 device->SuspendScreenSaver = photon_suspendscreensaver; | |
302 | |
303 return device; | |
304 } | |
305 | |
306 VideoBootStrap photon_bootstrap = { | |
307 "photon", | |
308 "SDL QNX Photon video driver", | |
309 photon_available, | |
310 photon_create | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 }; |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
313 /*****************************************************************************/ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
314 /* SDL Video and Display initialization/handling functions */ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
315 /*****************************************************************************/ |
3139 | 316 int |
317 photon_videoinit(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
318 { |
3139 | 319 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
320 PgHWCaps_t hwcaps; | |
321 PgVideoModeInfo_t modeinfo; | |
322 int32_t status; | |
323 SDL_VideoDisplay display; | |
324 SDL_DisplayMode current_mode; | |
325 SDL_DisplayData *didata; | |
326 uint32_t it; | |
327 uint32_t jt; | |
328 char *override; | |
329 | |
330 /* By default Photon do not uses swap on VSYNC */ | |
3411
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
331 #if defined(SDL_VIDEO_OPENGL_ES) |
3139 | 332 phdata->swapinterval = 0; |
3411
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
333 #endif /* SDL_VIDEO_OPENGL_ES */ |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
334 |
3139 | 335 for (it = 0; it < phdata->avail_rids; it++) { |
336 didata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData)); | |
337 if (didata == NULL) { | |
338 /* memory allocation error */ | |
339 SDL_OutOfMemory(); | |
340 return -1; | |
341 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
342 |
3139 | 343 /* Allocate two cursors with SDL_VIDEO_PHOTON_MAX_CURSOR_SIZE size */ |
344 /* and 128 bytes of spare place */ | |
345 didata->cursor_size = | |
346 ((SDL_VIDEO_PHOTON_MAX_CURSOR_SIZE * 4) >> 3) + 128; | |
347 didata->cursor = (PhCursorDef_t *) SDL_calloc(1, didata->cursor_size); | |
348 if (didata->cursor == NULL) { | |
349 /* memory allocation error */ | |
350 SDL_OutOfMemory(); | |
351 SDL_free(didata); | |
352 return -1; | |
353 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
354 |
3139 | 355 /* Initialize GF in case of OpenGL ES support is compiled in */ |
356 #if defined(SDL_VIDEO_OPENGL_ES) | |
357 /* TODO: add real device detection versus multiple heads */ | |
358 if (phdata->gfinitialized == SDL_TRUE) { | |
359 status = | |
360 gf_display_attach(&didata->display, phdata->gfdev, it, | |
361 &didata->display_info); | |
362 if (status != GF_ERR_OK) { | |
363 /* Just shutdown GF, do not fail */ | |
364 gf_dev_detach(phdata->gfdev); | |
365 phdata->gfinitialized = SDL_FALSE; | |
366 } | |
367 } | |
368 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
369 |
3139 | 370 /* Check if current device is not the same as target */ |
371 if (phdata->current_device_id != it) { | |
372 /* Set target device as default for Pd and Pg functions */ | |
373 status = PdSetTargetDevice(NULL, phdata->rid[it]); | |
374 if (status != 0) { | |
375 SDL_SetError("Photon: Can't set default target device\n"); | |
376 SDL_free(didata->cursor); | |
377 SDL_free(didata); | |
378 return -1; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
379 } |
3139 | 380 phdata->current_device_id = it; |
381 } | |
382 | |
383 /* Store device id */ | |
384 didata->device_id = it; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
385 |
3139 | 386 /* Query photon about graphics hardware caps and current video mode */ |
3384
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
387 SDL_memset(&hwcaps, 0x00, sizeof(PgHWCaps_t)); |
3139 | 388 status = PgGetGraphicsHWCaps(&hwcaps); |
389 if (status != 0) { | |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
390 PhRect_t extent; |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
391 PdOffscreenContext_t* curctx; |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
392 |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
393 /* If error happens, this also could mean, that photon is working */ |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
394 /* under custom (not listed by photon) video mode */ |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
395 status=PhWindowQueryVisible(Ph_QUERY_GRAPHICS, 0, 0, &extent); |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
396 if (status != 0) { |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
397 SDL_SetError("Photon: Can't get graphics driver region"); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
398 SDL_free(didata->cursor); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
399 SDL_free(didata); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
400 return -1; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
401 } |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
402 modeinfo.width=extent.lr.x+1; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
403 modeinfo.height=extent.lr.y+1; |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
404 /* Hardcode 60Hz, as the base refresh rate frequency */ |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
405 hwcaps.current_rrate=60; |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
406 /* Clear current video driver name, no way to get it somehow */ |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
407 hwcaps.chip_name[0]=0x00; |
3139 | 408 |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
409 /* Create offscreen context from video memory, which is currently */ |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
410 /* displayed on the screen */ |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
411 curctx=PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
412 if (curctx==NULL) |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
413 { |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
414 SDL_SetError("Photon: Can't get display area capabilities"); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
415 SDL_free(didata->cursor); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
416 SDL_free(didata); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
417 return -1; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
418 } |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
419 /* Retrieve current bpp */ |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
420 modeinfo.type=curctx->format; |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
421 PhDCRelease(curctx); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
422 } else { |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
423 /* Get current video mode details */ |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
424 status = PgGetVideoModeInfo(hwcaps.current_video_mode, &modeinfo); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
425 if (status != 0) { |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
426 SDL_SetError("Photon: Can't get current video mode information"); |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
427 SDL_free(didata->cursor); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
428 SDL_free(didata); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
429 return -1; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
430 } |
3384
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
431 |
3399
f96615051c8c
Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents:
3387
diff
changeset
|
432 /* Get current video mode 2D capabilities for the renderer */ |
3384
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
433 didata->mode_2dcaps=0; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
434 if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND)==PgVM_MODE_CAP2_ALPHA_BLEND) |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
435 { |
3386
fff074de9675
Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents:
3384
diff
changeset
|
436 didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND; |
3384
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
437 } |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
438 if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_SCALED_BLIT)==PgVM_MODE_CAP2_SCALED_BLIT) |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
439 { |
3386
fff074de9675
Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents:
3384
diff
changeset
|
440 didata->mode_2dcaps|=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
|
441 } |
3139 | 442 } |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
443 |
3139 | 444 /* Setup current desktop mode for SDL */ |
445 SDL_zero(current_mode); | |
446 current_mode.w = modeinfo.width; | |
447 current_mode.h = modeinfo.height; | |
448 current_mode.refresh_rate = hwcaps.current_rrate; | |
449 current_mode.format = photon_image_to_sdl_pixelformat(modeinfo.type); | |
450 current_mode.driverdata = NULL; | |
451 | |
452 /* Copy device name */ | |
453 SDL_strlcpy(didata->description, hwcaps.chip_name, | |
454 SDL_VIDEO_PHOTON_DEVICENAME_MAX - 1); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
455 |
3139 | 456 /* Search device capabilities and possible workarounds */ |
457 jt = 0; | |
458 do { | |
459 if (photon_devicename[jt].name == NULL) { | |
460 break; | |
461 } | |
462 if (SDL_strncmp | |
463 (photon_devicename[jt].name, didata->description, | |
464 SDL_strlen(photon_devicename[jt].name)) == 0) { | |
465 didata->caps = photon_devicename[jt].caps; | |
466 } | |
467 jt++; | |
468 } while (1); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
469 |
3139 | 470 /* Initialize display structure */ |
471 SDL_zero(display); | |
472 display.desktop_mode = current_mode; | |
473 display.current_mode = current_mode; | |
3399
f96615051c8c
Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents:
3387
diff
changeset
|
474 display.fullscreen_mode = current_mode; |
3139 | 475 display.driverdata = didata; |
476 didata->current_mode = current_mode; | |
477 SDL_AddVideoDisplay(&display); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
478 |
3139 | 479 /* Check for environment variables which could override some SDL settings */ |
480 didata->custom_refresh = 0; | |
481 override = SDL_getenv("SDL_VIDEO_PHOTON_REFRESH_RATE"); | |
482 if (override != NULL) { | |
483 if (SDL_sscanf(override, "%u", &didata->custom_refresh) != 1) { | |
484 didata->custom_refresh = 0; | |
485 } | |
486 } | |
487 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
488 |
3139 | 489 /* Add photon input devices */ |
490 status = photon_addinputdevices(_this); | |
491 if (status != 0) { | |
492 /* SDL error is set by photon_addinputdevices() function */ | |
493 return -1; | |
494 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
495 |
3139 | 496 /* Add photon renderer to SDL */ |
497 photon_addrenderdriver(_this); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
498 |
3139 | 499 /* video has been initialized successfully */ |
500 return 1; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
501 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
502 |
3139 | 503 void |
504 photon_videoquit(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
505 { |
3139 | 506 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
507 SDL_DisplayData *didata; | |
508 uint32_t it; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
509 |
3139 | 510 /* SDL will restore our desktop mode on exit */ |
511 for (it = 0; it < _this->num_displays; it++) { | |
512 didata = _this->displays[it].driverdata; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
513 |
3139 | 514 if (didata->cursor != NULL) { |
515 SDL_free(didata->cursor); | |
516 } | |
517 #if defined(SDL_VIDEO_OPENGL_ES) | |
518 if (phdata->gfinitialized == SDL_TRUE) { | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
519 /* Detach GF display */ |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
520 gf_display_detach(didata->display); |
3139 | 521 } |
522 #endif /* SDL_VIDEO_OPENGL_ES */ | |
523 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
524 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
525 |
3139 | 526 void |
527 photon_getdisplaymodes(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
528 { |
3139 | 529 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
530 SDL_DisplayData *didata = | |
531 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
532 SDL_DisplayMode mode; | |
533 PgVideoModes_t modes; | |
534 PgVideoModeInfo_t modeinfo; | |
535 int32_t status; | |
536 uint32_t it; | |
537 uint32_t jt; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
538 |
3139 | 539 /* Check if current device is not the same as target */ |
540 if (phdata->current_device_id != didata->device_id) { | |
541 /* Set target device as default for Pd and Pg functions */ | |
542 status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]); | |
543 if (status != 0) { | |
544 SDL_SetError("Photon: Can't set default target device\n"); | |
545 return; | |
546 } | |
547 phdata->current_device_id = didata->device_id; | |
548 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
549 |
3139 | 550 /* Get array of available video modes */ |
551 status = PgGetVideoModeList(&modes); | |
552 if (status != 0) { | |
553 SDL_SetError("Photon: Can't get video mode list"); | |
554 return; | |
555 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
556 |
3139 | 557 for (it = 0; it < modes.num_modes; it++) { |
558 status = PgGetVideoModeInfo(modes.modes[it], &modeinfo); | |
559 if (status != 0) { | |
560 /* Maybe something wrong with this particular mode, skip it */ | |
561 continue; | |
562 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
563 |
3139 | 564 jt = 0; |
565 do { | |
566 if (modeinfo.refresh_rates[jt] != 0) { | |
567 mode.w = modeinfo.width; | |
568 mode.h = modeinfo.height; | |
569 mode.refresh_rate = modeinfo.refresh_rates[jt]; | |
570 mode.format = photon_image_to_sdl_pixelformat(modeinfo.type); | |
571 mode.driverdata = NULL; | |
572 SDL_AddDisplayMode(_this->current_display, &mode); | |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
573 |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
574 /* If mode is RGBA8888, add the same mode as RGBx888 */ |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
575 if (modeinfo.type == Pg_IMAGE_DIRECT_8888) { |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
576 mode.w = modeinfo.width; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
577 mode.h = modeinfo.height; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
578 mode.refresh_rate = modeinfo.refresh_rates[jt]; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
579 mode.format = SDL_PIXELFORMAT_RGB888; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
580 mode.driverdata = NULL; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
581 SDL_AddDisplayMode(_this->current_display, &mode); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
582 } |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
583 |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
584 /* If mode is RGBA1555, add the same mode as RGBx555 */ |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
585 if (modeinfo.type == Pg_IMAGE_DIRECT_1555) { |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
586 mode.w = modeinfo.width; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
587 mode.h = modeinfo.height; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
588 mode.refresh_rate = modeinfo.refresh_rates[jt]; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
589 mode.format = SDL_PIXELFORMAT_RGB555; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
590 mode.driverdata = NULL; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
591 SDL_AddDisplayMode(_this->current_display, &mode); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
592 } |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
593 |
3139 | 594 jt++; |
595 } else { | |
596 break; | |
597 } | |
598 } while (1); | |
599 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
600 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
601 |
3139 | 602 int |
603 photon_setdisplaymode(_THIS, SDL_DisplayMode * mode) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
604 { |
3139 | 605 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
606 SDL_DisplayData *didata = | |
607 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
608 PgVideoModes_t modes; | |
609 PgVideoModeInfo_t modeinfo; | |
610 PgDisplaySettings_t modesettings; | |
611 uint32_t refresh_rate = 0; | |
612 int32_t status; | |
613 uint32_t it; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
614 |
3139 | 615 /* Check if current device is not the same as target */ |
616 if (phdata->current_device_id != didata->device_id) { | |
617 /* Set target device as default for Pd and Pg functions */ | |
618 status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]); | |
619 if (status != 0) { | |
620 SDL_SetError("Photon: Can't set default target device\n"); | |
3399
f96615051c8c
Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents:
3387
diff
changeset
|
621 return -1; |
3139 | 622 } |
623 phdata->current_device_id = didata->device_id; | |
624 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
625 |
3139 | 626 /* Get array of available video modes */ |
627 status = PgGetVideoModeList(&modes); | |
628 if (status != 0) { | |
629 SDL_SetError("Photon: Can't get video mode list"); | |
3399
f96615051c8c
Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents:
3387
diff
changeset
|
630 return -1; |
3139 | 631 } |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
632 |
3139 | 633 /* Current display dimension and bpp are no more valid */ |
634 didata->current_mode.format = SDL_PIXELFORMAT_UNKNOWN; | |
635 didata->current_mode.w = 0; | |
636 didata->current_mode.h = 0; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
637 |
3139 | 638 /* Check if custom refresh rate requested */ |
639 if (didata->custom_refresh != 0) { | |
640 refresh_rate = didata->custom_refresh; | |
641 } else { | |
642 refresh_rate = mode->refresh_rate; | |
643 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
644 |
3139 | 645 /* Check if SDL GF driver needs to find appropriate refresh rate itself */ |
646 if (refresh_rate == 0) { | |
647 SDL_DisplayMode tempmode; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
648 |
3139 | 649 /* Clear display mode structure */ |
650 SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode)); | |
651 tempmode.refresh_rate = 0x0000FFFF; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
652 |
3139 | 653 /* Check if window width and height matches one of our modes */ |
654 for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) { | |
655 if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) && | |
656 (SDL_CurrentDisplay.display_modes[it].h == mode->h) && | |
657 (SDL_CurrentDisplay.display_modes[it].format == mode->format)) | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
658 { |
3139 | 659 /* Find the lowest refresh rate available */ |
660 if (tempmode.refresh_rate > | |
661 SDL_CurrentDisplay.display_modes[it].refresh_rate) { | |
662 tempmode = SDL_CurrentDisplay.display_modes[it]; | |
663 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
664 } |
3139 | 665 } |
666 if (tempmode.refresh_rate != 0x0000FFFF) { | |
667 refresh_rate = tempmode.refresh_rate; | |
668 } else { | |
669 /* Let video driver decide what to do with this */ | |
670 refresh_rate = 0; | |
671 } | |
672 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
673 |
3139 | 674 /* Check if SDL GF driver needs to check custom refresh rate */ |
675 if (didata->custom_refresh != 0) { | |
676 SDL_DisplayMode tempmode; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
677 |
3139 | 678 /* Clear display mode structure */ |
679 SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode)); | |
680 tempmode.refresh_rate = 0x0000FFFF; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
681 |
3139 | 682 /* Check if window width and height matches one of our modes */ |
683 for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) { | |
684 if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) && | |
685 (SDL_CurrentDisplay.display_modes[it].h == mode->h) && | |
686 (SDL_CurrentDisplay.display_modes[it].format == mode->format)) | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
687 { |
3139 | 688 /* Find the lowest refresh rate available */ |
689 if (tempmode.refresh_rate > | |
690 SDL_CurrentDisplay.display_modes[it].refresh_rate) { | |
691 tempmode = SDL_CurrentDisplay.display_modes[it]; | |
692 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
693 |
3139 | 694 /* Check if requested refresh rate found */ |
695 if (refresh_rate == | |
696 SDL_CurrentDisplay.display_modes[it].refresh_rate) { | |
697 tempmode = SDL_CurrentDisplay.display_modes[it]; | |
698 break; | |
699 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
700 } |
3139 | 701 } |
702 if (tempmode.refresh_rate != 0x0000FFFF) { | |
703 refresh_rate = tempmode.refresh_rate; | |
704 } else { | |
705 /* Let video driver decide what to do with this */ | |
706 refresh_rate = 0; | |
707 } | |
708 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
709 |
3139 | 710 /* Find photon's video mode number */ |
711 for (it = 0; it < modes.num_modes; it++) { | |
712 uint32_t jt; | |
713 uint32_t foundrefresh; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
714 |
3139 | 715 /* Get current video mode details */ |
716 status = PgGetVideoModeInfo(modes.modes[it], &modeinfo); | |
717 if (status != 0) { | |
718 /* Maybe something wrong with this particular mode, skip it */ | |
719 continue; | |
720 } | |
721 if ((modeinfo.width == mode->w) && (modeinfo.height == mode->h) && | |
722 (modeinfo.type == photon_sdl_to_image_pixelformat(mode->format))) | |
723 { | |
724 /* Mode is found, find requested refresh rate, this case is for */ | |
725 /* video drivers, which provide non-generic video modes. */ | |
726 jt = 0; | |
727 foundrefresh = 0; | |
728 do { | |
729 if (modeinfo.refresh_rates[jt] != 0) { | |
730 if (modeinfo.refresh_rates[jt] == refresh_rate) { | |
731 foundrefresh = 1; | |
732 break; | |
733 } | |
734 jt++; | |
735 } else { | |
736 break; | |
737 } | |
738 } while (1); | |
739 if (foundrefresh != 0) { | |
740 break; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
741 } |
3139 | 742 } |
743 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
744 |
3139 | 745 /* Check if video mode has not been found */ |
746 if (it == modes.num_modes) { | |
747 SDL_SetError("Photon: Can't find appropriate video mode"); | |
748 return -1; | |
749 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
750 |
3139 | 751 /* Fill mode settings */ |
752 modesettings.flags = 0x00000000; | |
753 modesettings.mode = modes.modes[it]; | |
754 modesettings.refresh = refresh_rate; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
755 |
3139 | 756 /* Finally set new video mode */ |
757 status = PgSetVideoMode(&modesettings); | |
758 if (status != 0) { | |
759 SDL_SetError("Photon: Can't set new video mode"); | |
760 return -1; | |
761 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
762 |
3139 | 763 /* Store new video mode parameters */ |
764 didata->current_mode = *mode; | |
765 didata->current_mode.refresh_rate = refresh_rate; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
766 |
3399
f96615051c8c
Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents:
3387
diff
changeset
|
767 /* Get current video mode 2D capabilities for the renderer */ |
3384
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
768 didata->mode_2dcaps=0; |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
769 if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND)==PgVM_MODE_CAP2_ALPHA_BLEND) |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
770 { |
3386
fff074de9675
Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents:
3384
diff
changeset
|
771 didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND; |
3384
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
772 } |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
773 if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_SCALED_BLIT)==PgVM_MODE_CAP2_SCALED_BLIT) |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
774 { |
3386
fff074de9675
Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents:
3384
diff
changeset
|
775 didata->mode_2dcaps|=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
|
776 } |
04af265172f9
Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents:
3383
diff
changeset
|
777 |
3139 | 778 return 0; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
779 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
780 |
3139 | 781 int |
782 photon_setdisplaypalette(_THIS, SDL_Palette * palette) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
783 { |
3139 | 784 SDL_DisplayData *didata = |
785 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
786 |
3139 | 787 /* Setting display palette operation has been failed */ |
788 return -1; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
789 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
790 |
3139 | 791 int |
792 photon_getdisplaypalette(_THIS, SDL_Palette * palette) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
793 { |
3139 | 794 SDL_DisplayData *didata = |
795 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
796 |
3139 | 797 /* Getting display palette operation has been failed */ |
798 return -1; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
799 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
800 |
3139 | 801 int |
802 photon_setdisplaygammaramp(_THIS, Uint16 * ramp) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
803 { |
3139 | 804 SDL_DisplayData *didata = |
805 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
806 |
3139 | 807 /* Setting display gamma ramp operation has been failed */ |
808 return -1; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
809 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
810 |
3139 | 811 int |
812 photon_getdisplaygammaramp(_THIS, Uint16 * ramp) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
813 { |
3139 | 814 /* Getting display gamma ramp operation has been failed */ |
815 return -1; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
816 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
817 |
3139 | 818 int |
819 photon_createwindow(_THIS, SDL_Window * window) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
820 { |
3139 | 821 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
822 SDL_DisplayData *didata = | |
823 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
824 SDL_WindowData *wdata; | |
825 PhDim_t winsize; | |
826 PhPoint_t winpos; | |
827 PtArg_t winargs[32]; | |
828 uint32_t winargc = 0; | |
829 int32_t status; | |
830 PhRegion_t wregion; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
831 |
3139 | 832 /* Allocate window internal data */ |
833 wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); | |
834 if (wdata == NULL) { | |
835 SDL_OutOfMemory(); | |
836 return -1; | |
837 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
838 |
3139 | 839 /* Setup driver data for this window */ |
840 window->driverdata = wdata; | |
841 | |
842 /* Set initial window title */ | |
843 if (window->title != NULL) { | |
844 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_TITLE, window->title, 0); | |
845 } else { | |
3383
90935231e9b6
Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents:
3375
diff
changeset
|
846 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_TITLE, "SDL unnamed application", 0); |
3139 | 847 } |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
848 |
3139 | 849 /* TODO: handle SDL_WINDOW_INPUT_GRABBED */ |
850 | |
851 /* Disable default window filling on redraw */ | |
852 PtSetArg(&winargs[winargc++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, | |
853 Pt_BASIC_PREVENT_FILL); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
854 |
3139 | 855 /* Reset default managed flags to disabled state */ |
856 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, | |
857 Ph_WM_APP_DEF_MANAGED); | |
858 /* Set which events we will not handle, let WM to handle them */ | |
859 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, | |
860 Ph_WM_BACKDROP | Ph_WM_TOFRONT | Ph_WM_COLLAPSE | Ph_WM_FFRONT | | |
861 Ph_WM_FOCUS | Ph_WM_HELP | Ph_WM_HIDE | Ph_WM_MAX | | |
862 Ph_WM_MENU | Ph_WM_MOVE | Ph_WM_RESTORE | Ph_WM_TASKBAR | | |
863 Ph_WM_TOBACK | Ph_WM_RESIZE); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
864 |
3139 | 865 /* Reset default notify events to disable */ |
866 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE, | |
867 Ph_WM_RESIZE | Ph_WM_CLOSE | Ph_WM_HELP); | |
868 /* Set which events we will handle */ | |
869 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, | |
870 Ph_WM_CLOSE | Ph_WM_COLLAPSE | Ph_WM_FOCUS | Ph_WM_MAX | | |
871 Ph_WM_MOVE | Ph_WM_RESIZE | Ph_WM_RESTORE | Ph_WM_HIDE); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
872 |
3139 | 873 /* Borderless window can't be resizeable */ |
874 if ((window->flags & SDL_WINDOW_BORDERLESS) == SDL_WINDOW_BORDERLESS) { | |
875 window->flags &= ~(SDL_WINDOW_RESIZABLE); | |
876 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
877 |
3139 | 878 /* Reset all default decorations */ |
879 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, | |
880 Ph_WM_APP_DEF_RENDER); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
881 |
3139 | 882 /* Fullscreen window has its own decorations */ |
883 if ((window->flags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN) { | |
884 window->flags |= SDL_WINDOW_BORDERLESS; | |
885 window->flags &= ~(SDL_WINDOW_RESIZABLE); | |
886 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, | |
887 Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_TITLE); | |
888 } else { | |
889 uint32_t decorations = | |
890 Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_MENU | Ph_WM_RENDER_MIN | | |
891 Ph_WM_RENDER_TITLE | Ph_WM_RENDER_MOVE; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
892 |
3139 | 893 if ((window->flags & SDL_WINDOW_RESIZABLE) == SDL_WINDOW_RESIZABLE) { |
894 decorations |= | |
895 Ph_WM_RENDER_BORDER | Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX; | |
896 PtSetArg(&winargs[winargc++], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, | |
897 Pt_RESIZE_XY_AS_REQUIRED); | |
898 } | |
899 if ((window->flags & SDL_WINDOW_BORDERLESS) != SDL_WINDOW_BORDERLESS) { | |
900 decorations |= Ph_WM_RENDER_BORDER; | |
901 } | |
902 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, | |
903 decorations); | |
904 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
905 |
3139 | 906 /* Set initial window state */ |
907 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_STATE, Pt_FALSE, | |
908 Ph_WM_STATE_ISFOCUS); | |
909 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_STATE, Pt_TRUE, | |
910 Ph_WM_STATE_ISALTKEY); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
911 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
912 /* Special case, do not handle maximize events, if window can't be resized */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
913 if ((window->flags & SDL_WINDOW_RESIZABLE) != SDL_WINDOW_RESIZABLE) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
914 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
915 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
916 Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_RESIZE); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
917 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
918 |
3139 | 919 /* Set window dimension */ |
920 winsize.w = window->w; | |
921 winsize.h = window->h; | |
922 PtSetArg(&winargs[winargc++], Pt_ARG_DIM, &winsize, 0); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
923 |
3139 | 924 /* Check if upper level requests WM to position window */ |
925 if ((window->x == SDL_WINDOWPOS_UNDEFINED) | |
926 && (window->y == SDL_WINDOWPOS_UNDEFINED)) { | |
927 /* Do not set widget position, let WM to set it */ | |
928 } else { | |
929 if (window->x == SDL_WINDOWPOS_UNDEFINED) { | |
930 window->x = 0; | |
931 } | |
932 if (window->y == SDL_WINDOWPOS_UNDEFINED) { | |
933 window->y = 0; | |
934 } | |
935 if (window->x == SDL_WINDOWPOS_CENTERED) { | |
936 window->x = (didata->current_mode.w - window->w) / 2; | |
937 } | |
938 if (window->y == SDL_WINDOWPOS_CENTERED) { | |
939 window->y = (didata->current_mode.h - window->h) / 2; | |
940 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
941 |
3139 | 942 /* Now set window position */ |
943 winpos.x = window->x; | |
944 winpos.y = window->y; | |
945 PtSetArg(&winargs[winargc++], Pt_ARG_POS, &winpos, 0); | |
946 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
947 |
3139 | 948 /* Check if window must support OpenGL ES rendering */ |
949 if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) { | |
950 #if defined(SDL_VIDEO_OPENGL_ES) | |
951 EGLBoolean initstatus; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
952 |
3139 | 953 /* Check if GF was initialized correctly */ |
954 if (phdata->gfinitialized == SDL_FALSE) { | |
955 SDL_SetError | |
956 ("Photon: GF initialization failed, no OpenGL ES support"); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
957 return -1; |
3139 | 958 } |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
959 |
3139 | 960 /* Mark this window as OpenGL ES compatible */ |
961 wdata->uses_gles = SDL_TRUE; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
962 |
3139 | 963 /* Create connection to OpenGL ES */ |
964 if (phdata->egldisplay == EGL_NO_DISPLAY) { | |
965 phdata->egldisplay = eglGetDisplay(phdata->gfdev); | |
966 if (phdata->egldisplay == EGL_NO_DISPLAY) { | |
967 SDL_SetError("Photon: Can't get connection to OpenGL ES"); | |
968 return -1; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
969 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
970 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
971 /* Initialize OpenGL ES library, ignore EGL version */ |
3139 | 972 initstatus = eglInitialize(phdata->egldisplay, NULL, NULL); |
973 if (initstatus != EGL_TRUE) { | |
974 SDL_SetError("Photon: Can't init OpenGL ES library"); | |
975 return -1; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
976 } |
3139 | 977 } |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
978 |
3139 | 979 /* Increment GL ES reference count usage */ |
980 phdata->egl_refcount++; | |
981 #else | |
982 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
983 return -1; | |
984 #endif /* SDL_VIDEO_OPENGL_ES */ | |
985 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
986 |
3139 | 987 /* Finally create the window */ |
988 wdata->window = PtCreateWidget(PtWindow, Pt_NO_PARENT, winargc, winargs); | |
989 if (wdata->window == NULL) { | |
990 SDL_SetError("Photon: Can't create window widget"); | |
991 SDL_free(wdata); | |
992 return -1; | |
993 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
994 |
3139 | 995 /* Show widget */ |
996 status = PtRealizeWidget(wdata->window); | |
997 if (status != 0) { | |
998 SDL_SetError("Photon: Can't realize window widget"); | |
999 PtDestroyWidget(wdata->window); | |
1000 SDL_free(wdata); | |
1001 return; | |
1002 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1003 |
3139 | 1004 /* Just created SDL window always gets focus */ |
1005 window->flags |= SDL_WINDOW_INPUT_FOCUS; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1006 |
3139 | 1007 /* Create window-specific cursor after creation */ |
1008 if (didata->cursor_visible == SDL_TRUE) { | |
1009 /* Setup cursor type. shape and default color */ | |
1010 PtSetResource(wdata->window, Pt_ARG_CURSOR_COLOR, | |
1011 Ph_CURSOR_DEFAULT_COLOR, 0); | |
1012 PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0); | |
1013 PtSetResource(wdata->window, Pt_ARG_BITMAP_CURSOR, didata->cursor, | |
1014 didata->cursor->hdr.len + sizeof(PhRegionDataHdr_t)); | |
1015 } else { | |
1016 PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, 0); | |
1017 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1018 |
3139 | 1019 /* Set window region sensible to mouse motion events */ |
1020 status = | |
1021 PhRegionQuery(PtWidgetRid(wdata->window), &wregion, NULL, NULL, 0); | |
1022 if (status != 0) { | |
1023 SDL_SetError | |
1024 ("Photon: Can't set region sensivity to mouse motion events"); | |
1025 PtDestroyWidget(wdata->window); | |
1026 SDL_free(wdata); | |
1027 return -1; | |
1028 } | |
1029 wregion.events_sense |= | |
1030 Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON; | |
1031 status = PhRegionChange(Ph_REGION_EV_SENSE, 0, &wregion, NULL, NULL); | |
1032 if (status < 0) { | |
1033 SDL_SetError("Photon: Can't change region sensivity"); | |
1034 PtDestroyWidget(wdata->window); | |
1035 SDL_free(wdata); | |
1036 return -1; | |
1037 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1038 |
3139 | 1039 /* Flush all widget operations again */ |
1040 PtFlush(); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1041 |
3139 | 1042 /* By default last created window got a input focus */ |
1043 SDL_SetKeyboardFocus(0, window->id); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1044 |
3399
f96615051c8c
Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents:
3387
diff
changeset
|
1045 /* Emit focus gained event, because photon is not sending it */ |
f96615051c8c
Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents:
3387
diff
changeset
|
1046 SDL_OnWindowFocusGained(window); |
f96615051c8c
Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents:
3387
diff
changeset
|
1047 |
3139 | 1048 /* Window has been successfully created */ |
1049 return 0; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1050 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1051 |
3139 | 1052 int |
1053 photon_createwindowfrom(_THIS, SDL_Window * window, const void *data) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1054 { |
3139 | 1055 /* TODO: it is possible */ |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1056 |
3139 | 1057 /* Failed to create window from another window */ |
1058 return -1; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1059 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1060 |
3139 | 1061 void |
1062 photon_setwindowtitle(_THIS, SDL_Window * window) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1063 { |
3139 | 1064 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1065 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1066 |
3139 | 1067 /* Set window title */ |
1068 if (window->title != NULL) { | |
1069 status = | |
1070 PtSetResource(wdata->window, Pt_ARG_WINDOW_TITLE, window->title, | |
1071 0); | |
1072 } else { | |
1073 status = PtSetResource(wdata->window, Pt_ARG_WINDOW_TITLE, "", 0); | |
1074 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1075 |
3139 | 1076 if (status != 0) { |
1077 SDL_SetError("Photon: Can't set window title"); | |
1078 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1079 |
3139 | 1080 /* Flush all widget operations */ |
1081 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1082 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1083 |
3139 | 1084 void |
1085 photon_setwindowicon(_THIS, SDL_Window * window, SDL_Surface * icon) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1086 { |
3139 | 1087 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1088 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1089 |
3139 | 1090 /* TODO: Use iconify ? */ |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1091 |
3139 | 1092 /* Flush all widget operations */ |
1093 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1094 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1095 |
3139 | 1096 void |
1097 photon_setwindowposition(_THIS, SDL_Window * window) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1098 { |
3139 | 1099 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1100 SDL_DisplayData *didata = | |
1101 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
1102 PhPoint_t winpos; | |
1103 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1104 |
3139 | 1105 /* Check if upper level requests WM to position window */ |
1106 if ((window->x == SDL_WINDOWPOS_UNDEFINED) | |
1107 && (window->y == SDL_WINDOWPOS_UNDEFINED)) { | |
1108 /* Do not set widget position, let WM to set it */ | |
1109 } else { | |
1110 if (window->x == SDL_WINDOWPOS_UNDEFINED) { | |
1111 window->x = 0; | |
1112 } | |
1113 if (window->y == SDL_WINDOWPOS_UNDEFINED) { | |
1114 window->y = 0; | |
1115 } | |
1116 if (window->x == SDL_WINDOWPOS_CENTERED) { | |
1117 window->x = (didata->current_mode.w - window->w) / 2; | |
1118 } | |
1119 if (window->y == SDL_WINDOWPOS_CENTERED) { | |
1120 window->y = (didata->current_mode.h - window->h) / 2; | |
1121 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1122 |
3139 | 1123 /* Now set window position */ |
1124 winpos.x = window->x; | |
1125 winpos.y = window->y; | |
1126 status = PtSetResource(wdata->window, Pt_ARG_POS, &winpos, 0); | |
1127 if (status != 0) { | |
1128 SDL_SetError("Photon: Can't set window position"); | |
1129 } | |
1130 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1131 |
3139 | 1132 /* Flush all widget operations */ |
1133 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1134 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1135 |
3139 | 1136 void |
1137 photon_setwindowsize(_THIS, SDL_Window * window) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1138 { |
3139 | 1139 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1140 PhDim_t winsize; | |
1141 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1142 |
3139 | 1143 winsize.w = window->w; |
1144 winsize.h = window->h; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1145 |
3139 | 1146 status = PtSetResource(wdata->window, Pt_ARG_DIM, &winsize, 0); |
1147 if (status != 0) { | |
1148 SDL_SetError("Photon: Can't set window size"); | |
1149 } | |
1150 | |
1151 /* Flush all widget operations */ | |
1152 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1153 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1154 |
3139 | 1155 void |
1156 photon_showwindow(_THIS, SDL_Window * window) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1157 { |
3139 | 1158 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1159 int32_t status; | |
1160 | |
1161 /* Bring focus to window and put it in front of others */ | |
1162 PtWindowToFront(wdata->window); | |
1163 | |
1164 /* Flush all widget operations */ | |
1165 PtFlush(); | |
1166 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1167 |
3139 | 1168 void |
1169 photon_hidewindow(_THIS, SDL_Window * window) | |
1170 { | |
1171 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | |
1172 PhWindowEvent_t winevent; | |
1173 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1174 |
3139 | 1175 SDL_memset(&winevent, 0x00, sizeof(PhWindowEvent_t)); |
1176 winevent.event_f = Ph_WM_HIDE; | |
1177 winevent.rid = PtWidgetRid(wdata->window); | |
1178 winevent.event_state = Ph_WM_EVSTATE_HIDE; | |
1179 | |
1180 status = PtForwardWindowEvent(&winevent); | |
1181 if (status != 0) { | |
1182 SDL_SetError("Photon: Can't hide window"); | |
1183 } | |
1184 | |
1185 /* Flush all widget operations */ | |
1186 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1187 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1188 |
3139 | 1189 void |
1190 photon_raisewindow(_THIS, SDL_Window * window) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1191 { |
3139 | 1192 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1193 PhWindowEvent_t winevent; | |
1194 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1195 |
3139 | 1196 SDL_memset(&winevent, 0x00, sizeof(PhWindowEvent_t)); |
1197 winevent.event_f = Ph_WM_HIDE; | |
1198 winevent.rid = PtWidgetRid(wdata->window); | |
1199 winevent.event_state = Ph_WM_EVSTATE_UNHIDE; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1200 |
3139 | 1201 status = PtForwardWindowEvent(&winevent); |
1202 if (status != 0) { | |
1203 SDL_SetError("Photon: Can't hide window"); | |
1204 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1205 |
3139 | 1206 /* Flush all widget operations */ |
1207 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1208 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1209 |
3139 | 1210 void |
1211 photon_maximizewindow(_THIS, SDL_Window * window) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1212 { |
3139 | 1213 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1214 PhWindowEvent_t winevent; | |
1215 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1216 |
3139 | 1217 /* Flush all widget operations */ |
1218 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1219 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1220 |
3139 | 1221 void |
1222 photon_minimizewindow(_THIS, SDL_Window * window) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1223 { |
3139 | 1224 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1225 PhWindowEvent_t winevent; | |
1226 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1227 |
3139 | 1228 SDL_memset(&winevent, 0x00, sizeof(PhWindowEvent_t)); |
1229 winevent.event_f = Ph_WM_HIDE; | |
1230 winevent.rid = PtWidgetRid(wdata->window); | |
1231 winevent.event_state = Ph_WM_EVSTATE_HIDE; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1232 |
3139 | 1233 status = PtForwardWindowEvent(&winevent); |
1234 if (status != 0) { | |
1235 SDL_SetError("Photon: Can't hide window"); | |
1236 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1237 |
3139 | 1238 /* Flush all widget operations */ |
1239 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1240 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1241 |
3139 | 1242 void |
1243 photon_restorewindow(_THIS, SDL_Window * window) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1244 { |
3139 | 1245 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1246 PhWindowEvent_t winevent; | |
1247 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1248 |
3139 | 1249 /* Flush all widget operations */ |
1250 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1251 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1252 |
3139 | 1253 void |
1254 photon_setwindowgrab(_THIS, SDL_Window * window) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1255 { |
3139 | 1256 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1257 PhWindowEvent_t winevent; | |
1258 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1259 |
3139 | 1260 /* Flush all widget operations */ |
1261 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1262 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1263 |
3139 | 1264 void |
1265 photon_destroywindow(_THIS, SDL_Window * window) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1266 { |
3139 | 1267 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
1268 SDL_DisplayData *didata = | |
1269 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
1270 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | |
1271 int32_t status; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1272 |
3139 | 1273 if (wdata != NULL) { |
1274 status = PtDestroyWidget(wdata->window); | |
1275 if (status != 0) { | |
1276 SDL_SetError("Photon: Can't destroy window widget"); | |
1277 } | |
1278 wdata->window = NULL; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1279 |
3139 | 1280 #if defined(SDL_VIDEO_OPENGL_ES) |
1281 if (phdata->gfinitialized == SDL_TRUE) { | |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1282 /* Destroy photon handle to GF surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1283 if (wdata->phsurface != NULL) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1284 PhDCRelease(wdata->phsurface); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1285 wdata->phsurface=NULL; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1286 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1287 |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1288 /* Destroy OpenGL ES surface if it was created */ |
3139 | 1289 if (wdata->gles_surface != EGL_NO_SURFACE) { |
1290 eglDestroySurface(phdata->egldisplay, wdata->gles_surface); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1291 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1292 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1293 /* Free OpenGL ES target surface */ |
3139 | 1294 if (wdata->gfsurface != NULL) { |
1295 gf_surface_free(wdata->gfsurface); | |
3399
f96615051c8c
Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents:
3387
diff
changeset
|
1296 wdata->gfsurface=NULL; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1297 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1298 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1299 phdata->egl_refcount--; |
3139 | 1300 if (phdata->egl_refcount == 0) { |
1301 /* Terminate connection to OpenGL ES */ | |
1302 if (phdata->egldisplay != EGL_NO_DISPLAY) { | |
1303 eglTerminate(phdata->egldisplay); | |
1304 phdata->egldisplay = EGL_NO_DISPLAY; | |
1305 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1306 } |
3139 | 1307 } |
1308 #endif /* SDL_VIDEO_OPENGL_ES */ | |
1309 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1310 |
3139 | 1311 /* Flush all widget operations */ |
1312 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1313 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1314 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1315 /*****************************************************************************/ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1316 /* SDL Window Manager function */ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1317 /*****************************************************************************/ |
3139 | 1318 SDL_bool |
1319 photon_getwindowwminfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1320 { |
3139 | 1321 if (info->version.major <= SDL_MAJOR_VERSION) { |
1322 return SDL_TRUE; | |
1323 } else { | |
1324 SDL_SetError("application not compiled with SDL %d.%d\n", | |
1325 SDL_MAJOR_VERSION, SDL_MINOR_VERSION); | |
1326 return SDL_FALSE; | |
1327 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1328 |
3139 | 1329 /* Failed to get window manager information */ |
1330 return SDL_FALSE; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1331 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1332 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1333 /*****************************************************************************/ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1334 /* SDL OpenGL/OpenGL ES functions */ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1335 /*****************************************************************************/ |
3139 | 1336 int |
1337 photon_gl_loadlibrary(_THIS, const char *path) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1338 { |
3139 | 1339 #if defined(SDL_VIDEO_OPENGL_ES) |
1340 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1341 |
3139 | 1342 if (phdata->gfinitialized != SDL_TRUE) { |
1343 SDL_SetError | |
1344 ("Photon: GF initialization failed, no OpenGL ES support"); | |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
1345 return -1; |
3139 | 1346 } |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1347 |
3139 | 1348 /* Check if OpenGL ES library is specified for GF driver */ |
1349 if (path == NULL) { | |
1350 path = SDL_getenv("SDL_OPENGL_LIBRARY"); | |
1351 if (path == NULL) { | |
1352 path = SDL_getenv("SDL_OPENGLES_LIBRARY"); | |
1353 } | |
1354 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1355 |
3139 | 1356 /* Check if default library loading requested */ |
1357 if (path == NULL) { | |
1358 /* Already linked with GF library which provides egl* subset of */ | |
1359 /* functions, use Common profile of OpenGL ES library by default */ | |
1360 path = "/usr/lib/libGLES_CM.so.1"; | |
1361 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1362 |
3139 | 1363 /* Load dynamic library */ |
1364 _this->gl_config.dll_handle = SDL_LoadObject(path); | |
1365 if (!_this->gl_config.dll_handle) { | |
1366 /* Failed to load new GL ES library */ | |
1367 SDL_SetError("Photon: Failed to locate OpenGL ES library"); | |
1368 return -1; | |
1369 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1370 |
3139 | 1371 /* Store OpenGL ES library path and name */ |
1372 SDL_strlcpy(_this->gl_config.driver_path, path, | |
1373 SDL_arraysize(_this->gl_config.driver_path)); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1374 |
3139 | 1375 /* New OpenGL ES library is loaded */ |
1376 return 0; | |
1377 #else | |
1378 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1379 return -1; | |
1380 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1381 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1382 |
3139 | 1383 void * |
1384 photon_gl_getprocaddres(_THIS, const char *proc) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1385 { |
3139 | 1386 #if defined(SDL_VIDEO_OPENGL_ES) |
1387 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
1388 void *function_address; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1389 |
3139 | 1390 if (phdata->gfinitialized != SDL_TRUE) { |
1391 SDL_SetError | |
1392 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1393 return NULL; | |
1394 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1395 |
3139 | 1396 /* Try to get function address through the egl interface */ |
1397 function_address = eglGetProcAddress(proc); | |
1398 if (function_address != NULL) { | |
1399 return function_address; | |
1400 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1401 |
3139 | 1402 /* Then try to get function in the OpenGL ES library */ |
1403 if (_this->gl_config.dll_handle) { | |
1404 function_address = | |
1405 SDL_LoadFunction(_this->gl_config.dll_handle, proc); | |
1406 if (function_address != NULL) { | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1407 return function_address; |
3139 | 1408 } |
1409 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1410 |
3139 | 1411 /* Add emulated OpenGL ES 1.1 functions */ |
1412 if (SDL_strcmp(proc, "glTexParameteri") == 0) { | |
1413 return glTexParameteri; | |
1414 } | |
1415 if (SDL_strcmp(proc, "glTexParameteriv") == 0) { | |
1416 return glTexParameteriv; | |
1417 } | |
1418 if (SDL_strcmp(proc, "glColor4ub") == 0) { | |
1419 return glColor4ub; | |
1420 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1421 |
3139 | 1422 /* Failed to get GL ES function address pointer */ |
1423 SDL_SetError("Photon: Cannot locate OpenGL ES function name"); | |
1424 return NULL; | |
1425 #else | |
1426 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1427 return NULL; | |
1428 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1429 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1430 |
3139 | 1431 void |
1432 photon_gl_unloadlibrary(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1433 { |
3139 | 1434 #if defined(SDL_VIDEO_OPENGL_ES) |
1435 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1436 |
3139 | 1437 if (phdata->gfinitialized == SDL_TRUE) { |
1438 /* Unload OpenGL ES library */ | |
1439 if (_this->gl_config.dll_handle) { | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1440 SDL_UnloadObject(_this->gl_config.dll_handle); |
3139 | 1441 _this->gl_config.dll_handle = NULL; |
1442 } | |
1443 } else { | |
1444 SDL_SetError | |
1445 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1446 } | |
1447 #else | |
1448 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1449 return; | |
1450 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1451 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1452 |
3139 | 1453 SDL_GLContext |
1454 photon_gl_createcontext(_THIS, SDL_Window * window) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1455 { |
3139 | 1456 #if defined(SDL_VIDEO_OPENGL_ES) |
1457 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
1458 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | |
1459 SDL_DisplayData *didata = | |
1460 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
1461 EGLBoolean status; | |
1462 int32_t gfstatus; | |
1463 EGLint configs; | |
1464 uint32_t attr_pos; | |
1465 EGLint attr_value; | |
1466 EGLint cit; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1467 |
3139 | 1468 /* Check if GF was initialized */ |
1469 if (phdata->gfinitialized != SDL_TRUE) { | |
1470 SDL_SetError | |
1471 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1472 return NULL; | |
1473 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1474 |
3411
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1475 /* Prepare attributes list to pass them to OpenGL ES egl interface */ |
3139 | 1476 attr_pos = 0; |
1477 wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID; | |
1478 wdata->gles_attributes[attr_pos++] = | |
1479 qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format); | |
1480 wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE; | |
1481 wdata->gles_attributes[attr_pos++] = _this->gl_config.red_size; | |
1482 wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE; | |
1483 wdata->gles_attributes[attr_pos++] = _this->gl_config.green_size; | |
1484 wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE; | |
1485 wdata->gles_attributes[attr_pos++] = _this->gl_config.blue_size; | |
1486 wdata->gles_attributes[attr_pos++] = EGL_ALPHA_SIZE; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1487 |
3139 | 1488 /* Setup alpha size in bits */ |
1489 if (_this->gl_config.alpha_size) { | |
1490 wdata->gles_attributes[attr_pos++] = _this->gl_config.alpha_size; | |
1491 } else { | |
1492 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1493 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1494 |
3139 | 1495 /* Setup color buffer size */ |
1496 if (_this->gl_config.buffer_size) { | |
1497 wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE; | |
1498 wdata->gles_attributes[attr_pos++] = _this->gl_config.buffer_size; | |
1499 } else { | |
1500 wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE; | |
1501 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1502 } | |
1503 | |
1504 /* Setup depth buffer bits */ | |
1505 wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE; | |
3411
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1506 if (_this->gl_config.depth_size) |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1507 { |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1508 wdata->gles_attributes[attr_pos++] = _this->gl_config.depth_size; |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1509 } |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1510 else |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1511 { |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1512 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1513 } |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1514 |
3139 | 1515 /* Setup stencil bits */ |
1516 if (_this->gl_config.stencil_size) { | |
1517 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; | |
3411
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1518 wdata->gles_attributes[attr_pos++] = _this->gl_config.stencil_size; |
3139 | 1519 } else { |
1520 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; | |
1521 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1522 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1523 |
3139 | 1524 /* Set number of samples in multisampling */ |
1525 if (_this->gl_config.multisamplesamples) { | |
1526 wdata->gles_attributes[attr_pos++] = EGL_SAMPLES; | |
1527 wdata->gles_attributes[attr_pos++] = | |
1528 _this->gl_config.multisamplesamples; | |
1529 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1530 |
3139 | 1531 /* Multisample buffers, OpenGL ES 1.0 spec defines 0 or 1 buffer */ |
1532 if (_this->gl_config.multisamplebuffers) { | |
1533 wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS; | |
1534 wdata->gles_attributes[attr_pos++] = | |
1535 _this->gl_config.multisamplebuffers; | |
1536 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1537 |
3139 | 1538 /* Finish attributes list */ |
1539 wdata->gles_attributes[attr_pos] = EGL_NONE; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1540 |
3139 | 1541 /* Request first suitable framebuffer configuration */ |
1542 status = eglChooseConfig(phdata->egldisplay, wdata->gles_attributes, | |
1543 wdata->gles_configs, SDL_VIDEO_GF_OPENGLES_CONFS, | |
1544 &configs); | |
1545 if (status != EGL_TRUE) { | |
1546 SDL_SetError | |
1547 ("Photon: Can't find closest configuration for OpenGL ES"); | |
1548 return NULL; | |
1549 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1550 |
3139 | 1551 /* Check if nothing has been found, try "don't care" settings */ |
1552 if (configs == 0) { | |
1553 int32_t it; | |
1554 int32_t jt; | |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1555 static const GLint depthbits[4] = { 32, 24, 16, EGL_DONT_CARE }; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1556 |
3139 | 1557 for (it = 0; it < 4; it++) { |
1558 for (jt = 16; jt >= 0; jt--) { | |
1559 /* Don't care about color buffer bits, use what exist */ | |
1560 /* Replace previous set data with EGL_DONT_CARE */ | |
1561 attr_pos = 0; | |
1562 wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID; | |
1563 wdata->gles_attributes[attr_pos++] = | |
1564 qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format); | |
1565 wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE; | |
1566 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1567 wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE; | |
1568 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1569 wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE; | |
1570 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1571 wdata->gles_attributes[attr_pos++] = EGL_ALPHA_SIZE; | |
1572 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1573 wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE; | |
1574 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1575 |
3139 | 1576 /* Try to find requested or smallest depth */ |
1577 if (_this->gl_config.depth_size) { | |
1578 wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE; | |
1579 wdata->gles_attributes[attr_pos++] = depthbits[it]; | |
1580 } else { | |
1581 wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE; | |
1582 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1583 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1584 |
3139 | 1585 if (_this->gl_config.stencil_size) { |
1586 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; | |
1587 wdata->gles_attributes[attr_pos++] = jt; | |
1588 } else { | |
1589 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; | |
1590 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1591 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1592 |
3139 | 1593 wdata->gles_attributes[attr_pos++] = EGL_SAMPLES; |
1594 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1595 wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS; | |
1596 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1597 wdata->gles_attributes[attr_pos] = EGL_NONE; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1598 |
3139 | 1599 /* Request first suitable framebuffer configuration */ |
1600 status = | |
1601 eglChooseConfig(phdata->egldisplay, | |
1602 wdata->gles_attributes, | |
1603 wdata->gles_configs, | |
1604 SDL_VIDEO_GF_OPENGLES_CONFS, &configs); | |
1605 if (status != EGL_TRUE) { | |
1606 SDL_SetError | |
1607 ("Photon: Can't find closest configuration for OpenGL ES"); | |
1608 return NULL; | |
1609 } | |
1610 if (configs != 0) { | |
1611 break; | |
1612 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1613 } |
3139 | 1614 if (configs != 0) { |
1615 break; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1616 } |
3139 | 1617 } |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1618 |
3139 | 1619 /* No available configs */ |
1620 if (configs == 0) { | |
1621 SDL_SetError | |
1622 ("Photon: Can't find any configuration for OpenGL ES"); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1623 return NULL; |
3139 | 1624 } |
1625 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1626 |
3139 | 1627 /* Initialize config index */ |
1628 wdata->gles_config = 0; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1629 |
3139 | 1630 /* Now check each configuration to find out the best */ |
1631 for (cit = 0; cit < configs; cit++) { | |
1632 uint32_t stencil_found; | |
1633 uint32_t depth_found; | |
3411
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1634 EGLint cur_depth; |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1635 EGLint cur_stencil; |
3139 | 1636 |
1637 stencil_found = 0; | |
1638 depth_found = 0; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1639 |
3139 | 1640 if (_this->gl_config.stencil_size) { |
1641 status = | |
1642 eglGetConfigAttrib(phdata->egldisplay, | |
1643 wdata->gles_configs[cit], EGL_STENCIL_SIZE, | |
3411
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1644 &cur_stencil); |
3139 | 1645 if (status == EGL_TRUE) { |
3411
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1646 if (cur_stencil != 0) { |
3139 | 1647 stencil_found = 1; |
1648 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1649 } |
3139 | 1650 } else { |
1651 stencil_found = 1; | |
1652 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1653 |
3139 | 1654 if (_this->gl_config.depth_size) { |
1655 status = | |
1656 eglGetConfigAttrib(phdata->egldisplay, | |
1657 wdata->gles_configs[cit], EGL_DEPTH_SIZE, | |
3411
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1658 &cur_depth); |
3139 | 1659 if (status == EGL_TRUE) { |
3411
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1660 if (cur_depth != 0) { |
3139 | 1661 depth_found = 1; |
1662 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1663 } |
3139 | 1664 } else { |
1665 depth_found = 1; | |
1666 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1667 |
3139 | 1668 /* Exit from loop if found appropriate configuration */ |
1669 if ((depth_found != 0) && (stencil_found != 0)) { | |
3411
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1670 /* Store last satisfied configuration id */ |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1671 wdata->gles_config = cit; |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1672 |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1673 if (cur_depth==_this->gl_config.depth_size) |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1674 { |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1675 /* Exact match on depth bits */ |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1676 if (!_this->gl_config.stencil_size) |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1677 { |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1678 /* Stencil is not required */ |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1679 break; |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1680 } |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1681 else |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1682 { |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1683 if (cur_stencil==_this->gl_config.stencil_size) |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1684 { |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1685 /* Exact match on stencil bits */ |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1686 break; |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1687 } |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1688 } |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1689 } |
3139 | 1690 } |
1691 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1692 |
3411
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1693 /* If best could not be found, use first or last satisfied */ |
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1694 if ((cit == configs) && (wdata->gles_config==0)) { |
3139 | 1695 cit = 0; |
3411
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
1696 wdata->gles_config = cit; |
3139 | 1697 } |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1698 |
3139 | 1699 /* Create OpenGL ES context */ |
1700 wdata->gles_context = | |
1701 eglCreateContext(phdata->egldisplay, | |
1702 wdata->gles_configs[wdata->gles_config], | |
1703 EGL_NO_CONTEXT, NULL); | |
1704 if (wdata->gles_context == EGL_NO_CONTEXT) { | |
1705 SDL_SetError("Photon: OpenGL ES context creation has been failed"); | |
1706 return NULL; | |
1707 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1708 |
3139 | 1709 /* Check if surface is exist */ |
1710 if (wdata->gfsurface != NULL) { | |
1711 gf_surface_free(wdata->gfsurface); | |
1712 wdata->gfsurface = NULL; | |
1713 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1714 |
3139 | 1715 /* Create GF surface */ |
1716 gfstatus = | |
1717 gf_surface_create(&wdata->gfsurface, phdata->gfdev, window->w, | |
1718 window->h, | |
1719 qnxgf_sdl_to_gf_pixelformat(didata->current_mode. | |
1720 format), NULL, | |
1721 GF_SURFACE_CREATE_2D_ACCESSIBLE | | |
1722 GF_SURFACE_CREATE_3D_ACCESSIBLE | | |
1723 GF_SURFACE_CREATE_SHAREABLE); | |
1724 if (gfstatus != GF_ERR_OK) { | |
1725 eglDestroyContext(phdata->egldisplay, wdata->gles_context); | |
1726 wdata->gles_context = EGL_NO_CONTEXT; | |
1727 SDL_SetError("Photon: Can't create GF 3D surface (%08X)", gfstatus); | |
1728 return NULL; | |
1729 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1730 |
3139 | 1731 /* Create pixmap 3D target surface */ |
1732 wdata->gles_surface = | |
1733 eglCreatePixmapSurface(phdata->egldisplay, | |
1734 wdata->gles_configs[wdata->gles_config], | |
1735 wdata->gfsurface, NULL); | |
1736 if (wdata->gles_surface == EGL_NO_SURFACE) { | |
1737 gf_surface_free(wdata->gfsurface); | |
3399
f96615051c8c
Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents:
3387
diff
changeset
|
1738 wdata->gfsurface=NULL; |
3139 | 1739 eglDestroyContext(phdata->egldisplay, wdata->gles_context); |
1740 wdata->gles_context = EGL_NO_CONTEXT; | |
1741 SDL_SetError("Photon: Can't create EGL pixmap surface"); | |
1742 return NULL; | |
1743 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1744 |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1745 /* Store last used context and surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1746 phdata->lgles_surface=wdata->gles_surface; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1747 phdata->lgles_context=wdata->gles_context; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1748 |
3139 | 1749 /* Make just created context current */ |
1750 status = | |
1751 eglMakeCurrent(phdata->egldisplay, wdata->gles_surface, | |
1752 wdata->gles_surface, wdata->gles_context); | |
1753 if (status != EGL_TRUE) { | |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1754 /* Reset last used context and surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1755 phdata->lgles_surface=EGL_NO_SURFACE; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1756 phdata->lgles_context=EGL_NO_CONTEXT; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1757 |
3139 | 1758 /* Destroy OpenGL ES surface */ |
1759 eglDestroySurface(phdata->egldisplay, wdata->gles_surface); | |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1760 wdata->gles_surface=EGL_NO_SURFACE; |
3139 | 1761 gf_surface_free(wdata->gfsurface); |
3399
f96615051c8c
Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents:
3387
diff
changeset
|
1762 wdata->gfsurface=NULL; |
3139 | 1763 eglDestroyContext(phdata->egldisplay, wdata->gles_context); |
1764 wdata->gles_context = EGL_NO_CONTEXT; | |
1765 SDL_SetError("Photon: Can't set OpenGL ES context on creation"); | |
1766 return NULL; | |
1767 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1768 |
3139 | 1769 /* Setup into SDL internals state of OpenGL ES: */ |
1770 /* it is accelerated or not */ | |
1771 if ((didata->caps & SDL_PHOTON_ACCELERATED_3D) == | |
1772 SDL_PHOTON_ACCELERATED_3D) { | |
1773 _this->gl_config.accelerated = 1; | |
1774 } else { | |
1775 _this->gl_config.accelerated = 0; | |
1776 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1777 |
3139 | 1778 /* Always clear stereo enable, since OpenGL ES do not supports stereo */ |
1779 _this->gl_config.stereo = 0; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1780 |
3139 | 1781 /* Get back samples and samplebuffers configurations. Rest framebuffer */ |
1782 /* parameters could be obtained through the OpenGL ES API */ | |
1783 status = | |
1784 eglGetConfigAttrib(phdata->egldisplay, | |
1785 wdata->gles_configs[wdata->gles_config], | |
1786 EGL_SAMPLES, &attr_value); | |
1787 if (status == EGL_TRUE) { | |
1788 _this->gl_config.multisamplesamples = attr_value; | |
1789 } | |
1790 status = | |
1791 eglGetConfigAttrib(phdata->egldisplay, | |
1792 wdata->gles_configs[wdata->gles_config], | |
1793 EGL_SAMPLE_BUFFERS, &attr_value); | |
1794 if (status == EGL_TRUE) { | |
1795 _this->gl_config.multisamplebuffers = attr_value; | |
1796 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1797 |
3139 | 1798 /* Get back stencil and depth buffer sizes */ |
1799 status = | |
1800 eglGetConfigAttrib(phdata->egldisplay, | |
1801 wdata->gles_configs[wdata->gles_config], | |
1802 EGL_DEPTH_SIZE, &attr_value); | |
1803 if (status == EGL_TRUE) { | |
1804 _this->gl_config.depth_size = attr_value; | |
1805 } | |
1806 status = | |
1807 eglGetConfigAttrib(phdata->egldisplay, | |
1808 wdata->gles_configs[wdata->gles_config], | |
1809 EGL_STENCIL_SIZE, &attr_value); | |
1810 if (status == EGL_TRUE) { | |
1811 _this->gl_config.stencil_size = attr_value; | |
1812 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1813 |
3139 | 1814 /* Under Photon OpenGL ES output can't be double buffered */ |
1815 _this->gl_config.double_buffer = 0; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1816 |
3139 | 1817 /* Check if current device is not the same as target */ |
1818 if (phdata->current_device_id != didata->device_id) { | |
1819 /* Set target device as default for Pd and Pg functions */ | |
1820 status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]); | |
1821 if (status != 0) { | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1822 /* Destroy OpenGL ES surface */ |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1823 eglDestroySurface(phdata->egldisplay, wdata->gles_surface); |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1824 wdata->gles_surface=EGL_NO_SURFACE; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1825 gf_surface_free(wdata->gfsurface); |
3399
f96615051c8c
Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents:
3387
diff
changeset
|
1826 wdata->gfsurface=NULL; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1827 eglDestroyContext(phdata->egldisplay, wdata->gles_context); |
3139 | 1828 wdata->gles_context = EGL_NO_CONTEXT; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1829 SDL_SetError("Photon: Can't set default target device\n"); |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1830 return NULL; |
3139 | 1831 } |
1832 phdata->current_device_id = didata->device_id; | |
1833 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1834 |
3139 | 1835 wdata->phsurface = PdCreateOffscreenContextGF(wdata->gfsurface); |
1836 if (wdata->phsurface == NULL) { | |
1837 /* Destroy OpenGL ES surface */ | |
1838 eglDestroySurface(phdata->egldisplay, wdata->gles_surface); | |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1839 wdata->gles_surface=EGL_NO_SURFACE; |
3139 | 1840 gf_surface_free(wdata->gfsurface); |
3399
f96615051c8c
Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents:
3387
diff
changeset
|
1841 wdata->gfsurface=NULL; |
3139 | 1842 eglDestroyContext(phdata->egldisplay, wdata->gles_context); |
1843 wdata->gles_context = EGL_NO_CONTEXT; | |
1844 SDL_SetError("Photon: Can't bind GF surface to Photon\n"); | |
1845 return NULL; | |
1846 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1847 |
3139 | 1848 /* GL ES context was successfully created */ |
1849 return wdata->gles_context; | |
1850 #else | |
1851 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1852 return NULL; | |
1853 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1854 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1855 |
3139 | 1856 int |
1857 photon_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1858 { |
3139 | 1859 #if defined(SDL_VIDEO_OPENGL_ES) |
1860 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
1861 SDL_WindowData *wdata; | |
1862 EGLBoolean status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1863 |
3139 | 1864 if (phdata->gfinitialized != SDL_TRUE) { |
1865 SDL_SetError | |
1866 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1867 return -1; | |
1868 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1869 |
3139 | 1870 if ((window == NULL) && (context == NULL)) { |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1871 /* Reset last used context and surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1872 phdata->lgles_surface=EGL_NO_SURFACE; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1873 phdata->lgles_context=EGL_NO_CONTEXT; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1874 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1875 /* Unset current context */ |
3139 | 1876 status = |
1877 eglMakeCurrent(phdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, | |
1878 EGL_NO_CONTEXT); | |
1879 if (status != EGL_TRUE) { | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1880 /* Failed to set current GL ES context */ |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1881 SDL_SetError("Photon: Can't empty current OpenGL ES context"); |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1882 return -1; |
3139 | 1883 } |
1884 } else { | |
1885 wdata = (SDL_WindowData *) window->driverdata; | |
1886 if (wdata->gles_surface == EGL_NO_SURFACE) { | |
1887 SDL_SetError | |
1888 ("Photon: OpenGL ES surface is not initialized for this window"); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1889 return -1; |
3139 | 1890 } |
1891 if (wdata->gles_context == EGL_NO_CONTEXT) { | |
1892 SDL_SetError | |
1893 ("Photon: OpenGL ES context is not initialized for this window"); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1894 return -1; |
3139 | 1895 } |
1896 if (wdata->gles_context != context) { | |
1897 SDL_SetError | |
1898 ("Photon: OpenGL ES context is not belong to this window"); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1899 return -1; |
3139 | 1900 } |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1901 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1902 /* Store last set surface and context */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1903 phdata->lgles_surface=wdata->gles_surface; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1904 phdata->lgles_context=wdata->gles_context; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1905 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1906 /* Set new current context */ |
3139 | 1907 status = |
1908 eglMakeCurrent(phdata->egldisplay, wdata->gles_surface, | |
1909 wdata->gles_surface, wdata->gles_context); | |
1910 if (status != EGL_TRUE) { | |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1911 /* Reset last used context and surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1912 phdata->lgles_surface=EGL_NO_SURFACE; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1913 phdata->lgles_context=EGL_NO_CONTEXT; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1914 /* Failed to set current GL ES context */ |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1915 SDL_SetError("Photon: Can't set OpenGL ES context"); |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1916 return -1; |
3139 | 1917 } |
1918 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1919 |
3139 | 1920 return 0; |
1921 #else | |
1922 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1923 return -1; | |
1924 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1925 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1926 |
3139 | 1927 int |
1928 photon_gl_setswapinterval(_THIS, int interval) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1929 { |
3139 | 1930 #if defined(SDL_VIDEO_OPENGL_ES) |
1931 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
1932 EGLBoolean status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1933 |
3139 | 1934 if (phdata->gfinitialized != SDL_TRUE) { |
1935 SDL_SetError | |
1936 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1937 return -1; | |
1938 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1939 |
3139 | 1940 /* Check if OpenGL ES connection has been initialized */ |
1941 if (phdata->egldisplay != EGL_NO_DISPLAY) { | |
1942 /* Set swap OpenGL ES interval */ | |
1943 status = eglSwapInterval(phdata->egldisplay, interval); | |
1944 if (status == EGL_TRUE) { | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1945 /* Return success to upper level */ |
3139 | 1946 phdata->swapinterval = interval; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1947 return 0; |
3139 | 1948 } |
1949 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1950 |
3139 | 1951 /* Failed to set swap interval */ |
1952 SDL_SetError("Photon: Cannot set swap interval"); | |
1953 return -1; | |
1954 #else | |
1955 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1956 return -1; | |
1957 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1958 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1959 |
3139 | 1960 int |
1961 photon_gl_getswapinterval(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1962 { |
3139 | 1963 #if defined(SDL_VIDEO_OPENGL_ES) |
1964 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1965 |
3139 | 1966 if (phdata->gfinitialized != SDL_TRUE) { |
1967 SDL_SetError | |
1968 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1969 return -1; | |
1970 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1971 |
3139 | 1972 /* Return default swap interval value */ |
1973 return phdata->swapinterval; | |
1974 #else | |
1975 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1976 return -1; | |
1977 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1978 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1979 |
3139 | 1980 void |
1981 photon_gl_swapwindow(_THIS, SDL_Window * window) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1982 { |
3139 | 1983 #if defined(SDL_VIDEO_OPENGL_ES) |
1984 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
1985 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | |
1986 SDL_DisplayData *didata = | |
1987 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
1988 PhRect_t dst_rect; | |
1989 PhRect_t src_rect; | |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
1990 int32_t status; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1991 |
3139 | 1992 if (phdata->gfinitialized != SDL_TRUE) { |
1993 SDL_SetError | |
1994 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1995 return; | |
1996 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1997 |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1998 if (wdata->phsurface==NULL) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1999 SDL_SetError |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2000 ("Photon: Photon OpenGL ES surface is not initialized"); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2001 return; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2002 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2003 |
3139 | 2004 /* Many applications do not uses glFinish(), so we call it for them */ |
2005 glFinish(); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2006 |
3139 | 2007 /* Wait until OpenGL ES rendering is completed */ |
2008 eglWaitGL(); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2009 |
3139 | 2010 /* Wait for VSYNC manually, if it was enabled */ |
2011 if (phdata->swapinterval != 0) { | |
2012 /* Wait for VSYNC, we use GF function, since Photon requires */ | |
2013 /* to enter to the Direct mode to call PgWaitVSync() */ | |
2014 gf_display_wait_vsync(didata->display); | |
2015 } | |
2016 | |
2017 /* Set blit area */ | |
2018 dst_rect = *PtGetCanvas(wdata->window); | |
2019 src_rect.ul.x = 0; | |
2020 src_rect.ul.y = 0; | |
2021 src_rect.lr.x = window->w - 1; | |
2022 src_rect.lr.y = window->h - 1; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2023 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2024 /* 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:
3193
diff
changeset
|
2025 if (phdata->current_device_id != didata->device_id) { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2026 /* 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:
3193
diff
changeset
|
2027 status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2028 if (status != 0) { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2029 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:
3193
diff
changeset
|
2030 return; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2031 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2032 phdata->current_device_id = didata->device_id; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2033 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2034 |
3139 | 2035 /* Blit OpenGL ES pixmap surface directly to window region */ |
2036 PgFFlush(Ph_START_DRAW); | |
2037 PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window)); | |
2038 PgClearTranslationCx(PgGetGCCx(PhDCGetCurrent())); | |
2039 PgContextBlit(wdata->phsurface, &src_rect, NULL, &dst_rect); | |
2040 PgFFlush(Ph_DONE_DRAW); | |
2041 PgWaitHWIdle(); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2042 |
3139 | 2043 eglSwapBuffers(phdata->egldisplay, wdata->gles_surface); |
2044 #else | |
2045 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
2046 return; | |
2047 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2048 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2049 |
3139 | 2050 void |
2051 photon_gl_deletecontext(_THIS, SDL_GLContext context) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2052 { |
3139 | 2053 #if defined(SDL_VIDEO_OPENGL_ES) |
2054 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
2055 EGLBoolean status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2056 |
3139 | 2057 if (phdata->gfinitialized != SDL_TRUE) { |
2058 SDL_SetError | |
2059 ("Photon: GF initialization failed, no OpenGL ES support"); | |
2060 return; | |
2061 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2062 |
3139 | 2063 /* Check if OpenGL ES connection has been initialized */ |
2064 if (phdata->egldisplay != EGL_NO_DISPLAY) { | |
2065 if (context != EGL_NO_CONTEXT) { | |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2066 /* Check if we are destroying current active context */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2067 if (phdata->lgles_context==context) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2068 /* Release current context */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2069 eglMakeCurrent(phdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2070 phdata->lgles_context=EGL_NO_CONTEXT; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2071 phdata->lgles_surface=EGL_NO_SURFACE; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2072 } |
3139 | 2073 status = eglDestroyContext(phdata->egldisplay, context); |
2074 if (status != EGL_TRUE) { | |
2075 /* Error during OpenGL ES context destroying */ | |
2076 SDL_SetError("Photon: OpenGL ES context destroy error"); | |
2077 return; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2078 } |
3139 | 2079 } |
2080 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2081 |
3139 | 2082 return; |
2083 #else | |
2084 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
2085 return; | |
2086 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2087 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2088 |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2089 /* Helper function, which re-creates surface, not an API */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2090 int photon_gl_recreatesurface(_THIS, SDL_Window * window, uint32_t width, uint32_t height) |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2091 { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2092 #if defined(SDL_VIDEO_OPENGL_ES) |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2093 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2094 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2095 SDL_DisplayData *didata = |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2096 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2097 SDL_bool makecurrent=SDL_FALSE; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2098 int32_t gfstatus; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2099 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2100 /* Check if context has been initialized */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2101 if (wdata->gles_context == EGL_NO_CONTEXT) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2102 /* If no, abort surface re-creating */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2103 return -1; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2104 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2105 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2106 /* Check if last used surface the same as one which must be re-created */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2107 if (phdata->lgles_surface == wdata->gles_surface) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2108 makecurrent=SDL_TRUE; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2109 /* Flush all current drawings */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2110 glFinish(); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2111 /* Wait until OpenGL ES rendering is completed */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2112 eglWaitGL(); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2113 /* Release current context */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2114 eglMakeCurrent(phdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2115 phdata->lgles_surface=EGL_NO_SURFACE; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2116 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2117 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2118 /* Check if we need to destroy previous surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2119 if (wdata->gles_surface != EGL_NO_SURFACE) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2120 /* Destroy photon handle to GF surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2121 if (wdata->phsurface != NULL) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2122 PhDCRelease(wdata->phsurface); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2123 wdata->phsurface=NULL; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2124 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2125 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2126 /* Destroy previous surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2127 eglDestroySurface(phdata->egldisplay, wdata->gles_surface); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2128 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2129 /* Set surface to uninitialized */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2130 wdata->gles_surface = EGL_NO_SURFACE; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2131 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2132 if (wdata->gfsurface!=NULL) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2133 gf_surface_free(wdata->gfsurface); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2134 wdata->gfsurface=NULL; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2135 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2136 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2137 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2138 /* Create new GF surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2139 gfstatus = |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2140 gf_surface_create(&wdata->gfsurface, phdata->gfdev, width, |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2141 height, |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2142 qnxgf_sdl_to_gf_pixelformat(didata->current_mode. |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2143 format), NULL, |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2144 GF_SURFACE_CREATE_2D_ACCESSIBLE | |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2145 GF_SURFACE_CREATE_3D_ACCESSIBLE | |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2146 GF_SURFACE_CREATE_SHAREABLE); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2147 if (gfstatus != GF_ERR_OK) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2148 SDL_SetError("Photon: Can't create GF 3D surface (%08X)", gfstatus); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2149 return -1; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2150 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2151 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2152 /* Create new pixmap 3D target surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2153 wdata->gles_surface = |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2154 eglCreatePixmapSurface(phdata->egldisplay, |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2155 wdata->gles_configs[wdata->gles_config], |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2156 wdata->gfsurface, NULL); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2157 if (wdata->gles_surface == EGL_NO_SURFACE) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2158 gf_surface_free(wdata->gfsurface); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2159 wdata->gfsurface=NULL; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2160 SDL_SetError("Photon: Can't create EGL pixmap surface"); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2161 return -1; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2162 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2163 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2164 wdata->phsurface = PdCreateOffscreenContextGF(wdata->gfsurface); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2165 if (wdata->phsurface == NULL) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2166 /* Destroy OpenGL ES surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2167 eglDestroySurface(phdata->egldisplay, wdata->gles_surface); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2168 wdata->gles_surface=EGL_NO_SURFACE; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2169 gf_surface_free(wdata->gfsurface); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2170 wdata->gfsurface=NULL; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2171 SDL_SetError("Photon: Can't bind GF surface to Photon\n"); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2172 return -1; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2173 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2174 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2175 /* Check if we need to set this surface and context as current */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2176 if (makecurrent == SDL_TRUE) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2177 return photon_gl_makecurrent(_this, window, wdata->gles_context); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2178 } else { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2179 return 0; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2180 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2181 #else |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2182 /* Do nothing, if OpenGL ES support is not compiled in */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2183 return 0; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2184 #endif /* SDL_VIDEO_OPENGL_ES */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2185 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2186 |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2187 /*****************************************************************************/ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2188 /* SDL Event handling function */ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2189 /*****************************************************************************/ |
3139 | 2190 void |
2191 photon_pumpevents(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2192 { |
3139 | 2193 uint8_t eventbuffer[SDL_VIDEO_PHOTON_EVENT_SIZE]; |
2194 PhEvent_t *event = (PhEvent_t *) eventbuffer; | |
2195 int32_t status; | |
2196 uint32_t finish = 0; | |
2197 uint32_t it; | |
2198 SDL_Window *window; | |
2199 SDL_WindowData *wdata; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2200 |
3139 | 2201 do { |
2202 status = PhEventPeek(event, SDL_VIDEO_PHOTON_EVENT_SIZE); | |
2203 switch (status) { | |
2204 case Ph_RESIZE_MSG: | |
2205 { | |
2206 SDL_SetError("Photon: Event size too much for buffer"); | |
2207 return; | |
2208 } | |
2209 break; | |
2210 case Ph_EVENT_MSG: | |
2211 { | |
2212 /* Find a window, to which this handle destinated */ | |
2213 status = 0; | |
2214 for (it = 0; it < SDL_CurrentDisplay.num_windows; it++) { | |
2215 wdata = | |
2216 (SDL_WindowData *) SDL_CurrentDisplay.windows[it]. | |
2217 driverdata; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2218 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2219 /* Find the proper window */ |
3139 | 2220 if (wdata->window != NULL) { |
2221 if (PtWidgetRid(wdata->window) == | |
2222 event->collector.rid) { | |
2223 window = | |
2224 (SDL_Window *) & SDL_CurrentDisplay. | |
2225 windows[it]; | |
2226 status = 1; | |
2227 break; | |
2228 } | |
2229 } else { | |
2230 continue; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2231 } |
3139 | 2232 } |
2233 if (status == 0) { | |
2234 window = NULL; | |
2235 wdata = NULL; | |
2236 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2237 |
3139 | 2238 /* Event is ready */ |
2239 switch (event->type) { | |
2240 case Ph_EV_BOUNDARY: | |
2241 { | |
2242 switch (event->subtype) { | |
2243 case Ph_EV_PTR_ENTER: | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2244 { |
3139 | 2245 /* Mouse cursor over handled window */ |
2246 if (window != NULL) { | |
2247 SDL_SendWindowEvent(window->id, | |
2248 SDL_WINDOWEVENT_ENTER, | |
2249 0, 0); | |
2250 SDL_SetMouseFocus(0, window->id); | |
2251 } | |
2252 } | |
2253 break; | |
2254 case Ph_EV_PTR_LEAVE: | |
2255 { | |
2256 /* Mouse cursor out of handled window */ | |
2257 if (window != NULL) { | |
2258 SDL_SendWindowEvent(window->id, | |
2259 SDL_WINDOWEVENT_LEAVE, | |
2260 0, 0); | |
2261 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2262 } |
3139 | 2263 break; |
2264 } | |
2265 } | |
2266 break; | |
2267 case Ph_EV_PTR_MOTION_BUTTON: | |
2268 case Ph_EV_PTR_MOTION_NOBUTTON: | |
2269 { | |
2270 PhPointerEvent_t *pevent = NULL; | |
2271 PhRect_t *prects = NULL; | |
2272 | |
2273 /* Get event data */ | |
2274 pevent = PhGetData(event); | |
2275 /* Get associated event rectangles */ | |
2276 prects = PhGetRects(event); | |
2277 if ((pevent != NULL) && (prects != NULL)) { | |
2278 SDL_SendMouseMotion(0, 0, prects->ul.x, | |
2279 prects->ul.y, 0); | |
2280 } | |
2281 } | |
2282 break; | |
2283 case Ph_EV_BUT_PRESS: | |
2284 { | |
2285 /* Button press event */ | |
2286 PhPointerEvent_t *pevent = NULL; | |
2287 uint32_t sdlbutton = 0x00000000; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2288 |
3139 | 2289 /* Get event data */ |
2290 pevent = PhGetData(event); | |
2291 if (pevent != NULL) { | |
2292 for (it = 0; it < sizeof(pevent->buttons) * 8; | |
2293 it++) { | |
2294 if ((pevent->buttons & (0x0001 << it)) == | |
2295 (0x0001 << it)) { | |
2296 switch (it) { | |
2297 case 0: | |
2298 { | |
2299 sdlbutton = SDL_BUTTON_RIGHT; | |
2300 } | |
2301 break; | |
2302 case 1: | |
2303 { | |
2304 sdlbutton = SDL_BUTTON_MIDDLE; | |
2305 } | |
2306 break; | |
2307 case 2: | |
2308 { | |
2309 sdlbutton = SDL_BUTTON_LEFT; | |
2310 } | |
2311 break; | |
2312 default: | |
2313 { | |
2314 sdlbutton = it + 1; | |
2315 } | |
2316 break; | |
2317 } | |
2318 SDL_SendMouseButton(0, SDL_PRESSED, | |
2319 sdlbutton); | |
2320 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2321 } |
3139 | 2322 } |
2323 } | |
2324 break; | |
2325 case Ph_EV_BUT_RELEASE: | |
2326 { | |
2327 /* Button press event */ | |
2328 PhPointerEvent_t *pevent = NULL; | |
2329 uint32_t sdlbutton = 0x00000000; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2330 |
3139 | 2331 /* Get event data */ |
2332 pevent = PhGetData(event); | |
2333 if (pevent != NULL) { | |
2334 for (it = 0; it < sizeof(pevent->buttons) * 8; | |
2335 it++) { | |
2336 if ((pevent->buttons & (0x0001 << it)) == | |
2337 (0x0001 << it)) { | |
2338 switch (it) { | |
2339 case 0: | |
2340 { | |
2341 sdlbutton = SDL_BUTTON_RIGHT; | |
2342 } | |
2343 break; | |
2344 case 1: | |
2345 { | |
2346 sdlbutton = SDL_BUTTON_MIDDLE; | |
2347 } | |
2348 break; | |
2349 case 2: | |
2350 { | |
2351 sdlbutton = SDL_BUTTON_LEFT; | |
2352 } | |
2353 break; | |
2354 default: | |
2355 { | |
2356 sdlbutton = it + 1; | |
2357 } | |
2358 break; | |
2359 } | |
2360 } | |
2361 } | |
2362 } | |
2363 | |
2364 switch (event->subtype) { | |
2365 case Ph_EV_RELEASE_REAL: | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2366 { |
3139 | 2367 /* Real release button event */ |
2368 SDL_SendMouseButton(0, SDL_RELEASED, | |
2369 sdlbutton); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2370 } |
3139 | 2371 break; |
2372 case Ph_EV_RELEASE_PHANTOM: | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2373 { |
3139 | 2374 /* We will get phantom button release */ |
2375 /* event in case if it was unpressed */ | |
2376 /* outside of window */ | |
2377 if (window != NULL) { | |
2378 if ((window-> | |
2379 flags & SDL_WINDOW_MOUSE_FOCUS) != | |
2380 SDL_WINDOW_MOUSE_FOCUS) { | |
2381 /* Send phantom button release */ | |
2382 SDL_SendMouseButton(0, SDL_RELEASED, | |
2383 sdlbutton); | |
2384 } | |
2385 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2386 } |
3139 | 2387 break; |
2388 } | |
2389 } | |
2390 break; | |
2391 case Ph_EV_EXPOSE: | |
2392 { | |
2393 switch (event->subtype) { | |
2394 case Ph_NORMAL_EXPOSE: | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2395 { |
3139 | 2396 PhRect_t *rects = NULL; |
2397 | |
2398 /* Get array of rectangles to be updated */ | |
2399 rects = PhGetRects(event); | |
2400 if (rects == NULL) { | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2401 break; |
3139 | 2402 } |
2403 | |
2404 /* Check if expose come to one of the our windows */ | |
2405 if ((wdata != NULL) && (window != NULL)) { | |
2406 /* Check if window uses OpenGL ES */ | |
2407 if (wdata->uses_gles == SDL_TRUE) { | |
3411
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
2408 #if defined(SDL_VIDEO_OPENGL_ES) |
3139 | 2409 /* Cycle through each rectangle */ |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2410 for (it = 0; it < event->num_rects; it++) { |
3139 | 2411 /* Blit OpenGL ES pixmap surface directly to window region */ |
2412 PgFFlush(Ph_START_DRAW); | |
2413 PgSetRegionCx(PhDCGetCurrent(), | |
2414 PtWidgetRid(wdata-> | |
2415 window)); | |
2416 PgClearTranslationCx(PgGetGCCx | |
2417 (PhDCGetCurrent | |
2418 ())); | |
2419 PgContextBlit(wdata->phsurface, | |
2420 &rects[it], NULL, | |
2421 &rects[it]); | |
2422 PgFFlush(Ph_DONE_DRAW); | |
2423 PgWaitHWIdle(); | |
2424 } | |
3411
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
2425 #endif /* SDL_VIDEO_OPENGL_ES */ |
3139 | 2426 } else { |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2427 /* Cycle through each rectangle */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2428 for (it = 0; it < event->num_rects; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2429 it++) { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2430 /* Blit 2D pixmap surface directly to window region */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2431 _photon_update_rectangles(window->renderer, &rects[it]); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2432 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2433 PgFlush(); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2434 PgWaitHWIdle(); |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2435 } |
3139 | 2436 } |
2437 | |
2438 /* Flush all blittings */ | |
2439 PgFlush(); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2440 } |
3139 | 2441 break; |
2442 case Ph_CAPTURE_EXPOSE: | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2443 { |
3139 | 2444 /* Check if expose come to one of the our windows */ |
2445 if ((wdata != NULL) && (window != NULL)) { | |
2446 /* Check if window uses OpenGL ES */ | |
2447 if (wdata->uses_gles == SDL_TRUE) { | |
2448 PhRect_t dst_rect; | |
2449 PhRect_t src_rect; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2450 |
3139 | 2451 /* Set blit area */ |
2452 dst_rect = | |
2453 *PtGetCanvas(wdata->window); | |
2454 src_rect.ul.x = 0; | |
2455 src_rect.ul.y = 0; | |
2456 src_rect.lr.x = window->w - 1; | |
2457 src_rect.lr.y = window->h - 1; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2458 |
3411
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
2459 #if defined(SDL_VIDEO_OPENGL_ES) |
3139 | 2460 /* We need to redraw entire window */ |
2461 PgFFlush(Ph_START_DRAW); | |
2462 PgSetRegionCx(PhDCGetCurrent(), | |
2463 PtWidgetRid(wdata-> | |
2464 window)); | |
2465 PgClearTranslationCx(PgGetGCCx | |
2466 (PhDCGetCurrent | |
2467 ())); | |
2468 PgContextBlit(wdata->phsurface, | |
2469 &src_rect, NULL, | |
2470 &dst_rect); | |
2471 PgFFlush(Ph_DONE_DRAW); | |
2472 PgWaitHWIdle(); | |
3411
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
2473 #endif /* SDL_VIDEO_OPENGL_ES */ |
3139 | 2474 } else { |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2475 PhRect_t rect; |
3115
1102a3305928
Added handler for all window events.
Mike Gorchak <lestat@i.com.ua>
parents:
3108
diff
changeset
|
2476 |
3139 | 2477 /* We need to redraw entire window */ |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2478 rect.ul.x = 0; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2479 rect.ul.y = 0; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2480 rect.lr.x = window->w - 1; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2481 rect.lr.y = window->h - 1; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2482 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2483 /* Blit 2D pixmap surface directly to window region */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2484 PgFFlush(Ph_START_DRAW); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2485 _photon_update_rectangles(window->renderer, &rect); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2486 PgFFlush(Ph_DONE_DRAW); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2487 PgWaitHWIdle(); |
3139 | 2488 } |
2489 } | |
2490 } | |
2491 break; | |
2492 case Ph_GRAPHIC_EXPOSE: | |
2493 { | |
2494 /* TODO: What this event means ? */ | |
2495 } | |
2496 break; | |
2497 } | |
2498 } | |
2499 break; | |
2500 case Ph_EV_INFO: | |
2501 { | |
3387
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2502 switch (event->subtype) |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2503 { |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2504 case Ph_OFFSCREEN_INVALID: |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2505 { |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2506 uint32_t* type; |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2507 |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2508 type = PhGetData(event); |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2509 switch (*type) |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2510 { |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2511 case Pg_VIDEO_MODE_SWITCHED: |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2512 case Pg_ENTERED_DIRECT: |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2513 case Pg_EXITED_DIRECT: |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2514 case Pg_DRIVER_STARTED: |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2515 { |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2516 /* TODO: */ |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2517 /* We must tell the renderer, that it have */ |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2518 /* to recreate all surfaces */ |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2519 } |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2520 break; |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2521 default: |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2522 { |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2523 } |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2524 break; |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2525 } |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2526 } |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2527 break; |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2528 default: |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2529 break; |
05499ec8c022
Initial support for fullscreen application modes.
Mike Gorchak <lestat@i.com.ua>
parents:
3386
diff
changeset
|
2530 } |
3139 | 2531 } |
2532 break; | |
2533 case Ph_EV_KEY: | |
2534 { | |
2535 PhKeyEvent_t *keyevent = NULL; | |
2536 SDL_scancode scancode = SDL_SCANCODE_UNKNOWN; | |
2537 SDL_bool pressed = SDL_FALSE; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2538 |
3139 | 2539 keyevent = PhGetData(event); |
2540 if (keyevent == NULL) { | |
2541 break; | |
2542 } | |
2543 | |
2544 /* Check if key is repeated */ | |
2545 if ((keyevent->key_flags & Pk_KF_Key_Repeat) == | |
2546 Pk_KF_Key_Repeat) { | |
2547 /* Ignore such events */ | |
2548 break; | |
2549 } | |
2550 | |
2551 /* Check if key has its own scancode */ | |
2552 if ((keyevent->key_flags & Pk_KF_Scan_Valid) == | |
2553 Pk_KF_Scan_Valid) { | |
2554 if ((keyevent->key_flags & Pk_KF_Key_Down) == | |
2555 Pk_KF_Key_Down) { | |
2556 pressed = SDL_TRUE; | |
2557 } else { | |
2558 pressed = SDL_FALSE; | |
2559 } | |
2560 scancode = | |
2561 photon_to_sdl_keymap(keyevent->key_scan); | |
2562 | |
2563 /* Add details for the pressed key */ | |
2564 if ((keyevent->key_flags & Pk_KF_Cap_Valid) == | |
2565 Pk_KF_Cap_Valid) { | |
2566 switch (keyevent->key_cap) { | |
2567 case Pk_Hyper_R: /* Right windows flag key */ | |
2568 scancode = SDL_SCANCODE_RGUI; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2569 break; |
3139 | 2570 case Pk_Control_R: /* Right Ctrl key */ |
2571 scancode = SDL_SCANCODE_RCTRL; | |
2572 break; | |
2573 case Pk_Alt_R: /* Right Alt key */ | |
2574 scancode = SDL_SCANCODE_RALT; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2575 break; |
3139 | 2576 case Pk_Up: /* Up key but with invalid scan */ |
2577 if (scancode != SDL_SCANCODE_UP) { | |
2578 /* This is a mouse wheel event */ | |
2579 SDL_SendMouseWheel(0, 0, 1); | |
2580 return; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2581 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2582 break; |
3139 | 2583 case Pk_KP_8: /* Up arrow or 8 on keypad */ |
2584 scancode = SDL_SCANCODE_KP_8; | |
2585 break; | |
2586 case Pk_Down: /* Down key but with invalid scan */ | |
2587 if (scancode != SDL_SCANCODE_DOWN) { | |
2588 /* This is a mouse wheel event */ | |
2589 SDL_SendMouseWheel(0, 0, -1); | |
2590 return; | |
2591 } | |
2592 break; | |
2593 case Pk_KP_2: /* Down arrow or 2 on keypad */ | |
2594 scancode = SDL_SCANCODE_KP_2; | |
2595 break; | |
2596 case Pk_Left: /* Left arrow key */ | |
2597 scancode = SDL_SCANCODE_LEFT; | |
2598 break; | |
2599 case Pk_KP_4: /* Left arrow or 4 on keypad */ | |
2600 scancode = SDL_SCANCODE_KP_4; | |
2601 break; | |
2602 case Pk_Right: /* Right arrow key */ | |
2603 scancode = SDL_SCANCODE_RIGHT; | |
2604 break; | |
2605 case Pk_KP_6: /* Right arrow or 6 on keypad */ | |
2606 scancode = SDL_SCANCODE_KP_6; | |
2607 break; | |
2608 case Pk_Insert: /* Insert key */ | |
2609 scancode = SDL_SCANCODE_INSERT; | |
2610 break; | |
2611 case Pk_KP_0: /* Insert or 0 on keypad */ | |
2612 scancode = SDL_SCANCODE_KP_0; | |
2613 break; | |
2614 case Pk_Home: /* Home key */ | |
2615 scancode = SDL_SCANCODE_HOME; | |
2616 break; | |
2617 case Pk_KP_7: /* Home or 7 on keypad */ | |
2618 scancode = SDL_SCANCODE_KP_7; | |
2619 break; | |
2620 case Pk_Pg_Up: /* PageUp key */ | |
2621 scancode = SDL_SCANCODE_PAGEUP; | |
2622 break; | |
2623 case Pk_KP_9: /* PgUp or 9 on keypad */ | |
2624 scancode = SDL_SCANCODE_KP_9; | |
2625 break; | |
2626 case Pk_Delete: /* Delete key */ | |
2627 scancode = SDL_SCANCODE_DELETE; | |
2628 break; | |
2629 case Pk_KP_Decimal: /* Del or . on keypad */ | |
2630 scancode = SDL_SCANCODE_KP_PERIOD; | |
2631 break; | |
2632 case Pk_End: /* End key */ | |
2633 scancode = SDL_SCANCODE_END; | |
2634 break; | |
2635 case Pk_KP_1: /* End or 1 on keypad */ | |
2636 scancode = SDL_SCANCODE_KP_1; | |
2637 break; | |
2638 case Pk_Pg_Down: /* PageDown key */ | |
2639 scancode = SDL_SCANCODE_PAGEDOWN; | |
2640 break; | |
2641 case Pk_KP_3: /* PgDn or 3 on keypad */ | |
2642 scancode = SDL_SCANCODE_KP_3; | |
2643 break; | |
2644 case Pk_KP_5: /* 5 on keypad */ | |
2645 scancode = SDL_SCANCODE_KP_5; | |
2646 break; | |
2647 case Pk_KP_Enter: | |
2648 scancode = SDL_SCANCODE_KP_ENTER; | |
2649 break; | |
2650 case Pk_KP_Add: | |
2651 scancode = SDL_SCANCODE_KP_PLUS; | |
2652 break; | |
2653 case Pk_KP_Subtract: | |
2654 scancode = SDL_SCANCODE_KP_MINUS; | |
2655 break; | |
2656 case Pk_KP_Multiply: | |
2657 scancode = SDL_SCANCODE_KP_MULTIPLY; | |
2658 break; | |
2659 case Pk_KP_Divide: | |
2660 scancode = SDL_SCANCODE_KP_DIVIDE; | |
2661 break; | |
2662 case Pk_Pause: | |
2663 scancode = SDL_SCANCODE_PAUSE; | |
2664 break; | |
2665 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2666 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2667 |
3139 | 2668 /* Finally check if scancode has been decoded */ |
2669 if (scancode == SDL_SCANCODE_UNKNOWN) { | |
2670 /* Something was pressed, which is not supported */ | |
2671 break; | |
2672 } | |
2673 | |
2674 /* Report pressed/released key to SDL */ | |
2675 if (pressed == SDL_TRUE) { | |
2676 SDL_SendKeyboardKey(0, SDL_PRESSED, scancode); | |
2677 } else { | |
2678 SDL_SendKeyboardKey(0, SDL_RELEASED, | |
2679 scancode); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2680 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2681 |
3139 | 2682 /* Photon doesn't send a release event for PrnScr key */ |
2683 if ((scancode == SDL_SCANCODE_PRINTSCREEN) | |
2684 && (pressed)) { | |
2685 SDL_SendKeyboardKey(0, SDL_RELEASED, | |
2686 scancode); | |
2687 } | |
3465
0cbfec87e4f1
Support for UTF-8 text input has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3411
diff
changeset
|
2688 |
0cbfec87e4f1
Support for UTF-8 text input has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3411
diff
changeset
|
2689 } |
0cbfec87e4f1
Support for UTF-8 text input has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3411
diff
changeset
|
2690 |
0cbfec87e4f1
Support for UTF-8 text input has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3411
diff
changeset
|
2691 /* Handle UTF-8 text input if requested by caller */ |
0cbfec87e4f1
Support for UTF-8 text input has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3411
diff
changeset
|
2692 if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) |
0cbfec87e4f1
Support for UTF-8 text input has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3411
diff
changeset
|
2693 { |
0cbfec87e4f1
Support for UTF-8 text input has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3411
diff
changeset
|
2694 char text[5]; |
0cbfec87e4f1
Support for UTF-8 text input has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3411
diff
changeset
|
2695 |
0cbfec87e4f1
Support for UTF-8 text input has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3411
diff
changeset
|
2696 SDL_memset(text, 0x00, 5); |
0cbfec87e4f1
Support for UTF-8 text input has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3411
diff
changeset
|
2697 if (PhKeyToMb(text, keyevent)!=-1) |
0cbfec87e4f1
Support for UTF-8 text input has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3411
diff
changeset
|
2698 { |
0cbfec87e4f1
Support for UTF-8 text input has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3411
diff
changeset
|
2699 SDL_SendKeyboardText(0, text); |
0cbfec87e4f1
Support for UTF-8 text input has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3411
diff
changeset
|
2700 } |
0cbfec87e4f1
Support for UTF-8 text input has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3411
diff
changeset
|
2701 else |
0cbfec87e4f1
Support for UTF-8 text input has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3411
diff
changeset
|
2702 { |
0cbfec87e4f1
Support for UTF-8 text input has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3411
diff
changeset
|
2703 /* Just do nothing if it is not a UTF-8 character */ |
0cbfec87e4f1
Support for UTF-8 text input has been added.
Mike Gorchak <lestat@i.com.ua>
parents:
3411
diff
changeset
|
2704 } |
3139 | 2705 } |
2706 } | |
2707 break; | |
2708 case Ph_EV_SERVICE: | |
2709 { | |
2710 } | |
2711 break; | |
2712 case Ph_EV_SYSTEM: | |
2713 { | |
2714 } | |
2715 break; | |
2716 case Ph_EV_WM: | |
2717 { | |
2718 PhWindowEvent_t *wmevent = NULL; | |
2719 | |
2720 /* Get associated event data */ | |
2721 wmevent = PhGetData(event); | |
2722 if (wmevent == NULL) { | |
2723 break; | |
2724 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2725 |
3139 | 2726 switch (wmevent->event_f) { |
2727 case Ph_WM_CLOSE: | |
2728 { | |
2729 if (window != NULL) { | |
2730 SDL_SendWindowEvent(window->id, | |
2731 SDL_WINDOWEVENT_CLOSE, | |
2732 0, 0); | |
2733 } | |
2734 } | |
2735 break; | |
2736 case Ph_WM_FOCUS: | |
2737 { | |
2738 if (wmevent->event_state == | |
2739 Ph_WM_EVSTATE_FOCUS) { | |
2740 if (window != NULL) { | |
2741 PhRegion_t wregion; | |
2742 | |
2743 SDL_SendWindowEvent(window->id, | |
2744 SDL_WINDOWEVENT_FOCUS_GAINED, | |
2745 0, 0); | |
2746 SDL_SetKeyboardFocus(0, window->id); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2747 |
3139 | 2748 /* Set window region sensible to mouse motion events */ |
2749 PhRegionQuery(PtWidgetRid | |
2750 (wdata->window), | |
2751 &wregion, NULL, NULL, | |
2752 0); | |
2753 wregion.events_sense |= | |
2754 Ph_EV_PTR_MOTION_BUTTON | | |
2755 Ph_EV_PTR_MOTION_NOBUTTON; | |
2756 PhRegionChange(Ph_REGION_EV_SENSE, 0, | |
2757 &wregion, NULL, NULL); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2758 |
3411
d15a4daa4a58
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents:
3399
diff
changeset
|
2759 /* If window got a focus, then it is visible */ |
3139 | 2760 SDL_SendWindowEvent(window->id, |
2761 SDL_WINDOWEVENT_SHOWN, | |
2762 0, 0); | |
2763 } | |
2764 } | |
2765 if (wmevent->event_state == | |
2766 Ph_WM_EVSTATE_FOCUSLOST) { | |
2767 if (window != NULL) { | |
2768 PhRegion_t wregion; | |
2769 | |
2770 SDL_SendWindowEvent(window->id, | |
2771 SDL_WINDOWEVENT_FOCUS_LOST, | |
2772 0, 0); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2773 |
3139 | 2774 /* Set window region ignore mouse motion events */ |
2775 PhRegionQuery(PtWidgetRid | |
2776 (wdata->window), | |
2777 &wregion, NULL, NULL, | |
2778 0); | |
2779 wregion.events_sense &= | |
2780 ~(Ph_EV_PTR_MOTION_BUTTON | | |
2781 Ph_EV_PTR_MOTION_NOBUTTON); | |
2782 PhRegionChange(Ph_REGION_EV_SENSE, 0, | |
2783 &wregion, NULL, NULL); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2784 } |
3139 | 2785 } |
2786 } | |
2787 break; | |
2788 case Ph_WM_MOVE: | |
2789 { | |
2790 if (window != NULL) { | |
2791 SDL_SendWindowEvent(window->id, | |
2792 SDL_WINDOWEVENT_MOVED, | |
2793 wmevent->pos.x, | |
2794 wmevent->pos.y); | |
2795 } | |
2796 } | |
2797 break; | |
2798 case Ph_WM_RESIZE: | |
2799 { | |
2800 if (window != NULL) { | |
2801 /* Set new window position after resize */ | |
2802 SDL_SendWindowEvent(window->id, | |
2803 SDL_WINDOWEVENT_MOVED, | |
2804 wmevent->pos.x, | |
2805 wmevent->pos.y); | |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2806 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2807 /* Check if this window uses OpenGL ES */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2808 if (wdata->uses_gles == SDL_TRUE) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2809 /* If so, recreate surface with new dimensions */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2810 photon_gl_recreatesurface(_this, window, wmevent->size.w, wmevent->size.h); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2811 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2812 |
3139 | 2813 /* Set new window size after resize */ |
2814 SDL_SendWindowEvent(window->id, | |
2815 SDL_WINDOWEVENT_RESIZED, | |
2816 wmevent->size.w, | |
2817 wmevent->size.h); | |
2818 } | |
2819 } | |
2820 break; | |
2821 case Ph_WM_HIDE: | |
2822 { | |
2823 if (window != NULL) { | |
2824 /* Send new window state: minimized */ | |
2825 SDL_SendWindowEvent(window->id, | |
2826 SDL_WINDOWEVENT_MINIMIZED, | |
2827 0, 0); | |
2828 /* In case window is minimized, then it is hidden */ | |
2829 SDL_SendWindowEvent(window->id, | |
2830 SDL_WINDOWEVENT_HIDDEN, | |
2831 0, 0); | |
2832 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2833 } |
3139 | 2834 break; |
2835 case Ph_WM_MAX: | |
2836 { | |
2837 if (window != NULL) { | |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2838 if ((window->flags & SDL_WINDOW_RESIZABLE)==SDL_WINDOW_RESIZABLE) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2839 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2840 SDL_SendWindowEvent(window->id, |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2841 SDL_WINDOWEVENT_MAXIMIZED, |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2842 0, 0); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2843 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2844 else |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2845 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2846 /* otherwise ignor the resize events */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2847 } |
3139 | 2848 } |
2849 } | |
2850 break; | |
2851 case Ph_WM_RESTORE: | |
2852 { | |
2853 if (window != NULL) { | |
2854 SDL_SendWindowEvent(window->id, | |
2855 SDL_WINDOWEVENT_RESTORED, | |
2856 0, 0); | |
2857 } | |
2858 } | |
2859 break; | |
2860 } | |
2861 } | |
2862 break; | |
2863 } | |
2864 PtEventHandler(event); | |
2865 } | |
2866 break; | |
2867 case 0: | |
2868 { | |
2869 /* All events are read */ | |
2870 finish = 1; | |
2871 break; | |
2872 } | |
2873 case -1: | |
2874 { | |
2875 /* Error occured in event reading */ | |
2876 SDL_SetError("Photon: Can't read event"); | |
2877 return; | |
2878 } | |
2879 break; | |
2880 } | |
2881 if (finish != 0) { | |
2882 break; | |
2883 } | |
2884 } while (1); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2885 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2886 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2887 /*****************************************************************************/ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2888 /* SDL screen saver related functions */ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2889 /*****************************************************************************/ |
3139 | 2890 void |
2891 photon_suspendscreensaver(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2892 { |
3139 | 2893 /* There is no screensaver in pure console, it may exist when running */ |
2894 /* GF under Photon, but I do not know, how to disable screensaver */ | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2895 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2896 |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2897 /* vi: set ts=4 sw=4 expandtab: */ |