Mercurial > sdl-ios-xcode
annotate src/video/photon/SDL_photon.c @ 3378:a211710ebc37
Fixed bug #31
Set the default optimization level to -O3
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 11 Oct 2009 06:44:50 +0000 |
parents | dd105b317335 |
children | 90935231e9b6 |
rev | line source |
---|---|
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2009 Sam Lantinga |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
21 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
22 QNX Photon GUI SDL driver |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
23 Copyright (C) 2009 Mike Gorchak |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
24 (mike@malva.ua, lestat@i.com.ua) |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 */ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
27 /* SDL internals */ |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 #include "SDL_config.h" |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include "../SDL_sysvideo.h" |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
30 #include "SDL_version.h" |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
31 #include "SDL_syswm.h" |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
32 #include "SDL_loadso.h" |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
33 #include "SDL_events.h" |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
34 #include "../../events/SDL_mouse_c.h" |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
35 #include "../../events/SDL_keyboard_c.h" |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
36 |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
37 /* Photon declarations */ |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
38 #include "SDL_photon.h" |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
39 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
40 /* Pixel format conversion routines */ |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
41 #include "SDL_photon_pixelfmt.h" |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
42 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
43 /* Use GF's pixel format functions for OpenGL ES context creation */ |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
44 #if defined(SDL_VIDEO_OPENGL_ES) |
3139 | 45 #include "../qnxgf/SDL_gf_pixelfmt.h" |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
46 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
47 /* If GF driver is not compiled in, include some of usefull functions */ |
3139 | 48 #if !defined(SDL_VIDEO_DRIVER_QNXGF) |
49 #include "../qnxgf/SDL_gf_pixelfmt.c" | |
50 #endif /* SDL_VIDEO_DRIVER_QNXGF */ | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
51 #endif /* SDL_VIDEO_OPENGL_ES */ |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
52 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
53 /* Use GF's OpenGL ES 1.1 functions emulation */ |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
54 #if defined(SDL_VIDEO_OPENGL_ES) |
3139 | 55 #include "../qnxgf/SDL_gf_opengles.h" |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
56 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
57 /* If GF driver is not compiled in, include some of usefull functions */ |
3139 | 58 #if !defined(SDL_VIDEO_DRIVER_QNXGF) |
59 #include "../qnxgf/SDL_gf_opengles.c" | |
60 #endif /* SDL_VIDEO_DRIVER_QNXGF */ | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
61 #endif /* SDL_VIDEO_OPENGL_ES */ |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
62 |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
63 /* Low level device graphics driver names, which they are reporting */ |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
64 static const Photon_DeviceCaps photon_devicename[] = { |
3139 | 65 /* ATI Rage 128 graphics driver (devg-ati_rage128) */ |
66 {"ati_rage128", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
67 , | |
68 /* Fujitsu Carmine graphics driver (devg-carmine.so) */ | |
69 {"carmine", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} | |
70 , | |
71 /* C&T graphics driver (devg-chips.so) */ | |
72 {"chips", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
73 , | |
74 /* Fujitsu Coral graphics driver (devg-coral.so) */ | |
75 {"coral", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} | |
76 , | |
77 /* Intel integrated graphics driver (devg-extreme2.so) */ | |
78 {"extreme2", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} | |
79 , | |
80 /* Unaccelerated FB driver (devg-flat.so) */ | |
81 {"flat", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
82 , | |
83 /* NS Geode graphics driver (devg-geode.so) */ | |
84 {"geode", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
85 , | |
86 /* Geode LX graphics driver (devg-geodelx.so) */ | |
87 {"geodelx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
88 , | |
89 /* Intel integrated graphics driver (devg-gma9xx.so) */ | |
90 {"gma", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} | |
91 , | |
92 /* Intel integrated graphics driver (devg-i810.so) */ | |
93 {"i810", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
94 , | |
95 /* Intel integrated graphics driver (devg-i830.so) */ | |
96 {"i830", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
97 , | |
98 /* Geode LX graphics driver (devg-lx800.so) */ | |
99 {"lx800", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
100 , | |
101 /* Matrox Gxx graphics driver (devg-matroxg.so) */ | |
102 {"matroxg", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
103 , | |
104 /* Intel Poulsbo graphics driver (devg-poulsbo.so) */ | |
105 {"poulsbo", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} | |
106 , | |
107 /* ATI Radeon driver (devg-radeon.so) */ | |
108 {"radeon", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
109 , | |
110 /* ATI Rage driver (devg-rage.so) */ | |
111 {"rage", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
112 , | |
113 /* S3 Savage graphics driver (devg-s3_savage.so) */ | |
114 {"s3_savage", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
115 , | |
116 /* SiS630 integrated graphics driver (devg-sis630.so) */ | |
117 {"sis630", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
118 , | |
119 /* PowerVR SGX 535 graphics driver (devg-poulsbo.so) */ | |
120 {"sgx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} | |
121 , | |
122 /* SM Voyager GX graphics driver (devg-smi5xx.so) */ | |
123 {"smi5xx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
124 , | |
125 /* Silicon Motion graphics driver (devg-smi7xx.so) */ | |
126 {"smi7xx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
127 , | |
128 /* SVGA unaccelerated gfx driver (devg-svga.so) */ | |
129 {"svga", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
130 , | |
131 /* nVidia TNT graphics driver (devg-tnt.so) */ | |
132 {"tnt", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
133 , | |
134 /* VIA integrated graphics driver (devg-tvia.so) */ | |
135 {"tvia", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
136 , | |
137 /* VIA UniChrome graphics driver (devg-unichrome.so) */ | |
138 {"unichrome", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
139 , | |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
140 /* VESA unaccelerated gfx driver (devg-vesabios.so) */ |
3139 | 141 {"vesa", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D} |
142 , | |
143 /* VmWare graphics driver (devg-volari.so) */ | |
144 {"vmware", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
145 , | |
146 /* XGI XP10 graphics driver (devg-volari.so), OpenGL 1.5 */ | |
147 {"volari", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | |
148 , | |
149 /* End of list */ | |
150 {NULL, 0x00000000} | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
151 }; |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 |
3139 | 153 static SDL_bool photon_initialized = SDL_FALSE; |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 |
3139 | 155 static int |
156 photon_available(void) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 { |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
158 int32_t status; |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 |
3139 | 160 /* Check if Photon was initialized before */ |
161 if (photon_initialized == SDL_FALSE) { | |
162 /* Initialize Photon widget library and open channel to Photon */ | |
163 status = PtInit(NULL); | |
164 if (status == 0) { | |
165 photon_initialized = SDL_TRUE; | |
166 return 1; | |
167 } else { | |
168 photon_initialized = SDL_FALSE; | |
169 return 0; | |
170 } | |
171 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 |
3139 | 173 return 1; |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 |
3139 | 176 static void |
177 photon_destroy(SDL_VideoDevice * device) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 { |
3139 | 179 SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
180 |
3139 | 181 #if defined(SDL_VIDEO_OPENGL_ES) |
182 if (phdata->gfinitialized != SDL_FALSE) { | |
183 gf_dev_detach(phdata->gfdev); | |
184 } | |
185 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
186 |
3139 | 187 if (device->driverdata != NULL) { |
188 device->driverdata = NULL; | |
189 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 |
3139 | 192 static SDL_VideoDevice * |
193 photon_create(int devindex) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 { |
3139 | 195 SDL_VideoDevice *device; |
196 SDL_VideoData *phdata; | |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
197 int32_t status; |
3139 | 198 |
199 /* Check if photon could be initialized */ | |
200 status = photon_available(); | |
201 if (status == 0) { | |
202 /* Photon could not be used */ | |
203 return NULL; | |
204 } | |
205 | |
206 /* Photon agregates all video devices to one with multiple heads */ | |
207 if (devindex != 0) { | |
208 /* devindex could be zero only in Photon SDL driver */ | |
209 return NULL; | |
210 } | |
211 | |
212 /* Initialize SDL_VideoDevice structure */ | |
213 device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); | |
214 if (device == NULL) { | |
215 SDL_OutOfMemory(); | |
216 return NULL; | |
217 } | |
218 | |
219 /* Initialize internal photon specific data */ | |
220 phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); | |
221 if (phdata == NULL) { | |
222 SDL_OutOfMemory(); | |
223 SDL_free(device); | |
224 return NULL; | |
225 } | |
226 device->driverdata = phdata; | |
227 | |
228 /* Get all photon display devices */ | |
229 phdata->avail_rids = | |
230 PdGetDevices(&phdata->rid[0], SDL_VIDEO_PHOTON_MAX_RIDS); | |
231 if (phdata->avail_rids > SDL_VIDEO_PHOTON_MAX_RIDS) { | |
232 phdata->avail_rids = SDL_VIDEO_PHOTON_MAX_RIDS; | |
233 } | |
234 #if defined(SDL_VIDEO_OPENGL_ES) | |
235 /* TODO: add real device detection versus multiple heads */ | |
236 status = | |
237 gf_dev_attach(&phdata->gfdev, GF_DEVICE_INDEX(0), | |
238 &phdata->gfdev_info); | |
239 if (status != GF_ERR_OK) { | |
240 /* Do not fail right now, if GF can't be attached */ | |
241 phdata->gfinitialized = SDL_FALSE; | |
242 } else { | |
243 phdata->gfinitialized = SDL_TRUE; | |
244 } | |
245 #endif /* SDL_VIDEO_OPENGL_ES */ | |
246 | |
247 /* Set default target device */ | |
248 status = PdSetTargetDevice(NULL, phdata->rid[0]); | |
249 if (status == -1) { | |
250 SDL_SetError("Photon: Can't set default target device"); | |
251 #if defined(SDL_VIDEO_OPENGL_ES) | |
252 gf_dev_detach(phdata->gfdev); | |
253 #endif /* SDL_VIDEO_OPENGL_ES */ | |
254 SDL_free(phdata); | |
255 SDL_free(device); | |
256 return NULL; | |
257 } | |
258 phdata->current_device_id = 0; | |
259 | |
260 /* Setup amount of available displays and current display */ | |
261 device->num_displays = 0; | |
262 device->current_display = 0; | |
263 | |
264 /* Set device free function */ | |
265 device->free = photon_destroy; | |
266 | |
267 /* Setup all functions which we can handle */ | |
268 device->VideoInit = photon_videoinit; | |
269 device->VideoQuit = photon_videoquit; | |
270 device->GetDisplayModes = photon_getdisplaymodes; | |
271 device->SetDisplayMode = photon_setdisplaymode; | |
272 device->SetDisplayPalette = photon_setdisplaypalette; | |
273 device->GetDisplayPalette = photon_getdisplaypalette; | |
274 device->SetDisplayGammaRamp = photon_setdisplaygammaramp; | |
275 device->GetDisplayGammaRamp = photon_getdisplaygammaramp; | |
276 device->CreateWindow = photon_createwindow; | |
277 device->CreateWindowFrom = photon_createwindowfrom; | |
278 device->SetWindowTitle = photon_setwindowtitle; | |
279 device->SetWindowIcon = photon_setwindowicon; | |
280 device->SetWindowPosition = photon_setwindowposition; | |
281 device->SetWindowSize = photon_setwindowsize; | |
282 device->ShowWindow = photon_showwindow; | |
283 device->HideWindow = photon_hidewindow; | |
284 device->RaiseWindow = photon_raisewindow; | |
285 device->MaximizeWindow = photon_maximizewindow; | |
286 device->MinimizeWindow = photon_minimizewindow; | |
287 device->RestoreWindow = photon_restorewindow; | |
288 device->SetWindowGrab = photon_setwindowgrab; | |
289 device->DestroyWindow = photon_destroywindow; | |
290 device->GetWindowWMInfo = photon_getwindowwminfo; | |
291 device->GL_LoadLibrary = photon_gl_loadlibrary; | |
292 device->GL_GetProcAddress = photon_gl_getprocaddres; | |
293 device->GL_UnloadLibrary = photon_gl_unloadlibrary; | |
294 device->GL_CreateContext = photon_gl_createcontext; | |
295 device->GL_MakeCurrent = photon_gl_makecurrent; | |
296 device->GL_SetSwapInterval = photon_gl_setswapinterval; | |
297 device->GL_GetSwapInterval = photon_gl_getswapinterval; | |
298 device->GL_SwapWindow = photon_gl_swapwindow; | |
299 device->GL_DeleteContext = photon_gl_deletecontext; | |
300 device->PumpEvents = photon_pumpevents; | |
301 device->SuspendScreenSaver = photon_suspendscreensaver; | |
302 | |
303 return device; | |
304 } | |
305 | |
306 VideoBootStrap photon_bootstrap = { | |
307 "photon", | |
308 "SDL QNX Photon video driver", | |
309 photon_available, | |
310 photon_create | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 }; |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
313 /*****************************************************************************/ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
314 /* SDL Video and Display initialization/handling functions */ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
315 /*****************************************************************************/ |
3139 | 316 int |
317 photon_videoinit(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
318 { |
3139 | 319 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
320 PgHWCaps_t hwcaps; | |
321 PgVideoModeInfo_t modeinfo; | |
322 int32_t status; | |
323 SDL_VideoDisplay display; | |
324 SDL_DisplayMode current_mode; | |
325 SDL_DisplayData *didata; | |
326 uint32_t it; | |
327 uint32_t jt; | |
328 char *override; | |
329 | |
330 /* By default Photon do not uses swap on VSYNC */ | |
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; |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
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 */ |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
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 } |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
399 modeinfo.width=extent.lr.x+1; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
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 */ |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
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 */ |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
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 */ |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
408 curctx=PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
409 if (curctx==NULL) |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
410 { |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
411 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
|
412 SDL_free(didata->cursor); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
413 SDL_free(didata); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
414 return -1; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
415 } |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
416 /* Retrieve current bpp */ |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
417 modeinfo.type=curctx->format; |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
418 PhDCRelease(curctx); |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
419 } else { |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
420 /* Get current video mode details */ |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
421 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
|
422 if (status != 0) { |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
423 SDL_SetError("Photon: Can't get current video mode information"); |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
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 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
886 /* Special case, do not handle maximize events, if window can't be resized */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
887 if ((window->flags & SDL_WINDOW_RESIZABLE) != SDL_WINDOW_RESIZABLE) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
888 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
889 PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
890 Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_RESIZE); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
891 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
892 |
3139 | 893 /* Set window dimension */ |
894 winsize.w = window->w; | |
895 winsize.h = window->h; | |
896 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
|
897 |
3139 | 898 /* Check if upper level requests WM to position window */ |
899 if ((window->x == SDL_WINDOWPOS_UNDEFINED) | |
900 && (window->y == SDL_WINDOWPOS_UNDEFINED)) { | |
901 /* Do not set widget position, let WM to set it */ | |
902 } else { | |
903 if (window->x == SDL_WINDOWPOS_UNDEFINED) { | |
904 window->x = 0; | |
905 } | |
906 if (window->y == SDL_WINDOWPOS_UNDEFINED) { | |
907 window->y = 0; | |
908 } | |
909 if (window->x == SDL_WINDOWPOS_CENTERED) { | |
910 window->x = (didata->current_mode.w - window->w) / 2; | |
911 } | |
912 if (window->y == SDL_WINDOWPOS_CENTERED) { | |
913 window->y = (didata->current_mode.h - window->h) / 2; | |
914 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
915 |
3139 | 916 /* Now set window position */ |
917 winpos.x = window->x; | |
918 winpos.y = window->y; | |
919 PtSetArg(&winargs[winargc++], Pt_ARG_POS, &winpos, 0); | |
920 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
921 |
3139 | 922 /* Check if window must support OpenGL ES rendering */ |
923 if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) { | |
924 #if defined(SDL_VIDEO_OPENGL_ES) | |
925 EGLBoolean initstatus; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
926 |
3139 | 927 /* Check if GF was initialized correctly */ |
928 if (phdata->gfinitialized == SDL_FALSE) { | |
929 SDL_SetError | |
930 ("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
|
931 return -1; |
3139 | 932 } |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
933 |
3139 | 934 /* Mark this window as OpenGL ES compatible */ |
935 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
|
936 |
3139 | 937 /* Create connection to OpenGL ES */ |
938 if (phdata->egldisplay == EGL_NO_DISPLAY) { | |
939 phdata->egldisplay = eglGetDisplay(phdata->gfdev); | |
940 if (phdata->egldisplay == EGL_NO_DISPLAY) { | |
941 SDL_SetError("Photon: Can't get connection to OpenGL ES"); | |
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 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
944 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
945 /* Initialize OpenGL ES library, ignore EGL version */ |
3139 | 946 initstatus = eglInitialize(phdata->egldisplay, NULL, NULL); |
947 if (initstatus != EGL_TRUE) { | |
948 SDL_SetError("Photon: Can't init OpenGL ES library"); | |
949 return -1; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
950 } |
3139 | 951 } |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
952 |
3139 | 953 /* Increment GL ES reference count usage */ |
954 phdata->egl_refcount++; | |
955 #else | |
956 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
957 return -1; | |
958 #endif /* SDL_VIDEO_OPENGL_ES */ | |
959 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
960 |
3139 | 961 /* Finally create the window */ |
962 wdata->window = PtCreateWidget(PtWindow, Pt_NO_PARENT, winargc, winargs); | |
963 if (wdata->window == NULL) { | |
964 SDL_SetError("Photon: Can't create window widget"); | |
965 SDL_free(wdata); | |
966 return -1; | |
967 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
968 |
3139 | 969 /* Show widget */ |
970 status = PtRealizeWidget(wdata->window); | |
971 if (status != 0) { | |
972 SDL_SetError("Photon: Can't realize window widget"); | |
973 PtDestroyWidget(wdata->window); | |
974 SDL_free(wdata); | |
975 return; | |
976 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
977 |
3139 | 978 /* Just created SDL window always gets focus */ |
979 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
|
980 |
3139 | 981 /* Create window-specific cursor after creation */ |
982 if (didata->cursor_visible == SDL_TRUE) { | |
983 /* Setup cursor type. shape and default color */ | |
984 PtSetResource(wdata->window, Pt_ARG_CURSOR_COLOR, | |
985 Ph_CURSOR_DEFAULT_COLOR, 0); | |
986 PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0); | |
987 PtSetResource(wdata->window, Pt_ARG_BITMAP_CURSOR, didata->cursor, | |
988 didata->cursor->hdr.len + sizeof(PhRegionDataHdr_t)); | |
989 } else { | |
990 PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, 0); | |
991 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
992 |
3139 | 993 /* Set window region sensible to mouse motion events */ |
994 status = | |
995 PhRegionQuery(PtWidgetRid(wdata->window), &wregion, NULL, NULL, 0); | |
996 if (status != 0) { | |
997 SDL_SetError | |
998 ("Photon: Can't set region sensivity to mouse motion events"); | |
999 PtDestroyWidget(wdata->window); | |
1000 SDL_free(wdata); | |
1001 return -1; | |
1002 } | |
1003 wregion.events_sense |= | |
1004 Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON; | |
1005 status = PhRegionChange(Ph_REGION_EV_SENSE, 0, &wregion, NULL, NULL); | |
1006 if (status < 0) { | |
1007 SDL_SetError("Photon: Can't change region sensivity"); | |
1008 PtDestroyWidget(wdata->window); | |
1009 SDL_free(wdata); | |
1010 return -1; | |
1011 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1012 |
3139 | 1013 /* Flush all widget operations again */ |
1014 PtFlush(); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1015 |
3139 | 1016 /* By default last created window got a input focus */ |
1017 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
|
1018 |
3139 | 1019 /* Window has been successfully created */ |
1020 return 0; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1021 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1022 |
3139 | 1023 int |
1024 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
|
1025 { |
3139 | 1026 /* 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
|
1027 |
3139 | 1028 /* Failed to create window from another window */ |
1029 return -1; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1030 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1031 |
3139 | 1032 void |
1033 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
|
1034 { |
3139 | 1035 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1036 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1037 |
3139 | 1038 /* Set window title */ |
1039 if (window->title != NULL) { | |
1040 status = | |
1041 PtSetResource(wdata->window, Pt_ARG_WINDOW_TITLE, window->title, | |
1042 0); | |
1043 } else { | |
1044 status = PtSetResource(wdata->window, Pt_ARG_WINDOW_TITLE, "", 0); | |
1045 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1046 |
3139 | 1047 if (status != 0) { |
1048 SDL_SetError("Photon: Can't set window title"); | |
1049 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1050 |
3139 | 1051 /* Flush all widget operations */ |
1052 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1053 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1054 |
3139 | 1055 void |
1056 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
|
1057 { |
3139 | 1058 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1059 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1060 |
3139 | 1061 /* TODO: Use iconify ? */ |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1062 |
3139 | 1063 /* Flush all widget operations */ |
1064 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1065 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1066 |
3139 | 1067 void |
1068 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
|
1069 { |
3139 | 1070 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1071 SDL_DisplayData *didata = | |
1072 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
1073 PhPoint_t winpos; | |
1074 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1075 |
3139 | 1076 /* Check if upper level requests WM to position window */ |
1077 if ((window->x == SDL_WINDOWPOS_UNDEFINED) | |
1078 && (window->y == SDL_WINDOWPOS_UNDEFINED)) { | |
1079 /* Do not set widget position, let WM to set it */ | |
1080 } else { | |
1081 if (window->x == SDL_WINDOWPOS_UNDEFINED) { | |
1082 window->x = 0; | |
1083 } | |
1084 if (window->y == SDL_WINDOWPOS_UNDEFINED) { | |
1085 window->y = 0; | |
1086 } | |
1087 if (window->x == SDL_WINDOWPOS_CENTERED) { | |
1088 window->x = (didata->current_mode.w - window->w) / 2; | |
1089 } | |
1090 if (window->y == SDL_WINDOWPOS_CENTERED) { | |
1091 window->y = (didata->current_mode.h - window->h) / 2; | |
1092 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1093 |
3139 | 1094 /* Now set window position */ |
1095 winpos.x = window->x; | |
1096 winpos.y = window->y; | |
1097 status = PtSetResource(wdata->window, Pt_ARG_POS, &winpos, 0); | |
1098 if (status != 0) { | |
1099 SDL_SetError("Photon: Can't set window position"); | |
1100 } | |
1101 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1102 |
3139 | 1103 /* Flush all widget operations */ |
1104 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1105 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1106 |
3139 | 1107 void |
1108 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
|
1109 { |
3139 | 1110 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1111 PhDim_t winsize; | |
1112 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1113 |
3139 | 1114 winsize.w = window->w; |
1115 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
|
1116 |
3139 | 1117 status = PtSetResource(wdata->window, Pt_ARG_DIM, &winsize, 0); |
1118 if (status != 0) { | |
1119 SDL_SetError("Photon: Can't set window size"); | |
1120 } | |
1121 | |
1122 /* Flush all widget operations */ | |
1123 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1124 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1125 |
3139 | 1126 void |
1127 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
|
1128 { |
3139 | 1129 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1130 int32_t status; | |
1131 | |
1132 /* Bring focus to window and put it in front of others */ | |
1133 PtWindowToFront(wdata->window); | |
1134 | |
1135 /* Flush all widget operations */ | |
1136 PtFlush(); | |
1137 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1138 |
3139 | 1139 void |
1140 photon_hidewindow(_THIS, SDL_Window * window) | |
1141 { | |
1142 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | |
1143 PhWindowEvent_t winevent; | |
1144 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1145 |
3139 | 1146 SDL_memset(&winevent, 0x00, sizeof(PhWindowEvent_t)); |
1147 winevent.event_f = Ph_WM_HIDE; | |
1148 winevent.rid = PtWidgetRid(wdata->window); | |
1149 winevent.event_state = Ph_WM_EVSTATE_HIDE; | |
1150 | |
1151 status = PtForwardWindowEvent(&winevent); | |
1152 if (status != 0) { | |
1153 SDL_SetError("Photon: Can't hide window"); | |
1154 } | |
1155 | |
1156 /* Flush all widget operations */ | |
1157 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1158 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1159 |
3139 | 1160 void |
1161 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
|
1162 { |
3139 | 1163 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1164 PhWindowEvent_t winevent; | |
1165 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1166 |
3139 | 1167 SDL_memset(&winevent, 0x00, sizeof(PhWindowEvent_t)); |
1168 winevent.event_f = Ph_WM_HIDE; | |
1169 winevent.rid = PtWidgetRid(wdata->window); | |
1170 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
|
1171 |
3139 | 1172 status = PtForwardWindowEvent(&winevent); |
1173 if (status != 0) { | |
1174 SDL_SetError("Photon: Can't hide window"); | |
1175 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1176 |
3139 | 1177 /* Flush all widget operations */ |
1178 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1179 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1180 |
3139 | 1181 void |
1182 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
|
1183 { |
3139 | 1184 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1185 PhWindowEvent_t winevent; | |
1186 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1187 |
3139 | 1188 /* Flush all widget operations */ |
1189 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1190 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1191 |
3139 | 1192 void |
1193 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
|
1194 { |
3139 | 1195 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1196 PhWindowEvent_t winevent; | |
1197 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1198 |
3139 | 1199 SDL_memset(&winevent, 0x00, sizeof(PhWindowEvent_t)); |
1200 winevent.event_f = Ph_WM_HIDE; | |
1201 winevent.rid = PtWidgetRid(wdata->window); | |
1202 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
|
1203 |
3139 | 1204 status = PtForwardWindowEvent(&winevent); |
1205 if (status != 0) { | |
1206 SDL_SetError("Photon: Can't hide window"); | |
1207 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1208 |
3139 | 1209 /* Flush all widget operations */ |
1210 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1211 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1212 |
3139 | 1213 void |
1214 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
|
1215 { |
3139 | 1216 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1217 PhWindowEvent_t winevent; | |
1218 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1219 |
3139 | 1220 /* Flush all widget operations */ |
1221 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1222 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1223 |
3139 | 1224 void |
1225 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
|
1226 { |
3139 | 1227 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1228 PhWindowEvent_t winevent; | |
1229 int32_t status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1230 |
3139 | 1231 /* Flush all widget operations */ |
1232 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1233 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1234 |
3139 | 1235 void |
1236 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
|
1237 { |
3139 | 1238 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
1239 SDL_DisplayData *didata = | |
1240 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
1241 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | |
1242 int32_t status; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1243 |
3139 | 1244 if (wdata != NULL) { |
1245 status = PtDestroyWidget(wdata->window); | |
1246 if (status != 0) { | |
1247 SDL_SetError("Photon: Can't destroy window widget"); | |
1248 } | |
1249 wdata->window = NULL; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1250 |
3139 | 1251 #if defined(SDL_VIDEO_OPENGL_ES) |
1252 if (phdata->gfinitialized == SDL_TRUE) { | |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1253 /* Destroy photon handle to GF surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1254 if (wdata->phsurface != NULL) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1255 PhDCRelease(wdata->phsurface); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1256 wdata->phsurface=NULL; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1257 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1258 |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1259 /* Destroy OpenGL ES surface if it was created */ |
3139 | 1260 if (wdata->gles_surface != EGL_NO_SURFACE) { |
1261 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
|
1262 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1263 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1264 /* Free OpenGL ES target surface */ |
3139 | 1265 if (wdata->gfsurface != NULL) { |
1266 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
|
1267 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1268 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1269 phdata->egl_refcount--; |
3139 | 1270 if (phdata->egl_refcount == 0) { |
1271 /* Terminate connection to OpenGL ES */ | |
1272 if (phdata->egldisplay != EGL_NO_DISPLAY) { | |
1273 eglTerminate(phdata->egldisplay); | |
1274 phdata->egldisplay = EGL_NO_DISPLAY; | |
1275 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1276 } |
3139 | 1277 } |
1278 #endif /* SDL_VIDEO_OPENGL_ES */ | |
1279 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1280 |
3139 | 1281 /* Flush all widget operations */ |
1282 PtFlush(); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1283 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1284 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1285 /*****************************************************************************/ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1286 /* SDL Window Manager function */ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1287 /*****************************************************************************/ |
3139 | 1288 SDL_bool |
1289 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
|
1290 { |
3139 | 1291 if (info->version.major <= SDL_MAJOR_VERSION) { |
1292 return SDL_TRUE; | |
1293 } else { | |
1294 SDL_SetError("application not compiled with SDL %d.%d\n", | |
1295 SDL_MAJOR_VERSION, SDL_MINOR_VERSION); | |
1296 return SDL_FALSE; | |
1297 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1298 |
3139 | 1299 /* Failed to get window manager information */ |
1300 return SDL_FALSE; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1301 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1302 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1303 /*****************************************************************************/ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1304 /* SDL OpenGL/OpenGL ES functions */ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1305 /*****************************************************************************/ |
3139 | 1306 int |
1307 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
|
1308 { |
3139 | 1309 #if defined(SDL_VIDEO_OPENGL_ES) |
1310 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
|
1311 |
3139 | 1312 if (phdata->gfinitialized != SDL_TRUE) { |
1313 SDL_SetError | |
1314 ("Photon: GF initialization failed, no OpenGL ES support"); | |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
1315 return -1; |
3139 | 1316 } |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1317 |
3139 | 1318 /* Check if OpenGL ES library is specified for GF driver */ |
1319 if (path == NULL) { | |
1320 path = SDL_getenv("SDL_OPENGL_LIBRARY"); | |
1321 if (path == NULL) { | |
1322 path = SDL_getenv("SDL_OPENGLES_LIBRARY"); | |
1323 } | |
1324 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1325 |
3139 | 1326 /* Check if default library loading requested */ |
1327 if (path == NULL) { | |
1328 /* Already linked with GF library which provides egl* subset of */ | |
1329 /* functions, use Common profile of OpenGL ES library by default */ | |
1330 path = "/usr/lib/libGLES_CM.so.1"; | |
1331 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1332 |
3139 | 1333 /* Load dynamic library */ |
1334 _this->gl_config.dll_handle = SDL_LoadObject(path); | |
1335 if (!_this->gl_config.dll_handle) { | |
1336 /* Failed to load new GL ES library */ | |
1337 SDL_SetError("Photon: Failed to locate OpenGL ES library"); | |
1338 return -1; | |
1339 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1340 |
3139 | 1341 /* Store OpenGL ES library path and name */ |
1342 SDL_strlcpy(_this->gl_config.driver_path, path, | |
1343 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
|
1344 |
3139 | 1345 /* New OpenGL ES library is loaded */ |
1346 return 0; | |
1347 #else | |
1348 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1349 return -1; | |
1350 #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
|
1351 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1352 |
3139 | 1353 void * |
1354 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
|
1355 { |
3139 | 1356 #if defined(SDL_VIDEO_OPENGL_ES) |
1357 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
1358 void *function_address; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1359 |
3139 | 1360 if (phdata->gfinitialized != SDL_TRUE) { |
1361 SDL_SetError | |
1362 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1363 return NULL; | |
1364 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1365 |
3139 | 1366 /* Try to get function address through the egl interface */ |
1367 function_address = eglGetProcAddress(proc); | |
1368 if (function_address != NULL) { | |
1369 return function_address; | |
1370 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1371 |
3139 | 1372 /* Then try to get function in the OpenGL ES library */ |
1373 if (_this->gl_config.dll_handle) { | |
1374 function_address = | |
1375 SDL_LoadFunction(_this->gl_config.dll_handle, proc); | |
1376 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
|
1377 return function_address; |
3139 | 1378 } |
1379 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1380 |
3139 | 1381 /* Add emulated OpenGL ES 1.1 functions */ |
1382 if (SDL_strcmp(proc, "glTexParameteri") == 0) { | |
1383 return glTexParameteri; | |
1384 } | |
1385 if (SDL_strcmp(proc, "glTexParameteriv") == 0) { | |
1386 return glTexParameteriv; | |
1387 } | |
1388 if (SDL_strcmp(proc, "glColor4ub") == 0) { | |
1389 return glColor4ub; | |
1390 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1391 |
3139 | 1392 /* Failed to get GL ES function address pointer */ |
1393 SDL_SetError("Photon: Cannot locate OpenGL ES function name"); | |
1394 return NULL; | |
1395 #else | |
1396 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1397 return NULL; | |
1398 #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
|
1399 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1400 |
3139 | 1401 void |
1402 photon_gl_unloadlibrary(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1403 { |
3139 | 1404 #if defined(SDL_VIDEO_OPENGL_ES) |
1405 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
|
1406 |
3139 | 1407 if (phdata->gfinitialized == SDL_TRUE) { |
1408 /* Unload OpenGL ES library */ | |
1409 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
|
1410 SDL_UnloadObject(_this->gl_config.dll_handle); |
3139 | 1411 _this->gl_config.dll_handle = NULL; |
1412 } | |
1413 } else { | |
1414 SDL_SetError | |
1415 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1416 } | |
1417 #else | |
1418 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1419 return; | |
1420 #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
|
1421 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1422 |
3139 | 1423 SDL_GLContext |
1424 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
|
1425 { |
3139 | 1426 #if defined(SDL_VIDEO_OPENGL_ES) |
1427 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
1428 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | |
1429 SDL_DisplayData *didata = | |
1430 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
1431 EGLBoolean status; | |
1432 int32_t gfstatus; | |
1433 EGLint configs; | |
1434 uint32_t attr_pos; | |
1435 EGLint attr_value; | |
1436 EGLint cit; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1437 |
3139 | 1438 /* Check if GF was initialized */ |
1439 if (phdata->gfinitialized != SDL_TRUE) { | |
1440 SDL_SetError | |
1441 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1442 return NULL; | |
1443 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1444 |
3139 | 1445 /* Prepare attributes list to pass them to OpenGL ES */ |
1446 attr_pos = 0; | |
1447 wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID; | |
1448 wdata->gles_attributes[attr_pos++] = | |
1449 qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format); | |
1450 wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE; | |
1451 wdata->gles_attributes[attr_pos++] = _this->gl_config.red_size; | |
1452 wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE; | |
1453 wdata->gles_attributes[attr_pos++] = _this->gl_config.green_size; | |
1454 wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE; | |
1455 wdata->gles_attributes[attr_pos++] = _this->gl_config.blue_size; | |
1456 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
|
1457 |
3139 | 1458 /* Setup alpha size in bits */ |
1459 if (_this->gl_config.alpha_size) { | |
1460 wdata->gles_attributes[attr_pos++] = _this->gl_config.alpha_size; | |
1461 } else { | |
1462 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1463 } | |
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 color buffer size */ |
1466 if (_this->gl_config.buffer_size) { | |
1467 wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE; | |
1468 wdata->gles_attributes[attr_pos++] = _this->gl_config.buffer_size; | |
1469 } else { | |
1470 wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE; | |
1471 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1472 } | |
1473 | |
1474 /* Setup depth buffer bits */ | |
1475 wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE; | |
1476 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
|
1477 |
3139 | 1478 /* Setup stencil bits */ |
1479 if (_this->gl_config.stencil_size) { | |
1480 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; | |
1481 wdata->gles_attributes[attr_pos++] = _this->gl_config.buffer_size; | |
1482 } else { | |
1483 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; | |
1484 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1485 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1486 |
3139 | 1487 /* Set number of samples in multisampling */ |
1488 if (_this->gl_config.multisamplesamples) { | |
1489 wdata->gles_attributes[attr_pos++] = EGL_SAMPLES; | |
1490 wdata->gles_attributes[attr_pos++] = | |
1491 _this->gl_config.multisamplesamples; | |
1492 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1493 |
3139 | 1494 /* Multisample buffers, OpenGL ES 1.0 spec defines 0 or 1 buffer */ |
1495 if (_this->gl_config.multisamplebuffers) { | |
1496 wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS; | |
1497 wdata->gles_attributes[attr_pos++] = | |
1498 _this->gl_config.multisamplebuffers; | |
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 /* Finish attributes list */ |
1502 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
|
1503 |
3139 | 1504 /* Request first suitable framebuffer configuration */ |
1505 status = eglChooseConfig(phdata->egldisplay, wdata->gles_attributes, | |
1506 wdata->gles_configs, SDL_VIDEO_GF_OPENGLES_CONFS, | |
1507 &configs); | |
1508 if (status != EGL_TRUE) { | |
1509 SDL_SetError | |
1510 ("Photon: Can't find closest configuration for OpenGL ES"); | |
1511 return NULL; | |
1512 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1513 |
3139 | 1514 /* Check if nothing has been found, try "don't care" settings */ |
1515 if (configs == 0) { | |
1516 int32_t it; | |
1517 int32_t jt; | |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1518 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
|
1519 |
3139 | 1520 for (it = 0; it < 4; it++) { |
1521 for (jt = 16; jt >= 0; jt--) { | |
1522 /* Don't care about color buffer bits, use what exist */ | |
1523 /* Replace previous set data with EGL_DONT_CARE */ | |
1524 attr_pos = 0; | |
1525 wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID; | |
1526 wdata->gles_attributes[attr_pos++] = | |
1527 qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format); | |
1528 wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE; | |
1529 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1530 wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE; | |
1531 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1532 wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE; | |
1533 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1534 wdata->gles_attributes[attr_pos++] = EGL_ALPHA_SIZE; | |
1535 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1536 wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE; | |
1537 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
|
1538 |
3139 | 1539 /* Try to find requested or smallest depth */ |
1540 if (_this->gl_config.depth_size) { | |
1541 wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE; | |
1542 wdata->gles_attributes[attr_pos++] = depthbits[it]; | |
1543 } else { | |
1544 wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE; | |
1545 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1546 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1547 |
3139 | 1548 if (_this->gl_config.stencil_size) { |
1549 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; | |
1550 wdata->gles_attributes[attr_pos++] = jt; | |
1551 } else { | |
1552 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; | |
1553 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1554 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1555 |
3139 | 1556 wdata->gles_attributes[attr_pos++] = EGL_SAMPLES; |
1557 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1558 wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS; | |
1559 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1560 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
|
1561 |
3139 | 1562 /* Request first suitable framebuffer configuration */ |
1563 status = | |
1564 eglChooseConfig(phdata->egldisplay, | |
1565 wdata->gles_attributes, | |
1566 wdata->gles_configs, | |
1567 SDL_VIDEO_GF_OPENGLES_CONFS, &configs); | |
1568 if (status != EGL_TRUE) { | |
1569 SDL_SetError | |
1570 ("Photon: Can't find closest configuration for OpenGL ES"); | |
1571 return NULL; | |
1572 } | |
1573 if (configs != 0) { | |
1574 break; | |
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 if (configs != 0) { |
1578 break; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1579 } |
3139 | 1580 } |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1581 |
3139 | 1582 /* No available configs */ |
1583 if (configs == 0) { | |
1584 SDL_SetError | |
1585 ("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
|
1586 return NULL; |
3139 | 1587 } |
1588 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1589 |
3139 | 1590 /* Initialize config index */ |
1591 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
|
1592 |
3139 | 1593 /* Now check each configuration to find out the best */ |
1594 for (cit = 0; cit < configs; cit++) { | |
1595 uint32_t stencil_found; | |
1596 uint32_t depth_found; | |
1597 | |
1598 stencil_found = 0; | |
1599 depth_found = 0; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1600 |
3139 | 1601 if (_this->gl_config.stencil_size) { |
1602 status = | |
1603 eglGetConfigAttrib(phdata->egldisplay, | |
1604 wdata->gles_configs[cit], EGL_STENCIL_SIZE, | |
1605 &attr_value); | |
1606 if (status == EGL_TRUE) { | |
1607 if (attr_value != 0) { | |
1608 stencil_found = 1; | |
1609 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1610 } |
3139 | 1611 } else { |
1612 stencil_found = 1; | |
1613 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1614 |
3139 | 1615 if (_this->gl_config.depth_size) { |
1616 status = | |
1617 eglGetConfigAttrib(phdata->egldisplay, | |
1618 wdata->gles_configs[cit], EGL_DEPTH_SIZE, | |
1619 &attr_value); | |
1620 if (status == EGL_TRUE) { | |
1621 if (attr_value != 0) { | |
1622 depth_found = 1; | |
1623 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1624 } |
3139 | 1625 } else { |
1626 depth_found = 1; | |
1627 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1628 |
3139 | 1629 /* Exit from loop if found appropriate configuration */ |
1630 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
|
1631 break; |
3139 | 1632 } |
1633 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1634 |
3139 | 1635 /* If best could not be found, use first */ |
1636 if (cit == configs) { | |
1637 cit = 0; | |
1638 } | |
1639 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
|
1640 |
3139 | 1641 /* Create OpenGL ES context */ |
1642 wdata->gles_context = | |
1643 eglCreateContext(phdata->egldisplay, | |
1644 wdata->gles_configs[wdata->gles_config], | |
1645 EGL_NO_CONTEXT, NULL); | |
1646 if (wdata->gles_context == EGL_NO_CONTEXT) { | |
1647 SDL_SetError("Photon: OpenGL ES context creation has been failed"); | |
1648 return NULL; | |
1649 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1650 |
3139 | 1651 /* Check if surface is exist */ |
1652 if (wdata->gfsurface != NULL) { | |
1653 gf_surface_free(wdata->gfsurface); | |
1654 wdata->gfsurface = NULL; | |
1655 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1656 |
3139 | 1657 /* Create GF surface */ |
1658 gfstatus = | |
1659 gf_surface_create(&wdata->gfsurface, phdata->gfdev, window->w, | |
1660 window->h, | |
1661 qnxgf_sdl_to_gf_pixelformat(didata->current_mode. | |
1662 format), NULL, | |
1663 GF_SURFACE_CREATE_2D_ACCESSIBLE | | |
1664 GF_SURFACE_CREATE_3D_ACCESSIBLE | | |
1665 GF_SURFACE_CREATE_SHAREABLE); | |
1666 if (gfstatus != GF_ERR_OK) { | |
1667 eglDestroyContext(phdata->egldisplay, wdata->gles_context); | |
1668 wdata->gles_context = EGL_NO_CONTEXT; | |
1669 SDL_SetError("Photon: Can't create GF 3D surface (%08X)", gfstatus); | |
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 /* Create pixmap 3D target surface */ |
1674 wdata->gles_surface = | |
1675 eglCreatePixmapSurface(phdata->egldisplay, | |
1676 wdata->gles_configs[wdata->gles_config], | |
1677 wdata->gfsurface, NULL); | |
1678 if (wdata->gles_surface == EGL_NO_SURFACE) { | |
1679 gf_surface_free(wdata->gfsurface); | |
1680 eglDestroyContext(phdata->egldisplay, wdata->gles_context); | |
1681 wdata->gles_context = EGL_NO_CONTEXT; | |
1682 SDL_SetError("Photon: Can't create EGL pixmap surface"); | |
1683 return NULL; | |
1684 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1685 |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1686 /* Store last used context and surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1687 phdata->lgles_surface=wdata->gles_surface; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1688 phdata->lgles_context=wdata->gles_context; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1689 |
3139 | 1690 /* Make just created context current */ |
1691 status = | |
1692 eglMakeCurrent(phdata->egldisplay, wdata->gles_surface, | |
1693 wdata->gles_surface, wdata->gles_context); | |
1694 if (status != EGL_TRUE) { | |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1695 /* Reset last used context and surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1696 phdata->lgles_surface=EGL_NO_SURFACE; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1697 phdata->lgles_context=EGL_NO_CONTEXT; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1698 |
3139 | 1699 /* Destroy OpenGL ES surface */ |
1700 eglDestroySurface(phdata->egldisplay, wdata->gles_surface); | |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1701 wdata->gles_surface=EGL_NO_SURFACE; |
3139 | 1702 gf_surface_free(wdata->gfsurface); |
1703 eglDestroyContext(phdata->egldisplay, wdata->gles_context); | |
1704 wdata->gles_context = EGL_NO_CONTEXT; | |
1705 SDL_SetError("Photon: Can't set OpenGL ES context on creation"); | |
1706 return NULL; | |
1707 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1708 |
3139 | 1709 /* Setup into SDL internals state of OpenGL ES: */ |
1710 /* it is accelerated or not */ | |
1711 if ((didata->caps & SDL_PHOTON_ACCELERATED_3D) == | |
1712 SDL_PHOTON_ACCELERATED_3D) { | |
1713 _this->gl_config.accelerated = 1; | |
1714 } else { | |
1715 _this->gl_config.accelerated = 0; | |
1716 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1717 |
3139 | 1718 /* Always clear stereo enable, since OpenGL ES do not supports stereo */ |
1719 _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
|
1720 |
3139 | 1721 /* Get back samples and samplebuffers configurations. Rest framebuffer */ |
1722 /* parameters could be obtained through the OpenGL ES API */ | |
1723 status = | |
1724 eglGetConfigAttrib(phdata->egldisplay, | |
1725 wdata->gles_configs[wdata->gles_config], | |
1726 EGL_SAMPLES, &attr_value); | |
1727 if (status == EGL_TRUE) { | |
1728 _this->gl_config.multisamplesamples = attr_value; | |
1729 } | |
1730 status = | |
1731 eglGetConfigAttrib(phdata->egldisplay, | |
1732 wdata->gles_configs[wdata->gles_config], | |
1733 EGL_SAMPLE_BUFFERS, &attr_value); | |
1734 if (status == EGL_TRUE) { | |
1735 _this->gl_config.multisamplebuffers = attr_value; | |
1736 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1737 |
3139 | 1738 /* Get back stencil and depth buffer sizes */ |
1739 status = | |
1740 eglGetConfigAttrib(phdata->egldisplay, | |
1741 wdata->gles_configs[wdata->gles_config], | |
1742 EGL_DEPTH_SIZE, &attr_value); | |
1743 if (status == EGL_TRUE) { | |
1744 _this->gl_config.depth_size = attr_value; | |
1745 } | |
1746 status = | |
1747 eglGetConfigAttrib(phdata->egldisplay, | |
1748 wdata->gles_configs[wdata->gles_config], | |
1749 EGL_STENCIL_SIZE, &attr_value); | |
1750 if (status == EGL_TRUE) { | |
1751 _this->gl_config.stencil_size = attr_value; | |
1752 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1753 |
3139 | 1754 /* Under Photon OpenGL ES output can't be double buffered */ |
1755 _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
|
1756 |
3139 | 1757 /* Check if current device is not the same as target */ |
1758 if (phdata->current_device_id != didata->device_id) { | |
1759 /* Set target device as default for Pd and Pg functions */ | |
1760 status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]); | |
1761 if (status != 0) { | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1762 /* Destroy OpenGL ES surface */ |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1763 eglDestroySurface(phdata->egldisplay, wdata->gles_surface); |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1764 wdata->gles_surface=EGL_NO_SURFACE; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1765 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
|
1766 eglDestroyContext(phdata->egldisplay, wdata->gles_context); |
3139 | 1767 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
|
1768 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
|
1769 return NULL; |
3139 | 1770 } |
1771 phdata->current_device_id = didata->device_id; | |
1772 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1773 |
3139 | 1774 wdata->phsurface = PdCreateOffscreenContextGF(wdata->gfsurface); |
1775 if (wdata->phsurface == NULL) { | |
1776 /* Destroy OpenGL ES surface */ | |
1777 eglDestroySurface(phdata->egldisplay, wdata->gles_surface); | |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1778 wdata->gles_surface=EGL_NO_SURFACE; |
3139 | 1779 gf_surface_free(wdata->gfsurface); |
1780 eglDestroyContext(phdata->egldisplay, wdata->gles_context); | |
1781 wdata->gles_context = EGL_NO_CONTEXT; | |
1782 SDL_SetError("Photon: Can't bind GF surface to Photon\n"); | |
1783 return NULL; | |
1784 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1785 |
3139 | 1786 /* GL ES context was successfully created */ |
1787 return wdata->gles_context; | |
1788 #else | |
1789 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1790 return NULL; | |
1791 #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
|
1792 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1793 |
3139 | 1794 int |
1795 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
|
1796 { |
3139 | 1797 #if defined(SDL_VIDEO_OPENGL_ES) |
1798 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
1799 SDL_WindowData *wdata; | |
1800 EGLBoolean status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1801 |
3139 | 1802 if (phdata->gfinitialized != SDL_TRUE) { |
1803 SDL_SetError | |
1804 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1805 return -1; | |
1806 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1807 |
3139 | 1808 if ((window == NULL) && (context == NULL)) { |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1809 /* Reset last used context and surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1810 phdata->lgles_surface=EGL_NO_SURFACE; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1811 phdata->lgles_context=EGL_NO_CONTEXT; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1812 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1813 /* Unset current context */ |
3139 | 1814 status = |
1815 eglMakeCurrent(phdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, | |
1816 EGL_NO_CONTEXT); | |
1817 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
|
1818 /* Failed to set current GL ES context */ |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1819 SDL_SetError("Photon: Can't empty current OpenGL ES context"); |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1820 return -1; |
3139 | 1821 } |
1822 } else { | |
1823 wdata = (SDL_WindowData *) window->driverdata; | |
1824 if (wdata->gles_surface == EGL_NO_SURFACE) { | |
1825 SDL_SetError | |
1826 ("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
|
1827 return -1; |
3139 | 1828 } |
1829 if (wdata->gles_context == EGL_NO_CONTEXT) { | |
1830 SDL_SetError | |
1831 ("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
|
1832 return -1; |
3139 | 1833 } |
1834 if (wdata->gles_context != context) { | |
1835 SDL_SetError | |
1836 ("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
|
1837 return -1; |
3139 | 1838 } |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1839 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1840 /* Store last set surface and context */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1841 phdata->lgles_surface=wdata->gles_surface; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1842 phdata->lgles_context=wdata->gles_context; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1843 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1844 /* Set new current context */ |
3139 | 1845 status = |
1846 eglMakeCurrent(phdata->egldisplay, wdata->gles_surface, | |
1847 wdata->gles_surface, wdata->gles_context); | |
1848 if (status != EGL_TRUE) { | |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1849 /* Reset last used context and surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1850 phdata->lgles_surface=EGL_NO_SURFACE; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1851 phdata->lgles_context=EGL_NO_CONTEXT; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1852 /* 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
|
1853 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
|
1854 return -1; |
3139 | 1855 } |
1856 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1857 |
3139 | 1858 return 0; |
1859 #else | |
1860 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1861 return -1; | |
1862 #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
|
1863 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1864 |
3139 | 1865 int |
1866 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
|
1867 { |
3139 | 1868 #if defined(SDL_VIDEO_OPENGL_ES) |
1869 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
1870 EGLBoolean status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1871 |
3139 | 1872 if (phdata->gfinitialized != SDL_TRUE) { |
1873 SDL_SetError | |
1874 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1875 return -1; | |
1876 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1877 |
3139 | 1878 /* Check if OpenGL ES connection has been initialized */ |
1879 if (phdata->egldisplay != EGL_NO_DISPLAY) { | |
1880 /* Set swap OpenGL ES interval */ | |
1881 status = eglSwapInterval(phdata->egldisplay, interval); | |
1882 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
|
1883 /* Return success to upper level */ |
3139 | 1884 phdata->swapinterval = interval; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1885 return 0; |
3139 | 1886 } |
1887 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1888 |
3139 | 1889 /* Failed to set swap interval */ |
1890 SDL_SetError("Photon: Cannot set swap interval"); | |
1891 return -1; | |
1892 #else | |
1893 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1894 return -1; | |
1895 #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
|
1896 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1897 |
3139 | 1898 int |
1899 photon_gl_getswapinterval(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1900 { |
3139 | 1901 #if defined(SDL_VIDEO_OPENGL_ES) |
1902 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
|
1903 |
3139 | 1904 if (phdata->gfinitialized != SDL_TRUE) { |
1905 SDL_SetError | |
1906 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1907 return -1; | |
1908 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1909 |
3139 | 1910 /* Return default swap interval value */ |
1911 return phdata->swapinterval; | |
1912 #else | |
1913 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1914 return -1; | |
1915 #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
|
1916 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1917 |
3139 | 1918 void |
1919 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
|
1920 { |
3139 | 1921 #if defined(SDL_VIDEO_OPENGL_ES) |
1922 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
1923 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | |
1924 SDL_DisplayData *didata = | |
1925 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
1926 PhRect_t dst_rect; | |
1927 PhRect_t src_rect; | |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
1928 int32_t status; |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1929 |
3139 | 1930 if (phdata->gfinitialized != SDL_TRUE) { |
1931 SDL_SetError | |
1932 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1933 return; | |
1934 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1935 |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1936 if (wdata->phsurface==NULL) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1937 SDL_SetError |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1938 ("Photon: Photon OpenGL ES surface is not initialized"); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1939 return; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1940 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1941 |
3139 | 1942 /* Many applications do not uses glFinish(), so we call it for them */ |
1943 glFinish(); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1944 |
3139 | 1945 /* Wait until OpenGL ES rendering is completed */ |
1946 eglWaitGL(); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1947 |
3139 | 1948 /* Wait for VSYNC manually, if it was enabled */ |
1949 if (phdata->swapinterval != 0) { | |
1950 /* Wait for VSYNC, we use GF function, since Photon requires */ | |
1951 /* to enter to the Direct mode to call PgWaitVSync() */ | |
1952 gf_display_wait_vsync(didata->display); | |
1953 } | |
1954 | |
1955 /* Set blit area */ | |
1956 dst_rect = *PtGetCanvas(wdata->window); | |
1957 src_rect.ul.x = 0; | |
1958 src_rect.ul.y = 0; | |
1959 src_rect.lr.x = window->w - 1; | |
1960 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
|
1961 |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
1962 /* Check if current device is not the same as target */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
1963 if (phdata->current_device_id != didata->device_id) { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
1964 /* Set target device as default for Pd and Pg functions */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
1965 status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
1966 if (status != 0) { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
1967 SDL_SetError("Photon: Can't set default target device\n"); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
1968 return; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
1969 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
1970 phdata->current_device_id = didata->device_id; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
1971 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
1972 |
3139 | 1973 /* Blit OpenGL ES pixmap surface directly to window region */ |
1974 PgFFlush(Ph_START_DRAW); | |
1975 PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window)); | |
1976 PgClearTranslationCx(PgGetGCCx(PhDCGetCurrent())); | |
1977 PgContextBlit(wdata->phsurface, &src_rect, NULL, &dst_rect); | |
1978 PgFFlush(Ph_DONE_DRAW); | |
1979 PgWaitHWIdle(); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1980 |
3139 | 1981 eglSwapBuffers(phdata->egldisplay, wdata->gles_surface); |
1982 #else | |
1983 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
1984 return; | |
1985 #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
|
1986 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1987 |
3139 | 1988 void |
1989 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
|
1990 { |
3139 | 1991 #if defined(SDL_VIDEO_OPENGL_ES) |
1992 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; | |
1993 EGLBoolean status; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
1994 |
3139 | 1995 if (phdata->gfinitialized != SDL_TRUE) { |
1996 SDL_SetError | |
1997 ("Photon: GF initialization failed, no OpenGL ES support"); | |
1998 return; | |
1999 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2000 |
3139 | 2001 /* Check if OpenGL ES connection has been initialized */ |
2002 if (phdata->egldisplay != EGL_NO_DISPLAY) { | |
2003 if (context != EGL_NO_CONTEXT) { | |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2004 /* Check if we are destroying current active context */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2005 if (phdata->lgles_context==context) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2006 /* Release current context */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2007 eglMakeCurrent(phdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2008 phdata->lgles_context=EGL_NO_CONTEXT; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2009 phdata->lgles_surface=EGL_NO_SURFACE; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2010 } |
3139 | 2011 status = eglDestroyContext(phdata->egldisplay, context); |
2012 if (status != EGL_TRUE) { | |
2013 /* Error during OpenGL ES context destroying */ | |
2014 SDL_SetError("Photon: OpenGL ES context destroy error"); | |
2015 return; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2016 } |
3139 | 2017 } |
2018 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2019 |
3139 | 2020 return; |
2021 #else | |
2022 SDL_SetError("Photon: OpenGL ES support is not compiled in"); | |
2023 return; | |
2024 #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
|
2025 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2026 |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2027 /* Helper function, which re-creates surface, not an API */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2028 int photon_gl_recreatesurface(_THIS, SDL_Window * window, uint32_t width, uint32_t height) |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2029 { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2030 #if defined(SDL_VIDEO_OPENGL_ES) |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2031 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2032 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2033 SDL_DisplayData *didata = |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2034 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2035 SDL_bool makecurrent=SDL_FALSE; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2036 int32_t gfstatus; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2037 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2038 /* Check if context has been initialized */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2039 if (wdata->gles_context == EGL_NO_CONTEXT) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2040 /* If no, abort surface re-creating */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2041 return -1; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2042 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2043 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2044 /* Check if last used surface the same as one which must be re-created */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2045 if (phdata->lgles_surface == wdata->gles_surface) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2046 makecurrent=SDL_TRUE; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2047 /* Flush all current drawings */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2048 glFinish(); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2049 /* Wait until OpenGL ES rendering is completed */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2050 eglWaitGL(); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2051 /* Release current context */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2052 eglMakeCurrent(phdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2053 phdata->lgles_surface=EGL_NO_SURFACE; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2054 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2055 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2056 /* Check if we need to destroy previous surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2057 if (wdata->gles_surface != EGL_NO_SURFACE) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2058 /* Destroy photon handle to GF surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2059 if (wdata->phsurface != NULL) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2060 PhDCRelease(wdata->phsurface); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2061 wdata->phsurface=NULL; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2062 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2063 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2064 /* Destroy previous surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2065 eglDestroySurface(phdata->egldisplay, wdata->gles_surface); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2066 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2067 /* Set surface to uninitialized */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2068 wdata->gles_surface = EGL_NO_SURFACE; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2069 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2070 if (wdata->gfsurface!=NULL) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2071 gf_surface_free(wdata->gfsurface); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2072 wdata->gfsurface=NULL; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2073 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2074 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2075 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2076 /* Create new GF surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2077 gfstatus = |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2078 gf_surface_create(&wdata->gfsurface, phdata->gfdev, width, |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2079 height, |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2080 qnxgf_sdl_to_gf_pixelformat(didata->current_mode. |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2081 format), NULL, |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2082 GF_SURFACE_CREATE_2D_ACCESSIBLE | |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2083 GF_SURFACE_CREATE_3D_ACCESSIBLE | |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2084 GF_SURFACE_CREATE_SHAREABLE); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2085 if (gfstatus != GF_ERR_OK) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2086 SDL_SetError("Photon: Can't create GF 3D surface (%08X)", gfstatus); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2087 return -1; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2088 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2089 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2090 /* Create new pixmap 3D target surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2091 wdata->gles_surface = |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2092 eglCreatePixmapSurface(phdata->egldisplay, |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2093 wdata->gles_configs[wdata->gles_config], |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2094 wdata->gfsurface, NULL); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2095 if (wdata->gles_surface == EGL_NO_SURFACE) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2096 gf_surface_free(wdata->gfsurface); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2097 wdata->gfsurface=NULL; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2098 SDL_SetError("Photon: Can't create EGL pixmap surface"); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2099 return -1; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2100 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2101 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2102 wdata->phsurface = PdCreateOffscreenContextGF(wdata->gfsurface); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2103 if (wdata->phsurface == NULL) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2104 /* Destroy OpenGL ES surface */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2105 eglDestroySurface(phdata->egldisplay, wdata->gles_surface); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2106 wdata->gles_surface=EGL_NO_SURFACE; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2107 gf_surface_free(wdata->gfsurface); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2108 wdata->gfsurface=NULL; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2109 SDL_SetError("Photon: Can't bind GF surface to Photon\n"); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2110 return -1; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2111 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2112 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2113 /* Check if we need to set this surface and context as current */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2114 if (makecurrent == SDL_TRUE) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2115 return photon_gl_makecurrent(_this, window, wdata->gles_context); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2116 } else { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2117 return 0; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2118 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2119 #else |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2120 /* Do nothing, if OpenGL ES support is not compiled in */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2121 return 0; |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2122 #endif /* SDL_VIDEO_OPENGL_ES */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2123 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2124 |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2125 /*****************************************************************************/ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2126 /* SDL Event handling function */ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2127 /*****************************************************************************/ |
3139 | 2128 void |
2129 photon_pumpevents(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2130 { |
3139 | 2131 uint8_t eventbuffer[SDL_VIDEO_PHOTON_EVENT_SIZE]; |
2132 PhEvent_t *event = (PhEvent_t *) eventbuffer; | |
2133 int32_t status; | |
2134 uint32_t finish = 0; | |
2135 uint32_t it; | |
2136 SDL_Window *window; | |
2137 SDL_WindowData *wdata; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2138 |
3139 | 2139 do { |
2140 status = PhEventPeek(event, SDL_VIDEO_PHOTON_EVENT_SIZE); | |
2141 switch (status) { | |
2142 case Ph_RESIZE_MSG: | |
2143 { | |
2144 SDL_SetError("Photon: Event size too much for buffer"); | |
2145 return; | |
2146 } | |
2147 break; | |
2148 case Ph_EVENT_MSG: | |
2149 { | |
2150 /* Find a window, to which this handle destinated */ | |
2151 status = 0; | |
2152 for (it = 0; it < SDL_CurrentDisplay.num_windows; it++) { | |
2153 wdata = | |
2154 (SDL_WindowData *) SDL_CurrentDisplay.windows[it]. | |
2155 driverdata; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2156 |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2157 /* Find the proper window */ |
3139 | 2158 if (wdata->window != NULL) { |
2159 if (PtWidgetRid(wdata->window) == | |
2160 event->collector.rid) { | |
2161 window = | |
2162 (SDL_Window *) & SDL_CurrentDisplay. | |
2163 windows[it]; | |
2164 status = 1; | |
2165 break; | |
2166 } | |
2167 } else { | |
2168 continue; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2169 } |
3139 | 2170 } |
2171 if (status == 0) { | |
2172 window = NULL; | |
2173 wdata = NULL; | |
2174 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2175 |
3139 | 2176 /* Event is ready */ |
2177 switch (event->type) { | |
2178 case Ph_EV_BOUNDARY: | |
2179 { | |
2180 switch (event->subtype) { | |
2181 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
|
2182 { |
3139 | 2183 /* Mouse cursor over handled window */ |
2184 if (window != NULL) { | |
2185 SDL_SendWindowEvent(window->id, | |
2186 SDL_WINDOWEVENT_ENTER, | |
2187 0, 0); | |
2188 SDL_SetMouseFocus(0, window->id); | |
2189 } | |
2190 } | |
2191 break; | |
2192 case Ph_EV_PTR_LEAVE: | |
2193 { | |
2194 /* Mouse cursor out of handled window */ | |
2195 if (window != NULL) { | |
2196 SDL_SendWindowEvent(window->id, | |
2197 SDL_WINDOWEVENT_LEAVE, | |
2198 0, 0); | |
2199 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2200 } |
3139 | 2201 break; |
2202 } | |
2203 } | |
2204 break; | |
2205 case Ph_EV_PTR_MOTION_BUTTON: | |
2206 case Ph_EV_PTR_MOTION_NOBUTTON: | |
2207 { | |
2208 PhPointerEvent_t *pevent = NULL; | |
2209 PhRect_t *prects = NULL; | |
2210 | |
2211 /* Get event data */ | |
2212 pevent = PhGetData(event); | |
2213 /* Get associated event rectangles */ | |
2214 prects = PhGetRects(event); | |
2215 if ((pevent != NULL) && (prects != NULL)) { | |
2216 SDL_SendMouseMotion(0, 0, prects->ul.x, | |
2217 prects->ul.y, 0); | |
2218 } | |
2219 } | |
2220 break; | |
2221 case Ph_EV_BUT_PRESS: | |
2222 { | |
2223 /* Button press event */ | |
2224 PhPointerEvent_t *pevent = NULL; | |
2225 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
|
2226 |
3139 | 2227 /* Get event data */ |
2228 pevent = PhGetData(event); | |
2229 if (pevent != NULL) { | |
2230 for (it = 0; it < sizeof(pevent->buttons) * 8; | |
2231 it++) { | |
2232 if ((pevent->buttons & (0x0001 << it)) == | |
2233 (0x0001 << it)) { | |
2234 switch (it) { | |
2235 case 0: | |
2236 { | |
2237 sdlbutton = SDL_BUTTON_RIGHT; | |
2238 } | |
2239 break; | |
2240 case 1: | |
2241 { | |
2242 sdlbutton = SDL_BUTTON_MIDDLE; | |
2243 } | |
2244 break; | |
2245 case 2: | |
2246 { | |
2247 sdlbutton = SDL_BUTTON_LEFT; | |
2248 } | |
2249 break; | |
2250 default: | |
2251 { | |
2252 sdlbutton = it + 1; | |
2253 } | |
2254 break; | |
2255 } | |
2256 SDL_SendMouseButton(0, SDL_PRESSED, | |
2257 sdlbutton); | |
2258 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2259 } |
3139 | 2260 } |
2261 } | |
2262 break; | |
2263 case Ph_EV_BUT_RELEASE: | |
2264 { | |
2265 /* Button press event */ | |
2266 PhPointerEvent_t *pevent = NULL; | |
2267 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
|
2268 |
3139 | 2269 /* Get event data */ |
2270 pevent = PhGetData(event); | |
2271 if (pevent != NULL) { | |
2272 for (it = 0; it < sizeof(pevent->buttons) * 8; | |
2273 it++) { | |
2274 if ((pevent->buttons & (0x0001 << it)) == | |
2275 (0x0001 << it)) { | |
2276 switch (it) { | |
2277 case 0: | |
2278 { | |
2279 sdlbutton = SDL_BUTTON_RIGHT; | |
2280 } | |
2281 break; | |
2282 case 1: | |
2283 { | |
2284 sdlbutton = SDL_BUTTON_MIDDLE; | |
2285 } | |
2286 break; | |
2287 case 2: | |
2288 { | |
2289 sdlbutton = SDL_BUTTON_LEFT; | |
2290 } | |
2291 break; | |
2292 default: | |
2293 { | |
2294 sdlbutton = it + 1; | |
2295 } | |
2296 break; | |
2297 } | |
2298 } | |
2299 } | |
2300 } | |
2301 | |
2302 switch (event->subtype) { | |
2303 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
|
2304 { |
3139 | 2305 /* Real release button event */ |
2306 SDL_SendMouseButton(0, SDL_RELEASED, | |
2307 sdlbutton); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2308 } |
3139 | 2309 break; |
2310 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
|
2311 { |
3139 | 2312 /* We will get phantom button release */ |
2313 /* event in case if it was unpressed */ | |
2314 /* outside of window */ | |
2315 if (window != NULL) { | |
2316 if ((window-> | |
2317 flags & SDL_WINDOW_MOUSE_FOCUS) != | |
2318 SDL_WINDOW_MOUSE_FOCUS) { | |
2319 /* Send phantom button release */ | |
2320 SDL_SendMouseButton(0, SDL_RELEASED, | |
2321 sdlbutton); | |
2322 } | |
2323 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2324 } |
3139 | 2325 break; |
2326 } | |
2327 } | |
2328 break; | |
2329 case Ph_EV_EXPOSE: | |
2330 { | |
2331 switch (event->subtype) { | |
2332 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
|
2333 { |
3139 | 2334 PhRect_t *rects = NULL; |
2335 | |
2336 /* Get array of rectangles to be updated */ | |
2337 rects = PhGetRects(event); | |
2338 if (rects == NULL) { | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2339 break; |
3139 | 2340 } |
2341 | |
2342 /* Check if expose come to one of the our windows */ | |
2343 if ((wdata != NULL) && (window != NULL)) { | |
2344 /* Check if window uses OpenGL ES */ | |
2345 if (wdata->uses_gles == SDL_TRUE) { | |
2346 /* Cycle through each rectangle */ | |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2347 for (it = 0; it < event->num_rects; it++) { |
3139 | 2348 /* Blit OpenGL ES pixmap surface directly to window region */ |
2349 PgFFlush(Ph_START_DRAW); | |
2350 PgSetRegionCx(PhDCGetCurrent(), | |
2351 PtWidgetRid(wdata-> | |
2352 window)); | |
2353 PgClearTranslationCx(PgGetGCCx | |
2354 (PhDCGetCurrent | |
2355 ())); | |
2356 PgContextBlit(wdata->phsurface, | |
2357 &rects[it], NULL, | |
2358 &rects[it]); | |
2359 PgFFlush(Ph_DONE_DRAW); | |
2360 PgWaitHWIdle(); | |
2361 } | |
2362 } else { | |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2363 /* Cycle through each rectangle */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2364 for (it = 0; it < event->num_rects; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2365 it++) { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2366 /* Blit 2D pixmap surface directly to window region */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2367 _photon_update_rectangles(window->renderer, &rects[it]); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2368 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2369 PgFlush(); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2370 PgWaitHWIdle(); |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2371 } |
3139 | 2372 } |
2373 | |
2374 /* Flush all blittings */ | |
2375 PgFlush(); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2376 } |
3139 | 2377 break; |
2378 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
|
2379 { |
3139 | 2380 /* Check if expose come to one of the our windows */ |
2381 if ((wdata != NULL) && (window != NULL)) { | |
2382 /* Check if window uses OpenGL ES */ | |
2383 if (wdata->uses_gles == SDL_TRUE) { | |
2384 PhRect_t dst_rect; | |
2385 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
|
2386 |
3139 | 2387 /* Set blit area */ |
2388 dst_rect = | |
2389 *PtGetCanvas(wdata->window); | |
2390 src_rect.ul.x = 0; | |
2391 src_rect.ul.y = 0; | |
2392 src_rect.lr.x = window->w - 1; | |
2393 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
|
2394 |
3139 | 2395 /* We need to redraw entire window */ |
2396 PgFFlush(Ph_START_DRAW); | |
2397 PgSetRegionCx(PhDCGetCurrent(), | |
2398 PtWidgetRid(wdata-> | |
2399 window)); | |
2400 PgClearTranslationCx(PgGetGCCx | |
2401 (PhDCGetCurrent | |
2402 ())); | |
2403 PgContextBlit(wdata->phsurface, | |
2404 &src_rect, NULL, | |
2405 &dst_rect); | |
2406 PgFFlush(Ph_DONE_DRAW); | |
2407 PgWaitHWIdle(); | |
2408 } else { | |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2409 PhRect_t rect; |
3115
1102a3305928
Added handler for all window events.
Mike Gorchak <lestat@i.com.ua>
parents:
3108
diff
changeset
|
2410 |
3139 | 2411 /* We need to redraw entire window */ |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2412 rect.ul.x = 0; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2413 rect.ul.y = 0; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2414 rect.lr.x = window->w - 1; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2415 rect.lr.y = window->h - 1; |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2416 |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2417 /* Blit 2D pixmap surface directly to window region */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2418 PgFFlush(Ph_START_DRAW); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2419 _photon_update_rectangles(window->renderer, &rect); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2420 PgFFlush(Ph_DONE_DRAW); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2421 PgWaitHWIdle(); |
3139 | 2422 } |
2423 } | |
2424 } | |
2425 break; | |
2426 case Ph_GRAPHIC_EXPOSE: | |
2427 { | |
2428 /* TODO: What this event means ? */ | |
2429 } | |
2430 break; | |
2431 } | |
2432 } | |
2433 break; | |
2434 case Ph_EV_INFO: | |
2435 { | |
2436 } | |
2437 break; | |
2438 case Ph_EV_KEY: | |
2439 { | |
2440 PhKeyEvent_t *keyevent = NULL; | |
2441 SDL_scancode scancode = SDL_SCANCODE_UNKNOWN; | |
2442 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
|
2443 |
3139 | 2444 keyevent = PhGetData(event); |
2445 if (keyevent == NULL) { | |
2446 break; | |
2447 } | |
2448 | |
2449 /* Check if key is repeated */ | |
2450 if ((keyevent->key_flags & Pk_KF_Key_Repeat) == | |
2451 Pk_KF_Key_Repeat) { | |
2452 /* Ignore such events */ | |
2453 break; | |
2454 } | |
2455 | |
2456 /* Check if key has its own scancode */ | |
2457 if ((keyevent->key_flags & Pk_KF_Scan_Valid) == | |
2458 Pk_KF_Scan_Valid) { | |
2459 if ((keyevent->key_flags & Pk_KF_Key_Down) == | |
2460 Pk_KF_Key_Down) { | |
2461 pressed = SDL_TRUE; | |
2462 } else { | |
2463 pressed = SDL_FALSE; | |
2464 } | |
2465 scancode = | |
2466 photon_to_sdl_keymap(keyevent->key_scan); | |
2467 | |
2468 /* Add details for the pressed key */ | |
2469 if ((keyevent->key_flags & Pk_KF_Cap_Valid) == | |
2470 Pk_KF_Cap_Valid) { | |
2471 switch (keyevent->key_cap) { | |
2472 case Pk_Hyper_R: /* Right windows flag key */ | |
2473 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
|
2474 break; |
3139 | 2475 case Pk_Control_R: /* Right Ctrl key */ |
2476 scancode = SDL_SCANCODE_RCTRL; | |
2477 break; | |
2478 case Pk_Alt_R: /* Right Alt key */ | |
2479 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
|
2480 break; |
3139 | 2481 case Pk_Up: /* Up key but with invalid scan */ |
2482 if (scancode != SDL_SCANCODE_UP) { | |
2483 /* This is a mouse wheel event */ | |
2484 SDL_SendMouseWheel(0, 0, 1); | |
2485 return; | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2486 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2487 break; |
3139 | 2488 case Pk_KP_8: /* Up arrow or 8 on keypad */ |
2489 scancode = SDL_SCANCODE_KP_8; | |
2490 break; | |
2491 case Pk_Down: /* Down key but with invalid scan */ | |
2492 if (scancode != SDL_SCANCODE_DOWN) { | |
2493 /* This is a mouse wheel event */ | |
2494 SDL_SendMouseWheel(0, 0, -1); | |
2495 return; | |
2496 } | |
2497 break; | |
2498 case Pk_KP_2: /* Down arrow or 2 on keypad */ | |
2499 scancode = SDL_SCANCODE_KP_2; | |
2500 break; | |
2501 case Pk_Left: /* Left arrow key */ | |
2502 scancode = SDL_SCANCODE_LEFT; | |
2503 break; | |
2504 case Pk_KP_4: /* Left arrow or 4 on keypad */ | |
2505 scancode = SDL_SCANCODE_KP_4; | |
2506 break; | |
2507 case Pk_Right: /* Right arrow key */ | |
2508 scancode = SDL_SCANCODE_RIGHT; | |
2509 break; | |
2510 case Pk_KP_6: /* Right arrow or 6 on keypad */ | |
2511 scancode = SDL_SCANCODE_KP_6; | |
2512 break; | |
2513 case Pk_Insert: /* Insert key */ | |
2514 scancode = SDL_SCANCODE_INSERT; | |
2515 break; | |
2516 case Pk_KP_0: /* Insert or 0 on keypad */ | |
2517 scancode = SDL_SCANCODE_KP_0; | |
2518 break; | |
2519 case Pk_Home: /* Home key */ | |
2520 scancode = SDL_SCANCODE_HOME; | |
2521 break; | |
2522 case Pk_KP_7: /* Home or 7 on keypad */ | |
2523 scancode = SDL_SCANCODE_KP_7; | |
2524 break; | |
2525 case Pk_Pg_Up: /* PageUp key */ | |
2526 scancode = SDL_SCANCODE_PAGEUP; | |
2527 break; | |
2528 case Pk_KP_9: /* PgUp or 9 on keypad */ | |
2529 scancode = SDL_SCANCODE_KP_9; | |
2530 break; | |
2531 case Pk_Delete: /* Delete key */ | |
2532 scancode = SDL_SCANCODE_DELETE; | |
2533 break; | |
2534 case Pk_KP_Decimal: /* Del or . on keypad */ | |
2535 scancode = SDL_SCANCODE_KP_PERIOD; | |
2536 break; | |
2537 case Pk_End: /* End key */ | |
2538 scancode = SDL_SCANCODE_END; | |
2539 break; | |
2540 case Pk_KP_1: /* End or 1 on keypad */ | |
2541 scancode = SDL_SCANCODE_KP_1; | |
2542 break; | |
2543 case Pk_Pg_Down: /* PageDown key */ | |
2544 scancode = SDL_SCANCODE_PAGEDOWN; | |
2545 break; | |
2546 case Pk_KP_3: /* PgDn or 3 on keypad */ | |
2547 scancode = SDL_SCANCODE_KP_3; | |
2548 break; | |
2549 case Pk_KP_5: /* 5 on keypad */ | |
2550 scancode = SDL_SCANCODE_KP_5; | |
2551 break; | |
2552 case Pk_KP_Enter: | |
2553 scancode = SDL_SCANCODE_KP_ENTER; | |
2554 break; | |
2555 case Pk_KP_Add: | |
2556 scancode = SDL_SCANCODE_KP_PLUS; | |
2557 break; | |
2558 case Pk_KP_Subtract: | |
2559 scancode = SDL_SCANCODE_KP_MINUS; | |
2560 break; | |
2561 case Pk_KP_Multiply: | |
2562 scancode = SDL_SCANCODE_KP_MULTIPLY; | |
2563 break; | |
2564 case Pk_KP_Divide: | |
2565 scancode = SDL_SCANCODE_KP_DIVIDE; | |
2566 break; | |
2567 case Pk_Pause: | |
2568 scancode = SDL_SCANCODE_PAUSE; | |
2569 break; | |
2570 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2571 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2572 |
3139 | 2573 /* Finally check if scancode has been decoded */ |
2574 if (scancode == SDL_SCANCODE_UNKNOWN) { | |
2575 /* Something was pressed, which is not supported */ | |
2576 break; | |
2577 } | |
2578 | |
2579 /* Report pressed/released key to SDL */ | |
2580 if (pressed == SDL_TRUE) { | |
2581 SDL_SendKeyboardKey(0, SDL_PRESSED, scancode); | |
2582 } else { | |
2583 SDL_SendKeyboardKey(0, SDL_RELEASED, | |
2584 scancode); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2585 } |
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2586 |
3139 | 2587 /* Photon doesn't send a release event for PrnScr key */ |
2588 if ((scancode == SDL_SCANCODE_PRINTSCREEN) | |
2589 && (pressed)) { | |
2590 SDL_SendKeyboardKey(0, SDL_RELEASED, | |
2591 scancode); | |
2592 } | |
2593 } | |
2594 } | |
2595 break; | |
2596 case Ph_EV_SERVICE: | |
2597 { | |
2598 } | |
2599 break; | |
2600 case Ph_EV_SYSTEM: | |
2601 { | |
2602 } | |
2603 break; | |
2604 case Ph_EV_WM: | |
2605 { | |
2606 PhWindowEvent_t *wmevent = NULL; | |
2607 | |
2608 /* Get associated event data */ | |
2609 wmevent = PhGetData(event); | |
2610 if (wmevent == NULL) { | |
2611 break; | |
2612 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2613 |
3139 | 2614 switch (wmevent->event_f) { |
2615 case Ph_WM_CLOSE: | |
2616 { | |
2617 if (window != NULL) { | |
2618 SDL_SendWindowEvent(window->id, | |
2619 SDL_WINDOWEVENT_CLOSE, | |
2620 0, 0); | |
2621 } | |
2622 } | |
2623 break; | |
2624 case Ph_WM_FOCUS: | |
2625 { | |
2626 if (wmevent->event_state == | |
2627 Ph_WM_EVSTATE_FOCUS) { | |
2628 if (window != NULL) { | |
2629 PhRegion_t wregion; | |
2630 | |
2631 SDL_SendWindowEvent(window->id, | |
2632 SDL_WINDOWEVENT_FOCUS_GAINED, | |
2633 0, 0); | |
2634 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
|
2635 |
3139 | 2636 /* Set window region sensible to mouse motion events */ |
2637 PhRegionQuery(PtWidgetRid | |
2638 (wdata->window), | |
2639 &wregion, NULL, NULL, | |
2640 0); | |
2641 wregion.events_sense |= | |
2642 Ph_EV_PTR_MOTION_BUTTON | | |
2643 Ph_EV_PTR_MOTION_NOBUTTON; | |
2644 PhRegionChange(Ph_REGION_EV_SENSE, 0, | |
2645 &wregion, NULL, NULL); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2646 |
3139 | 2647 /* If window got a focus, the it is visible */ |
2648 SDL_SendWindowEvent(window->id, | |
2649 SDL_WINDOWEVENT_SHOWN, | |
2650 0, 0); | |
2651 } | |
2652 } | |
2653 if (wmevent->event_state == | |
2654 Ph_WM_EVSTATE_FOCUSLOST) { | |
2655 if (window != NULL) { | |
2656 PhRegion_t wregion; | |
2657 | |
2658 SDL_SendWindowEvent(window->id, | |
2659 SDL_WINDOWEVENT_FOCUS_LOST, | |
2660 0, 0); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2661 |
3139 | 2662 /* Set window region ignore mouse motion events */ |
2663 PhRegionQuery(PtWidgetRid | |
2664 (wdata->window), | |
2665 &wregion, NULL, NULL, | |
2666 0); | |
2667 wregion.events_sense &= | |
2668 ~(Ph_EV_PTR_MOTION_BUTTON | | |
2669 Ph_EV_PTR_MOTION_NOBUTTON); | |
2670 PhRegionChange(Ph_REGION_EV_SENSE, 0, | |
2671 &wregion, NULL, NULL); | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2672 } |
3139 | 2673 } |
2674 } | |
2675 break; | |
2676 case Ph_WM_MOVE: | |
2677 { | |
2678 if (window != NULL) { | |
2679 SDL_SendWindowEvent(window->id, | |
2680 SDL_WINDOWEVENT_MOVED, | |
2681 wmevent->pos.x, | |
2682 wmevent->pos.y); | |
2683 } | |
2684 } | |
2685 break; | |
2686 case Ph_WM_RESIZE: | |
2687 { | |
2688 if (window != NULL) { | |
2689 /* Set new window position after resize */ | |
2690 SDL_SendWindowEvent(window->id, | |
2691 SDL_WINDOWEVENT_MOVED, | |
2692 wmevent->pos.x, | |
2693 wmevent->pos.y); | |
3193
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2694 |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2695 /* Check if this window uses OpenGL ES */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2696 if (wdata->uses_gles == SDL_TRUE) { |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2697 /* If so, recreate surface with new dimensions */ |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2698 photon_gl_recreatesurface(_this, window, wmevent->size.w, wmevent->size.h); |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2699 } |
64e4442676a6
Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
2700 |
3139 | 2701 /* Set new window size after resize */ |
2702 SDL_SendWindowEvent(window->id, | |
2703 SDL_WINDOWEVENT_RESIZED, | |
2704 wmevent->size.w, | |
2705 wmevent->size.h); | |
2706 } | |
2707 } | |
2708 break; | |
2709 case Ph_WM_HIDE: | |
2710 { | |
2711 if (window != NULL) { | |
2712 /* Send new window state: minimized */ | |
2713 SDL_SendWindowEvent(window->id, | |
2714 SDL_WINDOWEVENT_MINIMIZED, | |
2715 0, 0); | |
2716 /* In case window is minimized, then it is hidden */ | |
2717 SDL_SendWindowEvent(window->id, | |
2718 SDL_WINDOWEVENT_HIDDEN, | |
2719 0, 0); | |
2720 } | |
3108
aa1897bee1e9
Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
3092
diff
changeset
|
2721 } |
3139 | 2722 break; |
2723 case Ph_WM_MAX: | |
2724 { | |
2725 if (window != NULL) { | |
3375
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2726 if ((window->flags & SDL_WINDOW_RESIZABLE)==SDL_WINDOW_RESIZABLE) |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2727 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2728 SDL_SendWindowEvent(window->id, |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2729 SDL_WINDOWEVENT_MAXIMIZED, |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2730 0, 0); |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2731 } |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2732 else |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2733 { |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2734 /* otherwise ignor the resize events */ |
dd105b317335
Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents:
3193
diff
changeset
|
2735 } |
3139 | 2736 } |
2737 } | |
2738 break; | |
2739 case Ph_WM_RESTORE: | |
2740 { | |
2741 if (window != NULL) { | |
2742 SDL_SendWindowEvent(window->id, | |
2743 SDL_WINDOWEVENT_RESTORED, | |
2744 0, 0); | |
2745 } | |
2746 } | |
2747 break; | |
2748 } | |
2749 } | |
2750 break; | |
2751 } | |
2752 PtEventHandler(event); | |
2753 } | |
2754 break; | |
2755 case 0: | |
2756 { | |
2757 /* All events are read */ | |
2758 finish = 1; | |
2759 break; | |
2760 } | |
2761 case -1: | |
2762 { | |
2763 /* Error occured in event reading */ | |
2764 SDL_SetError("Photon: Can't read event"); | |
2765 return; | |
2766 } | |
2767 break; | |
2768 } | |
2769 if (finish != 0) { | |
2770 break; | |
2771 } | |
2772 } while (1); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2773 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2774 |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2775 /*****************************************************************************/ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2776 /* SDL screen saver related functions */ |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2777 /*****************************************************************************/ |
3139 | 2778 void |
2779 photon_suspendscreensaver(_THIS) | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2780 { |
3139 | 2781 /* There is no screensaver in pure console, it may exist when running */ |
2782 /* 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
|
2783 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
2784 |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2785 /* vi: set ts=4 sw=4 expandtab: */ |