comparison src/video/qnxgf/SDL_qnxgf.c @ 3092:cad1aefa2ed9

Date: Thu, 12 Mar 2009 15:14:38 +0200 From: "Mike Gorchak" Subject: New QNX patches In photon.tar.gz there are new files to be placed into ./src/video/photon/ directory. qnx3.diff - new patches for QNX support. Since I've found a lot of bugs in the new GF QNX Graphics Framework and I'm suspended development for GF driver until already found bugs will be fixed and switched to Photon driver implementation. sdl.diff - I've found that renderer creation result has not been checked and SDL shows error like: "there is no current renderer", now SDL will show correct error which was set be renderer.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 17 Mar 2009 03:24:22 +0000
parents 0b6f51c29267
children 82e60908fab1
comparison
equal deleted inserted replaced
3091:32efcc94b3da 3092:cad1aefa2ed9
16 License along with this library; if not, write to the Free Software 16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 18
19 Sam Lantinga 19 Sam Lantinga
20 slouken@libsdl.org 20 slouken@libsdl.org
21
22 QNX Graphics Framework SDL driver
23 Copyright (C) 2009 Mike Gorchak
24 (mike@malva.ua, lestat@i.com.ua)
21 */ 25 */
22 26
23 #include "SDL_config.h" 27 #include "SDL_config.h"
24 28
25 #include "../SDL_sysvideo.h" 29 #include "../SDL_sysvideo.h"
28 32
29 /* Include QNX Graphics Framework declarations */ 33 /* Include QNX Graphics Framework declarations */
30 #include <gf/gf.h> 34 #include <gf/gf.h>
31 35
32 #include "SDL_qnxgf.h" 36 #include "SDL_qnxgf.h"
37 #include "SDL_gf_render.h"
33 #include "SDL_gf_pixelfmt.h" 38 #include "SDL_gf_pixelfmt.h"
34 39
35 /******************************************************************************/ 40 /******************************************************************************/
36 /* SDL Generic video modes, which could provide GF */ 41 /* SDL Generic video modes, which could provide GF */
37 /* This is real pain in the ass. GF is just wrapper around a selected driver */ 42 /* This is real pain in the ass. GF is just wrapper around a selected driver */
60 {0, 1024, 768, 75, NULL}, 65 {0, 1024, 768, 75, NULL},
61 {0, 1280, 720, 60, NULL}, /* 1280x720 mode is 60Hz only */ 66 {0, 1280, 720, 60, NULL}, /* 1280x720 mode is 60Hz only */
62 {0, 1280, 768, 60, NULL}, /* 1280x768 mode is 60Hz only */ 67 {0, 1280, 768, 60, NULL}, /* 1280x768 mode is 60Hz only */
63 {0, 1280, 800, 60, NULL}, /* 1280x800 mode is 60Hz only */ 68 {0, 1280, 800, 60, NULL}, /* 1280x800 mode is 60Hz only */
64 {0, 1280, 960, 60, NULL}, /* 1280x960 mode is 60Hz only */ 69 {0, 1280, 960, 60, NULL}, /* 1280x960 mode is 60Hz only */
65 {0, 1280, 1024, 60, NULL}, /* 1280x1024 mode is 60Hz only */ 70 {0, 1280, 1024, 60, NULL}, /* 1280x1024 modes are 60Hz, 75Hz, 85Hz and */
71 {0, 1280, 1024, 75, NULL}, /* 100 Hz */
72 {0, 1280, 1024, 85, NULL}, /* */
73 {0, 1280, 1024, 100, NULL}, /* */
66 {0, 1400, 1050, 60, NULL}, /* 1400x1050 mode is 60Hz only */ 74 {0, 1400, 1050, 60, NULL}, /* 1400x1050 mode is 60Hz only */
67 {0, 1440, 900, 60, NULL}, /* 1440x900 mode is 60Hz only */ 75 {0, 1440, 900, 60, NULL}, /* 1440x900 mode is 60Hz only */
68 {0, 1440, 960, 60, NULL}, /* 1440x960 mode is 60Hz only */ 76 {0, 1440, 960, 60, NULL}, /* 1440x960 mode is 60Hz only */
69 {0, 1600, 1200, 60, NULL}, /* 1600x1200 mode is 60Hz only */ 77 {0, 1600, 1200, 60, NULL}, /* 1600x1200 mode is 60Hz only */
70 {0, 1680, 1050, 60, NULL}, /* 1680x1050 mode is 60Hz only */ 78 {0, 1680, 1050, 60, NULL}, /* 1680x1050 mode is 60Hz only */
73 {0, 2048, 1536, 60, NULL}, /* 2048x1536 mode is 60Hz only */ 81 {0, 2048, 1536, 60, NULL}, /* 2048x1536 mode is 60Hz only */
74 {0, 2048, 1080, 60, NULL}, /* 2048x1080 mode is 60Hz only */ 82 {0, 2048, 1080, 60, NULL}, /* 2048x1080 mode is 60Hz only */
75 {0, 0, 0, 0, NULL} /* End of generic mode list */ 83 {0, 0, 0, 0, NULL} /* End of generic mode list */
76 }; 84 };
77 85
86 /* Low level device graphics driver names, which they are reporting */
87 GF_DeviceCaps gf_devicename[]=
88 {
89 /* ATI Rage 128 graphics driver (devg-ati_rage128) */
90 {"ati_rage128", SDL_GF_ACCELERATED},
91 /* Fujitsu Carmine graphics driver (devg-carmine.so) */
92 {"carmine", SDL_GF_ACCELERATED},
93 /* C&T graphics driver (devg-chips.so) */
94 {"chips", SDL_GF_ACCELERATED},
95 /* Fujitsu Coral graphics driver (devg-coral.so) */
96 {"coral", SDL_GF_ACCELERATED},
97 /* Intel integrated graphics driver (devg-extreme2.so) */
98 {"extreme2", SDL_GF_ACCELERATED},
99 /* Unaccelerated FB driver (devg-flat.so) */
100 {"flat", SDL_GF_UNACCELERATED},
101 /* NS Geode graphics driver (devg-geode.so) */
102 {"geode", SDL_GF_ACCELERATED},
103 /* Geode LX graphics driver (devg-geodelx.so) */
104 {"geodelx", SDL_GF_ACCELERATED},
105 /* Intel integrated graphics driver (devg-gma9xx.so) */
106 {"gma", SDL_GF_ACCELERATED},
107 /* Intel integrated graphics driver (devg-i810.so) */
108 {"i810", SDL_GF_ACCELERATED},
109 /* Intel integrated graphics driver (devg-i830.so) */
110 {"i830", SDL_GF_ACCELERATED},
111 /* Geode LX graphics driver (devg-lx800.so) */
112 {"lx800", SDL_GF_ACCELERATED},
113 /* Matrox Gxx graphics driver (devg-matroxg.so) */
114 {"matroxg", SDL_GF_ACCELERATED},
115 /* Intel Poulsbo graphics driver (devg-poulsbo.so) */
116 {"poulsbo", SDL_GF_ACCELERATED},
117 /* ATI Radeon driver (devg-radeon.so) */
118 {"radeon", SDL_GF_ACCELERATED},
119 /* ATI Rage driver (devg-rage.so) */
120 {"rage", SDL_GF_ACCELERATED},
121 /* S3 Savage graphics driver (devg-s3_savage.so) */
122 {"s3_savage", SDL_GF_ACCELERATED},
123 /* SiS630 integrated graphics driver (devg-sis630.so) */
124 {"sis630", SDL_GF_ACCELERATED},
125 /* PowerVR SGX 535 graphics driver (devg-poulsbo.so) */
126 {"sgx", SDL_GF_ACCELERATED},
127 /* SM Voyager GX graphics driver (devg-smi5xx.so) */
128 {"smi5xx", SDL_GF_ACCELERATED},
129 /* Silicon Motion graphics driver (devg-smi7xx.so) */
130 {"smi7xx", SDL_GF_ACCELERATED},
131 /* SVGA unaccelerated gfx driver (devg-svga.so) */
132 {"svga", SDL_GF_UNACCELERATED},
133 /* nVidia TNT graphics driver (devg-tnt.so) */
134 {"tnt", SDL_GF_ACCELERATED},
135 /* VIA integrated graphics driver (devg-tvia.so) */
136 {"tvia", SDL_GF_ACCELERATED},
137 /* VIA UniChrome graphics driver (devg-unichrome.so) */
138 {"unichrome", SDL_GF_ACCELERATED},
139 /* VESA unaccelerated gfx driver (devg-vesa.so) */
140 {"vesa", SDL_GF_UNACCELERATED},
141 /* VmWare graphics driver (devg-volari.so) */
142 {"vmware", SDL_GF_ACCELERATED},
143 /* XGI XP10 graphics driver (devg-volari.so) */
144 {"volari", SDL_GF_ACCELERATED},
145 /* End of list */
146 {NULL, 0x00000000}
147 };
148
78 /*****************************************************************************/ 149 /*****************************************************************************/
79 /* SDL Video Device initialization functions */ 150 /* SDL Video Device initialization functions */
80 /*****************************************************************************/ 151 /*****************************************************************************/
81 152
82 static int qnxgf_available(void) 153 static int qnxgf_available(void)
108 gf_dev_detach(gfdata->gfdev); 179 gf_dev_detach(gfdata->gfdev);
109 } 180 }
110 181
111 if (device->driverdata!=NULL) 182 if (device->driverdata!=NULL)
112 { 183 {
113 SDL_free(device->driverdata);
114 device->driverdata=NULL; 184 device->driverdata=NULL;
115 } 185 }
116 SDL_free(device);
117 } 186 }
118 187
119 static SDL_VideoDevice* qnxgf_create(int devindex) 188 static SDL_VideoDevice* qnxgf_create(int devindex)
120 { 189 {
121 SDL_VideoDevice* device; 190 SDL_VideoDevice* device;
122 SDL_VideoData* gfdata; 191 SDL_VideoData* gfdata;
123 int status; 192 int status;
124 193
125 /* Initialize SDL_VideoDevice structure */ 194 /* Initialize SDL_VideoDevice structure */
126 device = (SDL_VideoDevice*)SDL_calloc(1, sizeof(SDL_VideoDevice)); 195 device=(SDL_VideoDevice*)SDL_calloc(1, sizeof(SDL_VideoDevice));
127 if (device==NULL) 196 if (device==NULL)
128 { 197 {
129 SDL_OutOfMemory(); 198 SDL_OutOfMemory();
130 return NULL; 199 return NULL;
131 } 200 }
132 201
133 /* Initialize internal GF specific data */ 202 /* Initialize internal GF specific data */
134 gfdata = (SDL_VideoData*)SDL_calloc(1, sizeof(SDL_VideoData)); 203 gfdata=(SDL_VideoData*)SDL_calloc(1, sizeof(SDL_VideoData));
135 if (gfdata==NULL) 204 if (gfdata==NULL)
136 { 205 {
137 SDL_OutOfMemory(); 206 SDL_OutOfMemory();
138 SDL_free(device); 207 SDL_free(device);
139 return NULL; 208 return NULL;
210 /*****************************************************************************/ 279 /*****************************************************************************/
211 int qnxgf_videoinit(_THIS) 280 int qnxgf_videoinit(_THIS)
212 { 281 {
213 SDL_VideoData* gfdata=(SDL_VideoData*)_this->driverdata; 282 SDL_VideoData* gfdata=(SDL_VideoData*)_this->driverdata;
214 uint32_t it; 283 uint32_t it;
284 uint32_t jt;
285 char* override;
215 286
216 /* Add each detected output to SDL */ 287 /* Add each detected output to SDL */
217 for (it=0; it<gfdata->gfdev_info.ndisplays; it++) 288 for (it=0; it<gfdata->gfdev_info.ndisplays; it++)
218 { 289 {
219 SDL_VideoDisplay display; 290 SDL_VideoDisplay display;
241 } 312 }
242 else 313 else
243 { 314 {
244 /* video initialization problem */ 315 /* video initialization problem */
245 SDL_free(didata); 316 SDL_free(didata);
246 SDL_SetError("Display query failed"); 317 SDL_SetError("display query failed");
247 return -1; 318 return -1;
248 } 319 }
249 320
250 /* Attach GF to selected display */ 321 /* Attach GF to selected display */
251 status=gf_display_attach(&didata->display, gfdata->gfdev, it, NULL); 322 status=gf_display_attach(&didata->display, gfdata->gfdev, it, NULL);
252 if (status!=GF_ERR_OK) 323 if (status!=GF_ERR_OK)
253 { 324 {
254 /* video initialization problem */ 325 /* video initialization problem */
255 SDL_free(didata); 326 SDL_free(didata);
256 SDL_SetError("Couldn't not attach to display"); 327 SDL_SetError("couldn't attach to display");
257 return -1; 328 return -1;
258 } 329 }
259 330
331 /* Initialize status variables */
332 didata->layer_attached=SDL_FALSE;
333
334 /* Attach to main display layer */
335 status=gf_layer_attach(&didata->layer, didata->display, didata->display_info.main_layer_index, 0);
336 if (status!=GF_ERR_OK)
337 {
338 SDL_SetError("couldn't attach to main layer, it could be busy");
339
340 /* Failed to attach to main layer */
341 return -1;
342 }
343
344 /* Enable layer in case if hardware supports layer enable/disable */
345 gf_layer_enable(didata->layer);
346
347 /* Mark main display layer is attached */
348 didata->layer_attached=SDL_TRUE;
349
350 /* Copy device name for each display */
351 SDL_strlcpy(didata->description, gfdata->gfdev_info.description, SDL_VIDEO_GF_DEVICENAME_MAX-1);
352
353 /* Search device capabilities and possible workarounds */
354 jt=0;
355 do {
356 if (gf_devicename[jt].name==NULL)
357 {
358 break;
359 }
360 if (SDL_strncmp(gf_devicename[jt].name, didata->description, SDL_strlen(gf_devicename[jt].name))==0)
361 {
362 didata->caps=gf_devicename[jt].caps;
363 }
364 jt++;
365 } while(1);
366
367 /* Initialize display structure */
260 SDL_zero(display); 368 SDL_zero(display);
261 display.desktop_mode = current_mode; 369 display.desktop_mode = current_mode;
262 display.current_mode = current_mode; 370 display.current_mode = current_mode;
263 display.driverdata = didata; 371 display.driverdata = didata;
372 didata->current_mode=current_mode;
264 SDL_AddVideoDisplay(&display); 373 SDL_AddVideoDisplay(&display);
265 } 374
375 /* Check for environment variables which could override some SDL settings */
376 didata->custom_refresh=0;
377 override = SDL_getenv("SDL_VIDEO_GF_REFRESH_RATE");
378 if (override!=NULL)
379 {
380 if (SDL_sscanf(override, "%u", &didata->custom_refresh)!=1)
381 {
382 didata->custom_refresh=0;
383 }
384 }
385 }
386
387 /* Add GF renderer to SDL */
388 gf_addrenderdriver(_this);
266 389
267 /* video has been initialized successfully */ 390 /* video has been initialized successfully */
268 return 1; 391 return 1;
269 } 392 }
270 393
271 void qnxgf_videoquit(_THIS) 394 void qnxgf_videoquit(_THIS)
272 { 395 {
273 SDL_DisplayData* didata; 396 SDL_DisplayData* didata;
274 uint32_t it; 397 uint32_t it;
275 398
399 /* SDL will restore our desktop mode on exit */
276 for(it=0; it<_this->num_displays; it++) 400 for(it=0; it<_this->num_displays; it++)
277 { 401 {
278 didata=_this->displays[it].driverdata; 402 didata=_this->displays[it].driverdata;
279 403
280 /* Detach from selected display */ 404 /* Detach from selected display */
282 } 406 }
283 } 407 }
284 408
285 void qnxgf_getdisplaymodes(_THIS) 409 void qnxgf_getdisplaymodes(_THIS)
286 { 410 {
287 SDL_DisplayData* didata = (SDL_DisplayData*)SDL_CurrentDisplay.driverdata; 411 SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
288 SDL_DisplayMode mode; 412 SDL_DisplayMode mode;
289 gf_modeinfo_t modeinfo; 413 gf_modeinfo_t modeinfo;
290 uint32_t it=0; 414 uint32_t it=0;
291 uint32_t jt=0; 415 uint32_t jt=0;
292 uint32_t kt=0; 416 uint32_t kt=0;
356 } while(1); 480 } while(1);
357 } 481 }
358 482
359 int qnxgf_setdisplaymode(_THIS, SDL_DisplayMode* mode) 483 int qnxgf_setdisplaymode(_THIS, SDL_DisplayMode* mode)
360 { 484 {
361 SDL_DisplayData* didata = (SDL_DisplayData*)SDL_CurrentDisplay.driverdata; 485 SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
486 uint32_t refresh_rate=0;
362 int result; 487 int result;
363 488
364 result=gf_display_set_mode(didata->display, mode->w, mode->h, mode->refresh_rate, 489 /* Current display dimensions and bpp are no more valid */
490 didata->current_mode.format=SDL_PIXELFORMAT_UNKNOWN;
491 didata->current_mode.w=0;
492 didata->current_mode.h=0;
493
494 /* Check if custom refresh rate requested */
495 if (didata->custom_refresh!=0)
496 {
497 refresh_rate=didata->custom_refresh;
498 }
499 else
500 {
501 refresh_rate=mode->refresh_rate;
502 }
503
504 /* Check if SDL GF driver needs to find appropriate refresh rate itself */
505 if (refresh_rate==0)
506 {
507 uint32_t it;
508 SDL_DisplayMode tempmode;
509
510 /* Clear display mode structure */
511 SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode));
512 tempmode.refresh_rate=0x0000FFFF;
513
514 /* Check if window width and height matches one of our modes */
515 for (it=0; it<SDL_CurrentDisplay.num_display_modes; it++)
516 {
517 if ((SDL_CurrentDisplay.display_modes[it].w==mode->w) &&
518 (SDL_CurrentDisplay.display_modes[it].h==mode->h) &&
519 (SDL_CurrentDisplay.display_modes[it].format==mode->format))
520 {
521 /* Find the lowest refresh rate available */
522 if (tempmode.refresh_rate>SDL_CurrentDisplay.display_modes[it].refresh_rate)
523 {
524 tempmode=SDL_CurrentDisplay.display_modes[it];
525 }
526 }
527 }
528 if (tempmode.refresh_rate!=0x0000FFFF)
529 {
530 refresh_rate=tempmode.refresh_rate;
531 }
532 else
533 {
534 /* Let video driver decide what to do with this */
535 refresh_rate=0;
536 }
537 }
538
539 /* Check if SDL GF driver needs to check custom refresh rate */
540 if (didata->custom_refresh!=0)
541 {
542 uint32_t it;
543 SDL_DisplayMode tempmode;
544
545 /* Clear display mode structure */
546 SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode));
547 tempmode.refresh_rate=0x0000FFFF;
548
549 /* Check if window width and height matches one of our modes */
550 for (it=0; it<SDL_CurrentDisplay.num_display_modes; it++)
551 {
552 if ((SDL_CurrentDisplay.display_modes[it].w==mode->w) &&
553 (SDL_CurrentDisplay.display_modes[it].h==mode->h) &&
554 (SDL_CurrentDisplay.display_modes[it].format==mode->format))
555 {
556 /* Find the lowest refresh rate available */
557 if (tempmode.refresh_rate>SDL_CurrentDisplay.display_modes[it].refresh_rate)
558 {
559 tempmode=SDL_CurrentDisplay.display_modes[it];
560 }
561
562 /* Check if requested refresh rate found */
563 if (refresh_rate==SDL_CurrentDisplay.display_modes[it].refresh_rate)
564 {
565 tempmode=SDL_CurrentDisplay.display_modes[it];
566 break;
567 }
568 }
569 }
570 if (tempmode.refresh_rate!=0x0000FFFF)
571 {
572 refresh_rate=tempmode.refresh_rate;
573 }
574 else
575 {
576 /* Let video driver decide what to do with this */
577 refresh_rate=0;
578 }
579 }
580
581 /* Detach layer before switch to new graphics mode */
582 if (didata->layer_attached==SDL_TRUE)
583 {
584 /* Disable layer if hardware supports this */
585 gf_layer_disable(didata->layer);
586
587 /* Detach from layer, free it for others */
588 gf_layer_detach(didata->layer);
589
590 /* Mark it as detached */
591 didata->layer_attached=SDL_FALSE;
592 }
593
594 /* Set new display video mode */
595 result=gf_display_set_mode(didata->display, mode->w, mode->h, refresh_rate,
365 qnxgf_sdl_to_gf_pixelformat(mode->format), 0); 596 qnxgf_sdl_to_gf_pixelformat(mode->format), 0);
366 if (result!=GF_ERR_OK) 597 if (result!=GF_ERR_OK)
367 { 598 {
368 /* Display mode/resolution switch has been failed */ 599 /* Display mode/resolution switch has been failed */
369 SDL_SetError("Mode is not supported by qnxgf driver"); 600 SDL_SetError("mode is not supported by graphics driver");
370 return -1; 601 return -1;
371 } 602 }
603 else
604 {
605 didata->current_mode=*mode;
606 didata->current_mode.refresh_rate=refresh_rate;
607 }
608
609 /* Attach to main display layer */
610 result=gf_layer_attach(&didata->layer, didata->display, didata->display_info.main_layer_index, 0);
611 if (result!=GF_ERR_OK)
612 {
613 SDL_SetError("couldn't attach to main layer, it could be busy");
614
615 /* Failed to attach to main displayable layer */
616 return -1;
617 }
618
619 /* Enable layer in case if hardware supports layer enable/disable */
620 gf_layer_enable(didata->layer);
621
622 /* Mark main display layer is attached */
623 didata->layer_attached=SDL_TRUE;
372 624
373 return 0; 625 return 0;
374 } 626 }
375 627
376 int qnxgf_setdisplaypalette(_THIS, SDL_Palette* palette) 628 int qnxgf_setdisplaypalette(_THIS, SDL_Palette* palette)
377 { 629 {
378 /* Palette must be set through the QNXGF renderer */ 630 SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
379 /* It connected to surface, part of it */ 631
632 /* QNX GF doesn't have support for global palette changing, but we */
633 /* could store it for usage in future */
380 634
381 /* Setting display palette operation has been failed */ 635 /* Setting display palette operation has been failed */
382 return -1; 636 return -1;
383 } 637 }
384 638
385 int qnxgf_getdisplaypalette(_THIS, SDL_Palette* palette) 639 int qnxgf_getdisplaypalette(_THIS, SDL_Palette* palette)
386 { 640 {
387 /* We can give to upper level palette, which it set before */ 641 SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
642
643 /* We can't provide current palette settings and looks like SDL */
644 /* do not call this function also, in such case this function returns -1 */
388 645
389 /* Getting display palette operation has been failed */ 646 /* Getting display palette operation has been failed */
390 return -1; 647 return -1;
391 } 648 }
392 649
393 int qnxgf_setdisplaygammaramp(_THIS, Uint16* ramp) 650 int qnxgf_setdisplaygammaramp(_THIS, Uint16* ramp)
394 { 651 {
395 SDL_DisplayData* didata = (SDL_DisplayData*)SDL_CurrentDisplay.driverdata; 652 SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
396 int status; 653 int status;
397 654
398 /* GF can set Color LUT independently for each color channel, but SDL */ 655 /* Setup gamma ramp, for each color channel */
399 /* uses combined gamma ramp, set it to each channel */ 656 status=gf_display_set_color_lut16(didata->display, (uint16_t*)ramp, (uint16_t*)ramp+256, (uint16_t*)ramp+512);
400 status=gf_display_set_color_lut16(didata->display, (uint16_t*)ramp, (uint16_t*)ramp, (uint16_t*)ramp);
401 if (status!=GF_ERR_OK) 657 if (status!=GF_ERR_OK)
402 { 658 {
403 /* Setting display gamma ramp operation has been failed */ 659 /* Setting display gamma ramp operation has been failed */
404 return -1; 660 return -1;
405 } 661 }
407 return 0; 663 return 0;
408 } 664 }
409 665
410 int qnxgf_getdisplaygammaramp(_THIS, Uint16* ramp) 666 int qnxgf_getdisplaygammaramp(_THIS, Uint16* ramp)
411 { 667 {
412 /* We need to return previous gamma set */ 668 /* TODO: We need to return previous gamma set */
669 /* Also we need some initial fake gamma to return */
413 670
414 /* Getting display gamma ramp operation has been failed */ 671 /* Getting display gamma ramp operation has been failed */
415 return -1; 672 return -1;
416 } 673 }
417 674
418 int qnxgf_createwindow(_THIS, SDL_Window* window) 675 int qnxgf_createwindow(_THIS, SDL_Window* window)
419 { 676 {
420 /* Failed to create new window */ 677 SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
421 return -1; 678 SDL_WindowData* wdata;
679
680 /* QNX GF supports fullscreen window modes only */
681 if ((window->flags & SDL_WINDOW_FULLSCREEN)!=SDL_WINDOW_FULLSCREEN)
682 {
683 uint32_t it;
684 SDL_DisplayMode mode;
685
686 /* Clear display mode structure */
687 SDL_memset(&mode, 0x00, sizeof(SDL_DisplayMode));
688 mode.refresh_rate=0x0000FFFF;
689
690 /* Check if window width and height matches one of our modes */
691 for (it=0; it<SDL_CurrentDisplay.num_display_modes; it++)
692 {
693 if ((SDL_CurrentDisplay.display_modes[it].w==window->w) &&
694 (SDL_CurrentDisplay.display_modes[it].h==window->h) &&
695 (SDL_CurrentDisplay.display_modes[it].format==SDL_CurrentDisplay.desktop_mode.format))
696 {
697 /* Find the lowest refresh rate available */
698 if (mode.refresh_rate>SDL_CurrentDisplay.display_modes[it].refresh_rate)
699 {
700 mode=SDL_CurrentDisplay.display_modes[it];
701 }
702 }
703 }
704
705 /* Check if end of display list has been reached */
706 if (mode.refresh_rate==0x0000FFFF)
707 {
708 SDL_SetError("desired video mode is not supported");
709
710 /* Failed to create new window */
711 return -1;
712 }
713 else
714 {
715 /* Tell to the caller that mode will be fullscreen */
716 window->flags|=SDL_WINDOW_FULLSCREEN;
717
718 /* Setup fullscreen mode, bpp used from desktop mode in this case */
719 qnxgf_setdisplaymode(_this, &mode);
720 }
721 }
722
723 /* Setup our own window decorations, which are depend on fullscreen mode */
724 window->flags|=SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS |
725 SDL_WINDOW_MAXIMIZED | SDL_WINDOW_INPUT_GRABBED |
726 SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS;
727 window->flags&=~(SDL_WINDOW_RESIZABLE | SDL_WINDOW_MINIMIZED);
728
729 /* Ignore any window position settings */
730 window->x=SDL_WINDOWPOS_UNDEFINED;
731 window->y=SDL_WINDOWPOS_UNDEFINED;
732
733 /* Allocate window internal data */
734 wdata=(SDL_WindowData*)SDL_calloc(1, sizeof(SDL_WindowData));
735 if (wdata==NULL)
736 {
737 SDL_OutOfMemory();
738 return -1;
739 }
740
741 /* Setup driver data for this window */
742 window->driverdata=wdata;
743
744 /* Check if window must support OpenGL ES rendering */
745 if ((window->flags & SDL_WINDOW_OPENGL)==SDL_WINDOW_OPENGL)
746 {
747 /* Mark this window as OpenGL ES compatible */
748 wdata->uses_gles=SDL_TRUE;
749 }
750
751 /* Window has been successfully created */
752 return 0;
422 } 753 }
423 754
424 int qnxgf_createwindowfrom(_THIS, SDL_Window* window, const void* data) 755 int qnxgf_createwindowfrom(_THIS, SDL_Window* window, const void* data)
425 { 756 {
426 /* Failed to create window from another window */ 757 /* Failed to create window from another window */
471 { 802 {
472 } 803 }
473 804
474 void qnxgf_destroywindow(_THIS, SDL_Window* window) 805 void qnxgf_destroywindow(_THIS, SDL_Window* window)
475 { 806 {
476 printf("qnxgf_destroywindow()\n"); 807 SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
808 SDL_WindowData* wdata=(SDL_WindowData*)window->driverdata;
809
810 if (wdata!=NULL)
811 {
812 }
477 } 813 }
478 814
479 /*****************************************************************************/ 815 /*****************************************************************************/
480 /* SDL Window Manager function */ 816 /* SDL Window Manager function */
481 /*****************************************************************************/ 817 /*****************************************************************************/
482 SDL_bool qnxgf_getwindowwminfo(_THIS, SDL_Window* window, struct SDL_SysWMinfo* info) 818 SDL_bool qnxgf_getwindowwminfo(_THIS, SDL_Window* window, struct SDL_SysWMinfo* info)
483 { 819 {
484 if (info->version.major <= SDL_MAJOR_VERSION) 820 /* QNX GF do not operates at window level, this means we are have no */
821 /* Window Manager available, no specific data in SDL_SysWMinfo too */
822
823 if (info->version.major<=SDL_MAJOR_VERSION)
485 { 824 {
486 return SDL_TRUE; 825 return SDL_TRUE;
487 } 826 }
488 else 827 else
489 { 828 {
490 SDL_SetError("Application not compiled with SDL %d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION); 829 SDL_SetError("application not compiled with SDL %d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
491 return SDL_FALSE; 830 return SDL_FALSE;
492 } 831 }
493 832
494 /* Failed to get window manager information */ 833 /* Failed to get window manager information */
495 return SDL_FALSE; 834 return SDL_FALSE;