annotate src/video/photon/SDL_photon.c @ 3384:04af265172f9

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