Mercurial > sdl-ios-xcode
annotate src/video/qnxgf/SDL_qnxgf.c @ 3437:dc2911c207e4
Thank you automated tests (and bobbens!), fixed alpha blending for accuracy
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 16 Nov 2009 09:47:34 +0000 |
parents | fe9c8a5cab51 |
children | 87182c69e080 |
rev | line source |
---|---|
3083
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2009 Sam Lantinga |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +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 Graphics Framework 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) |
3083
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 */ |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 #include "SDL_config.h" |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include "../SDL_sysvideo.h" |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
30 #include "SDL_version.h" |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
31 #include "SDL_syswm.h" |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
32 #include "SDL_loadso.h" |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
33 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
34 /* Include QNX Graphics Framework declarations */ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
35 #include <gf/gf.h> |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
36 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
37 #include "SDL_qnxgf.h" |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
38 #include "SDL_gf_render.h" |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
39 #include "SDL_gf_pixelfmt.h" |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
40 #include "SDL_gf_opengles.h" |
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
41 #include "SDL_gf_input.h" |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
42 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
43 /******************************************************************************/ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
44 /* SDL Generic video modes, which could provide GF */ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
45 /* This is real pain in the ass. GF is just wrapper around a selected driver */ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
46 /* some drivers could support double scan modes, like 320x200, 512x384, etc */ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
47 /* but some drivers are not. Later we can distinguish one driver from another */ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
48 /* Feel free to add any new custom graphics mode */ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
49 /******************************************************************************/ |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
50 static const SDL_DisplayMode generic_mode[] = { |
3139 | 51 {0, 320, 200, 70, NULL}, /* 320x200 modes are 70Hz and 85Hz */ |
52 {0, 320, 200, 85, NULL}, | |
53 {0, 320, 240, 70, NULL}, /* 320x240 modes are 70Hz and 85Hz */ | |
54 {0, 320, 240, 85, NULL}, | |
55 {0, 400, 300, 60, NULL}, /* 400x300 mode is 60Hz only */ | |
56 {0, 480, 360, 60, NULL}, /* 480x360 mode is 60Hz only */ | |
57 {0, 512, 384, 60, NULL}, /* 512x384 modes are 60Hz and 70Hz */ | |
58 {0, 512, 384, 70, NULL}, | |
59 {0, 640, 480, 60, NULL}, /* 640x480 modes are 60Hz, 75Hz, 85Hz */ | |
60 {0, 640, 480, 75, NULL}, | |
61 {0, 640, 480, 85, NULL}, | |
62 {0, 800, 600, 60, NULL}, /* 800x600 modes are 60Hz, 75Hz, 85Hz */ | |
63 {0, 800, 600, 75, NULL}, | |
64 {0, 800, 600, 85, NULL}, | |
65 {0, 800, 480, 60, NULL}, /* 800x480 mode is 60Hz only */ | |
66 {0, 848, 480, 60, NULL}, /* 848x480 mode is 60Hz only */ | |
67 {0, 960, 600, 60, NULL}, /* 960x600 mode is 60Hz only */ | |
68 {0, 1024, 640, 60, NULL}, /* 1024x640 mode is 60Hz only */ | |
69 {0, 1024, 768, 60, NULL}, /* 1024x768 modes are 60Hz, 70Hz, 75Hz */ | |
70 {0, 1024, 768, 70, NULL}, | |
71 {0, 1024, 768, 75, NULL}, | |
72 {0, 1088, 612, 60, NULL}, /* 1088x612 mode is 60Hz only */ | |
73 {0, 1152, 864, 60, NULL}, /* 1152x864 modes are 60Hz, 70Hz, 72Hz */ | |
74 {0, 1152, 864, 70, NULL}, /* 75Hz and 85Hz */ | |
75 {0, 1152, 864, 72, NULL}, | |
76 {0, 1152, 864, 75, NULL}, | |
77 {0, 1152, 864, 85, NULL}, | |
78 {0, 1280, 720, 60, NULL}, /* 1280x720 mode is 60Hz only */ | |
79 {0, 1280, 768, 60, NULL}, /* 1280x768 mode is 60Hz only */ | |
80 {0, 1280, 800, 60, NULL}, /* 1280x800 mode is 60Hz only */ | |
81 {0, 1280, 960, 60, NULL}, /* 1280x960 mode is 60Hz only */ | |
82 {0, 1280, 1024, 60, NULL}, /* 1280x1024 modes are 60Hz, 75Hz, 85Hz and */ | |
83 {0, 1280, 1024, 75, NULL}, /* 100 Hz */ | |
84 {0, 1280, 1024, 85, NULL}, /* */ | |
85 {0, 1280, 1024, 100, NULL}, /* */ | |
86 {0, 1360, 768, 60, NULL}, /* 1360x768 mode is 60Hz only */ | |
87 {0, 1400, 1050, 60, NULL}, /* 1400x1050 mode is 60Hz only */ | |
88 {0, 1440, 900, 60, NULL}, /* 1440x900 mode is 60Hz only */ | |
89 {0, 1440, 960, 60, NULL}, /* 1440x960 mode is 60Hz only */ | |
90 {0, 1600, 900, 60, NULL}, /* 1600x900 mode is 60Hz only */ | |
91 {0, 1600, 1024, 60, NULL}, /* 1600x1024 mode is 60Hz only */ | |
92 {0, 1600, 1200, 60, NULL}, /* 1600x1200 mode is 60Hz only */ | |
93 {0, 1680, 1050, 60, NULL}, /* 1680x1050 mode is 60Hz only */ | |
94 {0, 1920, 1080, 60, NULL}, /* 1920x1080 mode is 60Hz only */ | |
95 {0, 1920, 1200, 60, NULL}, /* 1920x1200 mode is 60Hz only */ | |
96 {0, 1920, 1440, 60, NULL}, /* 1920x1440 mode is 60Hz only */ | |
97 {0, 2048, 1536, 60, NULL}, /* 2048x1536 mode is 60Hz only */ | |
98 {0, 2048, 1080, 60, NULL}, /* 2048x1080 mode is 60Hz only */ | |
99 {0, 0, 0, 0, NULL} /* End of generic mode list */ | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
100 }; |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
101 |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
102 /* 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
|
103 static const GF_DeviceCaps gf_devicename[] = { |
3139 | 104 /* ATI Rage 128 graphics driver (devg-ati_rage128) */ |
105 {"ati_rage128", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
106 SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
107 /* Fujitsu Carmine graphics driver (devg-carmine.so) */ | |
108 {"carmine", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
109 SDL_GF_ACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
110 /* C&T graphics driver (devg-chips.so) */ | |
111 {"chips", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
112 SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
113 /* Fujitsu Coral graphics driver (devg-coral.so) */ | |
114 {"coral", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
115 SDL_GF_ACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
116 /* Intel integrated graphics driver (devg-extreme2.so) */ | |
117 {"extreme2", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
118 SDL_GF_ACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
119 /* Unaccelerated FB driver (devg-flat.so) */ | |
120 {"flat", SDL_GF_UNACCELERATED | SDL_GF_LOWRESOLUTION | | |
121 SDL_GF_UNACCELERATED_3D | SDL_GF_NOVIDEOMEMORY}, | |
122 /* NS Geode graphics driver (devg-geode.so) */ | |
123 {"geode", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
124 SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
125 /* Geode LX graphics driver (devg-geodelx.so) */ | |
126 {"geodelx", SDL_GF_ACCELERATED | SDL_GF_LOWRESOLUTION | | |
127 SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
128 /* Intel integrated graphics driver (devg-gma9xx.so) */ | |
129 {"gma", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
130 SDL_GF_ACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
131 /* Intel integrated graphics driver (devg-i810.so) */ | |
132 {"i810", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
133 SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
134 /* Intel integrated graphics driver (devg-i830.so) */ | |
135 {"i830", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
136 SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
137 /* Geode LX graphics driver (devg-lx800.so) */ | |
138 {"lx800", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
139 SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
140 /* Matrox Gxx graphics driver (devg-matroxg.so) */ | |
141 {"matroxg", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
142 SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
143 /* Intel Poulsbo graphics driver (devg-poulsbo.so) */ | |
144 {"poulsbo", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
145 SDL_GF_ACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
146 /* ATI Radeon driver (devg-radeon.so) */ | |
147 {"radeon", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
148 SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
149 /* ATI Rage driver (devg-rage.so) */ | |
150 {"rage", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
151 SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
152 /* S3 Savage graphics driver (devg-s3_savage.so) */ | |
153 {"s3_savage", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
154 SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
155 /* SiS630 integrated graphics driver (devg-sis630.so) */ | |
156 {"sis630", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
157 SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
158 /* PowerVR SGX 535 graphics driver (devg-poulsbo.so) */ | |
159 {"sgx", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
160 SDL_GF_ACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
161 /* SM Voyager GX graphics driver (devg-smi5xx.so) */ | |
162 {"smi5xx", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
163 SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
164 /* Silicon Motion graphics driver (devg-smi7xx.so) */ | |
165 {"smi7xx", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
166 SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
167 /* SVGA unaccelerated gfx driver (devg-svga.so) */ | |
168 {"svga", SDL_GF_UNACCELERATED | SDL_GF_LOWRESOLUTION | | |
169 SDL_GF_UNACCELERATED_3D | SDL_GF_NOVIDEOMEMORY}, | |
170 /* nVidia TNT graphics driver (devg-tnt.so) */ | |
171 {"tnt", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
172 SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
173 /* VIA integrated graphics driver (devg-tvia.so) */ | |
174 {"tvia", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
175 SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
176 /* VIA UniChrome graphics driver (devg-unichrome.so) */ | |
177 {"unichrome", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | | |
178 SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
179 /* VESA unaccelerated gfx driver (devg-vesa.so) */ | |
180 {"vesa", SDL_GF_UNACCELERATED | SDL_GF_LOWRESOLUTION | | |
181 SDL_GF_UNACCELERATED_3D | SDL_GF_NOVIDEOMEMORY}, | |
182 /* VmWare graphics driver (devg-volari.so) */ | |
183 {"vmware", SDL_GF_ACCELERATED | SDL_GF_LOWRESOLUTION | | |
184 SDL_GF_UNACCELERATED_3D | SDL_GF_NOVIDEOMEMORY}, | |
185 /* XGI XP10 graphics driver (devg-volari.so) */ | |
186 {"volari", SDL_GF_ACCELERATED | SDL_GF_LOWRESOLUTION | | |
187 SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, | |
188 /* End of list */ | |
189 {NULL, 0x00000000} | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
190 }; |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
191 |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
192 /*****************************************************************************/ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
193 /* SDL Video Device initialization functions */ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
194 /*****************************************************************************/ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
195 |
3139 | 196 static int |
197 qnxgf_available(void) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
198 { |
3139 | 199 gf_dev_t gfdev; |
200 gf_dev_info_t gfdev_info; | |
201 int status; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
202 |
3139 | 203 /* Try to attach to graphics device driver */ |
204 status = gf_dev_attach(&gfdev, GF_DEVICE_INDEX(0), &gfdev_info); | |
205 if (status != GF_ERR_OK) { | |
206 return 0; | |
207 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
208 |
3139 | 209 /* Detach from graphics device driver for now */ |
210 gf_dev_detach(gfdev); | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
211 |
3139 | 212 return 1; |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
213 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
214 |
3139 | 215 static void |
216 qnxgf_destroy(SDL_VideoDevice * device) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
217 { |
3139 | 218 SDL_VideoData *gfdata = (SDL_VideoData *) device->driverdata; |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
219 |
3139 | 220 /* Detach from graphics device driver, if it was initialized */ |
221 if (gfdata->gfinitialized != SDL_FALSE) { | |
222 gf_dev_detach(gfdata->gfdev); | |
223 gfdata->gfdev = NULL; | |
224 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
225 |
3139 | 226 if (device->driverdata != NULL) { |
227 device->driverdata = NULL; | |
228 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
229 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
230 |
3139 | 231 static SDL_VideoDevice * |
232 qnxgf_create(int devindex) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
233 { |
3139 | 234 SDL_VideoDevice *device; |
235 SDL_VideoData *gfdata; | |
236 int status; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
237 |
3139 | 238 /* Initialize SDL_VideoDevice structure */ |
239 device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); | |
240 if (device == NULL) { | |
241 SDL_OutOfMemory(); | |
242 return NULL; | |
243 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
244 |
3139 | 245 /* Initialize internal GF specific data */ |
246 gfdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); | |
247 if (gfdata == NULL) { | |
248 SDL_OutOfMemory(); | |
249 SDL_free(device); | |
250 return NULL; | |
251 } | |
252 device->driverdata = gfdata; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
253 |
3139 | 254 /* Try to attach to graphics device driver */ |
255 status = | |
256 gf_dev_attach(&gfdata->gfdev, GF_DEVICE_INDEX(devindex), | |
257 &gfdata->gfdev_info); | |
258 if (status != GF_ERR_OK) { | |
259 SDL_OutOfMemory(); | |
260 SDL_free(gfdata); | |
261 SDL_free(device); | |
262 return NULL; | |
263 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
264 |
3139 | 265 if (gfdata->gfdev_info.description == NULL) { |
266 gf_dev_detach(gfdata->gfdev); | |
267 SDL_SetError("GF: Failed to initialize graphics driver"); | |
268 return NULL; | |
269 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
270 |
3139 | 271 /* Setup amount of available displays and current display */ |
272 device->num_displays = 0; | |
273 device->current_display = 0; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
274 |
3139 | 275 /* Setup device shutdown function */ |
276 gfdata->gfinitialized = SDL_TRUE; | |
277 device->free = qnxgf_destroy; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
278 |
3139 | 279 /* Setup all functions which we can handle */ |
280 device->VideoInit = qnxgf_videoinit; | |
281 device->VideoQuit = qnxgf_videoquit; | |
282 device->GetDisplayModes = qnxgf_getdisplaymodes; | |
283 device->SetDisplayMode = qnxgf_setdisplaymode; | |
284 device->SetDisplayPalette = qnxgf_setdisplaypalette; | |
285 device->GetDisplayPalette = qnxgf_getdisplaypalette; | |
286 device->SetDisplayGammaRamp = qnxgf_setdisplaygammaramp; | |
287 device->GetDisplayGammaRamp = qnxgf_getdisplaygammaramp; | |
288 device->CreateWindow = qnxgf_createwindow; | |
289 device->CreateWindowFrom = qnxgf_createwindowfrom; | |
290 device->SetWindowTitle = qnxgf_setwindowtitle; | |
291 device->SetWindowIcon = qnxgf_setwindowicon; | |
292 device->SetWindowPosition = qnxgf_setwindowposition; | |
293 device->SetWindowSize = qnxgf_setwindowsize; | |
294 device->ShowWindow = qnxgf_showwindow; | |
295 device->HideWindow = qnxgf_hidewindow; | |
296 device->RaiseWindow = qnxgf_raisewindow; | |
297 device->MaximizeWindow = qnxgf_maximizewindow; | |
298 device->MinimizeWindow = qnxgf_minimizewindow; | |
299 device->RestoreWindow = qnxgf_restorewindow; | |
300 device->SetWindowGrab = qnxgf_setwindowgrab; | |
301 device->DestroyWindow = qnxgf_destroywindow; | |
302 device->GetWindowWMInfo = qnxgf_getwindowwminfo; | |
303 device->GL_LoadLibrary = qnxgf_gl_loadlibrary; | |
304 device->GL_GetProcAddress = qnxgf_gl_getprocaddres; | |
305 device->GL_UnloadLibrary = qnxgf_gl_unloadlibrary; | |
306 device->GL_CreateContext = qnxgf_gl_createcontext; | |
307 device->GL_MakeCurrent = qnxgf_gl_makecurrent; | |
308 device->GL_SetSwapInterval = qnxgf_gl_setswapinterval; | |
309 device->GL_GetSwapInterval = qnxgf_gl_getswapinterval; | |
310 device->GL_SwapWindow = qnxgf_gl_swapwindow; | |
311 device->GL_DeleteContext = qnxgf_gl_deletecontext; | |
312 device->PumpEvents = qnxgf_pumpevents; | |
313 device->SuspendScreenSaver = qnxgf_suspendscreensaver; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
314 |
3139 | 315 return device; |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
316 } |
3083
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 |
3139 | 318 VideoBootStrap qnxgf_bootstrap = { |
319 "qnxgf", | |
320 "SDL QNX Graphics Framework (GF) video driver", | |
321 qnxgf_available, | |
322 qnxgf_create | |
3083
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 }; |
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
325 /*****************************************************************************/ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
326 /* SDL Video and Display initialization/handling functions */ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
327 /*****************************************************************************/ |
3139 | 328 int |
329 qnxgf_videoinit(_THIS) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
330 { |
3139 | 331 SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; |
332 uint32_t it; | |
333 uint32_t jt; | |
334 char *override; | |
335 int32_t status; | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
336 |
3139 | 337 /* By default GF uses buffer swap on vsync */ |
338 gfdata->swapinterval = 1; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
339 |
3139 | 340 /* Add each detected output to SDL */ |
341 for (it = 0; it < gfdata->gfdev_info.ndisplays; it++) { | |
342 SDL_VideoDisplay display; | |
343 SDL_DisplayMode current_mode; | |
344 SDL_DisplayData *didata; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
345 |
3139 | 346 didata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData)); |
347 if (didata == NULL) { | |
348 /* memory allocation problem */ | |
349 SDL_OutOfMemory(); | |
350 return -1; | |
351 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
352 |
3139 | 353 /* Set default cursor settings, maximum 128x128 cursor */ |
354 didata->cursor_visible = SDL_FALSE; | |
355 didata->cursor.type = GF_CURSOR_BITMAP; | |
356 didata->cursor.hotspot.x = 0; | |
357 didata->cursor.hotspot.y = 0; | |
358 didata->cursor.cursor.bitmap.w = SDL_VIDEO_GF_MAX_CURSOR_SIZE; | |
359 didata->cursor.cursor.bitmap.h = SDL_VIDEO_GF_MAX_CURSOR_SIZE; | |
360 didata->cursor.cursor.bitmap.stride = | |
361 (didata->cursor.cursor.bitmap.w + 7) / (sizeof(uint8_t) * 8); | |
362 didata->cursor.cursor.bitmap.color0 = 0x00000000; | |
363 didata->cursor.cursor.bitmap.color1 = 0x00000000; | |
364 didata->cursor.cursor.bitmap.image0 = | |
365 SDL_calloc(sizeof(uint8_t), | |
366 (didata->cursor.cursor.bitmap.w + | |
367 7) * didata->cursor.cursor.bitmap.h / | |
368 (sizeof(uint8_t) * 8)); | |
369 if (didata->cursor.cursor.bitmap.image0 == NULL) { | |
370 SDL_free(didata); | |
371 SDL_OutOfMemory(); | |
372 return -1; | |
373 } | |
374 didata->cursor.cursor.bitmap.image1 = | |
375 SDL_calloc(sizeof(uint8_t), | |
376 (didata->cursor.cursor.bitmap.w + | |
377 7) * didata->cursor.cursor.bitmap.h / | |
378 (sizeof(uint8_t) * 8)); | |
379 if (didata->cursor.cursor.bitmap.image1 == NULL) { | |
380 SDL_OutOfMemory(); | |
381 SDL_free((void *) didata->cursor.cursor.bitmap.image0); | |
382 SDL_free(didata); | |
383 return -1; | |
384 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
385 |
3139 | 386 /* Query current display settings */ |
387 status = gf_display_query(gfdata->gfdev, it, &didata->display_info); | |
388 if (status == GF_ERR_OK) { | |
389 SDL_zero(current_mode); | |
390 current_mode.w = didata->display_info.xres; | |
391 current_mode.h = didata->display_info.yres; | |
392 current_mode.refresh_rate = didata->display_info.refresh; | |
393 current_mode.format = | |
394 qnxgf_gf_to_sdl_pixelformat(didata->display_info.format); | |
395 current_mode.driverdata = NULL; | |
396 } else { | |
397 /* video initialization problem */ | |
398 SDL_free((void *) didata->cursor.cursor.bitmap.image0); | |
399 SDL_free((void *) didata->cursor.cursor.bitmap.image1); | |
400 SDL_free(didata); | |
401 SDL_SetError("GF: Display query failed"); | |
402 return -1; | |
403 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
404 |
3139 | 405 /* Attach GF to selected display */ |
406 status = gf_display_attach(&didata->display, gfdata->gfdev, it, NULL); | |
407 if (status != GF_ERR_OK) { | |
408 /* video initialization problem */ | |
409 SDL_free((void *) didata->cursor.cursor.bitmap.image0); | |
410 SDL_free((void *) didata->cursor.cursor.bitmap.image1); | |
411 SDL_free(didata); | |
412 SDL_SetError("GF: Couldn't attach to display"); | |
413 return -1; | |
414 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
415 |
3139 | 416 /* Initialize status variables */ |
417 didata->layer_attached = SDL_FALSE; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
418 |
3139 | 419 /* Attach to main display layer */ |
420 status = | |
421 gf_layer_attach(&didata->layer, didata->display, | |
422 didata->display_info.main_layer_index, 0); | |
423 if (status != GF_ERR_OK) { | |
424 /* Failed to attach to main layer */ | |
425 SDL_free((void *) didata->cursor.cursor.bitmap.image0); | |
426 SDL_free((void *) didata->cursor.cursor.bitmap.image1); | |
427 SDL_free(didata); | |
428 SDL_SetError | |
429 ("GF: Couldn't attach to main layer, it could be busy"); | |
430 return -1; | |
431 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
432 |
3139 | 433 /* Mark main display layer is attached */ |
434 didata->layer_attached = SDL_TRUE; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
435 |
3139 | 436 /* Set layer source and destination viewport */ |
437 gf_layer_set_src_viewport(didata->layer, 0, 0, current_mode.w - 1, | |
438 current_mode.h - 1); | |
439 gf_layer_set_dst_viewport(didata->layer, 0, 0, current_mode.w - 1, | |
440 current_mode.h - 1); | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
441 |
3139 | 442 /* Create main visible on display surface */ |
443 status = gf_surface_create_layer(&didata->surface[0], &didata->layer, | |
444 1, 0, current_mode.w, current_mode.h, | |
445 qnxgf_sdl_to_gf_pixelformat | |
446 (current_mode.format), NULL, | |
447 GF_SURFACE_CREATE_2D_ACCESSIBLE | | |
448 GF_SURFACE_CREATE_3D_ACCESSIBLE | | |
449 GF_SURFACE_CREATE_SHAREABLE); | |
450 if (status != GF_ERR_OK) { | |
451 gf_layer_disable(didata->layer); | |
452 gf_layer_detach(didata->layer); | |
453 didata->layer_attached = SDL_FALSE; | |
454 SDL_free((void *) didata->cursor.cursor.bitmap.image0); | |
455 SDL_free((void *) didata->cursor.cursor.bitmap.image1); | |
456 SDL_free(didata); | |
457 SDL_SetError("GF: Can't create main layer surface at init (%d)\n", | |
458 status); | |
459 return -1; | |
460 } | |
461 | |
462 /* Set just created surface as main visible on the layer */ | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
463 // gf_layer_set_surfaces(didata->layer, &didata->surface[0], 1); |
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
464 |
3139 | 465 /* Update layer parameters */ |
466 status = gf_layer_update(didata->layer, GF_LAYER_UPDATE_NO_WAIT_IDLE); | |
467 if (status != GF_ERR_OK) { | |
468 /* Free allocated surface */ | |
469 gf_surface_free(didata->surface[0]); | |
470 didata->surface[0] = NULL; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
471 |
3139 | 472 /* Disable and detach from layer */ |
473 gf_layer_disable(didata->layer); | |
474 gf_layer_detach(didata->layer); | |
475 didata->layer_attached = SDL_FALSE; | |
476 SDL_free((void *) didata->cursor.cursor.bitmap.image0); | |
477 SDL_free((void *) didata->cursor.cursor.bitmap.image1); | |
478 SDL_free(didata); | |
479 SDL_SetError("GF: Can't update layer parameters\n"); | |
480 return -1; | |
481 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
482 |
3139 | 483 /* Enable layer in case if hardware supports layer enable/disable */ |
484 gf_layer_enable(didata->layer); | |
485 | |
486 /* Copy device name for each display */ | |
487 SDL_strlcpy(didata->description, gfdata->gfdev_info.description, | |
488 SDL_VIDEO_GF_DEVICENAME_MAX - 1); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
489 |
3139 | 490 /* Search device capabilities and possible workarounds */ |
491 jt = 0; | |
492 do { | |
493 if (gf_devicename[jt].name == NULL) { | |
494 break; | |
495 } | |
496 if (SDL_strncmp | |
497 (gf_devicename[jt].name, didata->description, | |
498 SDL_strlen(gf_devicename[jt].name)) == 0) { | |
499 didata->caps = gf_devicename[jt].caps; | |
500 } | |
501 jt++; | |
502 } while (1); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
503 |
3139 | 504 /* Initialize display structure */ |
505 SDL_zero(display); | |
506 display.desktop_mode = current_mode; | |
507 display.current_mode = current_mode; | |
508 display.driverdata = didata; | |
509 didata->current_mode = current_mode; | |
510 SDL_AddVideoDisplay(&display); | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
511 |
3139 | 512 /* Check for environment variables which could override some SDL settings */ |
513 didata->custom_refresh = 0; | |
514 override = SDL_getenv("SDL_VIDEO_GF_REFRESH_RATE"); | |
515 if (override != NULL) { | |
516 if (SDL_sscanf(override, "%u", &didata->custom_refresh) != 1) { | |
517 didata->custom_refresh = 0; | |
518 } | |
519 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
520 |
3139 | 521 /* Get all display modes for this display */ |
522 _this->current_display = it; | |
523 qnxgf_getdisplaymodes(_this); | |
524 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
525 |
3139 | 526 /* Restore default display */ |
527 _this->current_display = 0; | |
528 | |
529 /* Add GF renderer to SDL */ | |
530 gf_addrenderdriver(_this); | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
531 |
3139 | 532 /* Add GF input devices */ |
533 status = gf_addinputdevices(_this); | |
534 if (status != 0) { | |
535 /* SDL error is set by gf_addinputdevices() function */ | |
536 return -1; | |
537 } | |
538 | |
539 /* video has been initialized successfully */ | |
540 return 1; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
541 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
542 |
3139 | 543 void |
544 qnxgf_videoquit(_THIS) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
545 { |
3139 | 546 SDL_DisplayData *didata = NULL; |
547 uint32_t it; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
548 |
3139 | 549 /* Stop collecting mouse events */ |
550 hiddi_disable_mouse(); | |
551 /* Delete GF input devices */ | |
552 gf_delinputdevices(_this); | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
553 |
3139 | 554 /* SDL will restore old desktop mode on exit */ |
555 for (it = 0; it < _this->num_displays; it++) { | |
556 didata = _this->displays[it].driverdata; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
557 |
3139 | 558 /* Free cursor image */ |
559 if (didata->cursor.cursor.bitmap.image0 != NULL) { | |
560 SDL_free((void *) didata->cursor.cursor.bitmap.image0); | |
561 didata->cursor.cursor.bitmap.image0 = NULL; | |
562 } | |
563 if (didata->cursor.cursor.bitmap.image1 != NULL) { | |
564 SDL_free((void *) didata->cursor.cursor.bitmap.image1); | |
565 didata->cursor.cursor.bitmap.image1 = NULL; | |
566 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
567 |
3139 | 568 /* Free main surface */ |
569 if (didata->surface[0] != NULL) { | |
570 gf_surface_free(didata->surface[0]); | |
571 didata->surface[0] = NULL; | |
572 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
573 |
3139 | 574 /* Free back surface */ |
575 if (didata->surface[1] != NULL) { | |
576 gf_surface_free(didata->surface[1]); | |
577 didata->surface[1] = NULL; | |
578 } | |
579 | |
580 /* Free second back surface */ | |
581 if (didata->surface[2] != NULL) { | |
582 gf_surface_free(didata->surface[2]); | |
583 didata->surface[2] = NULL; | |
584 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
585 |
3139 | 586 /* Detach layer before quit */ |
587 if (didata->layer_attached == SDL_TRUE) { | |
588 /* Disable layer if hardware supports this */ | |
589 gf_layer_disable(didata->layer); | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
590 |
3139 | 591 /* Detach from layer, free it for others */ |
592 gf_layer_detach(didata->layer); | |
593 didata->layer = NULL; | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
594 |
3139 | 595 /* Mark it as detached */ |
596 didata->layer_attached = SDL_FALSE; | |
597 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
598 |
3139 | 599 /* Detach from selected display */ |
600 gf_display_detach(didata->display); | |
601 didata->display = NULL; | |
602 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
603 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
604 |
3139 | 605 void |
606 qnxgf_getdisplaymodes(_THIS) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
607 { |
3139 | 608 SDL_DisplayData *didata = |
609 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
610 SDL_DisplayMode mode; | |
611 gf_modeinfo_t modeinfo; | |
612 uint32_t it = 0; | |
613 uint32_t jt = 0; | |
614 uint32_t kt = 0; | |
615 int status; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
616 |
3139 | 617 do { |
618 status = gf_display_query_mode(didata->display, it, &modeinfo); | |
619 if (status == GF_ERR_OK) { | |
620 /* Parsing current mode */ | |
621 if ((modeinfo.flags & GF_MODE_GENERIC) == GF_MODE_GENERIC) { | |
622 /* This mode is generic, so we can add to SDL our resolutions */ | |
623 /* Only pixel format is fixed, refresh rate could be any */ | |
624 jt = 0; | |
625 do { | |
626 if (generic_mode[jt].w == 0) { | |
627 break; | |
628 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
629 |
3139 | 630 /* Check if driver do not supports doublescan video modes */ |
631 if ((didata->caps & SDL_GF_LOWRESOLUTION) != | |
632 SDL_GF_LOWRESOLUTION) { | |
633 if (generic_mode[jt].w < 640) { | |
634 jt++; | |
635 continue; | |
636 } | |
637 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
638 |
3139 | 639 mode.w = generic_mode[jt].w; |
640 mode.h = generic_mode[jt].h; | |
641 mode.refresh_rate = generic_mode[jt].refresh_rate; | |
642 mode.format = | |
643 qnxgf_gf_to_sdl_pixelformat(modeinfo.primary_format); | |
644 mode.driverdata = NULL; | |
645 SDL_AddDisplayMode(_this->current_display, &mode); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
646 |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
647 /* If mode is RGBA8888, add the same mode as RGBx888 */ |
3186 | 648 if (modeinfo.primary_format == GF_FORMAT_BGRA8888) { |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
649 mode.w = generic_mode[jt].w; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
650 mode.h = generic_mode[jt].h; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
651 mode.refresh_rate = generic_mode[jt].refresh_rate; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
652 mode.format = SDL_PIXELFORMAT_RGB888; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
653 mode.driverdata = NULL; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
654 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
|
655 } |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
656 /* If mode is RGBA1555, add the same mode as RGBx555 */ |
3186 | 657 if (modeinfo.primary_format == GF_FORMAT_PACK_ARGB1555) { |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
658 mode.w = generic_mode[jt].w; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
659 mode.h = generic_mode[jt].h; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
660 mode.refresh_rate = generic_mode[jt].refresh_rate; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
661 mode.format = SDL_PIXELFORMAT_RGB555; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
662 mode.driverdata = NULL; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
663 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
|
664 } |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
665 |
3139 | 666 jt++; |
667 } while (1); | |
668 } else { | |
669 /* Add this display mode as is in case if it is non-generic */ | |
670 /* But go through the each refresh rate, supported by gf */ | |
671 jt = 0; | |
672 do { | |
673 if (modeinfo.refresh[jt] != 0) { | |
674 mode.w = modeinfo.xres; | |
675 mode.h = modeinfo.yres; | |
676 mode.refresh_rate = modeinfo.refresh[jt]; | |
677 mode.format = | |
678 qnxgf_gf_to_sdl_pixelformat(modeinfo. | |
679 primary_format); | |
680 mode.driverdata = NULL; | |
681 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
|
682 |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
683 /* If mode is RGBA8888, add the same mode as RGBx888 */ |
3186 | 684 if (modeinfo.primary_format == GF_FORMAT_BGRA8888) { |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
685 mode.w = modeinfo.xres; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
686 mode.h = modeinfo.yres; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
687 mode.refresh_rate = modeinfo.refresh[jt]; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
688 mode.format = SDL_PIXELFORMAT_RGB888; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
689 mode.driverdata = NULL; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
690 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
|
691 } |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
692 /* If mode is RGBA1555, add the same mode as RGBx555 */ |
3186 | 693 if (modeinfo.primary_format == |
694 GF_FORMAT_PACK_ARGB1555) { | |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
695 mode.w = modeinfo.xres; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
696 mode.h = modeinfo.yres; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
697 mode.refresh_rate = modeinfo.refresh[jt]; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
698 mode.format = SDL_PIXELFORMAT_RGB555; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
699 mode.driverdata = NULL; |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
700 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
|
701 } |
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
702 |
3139 | 703 jt++; |
704 } else { | |
705 break; | |
706 } | |
707 } while (1); | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
708 } |
3139 | 709 } else { |
710 if (status == GF_ERR_PARM) { | |
711 /* out of available modes, all are listed */ | |
712 break; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
713 } |
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
714 |
3139 | 715 /* Error occured during mode listing */ |
716 break; | |
717 } | |
718 it++; | |
719 } while (1); | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
720 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
721 |
3139 | 722 int |
723 qnxgf_setdisplaymode(_THIS, SDL_DisplayMode * mode) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
724 { |
3139 | 725 SDL_DisplayData *didata = |
726 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
727 uint32_t refresh_rate = 0; | |
728 int status; | |
729 | |
730 /* Current display dimensions and bpp are no more valid */ | |
731 didata->current_mode.format = SDL_PIXELFORMAT_UNKNOWN; | |
732 didata->current_mode.w = 0; | |
733 didata->current_mode.h = 0; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
734 |
3139 | 735 /* Check if custom refresh rate requested */ |
736 if (didata->custom_refresh != 0) { | |
737 refresh_rate = didata->custom_refresh; | |
738 } else { | |
739 refresh_rate = mode->refresh_rate; | |
740 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
741 |
3139 | 742 /* Check if SDL GF driver needs to find appropriate refresh rate itself */ |
743 if (refresh_rate == 0) { | |
744 uint32_t it; | |
745 SDL_DisplayMode tempmode; | |
746 | |
747 /* Clear display mode structure */ | |
748 SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode)); | |
749 tempmode.refresh_rate = 0x0000FFFF; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
750 |
3139 | 751 /* Check if window width and height matches one of our modes */ |
752 for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) { | |
753 if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) && | |
754 (SDL_CurrentDisplay.display_modes[it].h == mode->h) && | |
755 (SDL_CurrentDisplay.display_modes[it].format == mode->format)) | |
756 { | |
757 /* Find the lowest refresh rate available */ | |
758 if (tempmode.refresh_rate > | |
759 SDL_CurrentDisplay.display_modes[it].refresh_rate) { | |
760 tempmode = SDL_CurrentDisplay.display_modes[it]; | |
761 } | |
762 } | |
763 } | |
764 if (tempmode.refresh_rate != 0x0000FFFF) { | |
765 refresh_rate = tempmode.refresh_rate; | |
766 } else { | |
767 /* Let video driver decide what to do with this */ | |
768 refresh_rate = 0; | |
769 } | |
770 } | |
771 | |
772 /* Check if SDL GF driver needs to check custom refresh rate */ | |
773 if (didata->custom_refresh != 0) { | |
774 uint32_t it; | |
775 SDL_DisplayMode tempmode; | |
776 | |
777 /* Clear display mode structure */ | |
778 SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode)); | |
779 tempmode.refresh_rate = 0x0000FFFF; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
780 |
3139 | 781 /* Check if window width and height matches one of our modes */ |
782 for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) { | |
783 if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) && | |
784 (SDL_CurrentDisplay.display_modes[it].h == mode->h) && | |
785 (SDL_CurrentDisplay.display_modes[it].format == mode->format)) | |
786 { | |
787 /* Find the lowest refresh rate available */ | |
788 if (tempmode.refresh_rate > | |
789 SDL_CurrentDisplay.display_modes[it].refresh_rate) { | |
790 tempmode = SDL_CurrentDisplay.display_modes[it]; | |
791 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
792 |
3139 | 793 /* Check if requested refresh rate found */ |
794 if (refresh_rate == | |
795 SDL_CurrentDisplay.display_modes[it].refresh_rate) { | |
796 tempmode = SDL_CurrentDisplay.display_modes[it]; | |
797 break; | |
798 } | |
799 } | |
800 } | |
801 if (tempmode.refresh_rate != 0x0000FFFF) { | |
802 refresh_rate = tempmode.refresh_rate; | |
803 } else { | |
804 /* Let video driver decide what to do with this */ | |
805 refresh_rate = 0; | |
806 } | |
807 } | |
808 | |
809 /* Free main surface */ | |
810 if (didata->surface[0] != NULL) { | |
811 gf_surface_free(didata->surface[0]); | |
812 didata->surface[0] = NULL; | |
813 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
814 |
3139 | 815 /* Free back surface */ |
816 if (didata->surface[1] != NULL) { | |
817 gf_surface_free(didata->surface[1]); | |
818 didata->surface[1] = NULL; | |
819 } | |
820 | |
821 /* Free second back surface */ | |
822 if (didata->surface[2] != NULL) { | |
823 gf_surface_free(didata->surface[2]); | |
824 didata->surface[2] = NULL; | |
825 } | |
826 | |
827 /* Detach layer before switch to new graphics mode */ | |
828 if (didata->layer_attached == SDL_TRUE) { | |
829 /* Disable layer if hardware supports this */ | |
830 gf_layer_disable(didata->layer); | |
831 | |
832 /* Detach from layer, free it for others */ | |
833 gf_layer_detach(didata->layer); | |
834 | |
835 /* Mark it as detached */ | |
836 didata->layer_attached = SDL_FALSE; | |
837 } | |
838 | |
839 /* Set new display video mode */ | |
840 status = | |
841 gf_display_set_mode(didata->display, mode->w, mode->h, refresh_rate, | |
842 qnxgf_sdl_to_gf_pixelformat(mode->format), 0); | |
843 if (status != GF_ERR_OK) { | |
844 /* Display mode/resolution switch has been failed */ | |
845 SDL_SetError("GF: Mode is not supported by graphics driver"); | |
846 return -1; | |
847 } else { | |
848 didata->current_mode = *mode; | |
849 didata->current_mode.refresh_rate = refresh_rate; | |
850 } | |
851 | |
852 /* Attach to main display layer */ | |
853 status = | |
854 gf_layer_attach(&didata->layer, didata->display, | |
855 didata->display_info.main_layer_index, 0); | |
856 if (status != GF_ERR_OK) { | |
857 SDL_SetError("GF: Couldn't attach to main layer, it could be busy"); | |
858 | |
859 /* Failed to attach to main displayable layer */ | |
860 return -1; | |
861 } | |
862 | |
863 /* Mark main display layer is attached */ | |
864 didata->layer_attached = SDL_TRUE; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
865 |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
866 /* Set layer source and destination viewports */ |
3139 | 867 gf_layer_set_src_viewport(didata->layer, 0, 0, mode->w - 1, mode->h - 1); |
868 gf_layer_set_dst_viewport(didata->layer, 0, 0, mode->w - 1, mode->h - 1); | |
869 | |
870 /* Create main visible on display surface */ | |
871 status = | |
872 gf_surface_create_layer(&didata->surface[0], &didata->layer, 1, 0, | |
873 mode->w, mode->h, | |
874 qnxgf_sdl_to_gf_pixelformat(mode->format), | |
875 NULL, | |
876 GF_SURFACE_CREATE_2D_ACCESSIBLE | | |
877 GF_SURFACE_CREATE_3D_ACCESSIBLE | | |
878 GF_SURFACE_CREATE_SHAREABLE); | |
879 if (status != GF_ERR_OK) { | |
880 gf_layer_disable(didata->layer); | |
881 gf_layer_detach(didata->layer); | |
882 didata->layer_attached = SDL_FALSE; | |
883 SDL_SetError | |
884 ("GF: Can't create main layer surface at modeswitch (%d)\n", | |
885 status); | |
886 return -1; | |
887 } | |
888 | |
889 /* Set just created surface as main visible on the layer */ | |
890 gf_layer_set_surfaces(didata->layer, &didata->surface[0], 1); | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
891 |
3139 | 892 /* Update layer parameters */ |
893 status = gf_layer_update(didata->layer, GF_LAYER_UPDATE_NO_WAIT_IDLE); | |
894 if (status != GF_ERR_OK) { | |
895 /* Free main surface */ | |
896 gf_surface_free(didata->surface[0]); | |
897 didata->surface[0] = NULL; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
898 |
3139 | 899 /* Detach layer */ |
900 gf_layer_disable(didata->layer); | |
901 gf_layer_detach(didata->layer); | |
902 didata->layer_attached = SDL_FALSE; | |
903 SDL_SetError("GF: Can't update layer parameters\n"); | |
904 return -1; | |
905 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
906 |
3139 | 907 /* Restore cursor if it was visible */ |
908 if (didata->cursor_visible == SDL_TRUE) { | |
909 gf_cursor_set(didata->display, 0, &didata->cursor); | |
910 gf_cursor_enable(didata->display, 0); | |
911 } | |
912 | |
913 /* Enable layer in case if hardware supports layer enable/disable */ | |
914 gf_layer_enable(didata->layer); | |
915 | |
916 return 0; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
917 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
918 |
3139 | 919 int |
920 qnxgf_setdisplaypalette(_THIS, SDL_Palette * palette) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
921 { |
3139 | 922 SDL_DisplayData *didata = |
923 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
924 | |
925 /* QNX GF doesn't have support for global palette changing, but we */ | |
926 /* could store it for usage in future */ | |
927 | |
928 /* Setting display palette operation has been failed */ | |
929 return -1; | |
930 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
931 |
3139 | 932 int |
933 qnxgf_getdisplaypalette(_THIS, SDL_Palette * palette) | |
934 { | |
935 SDL_DisplayData *didata = | |
936 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
937 | |
938 /* We can't provide current palette settings and looks like SDL */ | |
939 /* do not call this function also, in such case this function returns -1 */ | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
940 |
3139 | 941 /* Getting display palette operation has been failed */ |
942 return -1; | |
943 } | |
944 | |
945 int | |
946 qnxgf_setdisplaygammaramp(_THIS, Uint16 * ramp) | |
947 { | |
948 SDL_DisplayData *didata = | |
949 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
950 int status; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
951 |
3139 | 952 /* Setup gamma ramp, for each color channel */ |
953 status = | |
954 gf_display_set_color_lut16(didata->display, (uint16_t *) ramp, | |
955 (uint16_t *) ramp + 256, | |
956 (uint16_t *) ramp + 512); | |
957 if (status != GF_ERR_OK) { | |
958 /* Setting display gamma ramp operation has been failed */ | |
959 return -1; | |
960 } | |
961 | |
962 return 0; | |
963 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
964 |
3139 | 965 int |
966 qnxgf_getdisplaygammaramp(_THIS, Uint16 * ramp) | |
967 { | |
968 /* TODO: We need to return previous gamma set */ | |
969 /* Also we need some initial fake gamma to return */ | |
970 | |
971 /* Getting display gamma ramp operation has been failed */ | |
972 return -1; | |
973 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
974 |
3139 | 975 int |
976 qnxgf_createwindow(_THIS, SDL_Window * window) | |
977 { | |
978 SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; | |
979 SDL_DisplayData *didata = | |
980 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
981 SDL_WindowData *wdata; | |
982 int32_t status; | |
983 | |
984 /* QNX GF supports fullscreen window modes only */ | |
985 if ((window->flags & SDL_WINDOW_FULLSCREEN) != SDL_WINDOW_FULLSCREEN) { | |
986 uint32_t it; | |
987 SDL_DisplayMode mode; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
988 |
3139 | 989 /* Clear display mode structure */ |
990 SDL_memset(&mode, 0x00, sizeof(SDL_DisplayMode)); | |
991 mode.refresh_rate = 0x0000FFFF; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
992 |
3139 | 993 /* Check if window width and height matches one of our modes */ |
994 for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) { | |
995 if ((SDL_CurrentDisplay.display_modes[it].w == window->w) && | |
996 (SDL_CurrentDisplay.display_modes[it].h == window->h) && | |
997 (SDL_CurrentDisplay.display_modes[it].format == | |
998 SDL_CurrentDisplay.desktop_mode.format)) { | |
999 /* Find the lowest refresh rate available */ | |
1000 if (mode.refresh_rate > | |
1001 SDL_CurrentDisplay.display_modes[it].refresh_rate) { | |
1002 mode = SDL_CurrentDisplay.display_modes[it]; | |
1003 } | |
1004 } | |
1005 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1006 |
3139 | 1007 /* Check if end of display list has been reached */ |
1008 if (mode.refresh_rate == 0x0000FFFF) { | |
1009 SDL_SetError("GF: Desired video mode is not supported"); | |
1010 | |
1011 /* Failed to create new window */ | |
1012 return -1; | |
1013 } else { | |
1014 /* Tell to the caller that mode will be fullscreen */ | |
1015 window->flags |= SDL_WINDOW_FULLSCREEN; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1016 |
3139 | 1017 /* Setup fullscreen mode, bpp used from desktop mode in this case */ |
1018 status = qnxgf_setdisplaymode(_this, &mode); | |
1019 if (status != 0) { | |
1020 /* Failed to swith fullscreen video mode */ | |
1021 return -1; | |
1022 } | |
1023 } | |
1024 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1025 |
3139 | 1026 /* Setup our own window decorations and states, which are depend on fullscreen mode */ |
1027 window->flags |= SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS | | |
1028 SDL_WINDOW_MAXIMIZED | SDL_WINDOW_INPUT_GRABBED | | |
1029 SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS; | |
1030 window->flags &= ~(SDL_WINDOW_RESIZABLE | SDL_WINDOW_MINIMIZED); | |
1031 | |
1032 /* Ignore any window position settings */ | |
1033 window->x = SDL_WINDOWPOS_UNDEFINED; | |
1034 window->y = SDL_WINDOWPOS_UNDEFINED; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1035 |
3139 | 1036 /* Allocate window internal data */ |
1037 wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); | |
1038 if (wdata == NULL) { | |
1039 SDL_OutOfMemory(); | |
1040 return -1; | |
1041 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1042 |
3139 | 1043 /* Setup driver data for this window */ |
1044 window->driverdata = wdata; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1045 |
3139 | 1046 /* Check if window must support OpenGL ES rendering */ |
1047 if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) { | |
1048 #if defined(SDL_VIDEO_OPENGL_ES) | |
1049 EGLBoolean initstatus; | |
1050 | |
1051 /* Mark this window as OpenGL ES compatible */ | |
1052 wdata->uses_gles = SDL_TRUE; | |
1053 | |
1054 /* Create connection to OpenGL ES */ | |
1055 if (gfdata->egldisplay == EGL_NO_DISPLAY) { | |
1056 gfdata->egldisplay = eglGetDisplay(gfdata->gfdev); | |
1057 if (gfdata->egldisplay == EGL_NO_DISPLAY) { | |
1058 SDL_SetError("GF: Can't get connection to OpenGL ES"); | |
1059 return -1; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1060 } |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1061 |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1062 /* Initialize OpenGL ES library, ignore EGL version */ |
3139 | 1063 initstatus = eglInitialize(gfdata->egldisplay, NULL, NULL); |
1064 if (initstatus != EGL_TRUE) { | |
1065 SDL_SetError("GF: Can't init OpenGL ES library"); | |
1066 return -1; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1067 } |
3139 | 1068 } |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1069 |
3139 | 1070 /* Increment GL ES reference count usage */ |
1071 gfdata->egl_refcount++; | |
1072 #else | |
1073 SDL_SetError("GF: OpenGL ES support is not compiled in"); | |
1074 return -1; | |
1075 #endif /* SDL_VIDEO_OPENGL_ES */ | |
1076 } | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1077 |
3139 | 1078 /* Enable mouse event collecting */ |
1079 hiddi_enable_mouse(); | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1080 |
3139 | 1081 /* By default last created window got a input focus */ |
1082 SDL_SetKeyboardFocus(0, window->id); | |
1083 SDL_SetMouseFocus(0, window->id); | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1084 |
3139 | 1085 /* Window has been successfully created */ |
1086 return 0; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1087 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1088 |
3139 | 1089 int |
1090 qnxgf_createwindowfrom(_THIS, SDL_Window * window, const void *data) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1091 { |
3139 | 1092 /* Failed to create window from another window */ |
1093 return -1; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1094 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1095 |
3139 | 1096 void |
1097 qnxgf_setwindowtitle(_THIS, SDL_Window * window) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1098 { |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1099 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1100 |
3139 | 1101 void |
1102 qnxgf_setwindowicon(_THIS, SDL_Window * window, SDL_Surface * icon) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1103 { |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1104 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1105 |
3139 | 1106 void |
1107 qnxgf_setwindowposition(_THIS, SDL_Window * window) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1108 { |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1109 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1110 |
3139 | 1111 void |
1112 qnxgf_setwindowsize(_THIS, SDL_Window * window) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1113 { |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1114 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1115 |
3139 | 1116 void |
1117 qnxgf_showwindow(_THIS, SDL_Window * window) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1118 { |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1119 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1120 |
3139 | 1121 void |
1122 qnxgf_hidewindow(_THIS, SDL_Window * window) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1123 { |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1124 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1125 |
3139 | 1126 void |
1127 qnxgf_raisewindow(_THIS, SDL_Window * window) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1128 { |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1129 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1130 |
3139 | 1131 void |
1132 qnxgf_maximizewindow(_THIS, SDL_Window * window) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1133 { |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1134 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1135 |
3139 | 1136 void |
1137 qnxgf_minimizewindow(_THIS, SDL_Window * window) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1138 { |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1139 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1140 |
3139 | 1141 void |
1142 qnxgf_restorewindow(_THIS, SDL_Window * window) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1143 { |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1144 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1145 |
3139 | 1146 void |
1147 qnxgf_setwindowgrab(_THIS, SDL_Window * window) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1148 { |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1149 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1150 |
3139 | 1151 void |
1152 qnxgf_destroywindow(_THIS, SDL_Window * window) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1153 { |
3139 | 1154 SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; |
1155 SDL_DisplayData *didata = | |
1156 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
1157 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1158 |
3139 | 1159 if (wdata != NULL) { |
1160 #if defined(SDL_VIDEO_OPENGL_ES) | |
1161 /* Destroy OpenGL ES surface if it was created */ | |
1162 if (wdata->gles_surface != EGL_NO_SURFACE) { | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1163 eglDestroySurface(gfdata->egldisplay, wdata->gles_surface); |
3139 | 1164 } |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1165 |
3139 | 1166 /* Free any 3D target if it was created before */ |
1167 if (wdata->target_created == SDL_TRUE) { | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1168 gf_3d_target_free(wdata->target); |
3139 | 1169 wdata->target_created == SDL_FALSE; |
1170 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1171 |
3139 | 1172 gfdata->egl_refcount--; |
1173 if (gfdata->egl_refcount == 0) { | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1174 /* Terminate connection to OpenGL ES */ |
3139 | 1175 if (gfdata->egldisplay != EGL_NO_DISPLAY) { |
1176 eglTerminate(gfdata->egldisplay); | |
1177 gfdata->egldisplay = EGL_NO_DISPLAY; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1178 } |
3139 | 1179 } |
1180 #endif /* SDL_VIDEO_OPENGL_ES */ | |
1181 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1182 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1183 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1184 /*****************************************************************************/ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1185 /* SDL Window Manager function */ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1186 /*****************************************************************************/ |
3139 | 1187 SDL_bool |
1188 qnxgf_getwindowwminfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1189 { |
3139 | 1190 /* QNX GF do not operates at window level, this means we are have no */ |
1191 /* Window Manager available, no specific data in SDL_SysWMinfo too */ | |
3092
cad1aefa2ed9
Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3087
diff
changeset
|
1192 |
3139 | 1193 if (info->version.major <= SDL_MAJOR_VERSION) { |
1194 return SDL_TRUE; | |
1195 } else { | |
1196 SDL_SetError("Application not compiled with SDL %d.%d\n", | |
1197 SDL_MAJOR_VERSION, SDL_MINOR_VERSION); | |
1198 return SDL_FALSE; | |
1199 } | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1200 |
3139 | 1201 /* Failed to get window manager information */ |
1202 return SDL_FALSE; | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1203 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1204 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1205 /*****************************************************************************/ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1206 /* SDL OpenGL/OpenGL ES functions */ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1207 /*****************************************************************************/ |
3139 | 1208 int |
1209 qnxgf_gl_loadlibrary(_THIS, const char *path) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1210 { |
3139 | 1211 #if defined(SDL_VIDEO_OPENGL_ES) |
1212 /* Check if OpenGL ES library is specified for GF driver */ | |
1213 if (path == NULL) { | |
1214 path = SDL_getenv("SDL_OPENGL_LIBRARY"); | |
1215 if (path == NULL) { | |
1216 path = SDL_getenv("SDL_OPENGLES_LIBRARY"); | |
1217 } | |
1218 } | |
1219 | |
1220 /* Check if default library loading requested */ | |
1221 if (path == NULL) { | |
1222 /* Already linked with GF library which provides egl* subset of */ | |
1223 /* functions, use Common profile of OpenGL ES library by default */ | |
1224 path = "/usr/lib/libGLES_CM.so.1"; | |
1225 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1226 |
3139 | 1227 /* Load dynamic library */ |
1228 _this->gl_config.dll_handle = SDL_LoadObject(path); | |
1229 if (!_this->gl_config.dll_handle) { | |
1230 /* Failed to load new GL ES library */ | |
1231 SDL_SetError("GF: Failed to locate OpenGL ES library"); | |
1232 return -1; | |
1233 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1234 |
3139 | 1235 /* Store OpenGL ES library path and name */ |
1236 SDL_strlcpy(_this->gl_config.driver_path, path, | |
1237 SDL_arraysize(_this->gl_config.driver_path)); | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1238 |
3139 | 1239 /* New OpenGL ES library is loaded */ |
1240 return 0; | |
1241 #else | |
1242 SDL_SetError("GF: OpenGL ES support is not compiled in"); | |
1243 return -1; | |
1244 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1245 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1246 |
3139 | 1247 void * |
1248 qnxgf_gl_getprocaddres(_THIS, const char *proc) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1249 { |
3139 | 1250 #if defined(SDL_VIDEO_OPENGL_ES) |
1251 void *function_address; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1252 |
3139 | 1253 /* Try to get function address through the egl interface */ |
1254 function_address = eglGetProcAddress(proc); | |
1255 if (function_address != NULL) { | |
1256 return function_address; | |
1257 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1258 |
3139 | 1259 /* Then try to get function in the OpenGL ES library */ |
1260 if (_this->gl_config.dll_handle) { | |
1261 function_address = | |
1262 SDL_LoadFunction(_this->gl_config.dll_handle, proc); | |
1263 if (function_address != NULL) { | |
1264 return function_address; | |
1265 } | |
1266 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1267 |
3139 | 1268 /* Add emulated OpenGL ES 1.1 functions */ |
1269 if (SDL_strcmp(proc, "glTexParameteri") == 0) { | |
1270 return glTexParameteri; | |
1271 } | |
1272 if (SDL_strcmp(proc, "glTexParameteriv") == 0) { | |
1273 return glTexParameteriv; | |
1274 } | |
1275 if (SDL_strcmp(proc, "glColor4ub") == 0) { | |
1276 return glColor4ub; | |
1277 } | |
1278 | |
1279 /* Failed to get GL ES function address pointer */ | |
1280 SDL_SetError("GF: Cannot locate OpenGL ES function name"); | |
1281 return NULL; | |
1282 #else | |
1283 SDL_SetError("GF: OpenGL ES support is not compiled in"); | |
1284 return NULL; | |
1285 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1286 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1287 |
3139 | 1288 void |
1289 qnxgf_gl_unloadlibrary(_THIS) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1290 { |
3139 | 1291 #if defined(SDL_VIDEO_OPENGL_ES) |
1292 /* Unload OpenGL ES library */ | |
1293 if (_this->gl_config.dll_handle) { | |
1294 SDL_UnloadObject(_this->gl_config.dll_handle); | |
1295 _this->gl_config.dll_handle = NULL; | |
1296 } | |
1297 #else | |
1298 SDL_SetError("GF: OpenGL ES support is not compiled in"); | |
1299 return; | |
1300 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1301 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1302 |
3139 | 1303 SDL_GLContext |
1304 qnxgf_gl_createcontext(_THIS, SDL_Window * window) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1305 { |
3139 | 1306 #if defined(SDL_VIDEO_OPENGL_ES) |
1307 SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; | |
1308 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | |
1309 SDL_DisplayData *didata = | |
1310 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
1311 EGLBoolean status; | |
1312 int32_t gfstatus; | |
1313 EGLint configs; | |
1314 uint32_t surfaces; | |
1315 uint32_t attr_pos; | |
1316 EGLint attr_value; | |
1317 EGLint cit; | |
1318 | |
1319 /* Choose buffeingr scheme */ | |
1320 if (!_this->gl_config.double_buffer) { | |
1321 surfaces = 1; | |
1322 } else { | |
1323 surfaces = 2; | |
1324 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1325 |
3139 | 1326 /* If driver has no support of video memory allocation, then */ |
1327 /* disable double buffering, use single buffer present copy */ | |
1328 if ((didata->caps & SDL_GF_VIDEOMEMORY) != SDL_GF_VIDEOMEMORY) { | |
1329 surfaces = 1; | |
1330 } | |
1331 | |
1332 /* Free main surface */ | |
1333 if (didata->surface[0] != NULL) { | |
1334 gf_surface_free(didata->surface[0]); | |
1335 didata->surface[0] = NULL; | |
1336 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1337 |
3139 | 1338 /* Free back surface */ |
1339 if (didata->surface[1] != NULL) { | |
1340 gf_surface_free(didata->surface[1]); | |
1341 didata->surface[1] = NULL; | |
1342 } | |
3116
b17f1ae7ad66
Added support for single buffering, if double buffering is not available.
Mike Gorchak <lestat@i.com.ua>
parents:
3109
diff
changeset
|
1343 |
3139 | 1344 /* Free second back surface */ |
1345 if (didata->surface[2] != NULL) { | |
1346 gf_surface_free(didata->surface[2]); | |
1347 didata->surface[2] = NULL; | |
1348 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1349 |
3139 | 1350 /* Detach layer before switch to new graphics mode */ |
1351 if (didata->layer_attached == SDL_TRUE) { | |
1352 /* Disable layer if hardware supports this */ | |
1353 gf_layer_disable(didata->layer); | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1354 |
3139 | 1355 /* Detach from layer, free it for others */ |
1356 gf_layer_detach(didata->layer); | |
1357 | |
1358 /* Mark it as detached */ | |
1359 didata->layer_attached = SDL_FALSE; | |
1360 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1361 |
3139 | 1362 /* Attach to main display layer */ |
1363 gfstatus = | |
1364 gf_layer_attach(&didata->layer, didata->display, | |
1365 didata->display_info.main_layer_index, 0); | |
1366 if (gfstatus != GF_ERR_OK) { | |
1367 SDL_SetError("GF: Couldn't attach to main layer, it could be busy"); | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1368 |
3139 | 1369 /* Failed to attach to main displayable layer */ |
1370 return NULL; | |
1371 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1372 |
3139 | 1373 /* Mark main display layer is attached */ |
1374 didata->layer_attached = SDL_TRUE; | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1375 |
3139 | 1376 /* Set layer source and destination viewport */ |
1377 gf_layer_set_src_viewport(didata->layer, 0, 0, didata->current_mode.w - 1, | |
1378 didata->current_mode.h - 1); | |
1379 gf_layer_set_dst_viewport(didata->layer, 0, 0, didata->current_mode.w - 1, | |
1380 didata->current_mode.h - 1); | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1381 |
3139 | 1382 /* Create main visible on display surface */ |
1383 gfstatus = | |
1384 gf_surface_create_layer(&didata->surface[0], &didata->layer, 1, 0, | |
1385 didata->current_mode.w, | |
1386 didata->current_mode.h, | |
1387 qnxgf_sdl_to_gf_pixelformat(didata-> | |
1388 current_mode. | |
1389 format), NULL, | |
1390 GF_SURFACE_CREATE_2D_ACCESSIBLE | | |
1391 GF_SURFACE_CREATE_3D_ACCESSIBLE | | |
1392 GF_SURFACE_CREATE_SHAREABLE); | |
1393 if (gfstatus != GF_ERR_OK) { | |
1394 gf_layer_disable(didata->layer); | |
1395 gf_layer_detach(didata->layer); | |
1396 didata->layer_attached = SDL_FALSE; | |
1397 SDL_SetError("GF: Can't create main layer surface at glctx (%d)\n", | |
1398 gfstatus); | |
1399 return NULL; | |
1400 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1401 |
3139 | 1402 /* Set just created surface as main visible on the layer */ |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1403 // gf_layer_set_surfaces(didata->layer, &didata->surface[0], 1); |
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1404 |
3139 | 1405 if (surfaces > 1) { |
1406 /* Create back display surface */ | |
1407 gfstatus = | |
1408 gf_surface_create_layer(&didata->surface[1], &didata->layer, 1, 0, | |
1409 didata->current_mode.w, | |
1410 didata->current_mode.h, | |
1411 qnxgf_sdl_to_gf_pixelformat(didata-> | |
1412 current_mode. | |
1413 format), NULL, | |
1414 GF_SURFACE_CREATE_2D_ACCESSIBLE | | |
1415 GF_SURFACE_CREATE_3D_ACCESSIBLE | | |
1416 GF_SURFACE_CREATE_SHAREABLE); | |
1417 if (gfstatus != GF_ERR_OK) { | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1418 gf_surface_free(didata->surface[0]); |
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1419 gf_layer_disable(didata->layer); |
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1420 gf_layer_detach(didata->layer); |
3139 | 1421 didata->layer_attached = SDL_FALSE; |
1422 SDL_SetError | |
1423 ("GF: Can't create main layer surface at glctx (%d)\n", | |
1424 gfstatus); | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1425 return NULL; |
3139 | 1426 } |
1427 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1428 |
3139 | 1429 /* Update layer parameters */ |
1430 gfstatus = gf_layer_update(didata->layer, GF_LAYER_UPDATE_NO_WAIT_IDLE); | |
1431 if (gfstatus != GF_ERR_OK) { | |
1432 /* Free main and back surfaces */ | |
1433 gf_surface_free(didata->surface[1]); | |
1434 didata->surface[1] = NULL; | |
1435 gf_surface_free(didata->surface[0]); | |
1436 didata->surface[0] = NULL; | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1437 |
3139 | 1438 /* Detach layer */ |
1439 gf_layer_disable(didata->layer); | |
1440 gf_layer_detach(didata->layer); | |
1441 didata->layer_attached = SDL_FALSE; | |
1442 SDL_SetError("GF: Can't update layer parameters\n"); | |
1443 return NULL; | |
1444 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1445 |
3139 | 1446 /* Enable layer in case if hardware supports layer enable/disable */ |
1447 gf_layer_enable(didata->layer); | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1448 |
3139 | 1449 /* Prepare attributes list to pass them to OpenGL ES */ |
1450 attr_pos = 0; | |
1451 wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID; | |
1452 wdata->gles_attributes[attr_pos++] = | |
1453 qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format); | |
1454 wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE; | |
1455 wdata->gles_attributes[attr_pos++] = _this->gl_config.red_size; | |
1456 wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE; | |
1457 wdata->gles_attributes[attr_pos++] = _this->gl_config.green_size; | |
1458 wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE; | |
1459 wdata->gles_attributes[attr_pos++] = _this->gl_config.blue_size; | |
1460 wdata->gles_attributes[attr_pos++] = EGL_ALPHA_SIZE; | |
1461 if (_this->gl_config.alpha_size) { | |
1462 wdata->gles_attributes[attr_pos++] = _this->gl_config.alpha_size; | |
1463 } else { | |
1464 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1465 } | |
3412
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1466 |
3139 | 1467 wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE; |
3412
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1468 if (_this->gl_config.depth_size) { |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1469 wdata->gles_attributes[attr_pos++] = _this->gl_config.depth_size; |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1470 } else { |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1471 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1472 } |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1473 |
3139 | 1474 if (_this->gl_config.buffer_size) { |
1475 wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE; | |
1476 wdata->gles_attributes[attr_pos++] = _this->gl_config.buffer_size; | |
1477 } | |
1478 if (_this->gl_config.stencil_size) { | |
1479 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; | |
3412
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1480 wdata->gles_attributes[attr_pos++] = _this->gl_config.stencil_size; |
3139 | 1481 } |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1482 |
3139 | 1483 /* Set number of samples in multisampling */ |
1484 if (_this->gl_config.multisamplesamples) { | |
1485 wdata->gles_attributes[attr_pos++] = EGL_SAMPLES; | |
1486 wdata->gles_attributes[attr_pos++] = | |
1487 _this->gl_config.multisamplesamples; | |
1488 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1489 |
3139 | 1490 /* Multisample buffers, OpenGL ES 1.0 spec defines 0 or 1 buffer */ |
1491 if (_this->gl_config.multisamplebuffers) { | |
1492 wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS; | |
1493 wdata->gles_attributes[attr_pos++] = | |
1494 _this->gl_config.multisamplebuffers; | |
1495 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1496 |
3139 | 1497 /* Finish attributes list */ |
1498 wdata->gles_attributes[attr_pos] = EGL_NONE; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1499 |
3139 | 1500 /* Request first suitable framebuffer configuration */ |
1501 status = eglChooseConfig(gfdata->egldisplay, wdata->gles_attributes, | |
1502 wdata->gles_configs, SDL_VIDEO_GF_OPENGLES_CONFS, | |
1503 &configs); | |
1504 if (status != EGL_TRUE) { | |
1505 SDL_SetError("GF: Can't find closest configuration for OpenGL ES"); | |
1506 return NULL; | |
1507 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1508 |
3139 | 1509 /* Check if nothing has been found, try "don't care" settings */ |
1510 if (configs == 0) { | |
1511 int32_t it; | |
1512 int32_t jt; | |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1513 static const GLint depthbits[4] = { 32, 24, 16, EGL_DONT_CARE }; |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1514 |
3139 | 1515 for (it = 0; it < 4; it++) { |
1516 for (jt = 16; jt >= 0; jt--) { | |
1517 /* Don't care about color buffer bits, use what exist */ | |
1518 /* Replace previous data set with EGL_DONT_CARE */ | |
1519 attr_pos = 0; | |
1520 wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID; | |
1521 wdata->gles_attributes[attr_pos++] = | |
1522 qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format); | |
1523 wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE; | |
1524 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1525 wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE; | |
1526 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1527 wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE; | |
1528 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1529 wdata->gles_attributes[attr_pos++] = EGL_ALPHA_SIZE; | |
1530 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1531 wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE; | |
1532 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1533 |
3139 | 1534 /* Try to find requested or smallest depth */ |
1535 if (_this->gl_config.depth_size) { | |
1536 wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE; | |
1537 wdata->gles_attributes[attr_pos++] = depthbits[it]; | |
1538 } else { | |
1539 wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE; | |
1540 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1541 } | |
1542 | |
1543 if (_this->gl_config.stencil_size) { | |
1544 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; | |
1545 wdata->gles_attributes[attr_pos++] = jt; | |
1546 } else { | |
1547 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; | |
1548 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1549 |
3139 | 1550 /* exit from stencil loop */ |
1551 jt = 0; | |
1552 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1553 |
3139 | 1554 /* Don't care about antialiasing */ |
1555 wdata->gles_attributes[attr_pos++] = EGL_SAMPLES; | |
1556 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1557 wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS; | |
1558 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; | |
1559 wdata->gles_attributes[attr_pos] = EGL_NONE; | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1560 |
3139 | 1561 /* Request first suitable framebuffer configuration */ |
1562 status = | |
1563 eglChooseConfig(gfdata->egldisplay, | |
1564 wdata->gles_attributes, | |
1565 wdata->gles_configs, | |
1566 SDL_VIDEO_GF_OPENGLES_CONFS, &configs); | |
1567 if (status != EGL_TRUE) { | |
1568 SDL_SetError | |
3185
44d5474c2c8a
Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents:
3139
diff
changeset
|
1569 ("GF: Can't find closest configuration for OpenGL ES"); |
3139 | 1570 return NULL; |
1571 } | |
1572 if (configs != 0) { | |
1573 break; | |
1574 } | |
1575 } | |
1576 if (configs != 0) { | |
1577 break; | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1578 } |
3139 | 1579 } |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1580 |
3139 | 1581 /* No available configs */ |
1582 if (configs == 0) { | |
3186 | 1583 SDL_SetError("GF: Can't find any configuration for OpenGL ES"); |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1584 return NULL; |
3139 | 1585 } |
1586 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1587 |
3139 | 1588 /* Initialize config index */ |
1589 wdata->gles_config = 0; | |
1590 | |
1591 /* Now check each configuration to find out the best */ | |
1592 for (cit = 0; cit < configs; cit++) { | |
1593 uint32_t stencil_found; | |
1594 uint32_t depth_found; | |
3412
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1595 EGLint cur_depth; |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1596 EGLint cur_stencil; |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1597 |
3139 | 1598 stencil_found = 0; |
1599 depth_found = 0; | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1600 |
3139 | 1601 if (_this->gl_config.stencil_size) { |
1602 status = | |
1603 eglGetConfigAttrib(gfdata->egldisplay, | |
1604 wdata->gles_configs[cit], EGL_STENCIL_SIZE, | |
3412
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1605 &cur_stencil); |
3139 | 1606 if (status == EGL_TRUE) { |
1607 if (attr_value != 0) { | |
1608 stencil_found = 1; | |
1609 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1610 } |
3139 | 1611 } else { |
1612 stencil_found = 1; | |
1613 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1614 |
3139 | 1615 if (_this->gl_config.depth_size) { |
1616 status = | |
1617 eglGetConfigAttrib(gfdata->egldisplay, | |
1618 wdata->gles_configs[cit], EGL_DEPTH_SIZE, | |
3412
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1619 &cur_depth); |
3139 | 1620 if (status == EGL_TRUE) { |
1621 if (attr_value != 0) { | |
1622 depth_found = 1; | |
1623 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1624 } |
3139 | 1625 } else { |
1626 depth_found = 1; | |
1627 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1628 |
3139 | 1629 /* Exit from loop if found appropriate configuration */ |
1630 if ((depth_found != 0) && (stencil_found != 0)) { | |
3412
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1631 /* Store last satisfied configuration id */ |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1632 wdata->gles_config = cit; |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1633 |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1634 if (cur_depth==_this->gl_config.depth_size) |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1635 { |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1636 /* Exact match on depth bits */ |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1637 if (!_this->gl_config.stencil_size) |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1638 { |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1639 /* Stencil is not required */ |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1640 break; |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1641 } |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1642 else |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1643 { |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1644 if (cur_stencil==_this->gl_config.stencil_size) |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1645 { |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1646 /* Exact match on stencil bits */ |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1647 break; |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1648 } |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1649 } |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1650 } |
3139 | 1651 } |
1652 } | |
1653 | |
3412
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1654 /* If best could not be found, use first or last satisfied */ |
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1655 if ((cit == configs) && (wdata->gles_config==0)) { |
3139 | 1656 cit = 0; |
3412
fe9c8a5cab51
Fixes in GLES configuration selection.
Mike Gorchak <lestat@i.com.ua>
parents:
3186
diff
changeset
|
1657 wdata->gles_config = cit; |
3139 | 1658 } |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1659 |
3139 | 1660 /* Create OpenGL ES context */ |
1661 wdata->gles_context = | |
1662 eglCreateContext(gfdata->egldisplay, | |
1663 wdata->gles_configs[wdata->gles_config], | |
1664 EGL_NO_CONTEXT, NULL); | |
1665 if (wdata->gles_context == EGL_NO_CONTEXT) { | |
1666 SDL_SetError("GF: OpenGL ES context creation has been failed"); | |
1667 return NULL; | |
1668 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1669 |
3139 | 1670 /* Free any 3D target if it was created before */ |
1671 if (wdata->target_created == SDL_TRUE) { | |
1672 gf_3d_target_free(wdata->target); | |
1673 wdata->target_created == SDL_FALSE; | |
1674 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1675 |
3139 | 1676 /* Create surface(s) target for OpenGL ES */ |
1677 gfstatus = | |
1678 gf_3d_target_create(&wdata->target, didata->layer, | |
1679 &didata->surface[0], surfaces, | |
1680 didata->current_mode.w, didata->current_mode.h, | |
1681 qnxgf_sdl_to_gf_pixelformat(didata->current_mode. | |
1682 format)); | |
1683 if (gfstatus != GF_ERR_OK) { | |
1684 /* Destroy just created context */ | |
1685 eglDestroyContext(gfdata->egldisplay, wdata->gles_context); | |
1686 wdata->gles_context = EGL_NO_CONTEXT; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1687 |
3139 | 1688 /* Mark 3D target as unallocated */ |
1689 wdata->target_created = SDL_FALSE; | |
1690 SDL_SetError("GF: OpenGL ES target could not be created"); | |
1691 return NULL; | |
1692 } else { | |
1693 wdata->target_created = SDL_TRUE; | |
1694 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1695 |
3139 | 1696 /* Create target rendering surface on whole screen */ |
1697 wdata->gles_surface = | |
1698 eglCreateWindowSurface(gfdata->egldisplay, | |
1699 wdata->gles_configs[wdata->gles_config], | |
1700 wdata->target, NULL); | |
1701 if (wdata->gles_surface == EGL_NO_SURFACE) { | |
1702 /* Destroy 3d target */ | |
1703 gf_3d_target_free(wdata->target); | |
1704 wdata->target_created = SDL_FALSE; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1705 |
3139 | 1706 /* Destroy OpenGL ES context */ |
1707 eglDestroyContext(gfdata->egldisplay, wdata->gles_context); | |
1708 wdata->gles_context = EGL_NO_CONTEXT; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1709 |
3139 | 1710 SDL_SetError("GF: OpenGL ES surface could not be created"); |
1711 return NULL; | |
1712 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1713 |
3139 | 1714 /* Make just created context current */ |
1715 status = | |
1716 eglMakeCurrent(gfdata->egldisplay, wdata->gles_surface, | |
1717 wdata->gles_surface, wdata->gles_context); | |
1718 if (status != EGL_TRUE) { | |
1719 /* Destroy OpenGL ES surface */ | |
1720 eglDestroySurface(gfdata->egldisplay, wdata->gles_surface); | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1721 |
3139 | 1722 /* Destroy 3d target */ |
1723 gf_3d_target_free(wdata->target); | |
1724 wdata->target_created = SDL_FALSE; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1725 |
3139 | 1726 /* Destroy OpenGL ES context */ |
1727 eglDestroyContext(gfdata->egldisplay, wdata->gles_context); | |
1728 wdata->gles_context = EGL_NO_CONTEXT; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1729 |
3139 | 1730 /* Failed to set current GL ES context */ |
1731 SDL_SetError("GF: Can't set OpenGL ES context on creation"); | |
1732 return NULL; | |
1733 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1734 |
3139 | 1735 /* Setup into SDL internals state of OpenGL ES: */ |
1736 /* it is accelerated or not */ | |
1737 if ((didata->caps & SDL_GF_ACCELERATED_3D) == SDL_GF_ACCELERATED_3D) { | |
1738 _this->gl_config.accelerated = 1; | |
1739 } else { | |
1740 _this->gl_config.accelerated = 0; | |
1741 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1742 |
3139 | 1743 /* Always clear stereo enable, since OpenGL ES do not supports stereo */ |
1744 _this->gl_config.stereo = 0; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1745 |
3139 | 1746 /* Get back samples and samplebuffers configurations. Rest framebuffer */ |
1747 /* parameters could be obtained through the OpenGL ES API */ | |
1748 status = | |
1749 eglGetConfigAttrib(gfdata->egldisplay, | |
1750 wdata->gles_configs[wdata->gles_config], | |
1751 EGL_SAMPLES, &attr_value); | |
1752 if (status == EGL_TRUE) { | |
1753 _this->gl_config.multisamplesamples = attr_value; | |
1754 } | |
1755 status = | |
1756 eglGetConfigAttrib(gfdata->egldisplay, | |
1757 wdata->gles_configs[wdata->gles_config], | |
1758 EGL_SAMPLE_BUFFERS, &attr_value); | |
1759 if (status == EGL_TRUE) { | |
1760 _this->gl_config.multisamplebuffers = attr_value; | |
1761 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1762 |
3139 | 1763 /* Get back stencil and depth buffer sizes */ |
1764 status = | |
1765 eglGetConfigAttrib(gfdata->egldisplay, | |
1766 wdata->gles_configs[wdata->gles_config], | |
1767 EGL_DEPTH_SIZE, &attr_value); | |
1768 if (status == EGL_TRUE) { | |
1769 _this->gl_config.depth_size = attr_value; | |
1770 } | |
1771 status = | |
1772 eglGetConfigAttrib(gfdata->egldisplay, | |
1773 wdata->gles_configs[wdata->gles_config], | |
1774 EGL_STENCIL_SIZE, &attr_value); | |
1775 if (status == EGL_TRUE) { | |
1776 _this->gl_config.stencil_size = attr_value; | |
1777 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1778 |
3139 | 1779 /* Restore cursor if it was visible */ |
1780 if (didata->cursor_visible == SDL_TRUE) { | |
1781 gf_cursor_set(didata->display, 0, &didata->cursor); | |
1782 gf_cursor_enable(didata->display, 0); | |
1783 } | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1784 |
3139 | 1785 /* GL ES context was successfully created */ |
1786 return wdata->gles_context; | |
1787 #else | |
1788 SDL_SetError("GF: OpenGL ES support is not compiled in"); | |
1789 return NULL; | |
1790 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1791 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1792 |
3139 | 1793 int |
1794 qnxgf_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1795 { |
3139 | 1796 #if defined(SDL_VIDEO_OPENGL_ES) |
1797 SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; | |
1798 SDL_WindowData *wdata; | |
1799 EGLBoolean status; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1800 |
3139 | 1801 if ((window == NULL) && (context == NULL)) { |
1802 status = | |
1803 eglMakeCurrent(gfdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, | |
1804 EGL_NO_CONTEXT); | |
1805 if (status != EGL_TRUE) { | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1806 /* Failed to set current GL ES context */ |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1807 SDL_SetError("GF: Can't set OpenGL ES context"); |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1808 return -1; |
3139 | 1809 } |
1810 } else { | |
1811 wdata = (SDL_WindowData *) window->driverdata; | |
1812 status = | |
1813 eglMakeCurrent(gfdata->egldisplay, wdata->gles_surface, | |
1814 wdata->gles_surface, wdata->gles_context); | |
1815 if (status != EGL_TRUE) { | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1816 /* Failed to set current GL ES context */ |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1817 SDL_SetError("GF: Can't set OpenGL ES context"); |
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1818 return -1; |
3139 | 1819 } |
1820 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1821 |
3139 | 1822 return 0; |
1823 #else | |
1824 SDL_SetError("GF: OpenGL ES support is not compiled in"); | |
1825 return -1; | |
1826 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1827 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1828 |
3139 | 1829 int |
1830 qnxgf_gl_setswapinterval(_THIS, int interval) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1831 { |
3139 | 1832 #if defined(SDL_VIDEO_OPENGL_ES) |
1833 SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; | |
1834 EGLBoolean status; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1835 |
3139 | 1836 /* Check if OpenGL ES connection has been initialized */ |
1837 if (gfdata->egldisplay != EGL_NO_DISPLAY) { | |
1838 /* Set swap OpenGL ES interval */ | |
1839 status = eglSwapInterval(gfdata->egldisplay, interval); | |
1840 if (status == EGL_TRUE) { | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1841 /* Return success to upper level */ |
3139 | 1842 gfdata->swapinterval = interval; |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1843 return 0; |
3139 | 1844 } |
1845 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1846 |
3139 | 1847 /* Failed to set swap interval */ |
1848 SDL_SetError("GF: Cannot set swap interval"); | |
1849 return -1; | |
1850 #else | |
1851 SDL_SetError("GF: OpenGL ES support is not compiled in"); | |
1852 return -1; | |
1853 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1854 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1855 |
3139 | 1856 int |
1857 qnxgf_gl_getswapinterval(_THIS) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1858 { |
3139 | 1859 #if defined(SDL_VIDEO_OPENGL_ES) |
1860 SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1861 |
3139 | 1862 /* Return default swap interval value */ |
1863 return gfdata->swapinterval; | |
1864 #else | |
1865 SDL_SetError("GF: OpenGL ES support is not compiled in"); | |
1866 return -1; | |
1867 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1868 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1869 |
3139 | 1870 void |
1871 qnxgf_gl_swapwindow(_THIS, SDL_Window * window) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1872 { |
3139 | 1873 #if defined(SDL_VIDEO_OPENGL_ES) |
1874 SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; | |
1875 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1876 |
3139 | 1877 /* Finish all drawings */ |
1878 glFinish(); | |
3109
7b3a09fb9c8b
Support for HID devices (mice and keyboards only for now) has been added
Mike Gorchak <lestat@i.com.ua>
parents:
3099
diff
changeset
|
1879 |
3139 | 1880 /* Swap buffers */ |
1881 eglSwapBuffers(gfdata->egldisplay, wdata->gles_surface); | |
1882 #else | |
1883 SDL_SetError("GF: OpenGL ES support is not compiled in"); | |
1884 return; | |
1885 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1886 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1887 |
3139 | 1888 void |
1889 qnxgf_gl_deletecontext(_THIS, SDL_GLContext context) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1890 { |
3139 | 1891 #if defined(SDL_VIDEO_OPENGL_ES) |
1892 SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; | |
1893 EGLBoolean status; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1894 |
3139 | 1895 /* Check if OpenGL ES connection has been initialized */ |
1896 if (gfdata->egldisplay != EGL_NO_DISPLAY) { | |
1897 if (context != EGL_NO_CONTEXT) { | |
1898 status = eglDestroyContext(gfdata->egldisplay, context); | |
1899 if (status != EGL_TRUE) { | |
1900 /* Error during OpenGL ES context destroying */ | |
1901 SDL_SetError("GF: OpenGL ES context destroy error"); | |
1902 return; | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1903 } |
3139 | 1904 } |
1905 } | |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3092
diff
changeset
|
1906 |
3139 | 1907 return; |
1908 #else | |
1909 SDL_SetError("GF: OpenGL ES support is not compiled in"); | |
1910 return; | |
1911 #endif /* SDL_VIDEO_OPENGL_ES */ | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1912 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1913 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1914 /*****************************************************************************/ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1915 /* SDL Event handling function */ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1916 /*****************************************************************************/ |
3139 | 1917 void |
1918 qnxgf_pumpevents(_THIS) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1919 { |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1920 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1921 |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1922 /*****************************************************************************/ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1923 /* SDL screen saver related functions */ |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1924 /*****************************************************************************/ |
3139 | 1925 void |
1926 qnxgf_suspendscreensaver(_THIS) | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1927 { |
3139 | 1928 /* There is no screensaver in pure console, it may exist when running */ |
1929 /* GF under Photon, but I do not know, how to disable screensaver */ | |
3087
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1930 } |
0b6f51c29267
Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
3083
diff
changeset
|
1931 |
3083
0bc41e0361d3
Date: Mon, 2 Mar 2009 16:27:42 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1932 /* vi: set ts=4 sw=4 expandtab: */ |