annotate src/video/qnxgf/SDL_qnxgf.c @ 3461:87182c69e080

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