comparison src/video/qnxgf/SDL_qnxgf.c @ 3099:82e60908fab1

Date: Mon, 23 Mar 2009 09:17:24 +0200 From: "Mike Gorchak" Subject: New QNX patches Please apply patch qnx4.diff, which is attached. What has been done: 1)Added back OpenGL ES renderer for QNX target. Added few corrections to OpenGL ES renderer to let it work under QNX. OpenGL ES renderer do not support textures under QNX, so I think some additional work must be done. 2) Added GL_OES_query_matrix extension to SDL_opengles.h header file, which required by OpenGL ES 1.1 specification. 3) Added attribute clearing at the entrance of function SDL_GL_GetAttribure(). Added error checking into the function SDL_GL_GetAttribure(), because some attributes can't be obtained in OpenGL ES 1.0. 4) Porting testdyngles to OpenGL ES 1.0 (1.1 has glColor4ub() and glColor4f() functions, but 1.0 has glColor4f() only). 5) Added error checking after obtaining attributes using SDL_GL_GetAttribute() function to the testgl2 and testgles. 6) Small correction to testmultiaudio with printing errors. 7) Added software and accelerated OpenGL ES 1.0 support into the QNX GF driver. Please remove ./src/audio/nto directory - it will not be used anymore. Please create ./src/audio/qsa directory and add content of the archive qsa.tar.gz into this directory. I rewrote some sound code, added support for multiple audio cards, enumeration, etc. Added initial support for capture. As far as I can understand SDL 1.3 is not supporting audio capture right now ? Sam, Am I right ? Or audio capture must be supported through the PlayDevice routine ? And last, please put file SDL_gf_opengles.c to the ./src/video/qnxgf directory. It is OpenGL ES 1.1 emulation layer for some functions, which are not supported by OpenGL ES 1.0.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 24 Mar 2009 10:33:12 +0000
parents cad1aefa2ed9
children 7b3a09fb9c8b
comparison
equal deleted inserted replaced
3098:5f372cef955d 3099:82e60908fab1
27 #include "SDL_config.h" 27 #include "SDL_config.h"
28 28
29 #include "../SDL_sysvideo.h" 29 #include "../SDL_sysvideo.h"
30 #include "SDL_version.h" 30 #include "SDL_version.h"
31 #include "SDL_syswm.h" 31 #include "SDL_syswm.h"
32 #include "SDL_loadso.h"
32 33
33 /* Include QNX Graphics Framework declarations */ 34 /* Include QNX Graphics Framework declarations */
34 #include <gf/gf.h> 35 #include <gf/gf.h>
35 36
36 #include "SDL_qnxgf.h" 37 #include "SDL_qnxgf.h"
44 /* but some drivers are not. Later we can distinguish one driver from another */ 45 /* but some drivers are not. Later we can distinguish one driver from another */
45 /* Feel free to add any new custom graphics mode */ 46 /* Feel free to add any new custom graphics mode */
46 /******************************************************************************/ 47 /******************************************************************************/
47 static SDL_DisplayMode generic_mode[]= 48 static SDL_DisplayMode generic_mode[]=
48 { 49 {
49 {0, 320, 200, 70, NULL}, /* 320x200 modes are 70Hz and 85Hz */ 50 {0, 320, 200, 70, NULL}, /* 320x200 modes are 70Hz and 85Hz */
50 {0, 320, 200, 85, NULL}, 51 {0, 320, 200, 85, NULL},
51 {0, 320, 240, 70, NULL}, /* 320x240 modes are 70Hz and 85Hz */ 52 {0, 320, 240, 70, NULL}, /* 320x240 modes are 70Hz and 85Hz */
52 {0, 320, 240, 85, NULL}, 53 {0, 320, 240, 85, NULL},
53 {0, 512, 384, 60, NULL}, /* 512x384 modes are 60Hz and 70Hz */ 54 {0, 512, 384, 60, NULL}, /* 512x384 modes are 60Hz and 70Hz */
54 {0, 512, 384, 70, NULL}, 55 {0, 512, 384, 70, NULL},
55 {0, 640, 480, 60, NULL}, /* 640x480 modes are 60Hz, 75Hz, 85Hz */ 56 {0, 640, 480, 60, NULL}, /* 640x480 modes are 60Hz, 75Hz, 85Hz */
56 {0, 640, 480, 75, NULL}, 57 {0, 640, 480, 75, NULL},
57 {0, 640, 480, 85, NULL}, 58 {0, 640, 480, 85, NULL},
58 {0, 800, 600, 60, NULL}, /* 800x600 modes are 60Hz, 75Hz, 85Hz */ 59 {0, 800, 600, 60, NULL}, /* 800x600 modes are 60Hz, 75Hz, 85Hz */
59 {0, 800, 600, 75, NULL}, 60 {0, 800, 600, 75, NULL},
60 {0, 800, 600, 85, NULL}, 61 {0, 800, 600, 85, NULL},
61 {0, 800, 480, 60, NULL}, /* 800x480 mode is 60Hz only */ 62 {0, 800, 480, 60, NULL}, /* 800x480 mode is 60Hz only */
62 {0, 1024, 640, 60, NULL}, /* 1024x640 mode is 60Hz only */ 63 {0, 1024, 640, 60, NULL}, /* 1024x640 mode is 60Hz only */
63 {0, 1024, 768, 60, NULL}, /* 1024x768 modes are 60Hz, 70Hz, 75Hz */ 64 {0, 1024, 768, 60, NULL}, /* 1024x768 modes are 60Hz, 70Hz, 75Hz */
64 {0, 1024, 768, 70, NULL}, 65 {0, 1024, 768, 70, NULL},
65 {0, 1024, 768, 75, NULL}, 66 {0, 1024, 768, 75, NULL},
66 {0, 1280, 720, 60, NULL}, /* 1280x720 mode is 60Hz only */ 67 {0, 1280, 720, 60, NULL}, /* 1280x720 mode is 60Hz only */
67 {0, 1280, 768, 60, NULL}, /* 1280x768 mode is 60Hz only */ 68 {0, 1280, 768, 60, NULL}, /* 1280x768 mode is 60Hz only */
68 {0, 1280, 800, 60, NULL}, /* 1280x800 mode is 60Hz only */ 69 {0, 1280, 800, 60, NULL}, /* 1280x800 mode is 60Hz only */
69 {0, 1280, 960, 60, NULL}, /* 1280x960 mode is 60Hz only */ 70 {0, 1280, 960, 60, NULL}, /* 1280x960 mode is 60Hz only */
70 {0, 1280, 1024, 60, NULL}, /* 1280x1024 modes are 60Hz, 75Hz, 85Hz and */ 71 {0, 1280, 1024, 60, NULL}, /* 1280x1024 modes are 60Hz, 75Hz, 85Hz and */
71 {0, 1280, 1024, 75, NULL}, /* 100 Hz */ 72 {0, 1280, 1024, 75, NULL}, /* 100 Hz */
72 {0, 1280, 1024, 85, NULL}, /* */ 73 {0, 1280, 1024, 85, NULL}, /* */
73 {0, 1280, 1024, 100, NULL}, /* */ 74 {0, 1280, 1024, 100, NULL}, /* */
74 {0, 1400, 1050, 60, NULL}, /* 1400x1050 mode is 60Hz only */ 75 {0, 1400, 1050, 60, NULL}, /* 1400x1050 mode is 60Hz only */
75 {0, 1440, 900, 60, NULL}, /* 1440x900 mode is 60Hz only */ 76 {0, 1440, 900, 60, NULL}, /* 1440x900 mode is 60Hz only */
76 {0, 1440, 960, 60, NULL}, /* 1440x960 mode is 60Hz only */ 77 {0, 1440, 960, 60, NULL}, /* 1440x960 mode is 60Hz only */
77 {0, 1600, 1200, 60, NULL}, /* 1600x1200 mode is 60Hz only */ 78 {0, 1600, 1200, 60, NULL}, /* 1600x1200 mode is 60Hz only */
78 {0, 1680, 1050, 60, NULL}, /* 1680x1050 mode is 60Hz only */ 79 {0, 1680, 1050, 60, NULL}, /* 1680x1050 mode is 60Hz only */
79 {0, 1920, 1080, 60, NULL}, /* 1920x1080 mode is 60Hz only */ 80 {0, 1920, 1080, 60, NULL}, /* 1920x1080 mode is 60Hz only */
80 {0, 1920, 1200, 60, NULL}, /* 1920x1200 mode is 60Hz only */ 81 {0, 1920, 1200, 60, NULL}, /* 1920x1200 mode is 60Hz only */
81 {0, 2048, 1536, 60, NULL}, /* 2048x1536 mode is 60Hz only */ 82 {0, 2048, 1536, 60, NULL}, /* 2048x1536 mode is 60Hz only */
82 {0, 2048, 1080, 60, NULL}, /* 2048x1080 mode is 60Hz only */ 83 {0, 2048, 1080, 60, NULL}, /* 2048x1080 mode is 60Hz only */
83 {0, 0, 0, 0, NULL} /* End of generic mode list */ 84 {0, 0, 0, 0, NULL} /* End of generic mode list */
84 }; 85 };
85 86
86 /* Low level device graphics driver names, which they are reporting */ 87 /* Low level device graphics driver names, which they are reporting */
87 GF_DeviceCaps gf_devicename[]= 88 GF_DeviceCaps gf_devicename[]=
88 { 89 {
89 /* ATI Rage 128 graphics driver (devg-ati_rage128) */ 90 /* ATI Rage 128 graphics driver (devg-ati_rage128) */
90 {"ati_rage128", SDL_GF_ACCELERATED}, 91 {"ati_rage128", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
92 SDL_GF_UNACCELERATED_3D},
91 /* Fujitsu Carmine graphics driver (devg-carmine.so) */ 93 /* Fujitsu Carmine graphics driver (devg-carmine.so) */
92 {"carmine", SDL_GF_ACCELERATED}, 94 {"carmine", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
95 SDL_GF_ACCELERATED_3D},
93 /* C&T graphics driver (devg-chips.so) */ 96 /* C&T graphics driver (devg-chips.so) */
94 {"chips", SDL_GF_ACCELERATED}, 97 {"chips", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
98 SDL_GF_UNACCELERATED_3D},
95 /* Fujitsu Coral graphics driver (devg-coral.so) */ 99 /* Fujitsu Coral graphics driver (devg-coral.so) */
96 {"coral", SDL_GF_ACCELERATED}, 100 {"coral", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
101 SDL_GF_ACCELERATED_3D},
97 /* Intel integrated graphics driver (devg-extreme2.so) */ 102 /* Intel integrated graphics driver (devg-extreme2.so) */
98 {"extreme2", SDL_GF_ACCELERATED}, 103 {"extreme2", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
104 SDL_GF_ACCELERATED_3D},
99 /* Unaccelerated FB driver (devg-flat.so) */ 105 /* Unaccelerated FB driver (devg-flat.so) */
100 {"flat", SDL_GF_UNACCELERATED}, 106 {"flat", SDL_GF_UNACCELERATED | SDL_GF_LOWRESOLUTION |
107 SDL_GF_UNACCELERATED_3D},
101 /* NS Geode graphics driver (devg-geode.so) */ 108 /* NS Geode graphics driver (devg-geode.so) */
102 {"geode", SDL_GF_ACCELERATED}, 109 {"geode", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
110 SDL_GF_UNACCELERATED_3D},
103 /* Geode LX graphics driver (devg-geodelx.so) */ 111 /* Geode LX graphics driver (devg-geodelx.so) */
104 {"geodelx", SDL_GF_ACCELERATED}, 112 {"geodelx", SDL_GF_ACCELERATED | SDL_GF_LOWRESOLUTION |
113 SDL_GF_UNACCELERATED_3D},
105 /* Intel integrated graphics driver (devg-gma9xx.so) */ 114 /* Intel integrated graphics driver (devg-gma9xx.so) */
106 {"gma", SDL_GF_ACCELERATED}, 115 {"gma", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
116 SDL_GF_ACCELERATED_3D},
107 /* Intel integrated graphics driver (devg-i810.so) */ 117 /* Intel integrated graphics driver (devg-i810.so) */
108 {"i810", SDL_GF_ACCELERATED}, 118 {"i810", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
119 SDL_GF_UNACCELERATED_3D},
109 /* Intel integrated graphics driver (devg-i830.so) */ 120 /* Intel integrated graphics driver (devg-i830.so) */
110 {"i830", SDL_GF_ACCELERATED}, 121 {"i830", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
122 SDL_GF_UNACCELERATED_3D},
111 /* Geode LX graphics driver (devg-lx800.so) */ 123 /* Geode LX graphics driver (devg-lx800.so) */
112 {"lx800", SDL_GF_ACCELERATED}, 124 {"lx800", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
125 SDL_GF_UNACCELERATED_3D},
113 /* Matrox Gxx graphics driver (devg-matroxg.so) */ 126 /* Matrox Gxx graphics driver (devg-matroxg.so) */
114 {"matroxg", SDL_GF_ACCELERATED}, 127 {"matroxg", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
128 SDL_GF_UNACCELERATED_3D},
115 /* Intel Poulsbo graphics driver (devg-poulsbo.so) */ 129 /* Intel Poulsbo graphics driver (devg-poulsbo.so) */
116 {"poulsbo", SDL_GF_ACCELERATED}, 130 {"poulsbo", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
131 SDL_GF_ACCELERATED_3D},
117 /* ATI Radeon driver (devg-radeon.so) */ 132 /* ATI Radeon driver (devg-radeon.so) */
118 {"radeon", SDL_GF_ACCELERATED}, 133 {"radeon", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
134 SDL_GF_UNACCELERATED_3D},
119 /* ATI Rage driver (devg-rage.so) */ 135 /* ATI Rage driver (devg-rage.so) */
120 {"rage", SDL_GF_ACCELERATED}, 136 {"rage", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
137 SDL_GF_UNACCELERATED_3D},
121 /* S3 Savage graphics driver (devg-s3_savage.so) */ 138 /* S3 Savage graphics driver (devg-s3_savage.so) */
122 {"s3_savage", SDL_GF_ACCELERATED}, 139 {"s3_savage", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
140 SDL_GF_UNACCELERATED_3D},
123 /* SiS630 integrated graphics driver (devg-sis630.so) */ 141 /* SiS630 integrated graphics driver (devg-sis630.so) */
124 {"sis630", SDL_GF_ACCELERATED}, 142 {"sis630", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
143 SDL_GF_UNACCELERATED_3D},
125 /* PowerVR SGX 535 graphics driver (devg-poulsbo.so) */ 144 /* PowerVR SGX 535 graphics driver (devg-poulsbo.so) */
126 {"sgx", SDL_GF_ACCELERATED}, 145 {"sgx", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
146 SDL_GF_ACCELERATED_3D},
127 /* SM Voyager GX graphics driver (devg-smi5xx.so) */ 147 /* SM Voyager GX graphics driver (devg-smi5xx.so) */
128 {"smi5xx", SDL_GF_ACCELERATED}, 148 {"smi5xx", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
149 SDL_GF_UNACCELERATED_3D},
129 /* Silicon Motion graphics driver (devg-smi7xx.so) */ 150 /* Silicon Motion graphics driver (devg-smi7xx.so) */
130 {"smi7xx", SDL_GF_ACCELERATED}, 151 {"smi7xx", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
152 SDL_GF_UNACCELERATED_3D},
131 /* SVGA unaccelerated gfx driver (devg-svga.so) */ 153 /* SVGA unaccelerated gfx driver (devg-svga.so) */
132 {"svga", SDL_GF_UNACCELERATED}, 154 {"svga", SDL_GF_UNACCELERATED | SDL_GF_LOWRESOLUTION |
155 SDL_GF_UNACCELERATED_3D},
133 /* nVidia TNT graphics driver (devg-tnt.so) */ 156 /* nVidia TNT graphics driver (devg-tnt.so) */
134 {"tnt", SDL_GF_ACCELERATED}, 157 {"tnt", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
158 SDL_GF_UNACCELERATED_3D},
135 /* VIA integrated graphics driver (devg-tvia.so) */ 159 /* VIA integrated graphics driver (devg-tvia.so) */
136 {"tvia", SDL_GF_ACCELERATED}, 160 {"tvia", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
161 SDL_GF_UNACCELERATED_3D},
137 /* VIA UniChrome graphics driver (devg-unichrome.so) */ 162 /* VIA UniChrome graphics driver (devg-unichrome.so) */
138 {"unichrome", SDL_GF_ACCELERATED}, 163 {"unichrome", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
164 SDL_GF_UNACCELERATED_3D},
139 /* VESA unaccelerated gfx driver (devg-vesa.so) */ 165 /* VESA unaccelerated gfx driver (devg-vesa.so) */
140 {"vesa", SDL_GF_UNACCELERATED}, 166 {"vesa", SDL_GF_UNACCELERATED | SDL_GF_LOWRESOLUTION |
167 SDL_GF_UNACCELERATED_3D},
141 /* VmWare graphics driver (devg-volari.so) */ 168 /* VmWare graphics driver (devg-volari.so) */
142 {"vmware", SDL_GF_ACCELERATED}, 169 {"vmware", SDL_GF_ACCELERATED | SDL_GF_LOWRESOLUTION |
170 SDL_GF_UNACCELERATED_3D},
143 /* XGI XP10 graphics driver (devg-volari.so) */ 171 /* XGI XP10 graphics driver (devg-volari.so) */
144 {"volari", SDL_GF_ACCELERATED}, 172 {"volari", SDL_GF_ACCELERATED | SDL_GF_LOWRESOLUTION |
173 SDL_GF_UNACCELERATED_3D},
145 /* End of list */ 174 /* End of list */
146 {NULL, 0x00000000} 175 {NULL, 0x00000000}
147 }; 176 };
148 177
149 /*****************************************************************************/ 178 /*****************************************************************************/
150 /* SDL Video Device initialization functions */ 179 /* SDL Video Device initialization functions */
151 /*****************************************************************************/ 180 /*****************************************************************************/
312 } 341 }
313 else 342 else
314 { 343 {
315 /* video initialization problem */ 344 /* video initialization problem */
316 SDL_free(didata); 345 SDL_free(didata);
317 SDL_SetError("display query failed"); 346 SDL_SetError("GF: Display query failed");
318 return -1; 347 return -1;
319 } 348 }
320 349
321 /* Attach GF to selected display */ 350 /* Attach GF to selected display */
322 status=gf_display_attach(&didata->display, gfdata->gfdev, it, NULL); 351 status=gf_display_attach(&didata->display, gfdata->gfdev, it, NULL);
323 if (status!=GF_ERR_OK) 352 if (status!=GF_ERR_OK)
324 { 353 {
325 /* video initialization problem */ 354 /* video initialization problem */
326 SDL_free(didata); 355 SDL_free(didata);
327 SDL_SetError("couldn't attach to display"); 356 SDL_SetError("GF: Couldn't attach to display");
328 return -1; 357 return -1;
329 } 358 }
330 359
331 /* Initialize status variables */ 360 /* Initialize status variables */
332 didata->layer_attached=SDL_FALSE; 361 didata->layer_attached=SDL_FALSE;
333 362
334 /* Attach to main display layer */ 363 /* Attach to main display layer */
335 status=gf_layer_attach(&didata->layer, didata->display, didata->display_info.main_layer_index, 0); 364 status=gf_layer_attach(&didata->layer, didata->display, didata->display_info.main_layer_index, 0);
336 if (status!=GF_ERR_OK) 365 if (status!=GF_ERR_OK)
337 { 366 {
338 SDL_SetError("couldn't attach to main layer, it could be busy"); 367 SDL_SetError("GF: Couldn't attach to main layer, it could be busy");
339 368
340 /* Failed to attach to main layer */ 369 /* Failed to attach to main layer */
341 return -1; 370 return -1;
342 } 371 }
343 372
428 jt=0; 457 jt=0;
429 do { 458 do {
430 if (generic_mode[jt].w==0) 459 if (generic_mode[jt].w==0)
431 { 460 {
432 break; 461 break;
462 }
463
464 /* Check if driver do not supports doublescan video modes */
465 if ((didata->caps & SDL_GF_LOWRESOLUTION)!=SDL_GF_LOWRESOLUTION)
466 {
467 if (generic_mode[jt].w<640)
468 {
469 jt++;
470 continue;
471 }
433 } 472 }
434 473
435 mode.w=generic_mode[jt].w; 474 mode.w=generic_mode[jt].w;
436 mode.h=generic_mode[jt].h; 475 mode.h=generic_mode[jt].h;
437 mode.refresh_rate=generic_mode[jt].refresh_rate; 476 mode.refresh_rate=generic_mode[jt].refresh_rate;
595 result=gf_display_set_mode(didata->display, mode->w, mode->h, refresh_rate, 634 result=gf_display_set_mode(didata->display, mode->w, mode->h, refresh_rate,
596 qnxgf_sdl_to_gf_pixelformat(mode->format), 0); 635 qnxgf_sdl_to_gf_pixelformat(mode->format), 0);
597 if (result!=GF_ERR_OK) 636 if (result!=GF_ERR_OK)
598 { 637 {
599 /* Display mode/resolution switch has been failed */ 638 /* Display mode/resolution switch has been failed */
600 SDL_SetError("mode is not supported by graphics driver"); 639 SDL_SetError("GF: Mode is not supported by graphics driver");
601 return -1; 640 return -1;
602 } 641 }
603 else 642 else
604 { 643 {
605 didata->current_mode=*mode; 644 didata->current_mode=*mode;
608 647
609 /* Attach to main display layer */ 648 /* Attach to main display layer */
610 result=gf_layer_attach(&didata->layer, didata->display, didata->display_info.main_layer_index, 0); 649 result=gf_layer_attach(&didata->layer, didata->display, didata->display_info.main_layer_index, 0);
611 if (result!=GF_ERR_OK) 650 if (result!=GF_ERR_OK)
612 { 651 {
613 SDL_SetError("couldn't attach to main layer, it could be busy"); 652 SDL_SetError("GF: Couldn't attach to main layer, it could be busy");
614 653
615 /* Failed to attach to main displayable layer */ 654 /* Failed to attach to main displayable layer */
616 return -1; 655 return -1;
617 } 656 }
618 657
672 return -1; 711 return -1;
673 } 712 }
674 713
675 int qnxgf_createwindow(_THIS, SDL_Window* window) 714 int qnxgf_createwindow(_THIS, SDL_Window* window)
676 { 715 {
716 SDL_VideoData* gfdata=(SDL_VideoData*)_this->driverdata;
677 SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata; 717 SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
678 SDL_WindowData* wdata; 718 SDL_WindowData* wdata;
719 int32_t status;
679 720
680 /* QNX GF supports fullscreen window modes only */ 721 /* QNX GF supports fullscreen window modes only */
681 if ((window->flags & SDL_WINDOW_FULLSCREEN)!=SDL_WINDOW_FULLSCREEN) 722 if ((window->flags & SDL_WINDOW_FULLSCREEN)!=SDL_WINDOW_FULLSCREEN)
682 { 723 {
683 uint32_t it; 724 uint32_t it;
703 } 744 }
704 745
705 /* Check if end of display list has been reached */ 746 /* Check if end of display list has been reached */
706 if (mode.refresh_rate==0x0000FFFF) 747 if (mode.refresh_rate==0x0000FFFF)
707 { 748 {
708 SDL_SetError("desired video mode is not supported"); 749 SDL_SetError("GF: Desired video mode is not supported");
709 750
710 /* Failed to create new window */ 751 /* Failed to create new window */
711 return -1; 752 return -1;
712 } 753 }
713 else 754 else
714 { 755 {
715 /* Tell to the caller that mode will be fullscreen */ 756 /* Tell to the caller that mode will be fullscreen */
716 window->flags|=SDL_WINDOW_FULLSCREEN; 757 window->flags|=SDL_WINDOW_FULLSCREEN;
717 758
718 /* Setup fullscreen mode, bpp used from desktop mode in this case */ 759 /* Setup fullscreen mode, bpp used from desktop mode in this case */
719 qnxgf_setdisplaymode(_this, &mode); 760 status=qnxgf_setdisplaymode(_this, &mode);
761 if (status!=0)
762 {
763 /* Failed to swith fullscreen video mode */
764 return -1;
765 }
720 } 766 }
721 } 767 }
722 768
723 /* Setup our own window decorations, which are depend on fullscreen mode */ 769 /* Setup our own window decorations, which are depend on fullscreen mode */
724 window->flags|=SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS | 770 window->flags|=SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS |
742 window->driverdata=wdata; 788 window->driverdata=wdata;
743 789
744 /* Check if window must support OpenGL ES rendering */ 790 /* Check if window must support OpenGL ES rendering */
745 if ((window->flags & SDL_WINDOW_OPENGL)==SDL_WINDOW_OPENGL) 791 if ((window->flags & SDL_WINDOW_OPENGL)==SDL_WINDOW_OPENGL)
746 { 792 {
747 /* Mark this window as OpenGL ES compatible */ 793 #if defined(SDL_VIDEO_OPENGL_ES)
748 wdata->uses_gles=SDL_TRUE; 794 EGLBoolean initstatus;
795
796 /* Mark this window as OpenGL ES compatible */
797 wdata->uses_gles=SDL_TRUE;
798
799 /* Create connection to OpenGL ES */
800 if (gfdata->egldisplay==EGL_NO_DISPLAY)
801 {
802 gfdata->egldisplay=eglGetDisplay(gfdata->gfdev);
803 if (gfdata->egldisplay==EGL_NO_DISPLAY)
804 {
805 SDL_SetError("GF: Can't get connection to OpenGL ES");
806 return -1;
807 }
808
809 /* Initialize OpenGL ES library, ignore EGL version */
810 initstatus=eglInitialize(gfdata->egldisplay, NULL, NULL);
811 if (initstatus!=EGL_TRUE)
812 {
813 SDL_SetError("GF: Can't init OpenGL ES library");
814 return -1;
815 }
816 }
817
818 /* Increment GL ES reference count usage */
819 gfdata->egl_refcount++;
820 #else
821 SDL_SetError("GF: OpenGL ES support is not compiled in");
822 return -1;
823 #endif /* SDL_VIDEO_OPENGL_ES */
749 } 824 }
750 825
751 /* Window has been successfully created */ 826 /* Window has been successfully created */
752 return 0; 827 return 0;
753 } 828 }
802 { 877 {
803 } 878 }
804 879
805 void qnxgf_destroywindow(_THIS, SDL_Window* window) 880 void qnxgf_destroywindow(_THIS, SDL_Window* window)
806 { 881 {
882 SDL_VideoData* gfdata=(SDL_VideoData*)_this->driverdata;
807 SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata; 883 SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
808 SDL_WindowData* wdata=(SDL_WindowData*)window->driverdata; 884 SDL_WindowData* wdata=(SDL_WindowData*)window->driverdata;
809 885
810 if (wdata!=NULL) 886 if (wdata!=NULL)
811 { 887 {
888 #if defined(SDL_VIDEO_OPENGL_ES)
889 /* Destroy OpenGL ES surface if it was created */
890 if (wdata->gles_surface!=EGL_NO_SURFACE)
891 {
892 eglDestroySurface(gfdata->egldisplay, wdata->gles_surface);
893 }
894
895 /* Free any 3D target if it was created before */
896 if (wdata->target_created==SDL_TRUE)
897 {
898 gf_3d_target_free(wdata->target);
899 }
900
901
902 gfdata->egl_refcount--;
903 if (gfdata->egl_refcount==0)
904 {
905 /* Terminate connection to OpenGL ES */
906 if (gfdata->egldisplay!=EGL_NO_DISPLAY)
907 {
908 eglTerminate(gfdata->egldisplay);
909 gfdata->egldisplay=EGL_NO_DISPLAY;
910 }
911 }
912 #endif /* SDL_VIDEO_OPENGL_ES */
812 } 913 }
813 } 914 }
814 915
815 /*****************************************************************************/ 916 /*****************************************************************************/
816 /* SDL Window Manager function */ 917 /* SDL Window Manager function */
824 { 925 {
825 return SDL_TRUE; 926 return SDL_TRUE;
826 } 927 }
827 else 928 else
828 { 929 {
829 SDL_SetError("application not compiled with SDL %d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION); 930 SDL_SetError("Application not compiled with SDL %d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
830 return SDL_FALSE; 931 return SDL_FALSE;
831 } 932 }
832 933
833 /* Failed to get window manager information */ 934 /* Failed to get window manager information */
834 return SDL_FALSE; 935 return SDL_FALSE;
837 /*****************************************************************************/ 938 /*****************************************************************************/
838 /* SDL OpenGL/OpenGL ES functions */ 939 /* SDL OpenGL/OpenGL ES functions */
839 /*****************************************************************************/ 940 /*****************************************************************************/
840 int qnxgf_gl_loadlibrary(_THIS, const char* path) 941 int qnxgf_gl_loadlibrary(_THIS, const char* path)
841 { 942 {
842 /* Failed to load new GL library */ 943 #if defined(SDL_VIDEO_OPENGL_ES)
843 return -1; 944 /* Check if OpenGL ES library is specified for GF driver */
945 if (path==NULL)
946 {
947 path=SDL_getenv("SDL_OPENGL_LIBRARY");
948 if (path==NULL)
949 {
950 path=SDL_getenv("SDL_OPENGLES_LIBRARY");
951 }
952 }
953
954 /* Check if default library loading requested */
955 if (path==NULL)
956 {
957 /* Already linked with GF library which provides egl* subset of */
958 /* functions, use Common profile of OpenGL ES library by default */
959 path="/usr/lib/libGLES_CM.so.1";
960 }
961
962 /* Load dynamic library */
963 _this->gl_config.dll_handle=SDL_LoadObject(path);
964 if (!_this->gl_config.dll_handle)
965 {
966 /* Failed to load new GL ES library */
967 SDL_SetError("GF: Failed to locate OpenGL ES library");
968 return -1;
969 }
970
971 /* Store OpenGL ES library path and name */
972 SDL_strlcpy(_this->gl_config.driver_path, path, SDL_arraysize(_this->gl_config.driver_path));
973
974 /* New OpenGL ES library is loaded */
975 return 0;
976 #else
977 SDL_SetError("GF: OpenGL ES support is not compiled in");
978 return -1;
979 #endif /* SDL_VIDEO_OPENGL_ES */
844 } 980 }
845 981
846 void* qnxgf_gl_getprocaddres(_THIS, const char* proc) 982 void* qnxgf_gl_getprocaddres(_THIS, const char* proc)
847 { 983 {
848 /* Failed to get GL function address pointer */ 984 #if defined(SDL_VIDEO_OPENGL_ES)
849 return NULL; 985 void* function_address;
986
987 /* Try to get function address through the egl interface */
988 function_address=eglGetProcAddress(proc);
989 if (function_address!=NULL)
990 {
991 return function_address;
992 }
993
994 /* Then try to get function in the OpenGL ES library */
995 if (_this->gl_config.dll_handle)
996 {
997 function_address=SDL_LoadFunction(_this->gl_config.dll_handle, proc);
998 if (function_address!=NULL)
999 {
1000 return function_address;
1001 }
1002 }
1003
1004 /* Failed to get GL ES function address pointer */
1005 SDL_SetError("GF: Cannot locate given function name");
1006 return NULL;
1007 #else
1008 SDL_SetError("GF: OpenGL ES support is not compiled in");
1009 return NULL;
1010 #endif /* SDL_VIDEO_OPENGL_ES */
850 } 1011 }
851 1012
852 void qnxgf_gl_unloadlibrary(_THIS) 1013 void qnxgf_gl_unloadlibrary(_THIS)
853 { 1014 {
1015 #if defined(SDL_VIDEO_OPENGL_ES)
1016 /* Unload OpenGL ES library */
1017 if (_this->gl_config.dll_handle)
1018 {
1019 SDL_UnloadObject(_this->gl_config.dll_handle);
1020 _this->gl_config.dll_handle=NULL;
1021 }
1022 #else
1023 SDL_SetError("GF: OpenGL ES support is not compiled in");
1024 return;
1025 #endif /* SDL_VIDEO_OPENGL_ES */
854 } 1026 }
855 1027
856 SDL_GLContext qnxgf_gl_createcontext(_THIS, SDL_Window* window) 1028 SDL_GLContext qnxgf_gl_createcontext(_THIS, SDL_Window* window)
857 { 1029 {
858 /* Failed to create GL context */ 1030 #if defined(SDL_VIDEO_OPENGL_ES)
859 return NULL; 1031 SDL_VideoData* gfdata=(SDL_VideoData*)_this->driverdata;
1032 SDL_WindowData* wdata=(SDL_WindowData*)window->driverdata;
1033 SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
1034 EGLBoolean status;
1035 int32_t gfstatus;
1036 EGLint configs;
1037 uint32_t surfaces;
1038 uint32_t attr_pos;
1039
1040 /* Prepare attributes list to pass them to OpenGL ES */
1041 attr_pos=0;
1042 wdata->gles_attributes[attr_pos++]=EGL_NATIVE_VISUAL_ID;
1043 wdata->gles_attributes[attr_pos++]=qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format);
1044 wdata->gles_attributes[attr_pos++]=EGL_RED_SIZE;
1045 wdata->gles_attributes[attr_pos++]=_this->gl_config.red_size;
1046 wdata->gles_attributes[attr_pos++]=EGL_GREEN_SIZE;
1047 wdata->gles_attributes[attr_pos++]=_this->gl_config.green_size;
1048 wdata->gles_attributes[attr_pos++]=EGL_BLUE_SIZE;
1049 wdata->gles_attributes[attr_pos++]=_this->gl_config.blue_size;
1050 wdata->gles_attributes[attr_pos++]=EGL_ALPHA_SIZE;
1051 if (_this->gl_config.alpha_size)
1052 {
1053 wdata->gles_attributes[attr_pos++]=_this->gl_config.alpha_size;
1054 }
1055 else
1056 {
1057 wdata->gles_attributes[attr_pos++]=EGL_DONT_CARE;
1058 }
1059 wdata->gles_attributes[attr_pos++]=EGL_DEPTH_SIZE;
1060 wdata->gles_attributes[attr_pos++]=_this->gl_config.depth_size;
1061 if (_this->gl_config.buffer_size)
1062 {
1063 wdata->gles_attributes[attr_pos++]=EGL_BUFFER_SIZE;
1064 wdata->gles_attributes[attr_pos++]=_this->gl_config.buffer_size;
1065 }
1066 if (_this->gl_config.stencil_size)
1067 {
1068 wdata->gles_attributes[attr_pos++]=EGL_STENCIL_SIZE;
1069 wdata->gles_attributes[attr_pos++]=_this->gl_config.buffer_size;
1070 }
1071
1072 /* OpenGL ES 1.0 uses double buffer by default, so if application */
1073 /* do not requested double buffering, switch to single buffer */
1074 if (!_this->gl_config.double_buffer)
1075 {
1076 wdata->gles_attributes[attr_pos++]=EGL_SINGLE_BUFFER;
1077 wdata->gles_attributes[attr_pos++]=EGL_TRUE;
1078 surfaces=1;
1079 }
1080 else
1081 {
1082 surfaces=2;
1083 }
1084
1085 /* Set number of samples in multisampling */
1086 if (_this->gl_config.multisamplesamples)
1087 {
1088 wdata->gles_attributes[attr_pos++]=EGL_SAMPLES;
1089 wdata->gles_attributes[attr_pos++]=_this->gl_config.multisamplesamples;
1090 }
1091
1092 /* Multisample buffers, OpenGL ES 1.0 spec defines 0 or 1 buffer */
1093 if (_this->gl_config.multisamplebuffers)
1094 {
1095 wdata->gles_attributes[attr_pos++]=EGL_SAMPLE_BUFFERS;
1096 wdata->gles_attributes[attr_pos++]=_this->gl_config.multisamplebuffers;
1097 }
1098
1099 /* Finish attributes list */
1100 wdata->gles_attributes[attr_pos]=EGL_NONE;
1101
1102 /* Request first suitable framebuffer configuration */
1103 status=eglChooseConfig(gfdata->egldisplay, wdata->gles_attributes, &wdata->gles_config, 1, &configs);
1104 if (status!=EGL_TRUE)
1105 {
1106 SDL_SetError("GF: Can't find closest configuration for OpenGL ES");
1107 return NULL;
1108 }
1109
1110 /* Create OpenGL ES context */
1111 wdata->gles_context=eglCreateContext(gfdata->egldisplay, wdata->gles_config, EGL_NO_CONTEXT, NULL);
1112 if (wdata->gles_context==EGL_NO_CONTEXT)
1113 {
1114 SDL_SetError("GF: OpenGL ES context creation has been failed");
1115 return NULL;
1116 }
1117
1118 /* Free any 3D target if it was created before */
1119 if (wdata->target_created==SDL_TRUE)
1120 {
1121 gf_3d_target_free(wdata->target);
1122 }
1123
1124 /* Create surface(s) target for OpenGL ES */
1125 gfstatus=gf_3d_target_create(&wdata->target, didata->layer, NULL,
1126 surfaces, didata->current_mode.w, didata->current_mode.h,
1127 qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format));
1128
1129 if (gfstatus!=GF_ERR_OK)
1130 {
1131 /* Destroy just created context */
1132 eglDestroyContext(gfdata->egldisplay, wdata->gles_context);
1133 wdata->gles_context=EGL_NO_CONTEXT;
1134
1135 /* Mark 3D target as unallocated */
1136 wdata->target_created=SDL_FALSE;
1137 SDL_SetError("GF: OpenGL ES target could not be created");
1138 return NULL;
1139 }
1140 else
1141 {
1142 wdata->target_created=SDL_TRUE;
1143 }
1144
1145 /* Create target rendering surface on whole screen */
1146 wdata->gles_surface=eglCreateWindowSurface(gfdata->egldisplay, wdata->gles_config, wdata->target, NULL);
1147 if (wdata->gles_surface==EGL_NO_SURFACE)
1148 {
1149 /* Destroy 3d target */
1150 gf_3d_target_free(wdata->target);
1151 wdata->target_created=SDL_FALSE;
1152
1153 /* Destroy OpenGL ES context */
1154 eglDestroyContext(gfdata->egldisplay, wdata->gles_context);
1155 wdata->gles_context=EGL_NO_CONTEXT;
1156
1157 SDL_SetError("GF: OpenGL ES surface could not be created");
1158 return NULL;
1159 }
1160
1161 /* Make just created context current */
1162 status=eglMakeCurrent(gfdata->egldisplay, wdata->gles_surface, wdata->gles_surface, wdata->gles_context);
1163 if (status!=EGL_TRUE)
1164 {
1165 /* Destroy OpenGL ES surface */
1166 eglDestroySurface(gfdata->egldisplay, wdata->gles_surface);
1167
1168 /* Destroy 3d target */
1169 gf_3d_target_free(wdata->target);
1170 wdata->target_created=SDL_FALSE;
1171
1172 /* Destroy OpenGL ES context */
1173 eglDestroyContext(gfdata->egldisplay, wdata->gles_context);
1174 wdata->gles_context=EGL_NO_CONTEXT;
1175
1176 /* Failed to set current GL ES context */
1177 SDL_SetError("GF: Can't set OpenGL ES context on creation");
1178 return NULL;
1179 }
1180
1181 /* Setup into SDL internals state of OpenGL ES: */
1182 /* it is accelerated or not */
1183 if ((didata->caps & SDL_GF_ACCELERATED_3D)==SDL_GF_ACCELERATED_3D)
1184 {
1185 _this->gl_config.accelerated=1;
1186 }
1187 else
1188 {
1189 _this->gl_config.accelerated=0;
1190 }
1191
1192 /* Always clear stereo enable, since OpenGL ES do not supports stereo */
1193 _this->gl_config.stereo=0;
1194
1195 /* Failed to create GL ES context */
1196 return wdata->gles_context;
1197 #else
1198 SDL_SetError("GF: OpenGL ES support is not compiled in");
1199 return NULL;
1200 #endif /* SDL_VIDEO_OPENGL_ES */
860 } 1201 }
861 1202
862 int qnxgf_gl_makecurrent(_THIS, SDL_Window* window, SDL_GLContext context) 1203 int qnxgf_gl_makecurrent(_THIS, SDL_Window* window, SDL_GLContext context)
863 { 1204 {
864 /* Failed to set current GL context */ 1205 #if defined(SDL_VIDEO_OPENGL_ES)
865 return -1; 1206 SDL_VideoData* gfdata=(SDL_VideoData*)_this->driverdata;
1207 SDL_WindowData* wdata;
1208 EGLBoolean status;
1209
1210 if ((window==NULL) && (context==NULL))
1211 {
1212 status=eglMakeCurrent(gfdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
1213 if (status!=EGL_TRUE)
1214 {
1215 /* Failed to set current GL ES context */
1216 SDL_SetError("GF: Can't set OpenGL ES context");
1217 return -1;
1218 }
1219 }
1220 else
1221 {
1222 wdata=(SDL_WindowData*)window->driverdata;
1223 status=eglMakeCurrent(gfdata->egldisplay, wdata->gles_surface, wdata->gles_surface, wdata->gles_context);
1224 if (status!=EGL_TRUE)
1225 {
1226 /* Failed to set current GL ES context */
1227 SDL_SetError("GF: Can't set OpenGL ES context");
1228 return -1;
1229 }
1230 }
1231
1232 return 0;
1233 #else
1234 SDL_SetError("GF: OpenGL ES support is not compiled in");
1235 return -1;
1236 #endif /* SDL_VIDEO_OPENGL_ES */
866 } 1237 }
867 1238
868 int qnxgf_gl_setswapinterval(_THIS, int interval) 1239 int qnxgf_gl_setswapinterval(_THIS, int interval)
869 { 1240 {
870 /* Failed to set swap interval */ 1241 #if defined(SDL_VIDEO_OPENGL_ES)
871 return -1; 1242 SDL_VideoData* gfdata=(SDL_VideoData*)_this->driverdata;
1243 EGLBoolean status;
1244
1245 /* Check if OpenGL ES connection has been initialized */
1246 if (gfdata->egldisplay!=EGL_NO_DISPLAY)
1247 {
1248 /* Set swap OpenGL ES interval */
1249 status=eglSwapInterval(gfdata->egldisplay, interval);
1250 if (status==EGL_TRUE)
1251 {
1252 /* Return success to upper level */
1253 gfdata->swapinterval=interval;
1254 return 0;
1255 }
1256 }
1257
1258 /* Failed to set swap interval */
1259 SDL_SetError("GF: Cannot set swap interval");
1260 return -1;
1261 #else
1262 SDL_SetError("GF: OpenGL ES support is not compiled in");
1263 return -1;
1264 #endif /* SDL_VIDEO_OPENGL_ES */
872 } 1265 }
873 1266
874 int qnxgf_gl_getswapinterval(_THIS) 1267 int qnxgf_gl_getswapinterval(_THIS)
875 { 1268 {
876 /* Failed to get default swap interval */ 1269 #if defined(SDL_VIDEO_OPENGL_ES)
877 return -1; 1270 SDL_VideoData* gfdata=(SDL_VideoData*)_this->driverdata;
1271
1272 /* Return default swap interval value */
1273 return gfdata->swapinterval;
1274 #else
1275 SDL_SetError("GF: OpenGL ES support is not compiled in");
1276 return -1;
1277 #endif /* SDL_VIDEO_OPENGL_ES */
878 } 1278 }
879 1279
880 void qnxgf_gl_swapwindow(_THIS, SDL_Window* window) 1280 void qnxgf_gl_swapwindow(_THIS, SDL_Window* window)
881 { 1281 {
1282 #if defined(SDL_VIDEO_OPENGL_ES)
1283 SDL_VideoData* gfdata=(SDL_VideoData*)_this->driverdata;
1284 SDL_WindowData* wdata=(SDL_WindowData*)window->driverdata;
1285
1286 eglSwapBuffers(gfdata->egldisplay, wdata->gles_surface);
1287 #else
1288 SDL_SetError("GF: OpenGL ES support is not compiled in");
1289 return;
1290 #endif /* SDL_VIDEO_OPENGL_ES */
882 } 1291 }
883 1292
884 void qnxgf_gl_deletecontext(_THIS, SDL_GLContext context) 1293 void qnxgf_gl_deletecontext(_THIS, SDL_GLContext context)
885 { 1294 {
1295 #if defined(SDL_VIDEO_OPENGL_ES)
1296 SDL_VideoData* gfdata=(SDL_VideoData*)_this->driverdata;
1297 EGLBoolean status;
1298
1299 /* Check if OpenGL ES connection has been initialized */
1300 if (gfdata->egldisplay!=EGL_NO_DISPLAY)
1301 {
1302 if (context!=EGL_NO_CONTEXT)
1303 {
1304 status=eglDestroyContext(gfdata->egldisplay, context);
1305 if (status!=EGL_TRUE)
1306 {
1307 /* Error during OpenGL ES context destroying */
1308 SDL_SetError("GF: OpenGL ES context destroy error");
1309 return;
1310 }
1311 }
1312 }
1313
1314 return;
1315 #else
1316 SDL_SetError("GF: OpenGL ES support is not compiled in");
1317 return;
1318 #endif /* SDL_VIDEO_OPENGL_ES */
886 } 1319 }
887 1320
888 /*****************************************************************************/ 1321 /*****************************************************************************/
889 /* SDL Event handling function */ 1322 /* SDL Event handling function */
890 /*****************************************************************************/ 1323 /*****************************************************************************/