Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
366 lines (296 loc) · 8.74 KB

SDL_photon.c

File metadata and controls

366 lines (296 loc) · 8.74 KB
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
Mar 17, 2009
Mar 17, 2009
21
22
23
24
QNX Photon GUI SDL driver
Copyright (C) 2009 Mike Gorchak
(mike@malva.ua, lestat@i.com.ua)
25
26
27
28
*/
#include "SDL_config.h"
Mar 17, 2009
Mar 17, 2009
29
30
31
32
#include "../SDL_sysvideo.h"
#include "SDL_version.h"
#include "SDL_syswm.h"
33
34
#include "../SDL_sysvideo.h"
Mar 17, 2009
Mar 17, 2009
35
36
#include "SDL_photon.h"
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
static SDL_bool photon_initialized=SDL_FALSE;
static int photon_available(void)
{
int status;
/* Check if Photon was initialized before */
if (photon_initialized==SDL_FALSE)
{
/* Initialize Photon widget library and open channel to Photon */
status=PtInit(NULL);
if (status==0)
{
photon_initialized=SDL_TRUE;
return 1;
}
else
{
photon_initialized=SDL_FALSE;
return 0;
}
}
return 1;
}
static void photon_destroy(SDL_VideoDevice* device)
{
}
static SDL_VideoDevice* photon_create(int devindex)
{
Mar 17, 2009
Mar 17, 2009
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
SDL_VideoDevice* device;
SDL_VideoData* phdata;
int status;
/* Check if photon could be initialized */
status=photon_available();
if (status==0)
{
/* Photon could not be used */
return NULL;
}
/* Initialize SDL_VideoDevice structure */
device=(SDL_VideoDevice*)SDL_calloc(1, sizeof(SDL_VideoDevice));
if (device==NULL)
{
SDL_OutOfMemory();
return NULL;
}
/* Initialize internal photon specific data */
phdata=(SDL_VideoData*)SDL_calloc(1, sizeof(SDL_VideoData));
if (phdata==NULL)
{
SDL_OutOfMemory();
SDL_free(device);
return NULL;
}
device->driverdata=phdata;
/* Setup amount of available displays and current display */
device->num_displays=0;
device->current_display=0;
102
103
104
105
106
}
VideoBootStrap photon_bootstrap=
{
"photon",
Mar 17, 2009
Mar 17, 2009
107
"SDL QNX Photon video driver",
108
109
110
111
photon_available,
photon_create
};
Mar 17, 2009
Mar 17, 2009
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
/*****************************************************************************/
/* SDL Video and Display initialization/handling functions */
/*****************************************************************************/
int photon_videoinit(_THIS)
{
SDL_VideoData* phdata=(SDL_VideoData*)_this->driverdata;
/* Check for environment variables which could override some SDL settings */
// didata->custom_refresh=0;
// override = SDL_getenv("SDL_VIDEO_PHOTON_REFRESH_RATE");
// if (override!=NULL)
// {
// if (SDL_sscanf(override, "%u", &didata->custom_refresh)!=1)
// {
// didata->custom_refresh=0;
// }
// }
/* Add photon renderer to SDL */
photon_addrenderdriver(_this);
/* video has been initialized successfully */
return 1;
}
void photon_videoquit(_THIS)
{
SDL_DisplayData* didata;
uint32_t it;
/* SDL will restore our desktop mode on exit */
for(it=0; it<_this->num_displays; it++)
{
didata=_this->displays[it].driverdata;
}
}
void photon_getdisplaymodes(_THIS)
{
SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
SDL_DisplayMode mode;
}
int photon_setdisplaymode(_THIS, SDL_DisplayMode* mode)
{
SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
return 0;
}
int photon_setdisplaypalette(_THIS, SDL_Palette* palette)
{
SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
/* Setting display palette operation has been failed */
return -1;
}
int photon_getdisplaypalette(_THIS, SDL_Palette* palette)
{
SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
/* Getting display palette operation has been failed */
return -1;
}
int photon_setdisplaygammaramp(_THIS, Uint16* ramp)
{
SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
/* Setting display gamma ramp operation has been failed */
return -1;
}
int photon_getdisplaygammaramp(_THIS, Uint16* ramp)
{
/* Getting display gamma ramp operation has been failed */
return -1;
}
int photon_createwindow(_THIS, SDL_Window* window)
{
SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
SDL_WindowData* wdata;
/* Allocate window internal data */
wdata=(SDL_WindowData*)SDL_calloc(1, sizeof(SDL_WindowData));
if (wdata==NULL)
{
SDL_OutOfMemory();
return -1;
}
/* Setup driver data for this window */
window->driverdata=wdata;
/* Check if window must support OpenGL ES rendering */
if ((window->flags & SDL_WINDOW_OPENGL)==SDL_WINDOW_OPENGL)
{
/* Mark this window as OpenGL ES compatible */
wdata->uses_gles=SDL_TRUE;
}
/* Window has been successfully created */
return 0;
}
int photon_createwindowfrom(_THIS, SDL_Window* window, const void* data)
{
/* Failed to create window from another window */
return -1;
}
void photon_setwindowtitle(_THIS, SDL_Window* window)
{
}
void photon_setwindowicon(_THIS, SDL_Window* window, SDL_Surface* icon)
{
}
void photon_setwindowposition(_THIS, SDL_Window* window)
{
}
void photon_setwindowsize(_THIS, SDL_Window* window)
{
}
void photon_showwindow(_THIS, SDL_Window* window)
{
}
void photon_hidewindow(_THIS, SDL_Window* window)
{
}
void photon_raisewindow(_THIS, SDL_Window* window)
{
}
void photon_maximizewindow(_THIS, SDL_Window* window)
{
}
void photon_minimizewindow(_THIS, SDL_Window* window)
{
}
void photon_restorewindow(_THIS, SDL_Window* window)
{
}
void photon_setwindowgrab(_THIS, SDL_Window* window)
{
}
void photon_destroywindow(_THIS, SDL_Window* window)
{
SDL_DisplayData* didata=(SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
SDL_WindowData* wdata=(SDL_WindowData*)window->driverdata;
if (wdata!=NULL)
{
}
}
/*****************************************************************************/
/* SDL Window Manager function */
/*****************************************************************************/
SDL_bool photon_getwindowwminfo(_THIS, SDL_Window* window, struct SDL_SysWMinfo* info)
{
if (info->version.major<=SDL_MAJOR_VERSION)
{
return SDL_TRUE;
}
else
{
SDL_SetError("application not compiled with SDL %d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
return SDL_FALSE;
}
/* Failed to get window manager information */
return SDL_FALSE;
}
/*****************************************************************************/
/* SDL OpenGL/OpenGL ES functions */
/*****************************************************************************/
int photon_gl_loadlibrary(_THIS, const char* path)
{
/* Failed to load new GL library */
return -1;
}
void* photon_gl_getprocaddres(_THIS, const char* proc)
{
/* Failed to get GL function address pointer */
return NULL;
}
void photon_gl_unloadlibrary(_THIS)
{
}
SDL_GLContext photon_gl_createcontext(_THIS, SDL_Window* window)
{
/* Failed to create GL context */
return NULL;
}
int photon_gl_makecurrent(_THIS, SDL_Window* window, SDL_GLContext context)
{
/* Failed to set current GL context */
return -1;
}
int photon_gl_setswapinterval(_THIS, int interval)
{
/* Failed to set swap interval */
return -1;
}
int photon_gl_getswapinterval(_THIS)
{
/* Failed to get default swap interval */
return -1;
}
void photon_gl_swapwindow(_THIS, SDL_Window* window)
{
}
void photon_gl_deletecontext(_THIS, SDL_GLContext context)
{
}
/*****************************************************************************/
/* SDL Event handling function */
/*****************************************************************************/
void photon_pumpevents(_THIS)
{
}
/*****************************************************************************/
/* SDL screen saver related functions */
/*****************************************************************************/
void photon_suspendscreensaver(_THIS)
{
/* There is no screensaver in pure console, it may exist when running */
/* GF under Photon, but I do not know, how to disable screensaver */
}
366
/* vi: set ts=4 sw=4 expandtab: */