Mercurial > sdl-ios-xcode
annotate src/video/photon/SDL_photon.c @ 3192:ec126b077b96
Note about hardware mouse cursor has been added.
author | Mike Gorchak <lestat@i.com.ua> |
---|---|
date | Wed, 10 Jun 2009 18:32:42 +0000 |
parents | 51750b7a966f |
children | 64e4442676a6 |
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 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
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 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
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 , | |
140 /* VESA unaccelerated gfx driver (devg-vesa.so) */ | |
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 { |
3139 | 158 int 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; | |
197 int status; | |
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 */ | |
331 phdata->swapinterval = 0; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
332 |
3139 | 333 for (it = 0; it < phdata->avail_rids; it++) { |
334 didata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData)); | |
335 if (didata == NULL) { | |
336 /* memory allocation error */ | |
337 SDL_OutOfMemory(); | |
338 return -1; | |
339 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
340 |
3139 | 341 /* Allocate two cursors with SDL_VIDEO_PHOTON_MAX_CURSOR_SIZE size */ |
342 /* and 128 bytes of spare place */ | |
343 didata->cursor_size = | |
344 ((SDL_VIDEO_PHOTON_MAX_CURSOR_SIZE * 4) >> 3) + 128; | |
345 didata->cursor = (PhCursorDef_t *) SDL_calloc(1, didata->cursor_size); | |
346 if (didata->cursor == NULL) { | |
347 /* memory allocation error */ | |
348 SDL_OutOfMemory(); | |
349 SDL_free(didata); | |
350 return -1; | |
351 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
352 |
3139 | 353 /* Initialize GF in case of OpenGL ES support is compiled in */ |
354 #if defined(SDL_VIDEO_OPENGL_ES) | |
355 /* TODO: add real device detection versus multiple heads */ | |
356 if (phdata->gfinitialized == SDL_TRUE) { | |
357 status = | |
358 gf_display_attach(&didata->display, phdata->gfdev, it, | |
359 &didata->display_info); | |
360 if (status != GF_ERR_OK) { | |
361 /* Just shutdown GF, do not fail */ | |
362 gf_dev_detach(phdata->gfdev); | |
363 phdata->gfinitialized = SDL_FALSE; | |
364 } | |
365 } | |
366 #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
|
367 |
3139 | 368 /* Check if current device is not the same as target */ |
369 if (phdata->current_device_id != it) { | |
370 /* Set target device as default for Pd and Pg functions */ | |
371 status = PdSetTargetDevice(NULL, phdata->rid[it]); | |
372 if (status != 0) { | |
373 SDL_SetError("Photon: Can't set default target device\n"); | |
374 SDL_free(didata->cursor); | |
375 SDL_free(didata); | |
376 return -1; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
377 } |
3139 | 378 phdata->current_device_id = it; |
379 } | |
380 | |
381 /* Store device id */ | |
382 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
|
383 |
3139 | 384 /* Query photon about graphics hardware caps and current video mode */ |
385 status = PgGetGraphicsHWCaps(&hwcaps); | |
386 if (status != 0) { | |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
387 PhRect_t extent; |
3186 | 388 PdOffscreenContext_t *curctx; |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
389 |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
390 /* 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
|
391 /* under custom (not listed by photon) video mode */ |
3186 | 392 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
|
393 if (status != 0) { |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
394 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
|
395 SDL_free(didata->cursor); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
396 SDL_free(didata); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
397 return -1; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
398 } |
3186 | 399 modeinfo.width = extent.lr.x + 1; |
400 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
|
401 /* Hardcode 60Hz, as the base refresh rate frequency */ |
3186 | 402 hwcaps.current_rrate = 60; |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
403 /* Clear current video driver name, no way to get it somehow */ |
3186 | 404 hwcaps.chip_name[0] = 0x00; |
3139 | 405 |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
406 /* 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
|
407 /* displayed on the screen */ |
3186 | 408 curctx = PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY); |
409 if (curctx == NULL) { | |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
410 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
|
411 SDL_free(didata->cursor); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
412 SDL_free(didata); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
413 return -1; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
414 } |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
415 /* Retrieve current bpp */ |
3186 | 416 modeinfo.type = curctx->format; |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
417 PhDCRelease(curctx); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
418 } else { |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
419 /* Get current video mode details */ |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
420 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
|
421 if (status != 0) { |
3186 | 422 SDL_SetError |
423 ("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
|
424 SDL_free(didata->cursor); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
425 SDL_free(didata); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
426 return -1; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
427 } |
3139 | 428 } |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
429 |
3139 | 430 /* Setup current desktop mode for SDL */ |
431 SDL_zero(current_mode); | |
432 current_mode.w = modeinfo.width; | |
433 current_mode.h = modeinfo.height; | |
434 current_mode.refresh_rate = hwcaps.current_rrate; | |
435 current_mode.format = photon_image_to_sdl_pixelformat(modeinfo.type); | |
436 current_mode.driverdata = NULL; | |
437 | |
438 /* Copy device name */ | |
439 SDL_strlcpy(didata->description, hwcaps.chip_name, | |
440 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
|
441 |
3139 | 442 /* Search device capabilities and possible workarounds */ |
443 jt = 0; | |
444 do { | |
445 if (photon_devicename[jt].name == NULL) { | |
446 break; | |
447 } | |
448 if (SDL_strncmp | |
449 (photon_devicename[jt].name, didata->description, | |
450 SDL_strlen(photon_devicename[jt].name)) == 0) { | |
451 didata->caps = photon_devicename[jt].caps; | |
452 } | |
453 jt++; | |
454 } while (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 /* Initialize display structure */ |
457 SDL_zero(display); | |
458 display.desktop_mode = current_mode; | |
459 display.current_mode = current_mode; | |
460 display.driverdata = didata; | |
461 didata->current_mode = current_mode; | |
462 SDL_AddVideoDisplay(&display); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
463 |
3139 | 464 /* Check for environment variables which could override some SDL settings */ |
465 didata->custom_refresh = 0; | |
466 override = SDL_getenv("SDL_VIDEO_PHOTON_REFRESH_RATE"); | |
467 if (override != NULL) { | |
468 if (SDL_sscanf(override, "%u", &didata->custom_refresh) != 1) { | |
469 didata->custom_refresh = 0; | |
470 } | |
471 } | |
472 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
473 |
3139 | 474 /* Add photon input devices */ |
475 status = photon_addinputdevices(_this); | |
476 if (status != 0) { | |
477 /* SDL error is set by photon_addinputdevices() function */ | |
478 return -1; | |
479 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
480 |
3139 | 481 /* Add photon renderer to SDL */ |
482 photon_addrenderdriver(_this); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
483 |
3139 | 484 /* video has been initialized successfully */ |
485 return 1; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
486 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
487 |
3139 | 488 void |
489 photon_videoquit(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
490 { |
3139 | 491 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
492 SDL_DisplayData *didata; | |
493 uint32_t it; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
494 |
3139 | 495 /* SDL will restore our desktop mode on exit */ |
496 for (it = 0; it < _this->num_displays; it++) { | |
497 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
|
498 |
3139 | 499 if (didata->cursor != NULL) { |
500 SDL_free(didata->cursor); | |
501 } | |
502 #if defined(SDL_VIDEO_OPENGL_ES) | |
503 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
|
504 /* Detach GF display */ |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
505 gf_display_detach(didata->display); |
3139 | 506 } |
507 #endif /* SDL_VIDEO_OPENGL_ES */ | |
508 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
509 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
510 |
3139 | 511 void |
512 photon_getdisplaymodes(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
513 { |
3139 | 514 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
515 SDL_DisplayData *didata = | |
516 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
517 SDL_DisplayMode mode; | |
518 PgVideoModes_t modes; | |
519 PgVideoModeInfo_t modeinfo; | |
520 int32_t status; | |
521 uint32_t it; | |
522 uint32_t jt; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
523 |
3139 | 524 /* Check if current device is not the same as target */ |
525 if (phdata->current_device_id != didata->device_id) { | |
526 /* Set target device as default for Pd and Pg functions */ | |
527 status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]); | |
528 if (status != 0) { | |
529 SDL_SetError("Photon: Can't set default target device\n"); | |
530 return; | |
531 } | |
532 phdata->current_device_id = didata->device_id; | |
533 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
534 |
3139 | 535 /* Get array of available video modes */ |
536 status = PgGetVideoModeList(&modes); | |
537 if (status != 0) { | |
538 SDL_SetError("Photon: Can't get video mode list"); | |
539 return; | |
540 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
541 |
3139 | 542 for (it = 0; it < modes.num_modes; it++) { |
543 status = PgGetVideoModeInfo(modes.modes[it], &modeinfo); | |
544 if (status != 0) { | |
545 /* Maybe something wrong with this particular mode, skip it */ | |
546 continue; | |
547 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
548 |
3139 | 549 jt = 0; |
550 do { | |
551 if (modeinfo.refresh_rates[jt] != 0) { | |
552 mode.w = modeinfo.width; | |
553 mode.h = modeinfo.height; | |
554 mode.refresh_rate = modeinfo.refresh_rates[jt]; | |
555 mode.format = photon_image_to_sdl_pixelformat(modeinfo.type); | |
556 mode.driverdata = NULL; | |
557 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
|
558 |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
559 /* 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
|
560 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
|
561 mode.w = modeinfo.width; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
562 mode.h = modeinfo.height; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
563 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
|
564 mode.format = SDL_PIXELFORMAT_RGB888; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
565 mode.driverdata = NULL; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
566 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
|
567 } |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
568 |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
569 /* 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
|
570 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
|
571 mode.w = modeinfo.width; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
572 mode.h = modeinfo.height; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
573 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
|
574 mode.format = SDL_PIXELFORMAT_RGB555; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
575 mode.driverdata = NULL; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
576 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
|
577 } |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
578 |
3139 | 579 jt++; |
580 } else { | |
581 break; | |
582 } | |
583 } while (1); | |
584 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
585 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
586 |
3139 | 587 int |
588 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
|
589 { |
3139 | 590 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
591 SDL_DisplayData *didata = | |
592 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
593 PgVideoModes_t modes; | |
594 PgVideoModeInfo_t modeinfo; | |
595 PgDisplaySettings_t modesettings; | |
596 uint32_t refresh_rate = 0; | |
597 int32_t status; | |
598 uint32_t it; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
599 |
3139 | 600 /* Check if current device is not the same as target */ |
601 if (phdata->current_device_id != didata->device_id) { | |
602 /* Set target device as default for Pd and Pg functions */ | |
603 status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]); | |
604 if (status != 0) { | |
605 SDL_SetError("Photon: Can't set default target device\n"); | |
606 return; | |
607 } | |
608 phdata->current_device_id = didata->device_id; | |
609 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
610 |
3139 | 611 /* Get array of available video modes */ |
612 status = PgGetVideoModeList(&modes); | |
613 if (status != 0) { | |
614 SDL_SetError("Photon: Can't get video mode list"); | |
615 return; | |
616 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
617 |
3139 | 618 /* Current display dimension and bpp are no more valid */ |
619 didata->current_mode.format = SDL_PIXELFORMAT_UNKNOWN; | |
620 didata->current_mode.w = 0; | |
621 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
|
622 |
3139 | 623 /* Check if custom refresh rate requested */ |
624 if (didata->custom_refresh != 0) { | |
625 refresh_rate = didata->custom_refresh; | |
626 } else { | |
627 refresh_rate = mode->refresh_rate; | |
628 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
629 |
3139 | 630 /* Check if SDL GF driver needs to find appropriate refresh rate itself */ |
631 if (refresh_rate == 0) { | |
632 SDL_DisplayMode tempmode; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
633 |
3139 | 634 /* Clear display mode structure */ |
635 SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode)); | |
636 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
|
637 |
3139 | 638 /* Check if window width and height matches one of our modes */ |
639 for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) { | |
640 if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) && | |
641 (SDL_CurrentDisplay.display_modes[it].h == mode->h) && | |
642 (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
|
643 { |
3139 | 644 /* Find the lowest refresh rate available */ |
645 if (tempmode.refresh_rate > | |
646 SDL_CurrentDisplay.display_modes[it].refresh_rate) { | |
647 tempmode = SDL_CurrentDisplay.display_modes[it]; | |
648 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
649 } |
3139 | 650 } |
651 if (tempmode.refresh_rate != 0x0000FFFF) { | |
652 refresh_rate = tempmode.refresh_rate; | |
653 } else { | |
654 /* Let video driver decide what to do with this */ | |
655 refresh_rate = 0; | |
656 } | |
657 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
658 |
3139 | 659 /* Check if SDL GF driver needs to check custom refresh rate */ |
660 if (didata->custom_refresh != 0) { | |
661 SDL_DisplayMode tempmode; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
662 |
3139 | 663 /* Clear display mode structure */ |
664 SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode)); | |
665 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
|
666 |
3139 | 667 /* Check if window width and height matches one of our modes */ |
668 for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) { | |
669 if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) && | |
670 (SDL_CurrentDisplay.display_modes[it].h == mode->h) && | |
671 (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
|
672 { |
3139 | 673 /* Find the lowest refresh rate available */ |
674 if (tempmode.refresh_rate > | |
675 SDL_CurrentDisplay.display_modes[it].refresh_rate) { | |
676 tempmode = SDL_CurrentDisplay.display_modes[it]; | |
677 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
678 |
3139 | 679 /* Check if requested refresh rate found */ |
680 if (refresh_rate == | |
681 SDL_CurrentDisplay.display_modes[it].refresh_rate) { | |
682 tempmode = SDL_CurrentDisplay.display_modes[it]; | |
683 break; | |
684 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
685 } |
3139 | 686 } |
687 if (tempmode.refresh_rate != 0x0000FFFF) { | |
688 refresh_rate = tempmode.refresh_rate; | |
689 } else { | |
690 /* Let video driver decide what to do with this */ | |
691 refresh_rate = 0; | |
692 } | |
693 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
694 |
3139 | 695 /* Find photon's video mode number */ |
696 for (it = 0; it < modes.num_modes; it++) { | |
697 uint32_t jt; | |
698 uint32_t foundrefresh; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
699 |
3139 | 700 /* Get current video mode details */ |
701 status = PgGetVideoModeInfo(modes.modes[it], &modeinfo); | |
702 if (status != 0) { | |
703 /* Maybe something wrong with this particular mode, skip it */ | |
704 continue; | |
705 } | |
706 if ((modeinfo.width == mode->w) && (modeinfo.height == mode->h) && | |
707 (modeinfo.type == photon_sdl_to_image_pixelformat(mode->format))) | |
708 { | |
709 /* Mode is found, find requested refresh rate, this case is for */ | |
710 /* video drivers, which provide non-generic video modes. */ | |
711 jt = 0; | |
712 foundrefresh = 0; | |
713 do { | |
714 if (modeinfo.refresh_rates[jt] != 0) { | |
715 if (modeinfo.refresh_rates[jt] == refresh_rate) { | |
716 foundrefresh = 1; | |
717 break; | |
718 } | |
719 jt++; | |
720 } else { | |
721 break; | |
722 } | |
723 } while (1); | |
724 if (foundrefresh != 0) { | |
725 break; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
726 } |
3139 | 727 } |
728 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
729 |
3139 | 730 /* Check if video mode has not been found */ |
731 if (it == modes.num_modes) { | |
732 SDL_SetError("Photon: Can't find appropriate video mode"); | |
733 return -1; | |
734 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
735 |
3139 | 736 /* Fill mode settings */ |
737 modesettings.flags = 0x00000000; | |
738 modesettings.mode = modes.modes[it]; | |
739 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
|
740 |
3139 | 741 /* Finally set new video mode */ |
742 status = PgSetVideoMode(&modesettings); | |
743 if (status != 0) { | |
744 SDL_SetError("Photon: Can't set new video mode"); | |
745 return -1; | |
746 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
747 |
3139 | 748 /* Store new video mode parameters */ |
749 didata->current_mode = *mode; | |
750 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
|
751 |
3139 | 752 return 0; |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
753 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
754 |
3139 | 755 int |
756 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
|
757 { |
3139 | 758 SDL_DisplayData *didata = |
759 (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
|
760 |
3139 | 761 /* Setting display palette operation has been failed */ |
762 return -1; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
763 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
764 |
3139 | 765 int |
766 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
|
767 { |
3139 | 768 SDL_DisplayData *didata = |
769 (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
|
770 |
3139 | 771 /* Getting display palette operation has been failed */ |
772 return -1; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
773 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
774 |
3139 | 775 int |
776 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
|
777 { |
3139 | 778 SDL_DisplayData *didata = |
779 (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
|
780 |
3139 | 781 /* Setting display gamma ramp operation has been failed */ |
782 return -1; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
783 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
784 |
3139 | 785 int |
786 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
|
787 { |
3139 | 788 /* Getting display gamma ramp operation has been failed */ |
789 return -1; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
790 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
791 |
3139 | 792 int |
793 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
|
794 { |
3139 | 795 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
796 SDL_DisplayData *didata = | |
797 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
798 SDL_WindowData *wdata; | |
799 PhDim_t winsize; | |
800 PhPoint_t winpos; | |
801 PtArg_t winargs[32]; | |
802 uint32_t winargc = 0; | |
803 int32_t status; | |
804 PhRegion_t wregion; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
805 |
3139 | 806 /* Allocate window internal data */ |
807 wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); | |
808 if (wdata == NULL) { | |
809 SDL_OutOfMemory(); | |
810 return -1; | |
811 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
812 |
3139 | 813 /* Setup driver data for this window */ |
814 window->driverdata = wdata; | |
815 | |
816 /* Set initial window title */ | |
817 if (window->title != NULL) { | |
818 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_TITLE, window->title, 0); | |
819 } else { | |
820 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_TITLE, "", 0); | |
821 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
822 |
3139 | 823 /* TODO: handle SDL_WINDOW_INPUT_GRABBED */ |
824 | |
825 /* Disable default window filling on redraw */ | |
826 PtSetArg(&winargs[winargc++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, | |
827 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
|
828 |
3139 | 829 /* Reset default managed flags to disabled state */ |
830 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, | |
831 Ph_WM_APP_DEF_MANAGED); | |
832 /* Set which events we will not handle, let WM to handle them */ | |
833 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, | |
834 Ph_WM_BACKDROP | Ph_WM_TOFRONT | Ph_WM_COLLAPSE | Ph_WM_FFRONT | | |
835 Ph_WM_FOCUS | Ph_WM_HELP | Ph_WM_HIDE | Ph_WM_MAX | | |
836 Ph_WM_MENU | Ph_WM_MOVE | Ph_WM_RESTORE | Ph_WM_TASKBAR | | |
837 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
|
838 |
3139 | 839 /* Reset default notify events to disable */ |
840 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE, | |
841 Ph_WM_RESIZE | Ph_WM_CLOSE | Ph_WM_HELP); | |
842 /* Set which events we will handle */ | |
843 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, | |
844 Ph_WM_CLOSE | Ph_WM_COLLAPSE | Ph_WM_FOCUS | Ph_WM_MAX | | |
845 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
|
846 |
3139 | 847 /* Borderless window can't be resizeable */ |
848 if ((window->flags & SDL_WINDOW_BORDERLESS) == SDL_WINDOW_BORDERLESS) { | |
849 window->flags &= ~(SDL_WINDOW_RESIZABLE); | |
850 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
851 |
3139 | 852 /* Reset all default decorations */ |
853 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, | |
854 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
|
855 |
3139 | 856 /* Fullscreen window has its own decorations */ |
857 if ((window->flags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN) { | |
858 window->flags |= SDL_WINDOW_BORDERLESS; | |
859 window->flags &= ~(SDL_WINDOW_RESIZABLE); | |
860 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, | |
861 Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_TITLE); | |
862 } else { | |
863 uint32_t decorations = | |
864 Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_MENU | Ph_WM_RENDER_MIN | | |
865 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
|
866 |
3139 | 867 if ((window->flags & SDL_WINDOW_RESIZABLE) == SDL_WINDOW_RESIZABLE) { |
868 decorations |= | |
869 Ph_WM_RENDER_BORDER | Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX; | |
870 PtSetArg(&winargs[winargc++], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, | |
871 Pt_RESIZE_XY_AS_REQUIRED); | |
872 } | |
873 if ((window->flags & SDL_WINDOW_BORDERLESS) != SDL_WINDOW_BORDERLESS) { | |
874 decorations |= Ph_WM_RENDER_BORDER; | |
875 } | |
876 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, | |
877 decorations); | |
878 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
879 |
3139 | 880 /* Set initial window state */ |
881 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_STATE, Pt_FALSE, | |
882 Ph_WM_STATE_ISFOCUS); | |
883 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_STATE, Pt_TRUE, | |
884 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
|
885 |
3139 | 886 /* Set window dimension */ |
887 winsize.w = window->w; | |
888 winsize.h = window->h; | |
889 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
|
890 |
3139 | 891 /* Check if upper level requests WM to position window */ |
892 if ((window->x == SDL_WINDOWPOS_UNDEFINED) | |
893 && (window->y == SDL_WINDOWPOS_UNDEFINED)) { | |
894 /* Do not set widget position, let WM to set it */ | |
895 } else { | |
896 if (window->x == SDL_WINDOWPOS_UNDEFINED) { | |
897 window->x = 0; | |
898 } | |
899 if (window->y == SDL_WINDOWPOS_UNDEFINED) { | |
900 window->y = 0; | |
901 } | |
902 if (window->x == SDL_WINDOWPOS_CENTERED) { | |
903 window->x = (didata->current_mode.w - window->w) / 2; | |
904 } | |
905 if (window->y == SDL_WINDOWPOS_CENTERED) { | |
906 window->y = (didata->current_mode.h - window->h) / 2; | |
907 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
908 |
3139 | 909 /* Now set window position */ |
910 winpos.x = window->x; | |
911 winpos.y = window->y; | |
912 PtSetArg(&winargs[winargc++], Pt_ARG_POS, &winpos, 0); | |
913 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
914 |
3139 | 915 /* Check if window must support OpenGL ES rendering */ |
916 if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) { | |
917 #if defined(SDL_VIDEO_OPENGL_ES) | |
918 EGLBoolean initstatus; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
919 |
3139 | 920 /* Check if GF was initialized correctly */ |
921 if (phdata->gfinitialized == SDL_FALSE) { | |
922 SDL_SetError | |
923 ("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
|
924 return -1; |
3139 | 925 } |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
926 |
3139 | 927 /* Mark this window as OpenGL ES compatible */ |
928 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
|
929 |
3139 | 930 /* Create connection to OpenGL ES */ |
931 if (phdata->egldisplay == EGL_NO_DISPLAY) { | |
932 phdata->egldisplay = eglGetDisplay(phdata->gfdev); | |
933 if (phdata->egldisplay == EGL_NO_DISPLAY) { | |
934 SDL_SetError("Photon: Can't get connection to OpenGL ES"); | |
935 return -1; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
936 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
937 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
938 /* Initialize OpenGL ES library, ignore EGL version */ |
3139 | 939 initstatus = eglInitialize(phdata->egldisplay, NULL, NULL); |
940 if (initstatus != EGL_TRUE) { | |
941 SDL_SetError("Photon: Can't init OpenGL ES library"); | |
942 return -1; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
943 } |
3139 | 944 } |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
945 |
3139 | 946 /* Increment GL ES reference count usage */ |
947 phdata->egl_refcount++; | |
948 #else | |
949 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
950 return -1; | |
951 #endif /* SDL_VIDEO_OPENGL_ES */ | |
952 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
953 |
3139 | 954 /* Finally create the window */ |
955 wdata->window = PtCreateWidget(PtWindow, Pt_NO_PARENT, winargc, winargs); | |
956 if (wdata->window == NULL) { | |
957 SDL_SetError("Photon: Can't create window widget"); | |
958 SDL_free(wdata); | |
959 return -1; | |
960 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
961 |
3139 | 962 /* Show widget */ |
963 status = PtRealizeWidget(wdata->window); | |
964 if (status != 0) { | |
965 SDL_SetError("Photon: Can't realize window widget"); | |
966 PtDestroyWidget(wdata->window); | |
967 SDL_free(wdata); | |
968 return; | |
969 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
970 |
3139 | 971 /* Just created SDL window always gets focus */ |
972 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
|
973 |
3139 | 974 /* Create window-specific cursor after creation */ |
975 if (didata->cursor_visible == SDL_TRUE) { | |
976 /* Setup cursor type. shape and default color */ | |
977 PtSetResource(wdata->window, Pt_ARG_CURSOR_COLOR, | |
978 Ph_CURSOR_DEFAULT_COLOR, 0); | |
979 PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0); | |
980 PtSetResource(wdata->window, Pt_ARG_BITMAP_CURSOR, didata->cursor, | |
981 didata->cursor->hdr.len + sizeof(PhRegionDataHdr_t)); | |
982 } else { | |
983 PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, 0); | |
984 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
985 |
3139 | 986 /* Set window region sensible to mouse motion events */ |
987 status = | |
988 PhRegionQuery(PtWidgetRid(wdata->window), &wregion, NULL, NULL, 0); | |
989 if (status != 0) { | |
990 SDL_SetError | |
991 ("Photon: Can't set region sensivity to mouse motion events"); | |
992 PtDestroyWidget(wdata->window); | |
993 SDL_free(wdata); | |
994 return -1; | |
995 } | |
996 wregion.events_sense |= | |
997 Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON; | |
998 status = PhRegionChange(Ph_REGION_EV_SENSE, 0, &wregion, NULL, NULL); | |
999 if (status < 0) { | |
1000 SDL_SetError("Photon: Can't change region sensivity"); | |
1001 PtDestroyWidget(wdata->window); | |
1002 SDL_free(wdata); | |
1003 return -1; | |
1004 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1005 |
3139 | 1006 /* Flush all widget operations again */ |
1007 PtFlush(); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1008 |
3139 | 1009 /* By default last created window got a input focus */ |
1010 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
|
1011 |
3139 | 1012 /* Window has been successfully created */ |
1013 return 0; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1014 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1015 |
3139 | 1016 int |
1017 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
|
1018 { |
3139 | 1019 /* 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
|
1020 |
3139 | 1021 /* Failed to create window from another window */ |
1022 return -1; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1023 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1024 |
3139 | 1025 void |
1026 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
|
1027 { |
3139 | 1028 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1029 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1030 |
3139 | 1031 /* Set window title */ |
1032 if (window->title != NULL) { | |
1033 status = | |
1034 PtSetResource(wdata->window, Pt_ARG_WINDOW_TITLE, window->title, | |
1035 0); | |
1036 } else { | |
1037 status = PtSetResource(wdata->window, Pt_ARG_WINDOW_TITLE, "", 0); | |
1038 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1039 |
3139 | 1040 if (status != 0) { |
1041 SDL_SetError("Photon: Can't set window title"); | |
1042 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1043 |
3139 | 1044 /* Flush all widget operations */ |
1045 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1046 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1047 |
3139 | 1048 void |
1049 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
|
1050 { |
3139 | 1051 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1052 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1053 |
3139 | 1054 /* TODO: Use iconify ? */ |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1055 |
3139 | 1056 /* Flush all widget operations */ |
1057 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1058 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1059 |
3139 | 1060 void |
1061 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
|
1062 { |
3139 | 1063 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1064 SDL_DisplayData *didata = | |
1065 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
1066 PhPoint_t winpos; | |
1067 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1068 |
3139 | 1069 /* Check if upper level requests WM to position window */ |
1070 if ((window->x == SDL_WINDOWPOS_UNDEFINED) | |
1071 && (window->y == SDL_WINDOWPOS_UNDEFINED)) { | |
1072 /* Do not set widget position, let WM to set it */ | |
1073 } else { | |
1074 if (window->x == SDL_WINDOWPOS_UNDEFINED) { | |
1075 window->x = 0; | |
1076 } | |
1077 if (window->y == SDL_WINDOWPOS_UNDEFINED) { | |
1078 window->y = 0; | |
1079 } | |
1080 if (window->x == SDL_WINDOWPOS_CENTERED) { | |
1081 window->x = (didata->current_mode.w - window->w) / 2; | |
1082 } | |
1083 if (window->y == SDL_WINDOWPOS_CENTERED) { | |
1084 window->y = (didata->current_mode.h - window->h) / 2; | |
1085 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1086 |
3139 | 1087 /* Now set window position */ |
1088 winpos.x = window->x; | |
1089 winpos.y = window->y; | |
1090 status = PtSetResource(wdata->window, Pt_ARG_POS, &winpos, 0); | |
1091 if (status != 0) { | |
1092 SDL_SetError("Photon: Can't set window position"); | |
1093 } | |
1094 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1095 |
3139 | 1096 /* Flush all widget operations */ |
1097 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1098 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1099 |
3139 | 1100 void |
1101 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
|
1102 { |
3139 | 1103 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1104 PhDim_t winsize; | |
1105 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1106 |
3139 | 1107 winsize.w = window->w; |
1108 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
|
1109 |
3139 | 1110 status = PtSetResource(wdata->window, Pt_ARG_DIM, &winsize, 0); |
1111 if (status != 0) { | |
1112 SDL_SetError("Photon: Can't set window size"); | |
1113 } | |
1114 | |
1115 /* Flush all widget operations */ | |
1116 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1117 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1118 |
3139 | 1119 void |
1120 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
|
1121 { |
3139 | 1122 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1123 int32_t status; | |
1124 | |
1125 /* Bring focus to window and put it in front of others */ | |
1126 PtWindowToFront(wdata->window); | |
1127 | |
1128 /* Flush all widget operations */ | |
1129 PtFlush(); | |
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 void |
1133 photon_hidewindow(_THIS, SDL_Window * window) | |
1134 { | |
1135 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | |
1136 PhWindowEvent_t winevent; | |
1137 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1138 |
3139 | 1139 SDL_memset(&winevent, 0x00, sizeof(PhWindowEvent_t)); |
1140 winevent.event_f = Ph_WM_HIDE; | |
1141 winevent.rid = PtWidgetRid(wdata->window); | |
1142 winevent.event_state = Ph_WM_EVSTATE_HIDE; | |
1143 | |
1144 status = PtForwardWindowEvent(&winevent); | |
1145 if (status != 0) { | |
1146 SDL_SetError("Photon: Can't hide window"); | |
1147 } | |
1148 | |
1149 /* Flush all widget operations */ | |
1150 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1151 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1152 |
3139 | 1153 void |
1154 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
|
1155 { |
3139 | 1156 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1157 PhWindowEvent_t winevent; | |
1158 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1159 |
3139 | 1160 SDL_memset(&winevent, 0x00, sizeof(PhWindowEvent_t)); |
1161 winevent.event_f = Ph_WM_HIDE; | |
1162 winevent.rid = PtWidgetRid(wdata->window); | |
1163 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
|
1164 |
3139 | 1165 status = PtForwardWindowEvent(&winevent); |
1166 if (status != 0) { | |
1167 SDL_SetError("Photon: Can't hide window"); | |
1168 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1169 |
3139 | 1170 /* Flush all widget operations */ |
1171 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1172 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1173 |
3139 | 1174 void |
1175 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
|
1176 { |
3139 | 1177 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1178 PhWindowEvent_t winevent; | |
1179 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1180 |
3139 | 1181 /* Flush all widget operations */ |
1182 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1183 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1184 |
3139 | 1185 void |
1186 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
|
1187 { |
3139 | 1188 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1189 PhWindowEvent_t winevent; | |
1190 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1191 |
3139 | 1192 SDL_memset(&winevent, 0x00, sizeof(PhWindowEvent_t)); |
1193 winevent.event_f = Ph_WM_HIDE; | |
1194 winevent.rid = PtWidgetRid(wdata->window); | |
1195 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
|
1196 |
3139 | 1197 status = PtForwardWindowEvent(&winevent); |
1198 if (status != 0) { | |
1199 SDL_SetError("Photon: Can't hide window"); | |
1200 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1201 |
3139 | 1202 /* Flush all widget operations */ |
1203 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1204 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1205 |
3139 | 1206 void |
1207 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
|
1208 { |
3139 | 1209 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1210 PhWindowEvent_t winevent; | |
1211 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1212 |
3139 | 1213 /* Flush all widget operations */ |
1214 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1215 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1216 |
3139 | 1217 void |
1218 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
|
1219 { |
3139 | 1220 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1221 PhWindowEvent_t winevent; | |
1222 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1223 |
3139 | 1224 /* Flush all widget operations */ |
1225 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1226 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1227 |
3139 | 1228 void |
1229 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
|
1230 { |
3139 | 1231 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
1232 SDL_DisplayData *didata = | |
1233 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
1234 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | |
1235 int32_t status; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1236 |
3139 | 1237 if (wdata != NULL) { |
1238 status = PtDestroyWidget(wdata->window); | |
1239 if (status != 0) { | |
1240 SDL_SetError("Photon: Can't destroy window widget"); | |
1241 } | |
1242 wdata->window = NULL; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1243 |
3139 | 1244 #if defined(SDL_VIDEO_OPENGL_ES) |
1245 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
|
1246 /* Destroy OpenGL ES surface if it was created */ |
3139 | 1247 if (wdata->gles_surface != EGL_NO_SURFACE) { |
1248 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
|
1249 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1250 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1251 /* Free OpenGL ES target surface */ |
3139 | 1252 if (wdata->gfsurface != NULL) { |
1253 gf_surface_free(wdata->gfsurface); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1254 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1255 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1256 phdata->egl_refcount--; |
3139 | 1257 if (phdata->egl_refcount == 0) { |
1258 /* Terminate connection to OpenGL ES */ | |
1259 if (phdata->egldisplay != EGL_NO_DISPLAY) { | |
1260 eglTerminate(phdata->egldisplay); | |
1261 phdata->egldisplay = EGL_NO_DISPLAY; | |
1262 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1263 } |
3139 | 1264 } |
1265 #endif /* SDL_VIDEO_OPENGL_ES */ | |
1266 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1267 |
3139 | 1268 /* Flush all widget operations */ |
1269 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1270 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1271 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1272 /*****************************************************************************/ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1273 /* SDL Window Manager function */ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1274 /*****************************************************************************/ |
3139 | 1275 SDL_bool |
1276 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
|
1277 { |
3139 | 1278 if (info->version.major <= SDL_MAJOR_VERSION) { |
1279 return SDL_TRUE; | |
1280 } else { | |
1281 SDL_SetError("application not compiled with SDL %d.%d\n", | |
1282 SDL_MAJOR_VERSION, SDL_MINOR_VERSION); | |
1283 return SDL_FALSE; | |
1284 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1285 |
3139 | 1286 /* Failed to get window manager information */ |
1287 return SDL_FALSE; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1288 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1289 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1290 /*****************************************************************************/ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1291 /* SDL OpenGL/OpenGL ES functions */ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1292 /*****************************************************************************/ |
3139 | 1293 int |
1294 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
|
1295 { |
3139 | 1296 #if defined(SDL_VIDEO_OPENGL_ES) |
1297 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
|
1298 |
3139 | 1299 if (phdata->gfinitialized != SDL_TRUE) { |
1300 SDL_SetError | |
1301 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1302 return NULL; | |
1303 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1304 |
3139 | 1305 /* Check if OpenGL ES library is specified for GF driver */ |
1306 if (path == NULL) { | |
1307 path = SDL_getenv("SDL_OPENGL_LIBRARY"); | |
1308 if (path == NULL) { | |
1309 path = SDL_getenv("SDL_OPENGLES_LIBRARY"); | |
1310 } | |
1311 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1312 |
3139 | 1313 /* Check if default library loading requested */ |
1314 if (path == NULL) { | |
1315 /* Already linked with GF library which provides egl* subset of */ | |
1316 /* functions, use Common profile of OpenGL ES library by default */ | |
1317 path = "/usr/lib/libGLES_CM.so.1"; | |
1318 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1319 |
3139 | 1320 /* Load dynamic library */ |
1321 _this->gl_config.dll_handle = SDL_LoadObject(path); | |
1322 if (!_this->gl_config.dll_handle) { | |
1323 /* Failed to load new GL ES library */ | |
1324 SDL_SetError("Photon: Failed to locate OpenGL ES library"); | |
1325 return -1; | |
1326 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1327 |
3139 | 1328 /* Store OpenGL ES library path and name */ |
1329 SDL_strlcpy(_this->gl_config.driver_path, path, | |
1330 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
|
1331 |
3139 | 1332 /* New OpenGL ES library is loaded */ |
1333 return 0; | |
1334 #else | |
1335 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1336 return -1; | |
1337 #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
|
1338 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1339 |
3139 | 1340 void * |
1341 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
|
1342 { |
3139 | 1343 #if defined(SDL_VIDEO_OPENGL_ES) |
1344 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
1345 void *function_address; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1346 |
3139 | 1347 if (phdata->gfinitialized != SDL_TRUE) { |
1348 SDL_SetError | |
1349 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1350 return NULL; | |
1351 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1352 |
3139 | 1353 /* Try to get function address through the egl interface */ |
1354 function_address = eglGetProcAddress(proc); | |
1355 if (function_address != NULL) { | |
1356 return function_address; | |
1357 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1358 |
3139 | 1359 /* Then try to get function in the OpenGL ES library */ |
1360 if (_this->gl_config.dll_handle) { | |
1361 function_address = | |
1362 SDL_LoadFunction(_this->gl_config.dll_handle, proc); | |
1363 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
|
1364 return function_address; |
3139 | 1365 } |
1366 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1367 |
3139 | 1368 /* Add emulated OpenGL ES 1.1 functions */ |
1369 if (SDL_strcmp(proc, "glTexParameteri") == 0) { | |
1370 return glTexParameteri; | |
1371 } | |
1372 if (SDL_strcmp(proc, "glTexParameteriv") == 0) { | |
1373 return glTexParameteriv; | |
1374 } | |
1375 if (SDL_strcmp(proc, "glColor4ub") == 0) { | |
1376 return glColor4ub; | |
1377 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1378 |
3139 | 1379 /* Failed to get GL ES function address pointer */ |
1380 SDL_SetError("Photon: Cannot locate OpenGL ES function name"); | |
1381 return NULL; | |
1382 #else | |
1383 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1384 return NULL; | |
1385 #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
|
1386 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1387 |
3139 | 1388 void |
1389 photon_gl_unloadlibrary(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1390 { |
3139 | 1391 #if defined(SDL_VIDEO_OPENGL_ES) |
1392 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
|
1393 |
3139 | 1394 if (phdata->gfinitialized == SDL_TRUE) { |
1395 /* Unload OpenGL ES library */ | |
1396 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
|
1397 SDL_UnloadObject(_this->gl_config.dll_handle); |
3139 | 1398 _this->gl_config.dll_handle = NULL; |
1399 } | |
1400 } else { | |
1401 SDL_SetError | |
1402 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1403 } | |
1404 #else | |
1405 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1406 return; | |
1407 #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
|
1408 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1409 |
3139 | 1410 SDL_GLContext |
1411 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
|
1412 { |
3139 | 1413 #if defined(SDL_VIDEO_OPENGL_ES) |
1414 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
1415 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | |
1416 SDL_DisplayData *didata = | |
1417 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
1418 EGLBoolean status; | |
1419 int32_t gfstatus; | |
1420 EGLint configs; | |
1421 uint32_t attr_pos; | |
1422 EGLint attr_value; | |
1423 EGLint cit; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1424 |
3139 | 1425 /* Check if GF was initialized */ |
1426 if (phdata->gfinitialized != SDL_TRUE) { | |
1427 SDL_SetError | |
1428 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1429 return NULL; | |
1430 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1431 |
3139 | 1432 /* Prepare attributes list to pass them to OpenGL ES */ |
1433 attr_pos = 0; | |
1434 wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID; | |
1435 wdata->gles_attributes[attr_pos++] = | |
1436 qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format); | |
1437 wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE; | |
1438 wdata->gles_attributes[attr_pos++] = _this->gl_config.red_size; | |
1439 wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE; | |
1440 wdata->gles_attributes[attr_pos++] = _this->gl_config.green_size; | |
1441 wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE; | |
1442 wdata->gles_attributes[attr_pos++] = _this->gl_config.blue_size; | |
1443 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
|
1444 |
3139 | 1445 /* Setup alpha size in bits */ |
1446 if (_this->gl_config.alpha_size) { | |
1447 wdata->gles_attributes[attr_pos++] = _this->gl_config.alpha_size; | |
1448 } else { | |
1449 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1450 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1451 |
3139 | 1452 /* Setup color buffer size */ |
1453 if (_this->gl_config.buffer_size) { | |
1454 wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE; | |
1455 wdata->gles_attributes[attr_pos++] = _this->gl_config.buffer_size; | |
1456 } else { | |
1457 wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE; | |
1458 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1459 } | |
1460 | |
1461 /* Setup depth buffer bits */ | |
1462 wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE; | |
1463 wdata->gles_attributes[attr_pos++] = _this->gl_config.depth_size; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1464 |
3139 | 1465 /* Setup stencil bits */ |
1466 if (_this->gl_config.stencil_size) { | |
1467 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; | |
1468 wdata->gles_attributes[attr_pos++] = _this->gl_config.buffer_size; | |
1469 } else { | |
1470 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; | |
1471 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1472 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1473 |
3139 | 1474 /* Set number of samples in multisampling */ |
1475 if (_this->gl_config.multisamplesamples) { | |
1476 wdata->gles_attributes[attr_pos++] = EGL_SAMPLES; | |
1477 wdata->gles_attributes[attr_pos++] = | |
1478 _this->gl_config.multisamplesamples; | |
1479 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1480 |
3139 | 1481 /* Multisample buffers, OpenGL ES 1.0 spec defines 0 or 1 buffer */ |
1482 if (_this->gl_config.multisamplebuffers) { | |
1483 wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS; | |
1484 wdata->gles_attributes[attr_pos++] = | |
1485 _this->gl_config.multisamplebuffers; | |
1486 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1487 |
3139 | 1488 /* Finish attributes list */ |
1489 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
|
1490 |
3139 | 1491 /* Request first suitable framebuffer configuration */ |
1492 status = eglChooseConfig(phdata->egldisplay, wdata->gles_attributes, | |
1493 wdata->gles_configs, SDL_VIDEO_GF_OPENGLES_CONFS, | |
1494 &configs); | |
1495 if (status != EGL_TRUE) { | |
1496 SDL_SetError | |
1497 ("Photon: Can't find closest configuration for OpenGL ES"); | |
1498 return NULL; | |
1499 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1500 |
3139 | 1501 /* Check if nothing has been found, try "don't care" settings */ |
1502 if (configs == 0) { | |
1503 int32_t it; | |
1504 int32_t jt; | |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1505 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
|
1506 |
3139 | 1507 for (it = 0; it < 4; it++) { |
1508 for (jt = 16; jt >= 0; jt--) { | |
1509 /* Don't care about color buffer bits, use what exist */ | |
1510 /* Replace previous set data with EGL_DONT_CARE */ | |
1511 attr_pos = 0; | |
1512 wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID; | |
1513 wdata->gles_attributes[attr_pos++] = | |
1514 qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format); | |
1515 wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE; | |
1516 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1517 wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE; | |
1518 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1519 wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE; | |
1520 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1521 wdata->gles_attributes[attr_pos++] = EGL_ALPHA_SIZE; | |
1522 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1523 wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE; | |
1524 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
|
1525 |
3139 | 1526 /* Try to find requested or smallest depth */ |
1527 if (_this->gl_config.depth_size) { | |
1528 wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE; | |
1529 wdata->gles_attributes[attr_pos++] = depthbits[it]; | |
1530 } else { | |
1531 wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE; | |
1532 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1533 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1534 |
3139 | 1535 if (_this->gl_config.stencil_size) { |
1536 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; | |
1537 wdata->gles_attributes[attr_pos++] = jt; | |
1538 } else { | |
1539 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; | |
1540 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1541 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1542 |
3139 | 1543 wdata->gles_attributes[attr_pos++] = EGL_SAMPLES; |
1544 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1545 wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS; | |
1546 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1547 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
|
1548 |
3139 | 1549 /* Request first suitable framebuffer configuration */ |
1550 status = | |
1551 eglChooseConfig(phdata->egldisplay, | |
1552 wdata->gles_attributes, | |
1553 wdata->gles_configs, | |
1554 SDL_VIDEO_GF_OPENGLES_CONFS, &configs); | |
1555 if (status != EGL_TRUE) { | |
1556 SDL_SetError | |
1557 ("Photon: Can't find closest configuration for OpenGL ES"); | |
1558 return NULL; | |
1559 } | |
1560 if (configs != 0) { | |
1561 break; | |
1562 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1563 } |
3139 | 1564 if (configs != 0) { |
1565 break; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1566 } |
3139 | 1567 } |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1568 |
3139 | 1569 /* No available configs */ |
1570 if (configs == 0) { | |
1571 SDL_SetError | |
1572 ("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
|
1573 return NULL; |
3139 | 1574 } |
1575 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1576 |
3139 | 1577 /* Initialize config index */ |
1578 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
|
1579 |
3139 | 1580 /* Now check each configuration to find out the best */ |
1581 for (cit = 0; cit < configs; cit++) { | |
1582 uint32_t stencil_found; | |
1583 uint32_t depth_found; | |
1584 | |
1585 stencil_found = 0; | |
1586 depth_found = 0; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1587 |
3139 | 1588 if (_this->gl_config.stencil_size) { |
1589 status = | |
1590 eglGetConfigAttrib(phdata->egldisplay, | |
1591 wdata->gles_configs[cit], EGL_STENCIL_SIZE, | |
1592 &attr_value); | |
1593 if (status == EGL_TRUE) { | |
1594 if (attr_value != 0) { | |
1595 stencil_found = 1; | |
1596 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1597 } |
3139 | 1598 } else { |
1599 stencil_found = 1; | |
1600 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1601 |
3139 | 1602 if (_this->gl_config.depth_size) { |
1603 status = | |
1604 eglGetConfigAttrib(phdata->egldisplay, | |
1605 wdata->gles_configs[cit], EGL_DEPTH_SIZE, | |
1606 &attr_value); | |
1607 if (status == EGL_TRUE) { | |
1608 if (attr_value != 0) { | |
1609 depth_found = 1; | |
1610 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1611 } |
3139 | 1612 } else { |
1613 depth_found = 1; | |
1614 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1615 |
3139 | 1616 /* Exit from loop if found appropriate configuration */ |
1617 if ((depth_found != 0) && (stencil_found != 0)) { | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1618 break; |
3139 | 1619 } |
1620 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1621 |
3139 | 1622 /* If best could not be found, use first */ |
1623 if (cit == configs) { | |
1624 cit = 0; | |
1625 } | |
1626 wdata->gles_config = cit; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1627 |
3139 | 1628 /* Create OpenGL ES context */ |
1629 wdata->gles_context = | |
1630 eglCreateContext(phdata->egldisplay, | |
1631 wdata->gles_configs[wdata->gles_config], | |
1632 EGL_NO_CONTEXT, NULL); | |
1633 if (wdata->gles_context == EGL_NO_CONTEXT) { | |
1634 SDL_SetError("Photon: OpenGL ES context creation has been failed"); | |
1635 return NULL; | |
1636 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1637 |
3139 | 1638 /* Check if surface is exist */ |
1639 if (wdata->gfsurface != NULL) { | |
1640 gf_surface_free(wdata->gfsurface); | |
1641 wdata->gfsurface = NULL; | |
1642 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1643 |
3139 | 1644 /* Create GF surface */ |
1645 gfstatus = | |
1646 gf_surface_create(&wdata->gfsurface, phdata->gfdev, window->w, | |
1647 window->h, | |
1648 qnxgf_sdl_to_gf_pixelformat(didata->current_mode. | |
1649 format), NULL, | |
1650 GF_SURFACE_CREATE_2D_ACCESSIBLE | | |
1651 GF_SURFACE_CREATE_3D_ACCESSIBLE | | |
1652 GF_SURFACE_CREATE_SHAREABLE); | |
1653 if (gfstatus != GF_ERR_OK) { | |
1654 eglDestroyContext(phdata->egldisplay, wdata->gles_context); | |
1655 wdata->gles_context = EGL_NO_CONTEXT; | |
1656 SDL_SetError("Photon: Can't create GF 3D surface (%08X)", gfstatus); | |
1657 return NULL; | |
1658 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1659 |
3139 | 1660 /* Create pixmap 3D target surface */ |
1661 wdata->gles_surface = | |
1662 eglCreatePixmapSurface(phdata->egldisplay, | |
1663 wdata->gles_configs[wdata->gles_config], | |
1664 wdata->gfsurface, NULL); | |
1665 if (wdata->gles_surface == EGL_NO_SURFACE) { | |
1666 gf_surface_free(wdata->gfsurface); | |
1667 eglDestroyContext(phdata->egldisplay, wdata->gles_context); | |
1668 wdata->gles_context = EGL_NO_CONTEXT; | |
1669 SDL_SetError("Photon: Can't create EGL pixmap surface"); | |
1670 return NULL; | |
1671 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1672 |
3139 | 1673 /* Make just created context current */ |
1674 status = | |
1675 eglMakeCurrent(phdata->egldisplay, wdata->gles_surface, | |
1676 wdata->gles_surface, wdata->gles_context); | |
1677 if (status != EGL_TRUE) { | |
1678 /* Destroy OpenGL ES surface */ | |
1679 eglDestroySurface(phdata->egldisplay, wdata->gles_surface); | |
1680 gf_surface_free(wdata->gfsurface); | |
1681 eglDestroyContext(phdata->egldisplay, wdata->gles_context); | |
1682 wdata->gles_context = EGL_NO_CONTEXT; | |
1683 SDL_SetError("Photon: Can't set OpenGL ES context on creation"); | |
1684 return NULL; | |
1685 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1686 |
3139 | 1687 /* Setup into SDL internals state of OpenGL ES: */ |
1688 /* it is accelerated or not */ | |
1689 if ((didata->caps & SDL_PHOTON_ACCELERATED_3D) == | |
1690 SDL_PHOTON_ACCELERATED_3D) { | |
1691 _this->gl_config.accelerated = 1; | |
1692 } else { | |
1693 _this->gl_config.accelerated = 0; | |
1694 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1695 |
3139 | 1696 /* Always clear stereo enable, since OpenGL ES do not supports stereo */ |
1697 _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
|
1698 |
3139 | 1699 /* Get back samples and samplebuffers configurations. Rest framebuffer */ |
1700 /* parameters could be obtained through the OpenGL ES API */ | |
1701 status = | |
1702 eglGetConfigAttrib(phdata->egldisplay, | |
1703 wdata->gles_configs[wdata->gles_config], | |
1704 EGL_SAMPLES, &attr_value); | |
1705 if (status == EGL_TRUE) { | |
1706 _this->gl_config.multisamplesamples = attr_value; | |
1707 } | |
1708 status = | |
1709 eglGetConfigAttrib(phdata->egldisplay, | |
1710 wdata->gles_configs[wdata->gles_config], | |
1711 EGL_SAMPLE_BUFFERS, &attr_value); | |
1712 if (status == EGL_TRUE) { | |
1713 _this->gl_config.multisamplebuffers = attr_value; | |
1714 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1715 |
3139 | 1716 /* Get back stencil and depth buffer sizes */ |
1717 status = | |
1718 eglGetConfigAttrib(phdata->egldisplay, | |
1719 wdata->gles_configs[wdata->gles_config], | |
1720 EGL_DEPTH_SIZE, &attr_value); | |
1721 if (status == EGL_TRUE) { | |
1722 _this->gl_config.depth_size = attr_value; | |
1723 } | |
1724 status = | |
1725 eglGetConfigAttrib(phdata->egldisplay, | |
1726 wdata->gles_configs[wdata->gles_config], | |
1727 EGL_STENCIL_SIZE, &attr_value); | |
1728 if (status == EGL_TRUE) { | |
1729 _this->gl_config.stencil_size = attr_value; | |
1730 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1731 |
3139 | 1732 /* Under Photon OpenGL ES output can't be double buffered */ |
1733 _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
|
1734 |
3139 | 1735 /* Check if current device is not the same as target */ |
1736 if (phdata->current_device_id != didata->device_id) { | |
1737 /* Set target device as default for Pd and Pg functions */ | |
1738 status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]); | |
1739 if (status != 0) { | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1740 /* Destroy OpenGL ES surface */ |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1741 eglDestroySurface(phdata->egldisplay, wdata->gles_surface); |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1742 gf_surface_free(wdata->gfsurface); |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1743 eglDestroyContext(phdata->egldisplay, wdata->gles_context); |
3139 | 1744 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
|
1745 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
|
1746 return NULL; |
3139 | 1747 } |
1748 phdata->current_device_id = didata->device_id; | |
1749 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1750 |
3139 | 1751 wdata->phsurface = PdCreateOffscreenContextGF(wdata->gfsurface); |
1752 if (wdata->phsurface == NULL) { | |
1753 /* Destroy OpenGL ES surface */ | |
1754 eglDestroySurface(phdata->egldisplay, wdata->gles_surface); | |
1755 gf_surface_free(wdata->gfsurface); | |
1756 eglDestroyContext(phdata->egldisplay, wdata->gles_context); | |
1757 wdata->gles_context = EGL_NO_CONTEXT; | |
1758 SDL_SetError("Photon: Can't bind GF surface to Photon\n"); | |
1759 return NULL; | |
1760 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1761 |
3139 | 1762 /* GL ES context was successfully created */ |
1763 return wdata->gles_context; | |
1764 #else | |
1765 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1766 return NULL; | |
1767 #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
|
1768 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1769 |
3139 | 1770 int |
1771 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
|
1772 { |
3139 | 1773 #if defined(SDL_VIDEO_OPENGL_ES) |
1774 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
1775 SDL_WindowData *wdata; | |
1776 EGLBoolean status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1777 |
3139 | 1778 if (phdata->gfinitialized != SDL_TRUE) { |
1779 SDL_SetError | |
1780 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1781 return -1; | |
1782 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1783 |
3139 | 1784 if ((window == NULL) && (context == NULL)) { |
1785 status = | |
1786 eglMakeCurrent(phdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, | |
1787 EGL_NO_CONTEXT); | |
1788 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
|
1789 /* 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
|
1790 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
|
1791 return -1; |
3139 | 1792 } |
1793 } else { | |
1794 wdata = (SDL_WindowData *) window->driverdata; | |
1795 if (wdata->gles_surface == EGL_NO_SURFACE) { | |
1796 SDL_SetError | |
1797 ("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
|
1798 return -1; |
3139 | 1799 } |
1800 if (wdata->gles_context == EGL_NO_CONTEXT) { | |
1801 SDL_SetError | |
1802 ("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
|
1803 return -1; |
3139 | 1804 } |
1805 if (wdata->gles_context != context) { | |
1806 SDL_SetError | |
1807 ("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
|
1808 return -1; |
3139 | 1809 } |
1810 status = | |
1811 eglMakeCurrent(phdata->egldisplay, wdata->gles_surface, | |
1812 wdata->gles_surface, wdata->gles_context); | |
1813 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
|
1814 /* 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
|
1815 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
|
1816 return -1; |
3139 | 1817 } |
1818 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1819 |
3139 | 1820 return 0; |
1821 #else | |
1822 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1823 return -1; | |
1824 #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
|
1825 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1826 |
3139 | 1827 int |
1828 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
|
1829 { |
3139 | 1830 #if defined(SDL_VIDEO_OPENGL_ES) |
1831 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
1832 EGLBoolean status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1833 |
3139 | 1834 if (phdata->gfinitialized != SDL_TRUE) { |
1835 SDL_SetError | |
1836 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1837 return -1; | |
1838 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1839 |
3139 | 1840 /* Check if OpenGL ES connection has been initialized */ |
1841 if (phdata->egldisplay != EGL_NO_DISPLAY) { | |
1842 /* Set swap OpenGL ES interval */ | |
1843 status = eglSwapInterval(phdata->egldisplay, interval); | |
1844 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
|
1845 /* Return success to upper level */ |
3139 | 1846 phdata->swapinterval = interval; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1847 return 0; |
3139 | 1848 } |
1849 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1850 |
3139 | 1851 /* Failed to set swap interval */ |
1852 SDL_SetError("Photon: Cannot set swap interval"); | |
1853 return -1; | |
1854 #else | |
1855 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1856 return -1; | |
1857 #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
|
1858 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1859 |
3139 | 1860 int |
1861 photon_gl_getswapinterval(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1862 { |
3139 | 1863 #if defined(SDL_VIDEO_OPENGL_ES) |
1864 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
|
1865 |
3139 | 1866 if (phdata->gfinitialized != SDL_TRUE) { |
1867 SDL_SetError | |
1868 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1869 return -1; | |
1870 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1871 |
3139 | 1872 /* Return default swap interval value */ |
1873 return phdata->swapinterval; | |
1874 #else | |
1875 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1876 return -1; | |
1877 #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
|
1878 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1879 |
3139 | 1880 void |
1881 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
|
1882 { |
3139 | 1883 #if defined(SDL_VIDEO_OPENGL_ES) |
1884 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
1885 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | |
1886 SDL_DisplayData *didata = | |
1887 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
1888 PhRect_t dst_rect; | |
1889 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
|
1890 |
3139 | 1891 if (phdata->gfinitialized != SDL_TRUE) { |
1892 SDL_SetError | |
1893 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1894 return; | |
1895 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1896 |
3139 | 1897 /* Many applications do not uses glFinish(), so we call it for them */ |
1898 glFinish(); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1899 |
3139 | 1900 /* Wait until OpenGL ES rendering is completed */ |
1901 eglWaitGL(); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1902 |
3139 | 1903 /* Wait for VSYNC manually, if it was enabled */ |
1904 if (phdata->swapinterval != 0) { | |
1905 /* Wait for VSYNC, we use GF function, since Photon requires */ | |
1906 /* to enter to the Direct mode to call PgWaitVSync() */ | |
1907 gf_display_wait_vsync(didata->display); | |
1908 } | |
1909 | |
1910 /* Set blit area */ | |
1911 dst_rect = *PtGetCanvas(wdata->window); | |
1912 src_rect.ul.x = 0; | |
1913 src_rect.ul.y = 0; | |
1914 src_rect.lr.x = window->w - 1; | |
1915 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
|
1916 |
3139 | 1917 /* Blit OpenGL ES pixmap surface directly to window region */ |
1918 PgFFlush(Ph_START_DRAW); | |
1919 PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window)); | |
1920 PgClearTranslationCx(PgGetGCCx(PhDCGetCurrent())); | |
1921 PgContextBlit(wdata->phsurface, &src_rect, NULL, &dst_rect); | |
1922 PgFFlush(Ph_DONE_DRAW); | |
1923 PgWaitHWIdle(); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1924 |
3139 | 1925 eglSwapBuffers(phdata->egldisplay, wdata->gles_surface); |
1926 #else | |
1927 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1928 return; | |
1929 #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
|
1930 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1931 |
3139 | 1932 void |
1933 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
|
1934 { |
3139 | 1935 #if defined(SDL_VIDEO_OPENGL_ES) |
1936 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
1937 EGLBoolean status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1938 |
3139 | 1939 if (phdata->gfinitialized != SDL_TRUE) { |
1940 SDL_SetError | |
1941 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1942 return; | |
1943 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1944 |
3139 | 1945 /* Check if OpenGL ES connection has been initialized */ |
1946 if (phdata->egldisplay != EGL_NO_DISPLAY) { | |
1947 if (context != EGL_NO_CONTEXT) { | |
1948 status = eglDestroyContext(phdata->egldisplay, context); | |
1949 if (status != EGL_TRUE) { | |
1950 /* Error during OpenGL ES context destroying */ | |
1951 SDL_SetError("Photon: OpenGL ES context destroy error"); | |
1952 return; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1953 } |
3139 | 1954 } |
1955 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1956 |
3139 | 1957 return; |
1958 #else | |
1959 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1960 return; | |
1961 #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
|
1962 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1963 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1964 /*****************************************************************************/ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1965 /* SDL Event handling function */ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1966 /*****************************************************************************/ |
3139 | 1967 void |
1968 photon_pumpevents(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1969 { |
3139 | 1970 uint8_t eventbuffer[SDL_VIDEO_PHOTON_EVENT_SIZE]; |
1971 PhEvent_t *event = (PhEvent_t *) eventbuffer; | |
1972 int32_t status; | |
1973 uint32_t finish = 0; | |
1974 uint32_t it; | |
1975 SDL_Window *window; | |
1976 SDL_WindowData *wdata; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1977 |
3139 | 1978 do { |
1979 status = PhEventPeek(event, SDL_VIDEO_PHOTON_EVENT_SIZE); | |
1980 switch (status) { | |
1981 case Ph_RESIZE_MSG: | |
1982 { | |
1983 SDL_SetError("Photon: Event size too much for buffer"); | |
1984 return; | |
1985 } | |
1986 break; | |
1987 case Ph_EVENT_MSG: | |
1988 { | |
1989 /* Find a window, to which this handle destinated */ | |
1990 status = 0; | |
1991 for (it = 0; it < SDL_CurrentDisplay.num_windows; it++) { | |
1992 wdata = | |
1993 (SDL_WindowData *) SDL_CurrentDisplay.windows[it]. | |
1994 driverdata; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1995 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1996 /* Find the proper window */ |
3139 | 1997 if (wdata->window != NULL) { |
1998 if (PtWidgetRid(wdata->window) == | |
1999 event->collector.rid) { | |
2000 window = | |
2001 (SDL_Window *) & SDL_CurrentDisplay. | |
2002 windows[it]; | |
2003 status = 1; | |
2004 break; | |
2005 } | |
2006 } else { | |
2007 continue; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2008 } |
3139 | 2009 } |
2010 if (status == 0) { | |
2011 window = NULL; | |
2012 wdata = NULL; | |
2013 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2014 |
3139 | 2015 /* Event is ready */ |
2016 switch (event->type) { | |
2017 case Ph_EV_BOUNDARY: | |
2018 { | |
2019 switch (event->subtype) { | |
2020 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
|
2021 { |
3139 | 2022 /* Mouse cursor over handled window */ |
2023 if (window != NULL) { | |
2024 SDL_SendWindowEvent(window->id, | |
2025 SDL_WINDOWEVENT_ENTER, | |
2026 0, 0); | |
2027 SDL_SetMouseFocus(0, window->id); | |
2028 } | |
2029 } | |
2030 break; | |
2031 case Ph_EV_PTR_LEAVE: | |
2032 { | |
2033 /* Mouse cursor out of handled window */ | |
2034 if (window != NULL) { | |
2035 SDL_SendWindowEvent(window->id, | |
2036 SDL_WINDOWEVENT_LEAVE, | |
2037 0, 0); | |
2038 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2039 } |
3139 | 2040 break; |
2041 } | |
2042 } | |
2043 break; | |
2044 case Ph_EV_PTR_MOTION_BUTTON: | |
2045 case Ph_EV_PTR_MOTION_NOBUTTON: | |
2046 { | |
2047 PhPointerEvent_t *pevent = NULL; | |
2048 PhRect_t *prects = NULL; | |
2049 | |
2050 /* Get event data */ | |
2051 pevent = PhGetData(event); | |
2052 /* Get associated event rectangles */ | |
2053 prects = PhGetRects(event); | |
2054 if ((pevent != NULL) && (prects != NULL)) { | |
2055 SDL_SendMouseMotion(0, 0, prects->ul.x, | |
2056 prects->ul.y, 0); | |
2057 } | |
2058 } | |
2059 break; | |
2060 case Ph_EV_BUT_PRESS: | |
2061 { | |
2062 /* Button press event */ | |
2063 PhPointerEvent_t *pevent = NULL; | |
2064 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
|
2065 |
3139 | 2066 /* Get event data */ |
2067 pevent = PhGetData(event); | |
2068 if (pevent != NULL) { | |
2069 for (it = 0; it < sizeof(pevent->buttons) * 8; | |
2070 it++) { | |
2071 if ((pevent->buttons & (0x0001 << it)) == | |
2072 (0x0001 << it)) { | |
2073 switch (it) { | |
2074 case 0: | |
2075 { | |
2076 sdlbutton = SDL_BUTTON_RIGHT; | |
2077 } | |
2078 break; | |
2079 case 1: | |
2080 { | |
2081 sdlbutton = SDL_BUTTON_MIDDLE; | |
2082 } | |
2083 break; | |
2084 case 2: | |
2085 { | |
2086 sdlbutton = SDL_BUTTON_LEFT; | |
2087 } | |
2088 break; | |
2089 default: | |
2090 { | |
2091 sdlbutton = it + 1; | |
2092 } | |
2093 break; | |
2094 } | |
2095 SDL_SendMouseButton(0, SDL_PRESSED, | |
2096 sdlbutton); | |
2097 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2098 } |
3139 | 2099 } |
2100 } | |
2101 break; | |
2102 case Ph_EV_BUT_RELEASE: | |
2103 { | |
2104 /* Button press event */ | |
2105 PhPointerEvent_t *pevent = NULL; | |
2106 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
|
2107 |
3139 | 2108 /* Get event data */ |
2109 pevent = PhGetData(event); | |
2110 if (pevent != NULL) { | |
2111 for (it = 0; it < sizeof(pevent->buttons) * 8; | |
2112 it++) { | |
2113 if ((pevent->buttons & (0x0001 << it)) == | |
2114 (0x0001 << it)) { | |
2115 switch (it) { | |
2116 case 0: | |
2117 { | |
2118 sdlbutton = SDL_BUTTON_RIGHT; | |
2119 } | |
2120 break; | |
2121 case 1: | |
2122 { | |
2123 sdlbutton = SDL_BUTTON_MIDDLE; | |
2124 } | |
2125 break; | |
2126 case 2: | |
2127 { | |
2128 sdlbutton = SDL_BUTTON_LEFT; | |
2129 } | |
2130 break; | |
2131 default: | |
2132 { | |
2133 sdlbutton = it + 1; | |
2134 } | |
2135 break; | |
2136 } | |
2137 } | |
2138 } | |
2139 } | |
2140 | |
2141 switch (event->subtype) { | |
2142 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
|
2143 { |
3139 | 2144 /* Real release button event */ |
2145 SDL_SendMouseButton(0, SDL_RELEASED, | |
2146 sdlbutton); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2147 } |
3139 | 2148 break; |
2149 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
|
2150 { |
3139 | 2151 /* We will get phantom button release */ |
2152 /* event in case if it was unpressed */ | |
2153 /* outside of window */ | |
2154 if (window != NULL) { | |
2155 if ((window-> | |
2156 flags & SDL_WINDOW_MOUSE_FOCUS) != | |
2157 SDL_WINDOW_MOUSE_FOCUS) { | |
2158 /* Send phantom button release */ | |
2159 SDL_SendMouseButton(0, SDL_RELEASED, | |
2160 sdlbutton); | |
2161 } | |
2162 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2163 } |
3139 | 2164 break; |
2165 } | |
2166 } | |
2167 break; | |
2168 case Ph_EV_EXPOSE: | |
2169 { | |
2170 switch (event->subtype) { | |
2171 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
|
2172 { |
3139 | 2173 PhRect_t *rects = NULL; |
2174 | |
2175 /* Get array of rectangles to be updated */ | |
2176 rects = PhGetRects(event); | |
2177 if (rects == NULL) { | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2178 break; |
3139 | 2179 } |
2180 | |
2181 /* Check if expose come to one of the our windows */ | |
2182 if ((wdata != NULL) && (window != NULL)) { | |
2183 /* Check if window uses OpenGL ES */ | |
2184 if (wdata->uses_gles == SDL_TRUE) { | |
2185 PhRect_t dst_rect; | |
2186 PhRect_t src_rect; | |
2187 | |
2188 /* Cycle through each rectangle */ | |
2189 for (it = 0; it < event->num_rects; | |
2190 it++) { | |
2191 /* Blit OpenGL ES pixmap surface directly to window region */ | |
2192 PgFFlush(Ph_START_DRAW); | |
2193 PgSetRegionCx(PhDCGetCurrent(), | |
2194 PtWidgetRid(wdata-> | |
2195 window)); | |
2196 PgClearTranslationCx(PgGetGCCx | |
2197 (PhDCGetCurrent | |
2198 ())); | |
2199 PgContextBlit(wdata->phsurface, | |
2200 &rects[it], NULL, | |
2201 &rects[it]); | |
2202 PgFFlush(Ph_DONE_DRAW); | |
2203 PgWaitHWIdle(); | |
2204 } | |
2205 } else { | |
2206 /* Normal window */ | |
2207 /* TODO: update the damaged rectangles */ | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2208 } |
3139 | 2209 } |
2210 | |
2211 /* Flush all blittings */ | |
2212 PgFlush(); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2213 } |
3139 | 2214 break; |
2215 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
|
2216 { |
3139 | 2217 /* Check if expose come to one of the our windows */ |
2218 if ((wdata != NULL) && (window != NULL)) { | |
2219 /* Check if window uses OpenGL ES */ | |
2220 if (wdata->uses_gles == SDL_TRUE) { | |
2221 PhRect_t dst_rect; | |
2222 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
|
2223 |
3139 | 2224 /* Set blit area */ |
2225 dst_rect = | |
2226 *PtGetCanvas(wdata->window); | |
2227 src_rect.ul.x = 0; | |
2228 src_rect.ul.y = 0; | |
2229 src_rect.lr.x = window->w - 1; | |
2230 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
|
2231 |
3139 | 2232 /* We need to redraw entire window */ |
2233 PgFFlush(Ph_START_DRAW); | |
2234 PgSetRegionCx(PhDCGetCurrent(), | |
2235 PtWidgetRid(wdata-> | |
2236 window)); | |
2237 PgClearTranslationCx(PgGetGCCx | |
2238 (PhDCGetCurrent | |
2239 ())); | |
2240 PgContextBlit(wdata->phsurface, | |
2241 &src_rect, NULL, | |
2242 &dst_rect); | |
2243 PgFFlush(Ph_DONE_DRAW); | |
2244 PgWaitHWIdle(); | |
2245 } else { | |
2246 /* Normal window */ | |
2247 /* TODO: update the damaged rectangles */ | |
3115
1102a3305928
Added handler for all window events.
Mike Gorchak <lestat@i.com.ua>
parents:
3108
diff
changeset
|
2248 |
3139 | 2249 /* We need to redraw entire window */ |
2250 } | |
2251 } | |
2252 } | |
2253 break; | |
2254 case Ph_GRAPHIC_EXPOSE: | |
2255 { | |
2256 /* TODO: What this event means ? */ | |
2257 } | |
2258 break; | |
2259 } | |
2260 } | |
2261 break; | |
2262 case Ph_EV_INFO: | |
2263 { | |
2264 } | |
2265 break; | |
2266 case Ph_EV_KEY: | |
2267 { | |
2268 PhKeyEvent_t *keyevent = NULL; | |
2269 SDL_scancode scancode = SDL_SCANCODE_UNKNOWN; | |
2270 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
|
2271 |
3139 | 2272 keyevent = PhGetData(event); |
2273 if (keyevent == NULL) { | |
2274 break; | |
2275 } | |
2276 | |
2277 /* Check if key is repeated */ | |
2278 if ((keyevent->key_flags & Pk_KF_Key_Repeat) == | |
2279 Pk_KF_Key_Repeat) { | |
2280 /* Ignore such events */ | |
2281 break; | |
2282 } | |
2283 | |
2284 /* Check if key has its own scancode */ | |
2285 if ((keyevent->key_flags & Pk_KF_Scan_Valid) == | |
2286 Pk_KF_Scan_Valid) { | |
2287 if ((keyevent->key_flags & Pk_KF_Key_Down) == | |
2288 Pk_KF_Key_Down) { | |
2289 pressed = SDL_TRUE; | |
2290 } else { | |
2291 pressed = SDL_FALSE; | |
2292 } | |
2293 scancode = | |
2294 photon_to_sdl_keymap(keyevent->key_scan); | |
2295 | |
2296 /* Add details for the pressed key */ | |
2297 if ((keyevent->key_flags & Pk_KF_Cap_Valid) == | |
2298 Pk_KF_Cap_Valid) { | |
2299 switch (keyevent->key_cap) { | |
2300 case Pk_Hyper_R: /* Right windows flag key */ | |
2301 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
|
2302 break; |
3139 | 2303 case Pk_Control_R: /* Right Ctrl key */ |
2304 scancode = SDL_SCANCODE_RCTRL; | |
2305 break; | |
2306 case Pk_Alt_R: /* Right Alt key */ | |
2307 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
|
2308 break; |
3139 | 2309 case Pk_Up: /* Up key but with invalid scan */ |
2310 if (scancode != SDL_SCANCODE_UP) { | |
2311 /* This is a mouse wheel event */ | |
2312 SDL_SendMouseWheel(0, 0, 1); | |
2313 return; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2314 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2315 break; |
3139 | 2316 case Pk_KP_8: /* Up arrow or 8 on keypad */ |
2317 scancode = SDL_SCANCODE_KP_8; | |
2318 break; | |
2319 case Pk_Down: /* Down key but with invalid scan */ | |
2320 if (scancode != SDL_SCANCODE_DOWN) { | |
2321 /* This is a mouse wheel event */ | |
2322 SDL_SendMouseWheel(0, 0, -1); | |
2323 return; | |
2324 } | |
2325 break; | |
2326 case Pk_KP_2: /* Down arrow or 2 on keypad */ | |
2327 scancode = SDL_SCANCODE_KP_2; | |
2328 break; | |
2329 case Pk_Left: /* Left arrow key */ | |
2330 scancode = SDL_SCANCODE_LEFT; | |
2331 break; | |
2332 case Pk_KP_4: /* Left arrow or 4 on keypad */ | |
2333 scancode = SDL_SCANCODE_KP_4; | |
2334 break; | |
2335 case Pk_Right: /* Right arrow key */ | |
2336 scancode = SDL_SCANCODE_RIGHT; | |
2337 break; | |
2338 case Pk_KP_6: /* Right arrow or 6 on keypad */ | |
2339 scancode = SDL_SCANCODE_KP_6; | |
2340 break; | |
2341 case Pk_Insert: /* Insert key */ | |
2342 scancode = SDL_SCANCODE_INSERT; | |
2343 break; | |
2344 case Pk_KP_0: /* Insert or 0 on keypad */ | |
2345 scancode = SDL_SCANCODE_KP_0; | |
2346 break; | |
2347 case Pk_Home: /* Home key */ | |
2348 scancode = SDL_SCANCODE_HOME; | |
2349 break; | |
2350 case Pk_KP_7: /* Home or 7 on keypad */ | |
2351 scancode = SDL_SCANCODE_KP_7; | |
2352 break; | |
2353 case Pk_Pg_Up: /* PageUp key */ | |
2354 scancode = SDL_SCANCODE_PAGEUP; | |
2355 break; | |
2356 case Pk_KP_9: /* PgUp or 9 on keypad */ | |
2357 scancode = SDL_SCANCODE_KP_9; | |
2358 break; | |
2359 case Pk_Delete: /* Delete key */ | |
2360 scancode = SDL_SCANCODE_DELETE; | |
2361 break; | |
2362 case Pk_KP_Decimal: /* Del or . on keypad */ | |
2363 scancode = SDL_SCANCODE_KP_PERIOD; | |
2364 break; | |
2365 case Pk_End: /* End key */ | |
2366 scancode = SDL_SCANCODE_END; | |
2367 break; | |
2368 case Pk_KP_1: /* End or 1 on keypad */ | |
2369 scancode = SDL_SCANCODE_KP_1; | |
2370 break; | |
2371 case Pk_Pg_Down: /* PageDown key */ | |
2372 scancode = SDL_SCANCODE_PAGEDOWN; | |
2373 break; | |
2374 case Pk_KP_3: /* PgDn or 3 on keypad */ | |
2375 scancode = SDL_SCANCODE_KP_3; | |
2376 break; | |
2377 case Pk_KP_5: /* 5 on keypad */ | |
2378 scancode = SDL_SCANCODE_KP_5; | |
2379 break; | |
2380 case Pk_KP_Enter: | |
2381 scancode = SDL_SCANCODE_KP_ENTER; | |
2382 break; | |
2383 case Pk_KP_Add: | |
2384 scancode = SDL_SCANCODE_KP_PLUS; | |
2385 break; | |
2386 case Pk_KP_Subtract: | |
2387 scancode = SDL_SCANCODE_KP_MINUS; | |
2388 break; | |
2389 case Pk_KP_Multiply: | |
2390 scancode = SDL_SCANCODE_KP_MULTIPLY; | |
2391 break; | |
2392 case Pk_KP_Divide: | |
2393 scancode = SDL_SCANCODE_KP_DIVIDE; | |
2394 break; | |
2395 case Pk_Pause: | |
2396 scancode = SDL_SCANCODE_PAUSE; | |
2397 break; | |
2398 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2399 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2400 |
3139 | 2401 /* Finally check if scancode has been decoded */ |
2402 if (scancode == SDL_SCANCODE_UNKNOWN) { | |
2403 /* Something was pressed, which is not supported */ | |
2404 break; | |
2405 } | |
2406 | |
2407 /* Report pressed/released key to SDL */ | |
2408 if (pressed == SDL_TRUE) { | |
2409 SDL_SendKeyboardKey(0, SDL_PRESSED, scancode); | |
2410 } else { | |
2411 SDL_SendKeyboardKey(0, SDL_RELEASED, | |
2412 scancode); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2413 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2414 |
3139 | 2415 /* Photon doesn't send a release event for PrnScr key */ |
2416 if ((scancode == SDL_SCANCODE_PRINTSCREEN) | |
2417 && (pressed)) { | |
2418 SDL_SendKeyboardKey(0, SDL_RELEASED, | |
2419 scancode); | |
2420 } | |
2421 } | |
2422 } | |
2423 break; | |
2424 case Ph_EV_SERVICE: | |
2425 { | |
2426 } | |
2427 break; | |
2428 case Ph_EV_SYSTEM: | |
2429 { | |
2430 } | |
2431 break; | |
2432 case Ph_EV_WM: | |
2433 { | |
2434 PhWindowEvent_t *wmevent = NULL; | |
2435 | |
2436 /* Get associated event data */ | |
2437 wmevent = PhGetData(event); | |
2438 if (wmevent == NULL) { | |
2439 break; | |
2440 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2441 |
3139 | 2442 switch (wmevent->event_f) { |
2443 case Ph_WM_CLOSE: | |
2444 { | |
2445 if (window != NULL) { | |
2446 SDL_SendWindowEvent(window->id, | |
2447 SDL_WINDOWEVENT_CLOSE, | |
2448 0, 0); | |
2449 } | |
2450 } | |
2451 break; | |
2452 case Ph_WM_FOCUS: | |
2453 { | |
2454 if (wmevent->event_state == | |
2455 Ph_WM_EVSTATE_FOCUS) { | |
2456 if (window != NULL) { | |
2457 PhRegion_t wregion; | |
2458 | |
2459 SDL_SendWindowEvent(window->id, | |
2460 SDL_WINDOWEVENT_FOCUS_GAINED, | |
2461 0, 0); | |
2462 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
|
2463 |
3139 | 2464 /* Set window region sensible to mouse motion events */ |
2465 PhRegionQuery(PtWidgetRid | |
2466 (wdata->window), | |
2467 &wregion, NULL, NULL, | |
2468 0); | |
2469 wregion.events_sense |= | |
2470 Ph_EV_PTR_MOTION_BUTTON | | |
2471 Ph_EV_PTR_MOTION_NOBUTTON; | |
2472 PhRegionChange(Ph_REGION_EV_SENSE, 0, | |
2473 &wregion, NULL, NULL); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2474 |
3139 | 2475 /* If window got a focus, the it is visible */ |
2476 SDL_SendWindowEvent(window->id, | |
2477 SDL_WINDOWEVENT_SHOWN, | |
2478 0, 0); | |
2479 } | |
2480 } | |
2481 if (wmevent->event_state == | |
2482 Ph_WM_EVSTATE_FOCUSLOST) { | |
2483 if (window != NULL) { | |
2484 PhRegion_t wregion; | |
2485 | |
2486 SDL_SendWindowEvent(window->id, | |
2487 SDL_WINDOWEVENT_FOCUS_LOST, | |
2488 0, 0); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2489 |
3139 | 2490 /* Set window region ignore mouse motion events */ |
2491 PhRegionQuery(PtWidgetRid | |
2492 (wdata->window), | |
2493 &wregion, NULL, NULL, | |
2494 0); | |
2495 wregion.events_sense &= | |
2496 ~(Ph_EV_PTR_MOTION_BUTTON | | |
2497 Ph_EV_PTR_MOTION_NOBUTTON); | |
2498 PhRegionChange(Ph_REGION_EV_SENSE, 0, | |
2499 &wregion, NULL, NULL); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2500 } |
3139 | 2501 } |
2502 } | |
2503 break; | |
2504 case Ph_WM_MOVE: | |
2505 { | |
2506 if (window != NULL) { | |
2507 SDL_SendWindowEvent(window->id, | |
2508 SDL_WINDOWEVENT_MOVED, | |
2509 wmevent->pos.x, | |
2510 wmevent->pos.y); | |
2511 } | |
2512 } | |
2513 break; | |
2514 case Ph_WM_RESIZE: | |
2515 { | |
2516 if (window != NULL) { | |
2517 /* Set new window position after resize */ | |
2518 SDL_SendWindowEvent(window->id, | |
2519 SDL_WINDOWEVENT_MOVED, | |
2520 wmevent->pos.x, | |
2521 wmevent->pos.y); | |
2522 /* Set new window size after resize */ | |
2523 SDL_SendWindowEvent(window->id, | |
2524 SDL_WINDOWEVENT_RESIZED, | |
2525 wmevent->size.w, | |
2526 wmevent->size.h); | |
2527 } | |
2528 } | |
2529 break; | |
2530 case Ph_WM_HIDE: | |
2531 { | |
2532 if (window != NULL) { | |
2533 /* Send new window state: minimized */ | |
2534 SDL_SendWindowEvent(window->id, | |
2535 SDL_WINDOWEVENT_MINIMIZED, | |
2536 0, 0); | |
2537 /* In case window is minimized, then it is hidden */ | |
2538 SDL_SendWindowEvent(window->id, | |
2539 SDL_WINDOWEVENT_HIDDEN, | |
2540 0, 0); | |
2541 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2542 } |
3139 | 2543 break; |
2544 case Ph_WM_MAX: | |
2545 { | |
2546 if (window != NULL) { | |
2547 SDL_SendWindowEvent(window->id, | |
2548 SDL_WINDOWEVENT_MAXIMIZED, | |
2549 0, 0); | |
2550 } | |
2551 } | |
2552 break; | |
2553 case Ph_WM_RESTORE: | |
2554 { | |
2555 if (window != NULL) { | |
2556 SDL_SendWindowEvent(window->id, | |
2557 SDL_WINDOWEVENT_RESTORED, | |
2558 0, 0); | |
2559 } | |
2560 } | |
2561 break; | |
2562 } | |
2563 } | |
2564 break; | |
2565 } | |
2566 PtEventHandler(event); | |
2567 } | |
2568 break; | |
2569 case 0: | |
2570 { | |
2571 /* All events are read */ | |
2572 finish = 1; | |
2573 break; | |
2574 } | |
2575 case -1: | |
2576 { | |
2577 /* Error occured in event reading */ | |
2578 SDL_SetError("Photon: Can't read event"); | |
2579 return; | |
2580 } | |
2581 break; | |
2582 } | |
2583 if (finish != 0) { | |
2584 break; | |
2585 } | |
2586 } while (1); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2587 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2588 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2589 /*****************************************************************************/ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2590 /* SDL screen saver related functions */ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2591 /*****************************************************************************/ |
3139 | 2592 void |
2593 photon_suspendscreensaver(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2594 { |
3139 | 2595 /* There is no screensaver in pure console, it may exist when running */ |
2596 /* 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
|
2597 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2598 |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2599 /* vi: set ts=4 sw=4 expandtab: */ |