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