/
SDL_ph_video.c
699 lines (607 loc) · 20.2 KB
1
2
/*
SDL - Simple DirectMedia Layer
3
Copyright (C) 1997-2004 Sam Lantinga
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
20
slouken@libsdl.org
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/ioctl.h>
#include "SDL.h"
#include "SDL_error.h"
#include "SDL_timer.h"
#include "SDL_thread.h"
#include "SDL_video.h"
#include "SDL_mouse.h"
#include "SDL_endian.h"
#include "SDL_sysvideo.h"
#include "SDL_pixels_c.h"
#include "SDL_events_c.h"
#include "SDL_ph_video.h"
#include "SDL_ph_modes_c.h"
#include "SDL_ph_image_c.h"
#include "SDL_ph_events_c.h"
#include "SDL_ph_mouse_c.h"
49
#include "SDL_ph_wm_c.h"
50
51
52
#include "SDL_phyuv_c.h"
#include "blank_cursor.h"
53
54
55
static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat);
static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
static int ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
56
57
static void ph_VideoQuit(_THIS);
static void ph_DeleteDevice(SDL_VideoDevice *device);
58
59
#ifdef HAVE_OPENGL
60
61
62
static void ph_GL_SwapBuffers(_THIS);
static int ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
static int ph_GL_LoadLibrary(_THIS, const char* path);
63
static void* ph_GL_GetProcAddress(_THIS, const char* proc);
64
static int ph_GL_MakeCurrent(_THIS);
65
#endif /* HAVE_OPENGL */
66
67
68
static int phstatus=-1;
69
70
static int ph_Available(void)
{
71
if (phstatus==-1)
72
{
73
74
75
76
77
78
79
80
81
phstatus=PtInit(NULL);
if (phstatus==0)
{
return 1;
}
else
{
return 0;
}
82
}
83
return 1;
84
85
86
87
88
89
90
91
}
static SDL_VideoDevice *ph_CreateDevice(int devindex)
{
SDL_VideoDevice *device;
/* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
92
if (device) {
93
94
95
96
97
memset(device, 0, (sizeof *device));
device->hidden = (struct SDL_PrivateVideoData *)
malloc((sizeof *device->hidden));
device->gl_data = NULL;
}
98
if ((device == NULL) || (device->hidden == NULL)) {
99
100
101
102
103
104
105
SDL_OutOfMemory();
ph_DeleteDevice(device);
return(0);
}
memset(device->hidden, 0, (sizeof *device->hidden));
/* Set the driver flags */
106
device->handles_any_size = 1; /* JB not true for fullscreen */
107
108
/* Set the function pointers */
109
device->CreateYUVOverlay = ph_CreateYUVOverlay;
110
111
112
device->VideoInit = ph_VideoInit;
device->ListModes = ph_ListModes;
device->SetVideoMode = ph_SetVideoMode;
113
device->ToggleFullScreen = ph_ToggleFullScreen;
114
device->UpdateMouse = ph_UpdateMouse;
115
device->SetColors = ph_SetColors;
116
device->UpdateRects = NULL; /* set up in ph_SetupUpdateFunction */
117
118
119
120
121
122
123
124
125
126
device->VideoQuit = ph_VideoQuit;
device->AllocHWSurface = ph_AllocHWSurface;
device->CheckHWBlit = NULL;
device->FillHWRect = NULL;
device->SetHWColorKey = NULL;
device->SetHWAlpha = NULL;
device->LockHWSurface = ph_LockHWSurface;
device->UnlockHWSurface = ph_UnlockHWSurface;
device->FlipHWSurface = ph_FlipHWSurface;
device->FreeHWSurface = ph_FreeHWSurface;
127
device->SetCaption = ph_SetCaption;
128
device->SetIcon = NULL;
129
device->IconifyWindow = ph_IconifyWindow;
130
device->GrabInput = ph_GrabInput;
131
device->GetWMInfo = ph_GetWMInfo;
132
133
134
135
device->FreeWMCursor = ph_FreeWMCursor;
device->CreateWMCursor = ph_CreateWMCursor;
device->ShowWMCursor = ph_ShowWMCursor;
device->WarpWMCursor = ph_WarpWMCursor;
136
device->MoveWMCursor = NULL;
137
138
139
140
device->CheckMouseMode = ph_CheckMouseMode;
device->InitOSKeymap = ph_InitOSKeymap;
device->PumpEvents = ph_PumpEvents;
141
142
/* OpenGL support. */
#ifdef HAVE_OPENGL
143
device->GL_MakeCurrent = ph_GL_MakeCurrent;
144
device->GL_SwapBuffers = ph_GL_SwapBuffers;
145
device->GL_GetAttribute = ph_GL_GetAttribute;
146
147
device->GL_LoadLibrary = ph_GL_LoadLibrary;
device->GL_GetProcAddress = ph_GL_GetProcAddress;
148
#else
149
device->GL_MakeCurrent = NULL;
150
device->GL_SwapBuffers = NULL;
151
device->GL_GetAttribute = NULL;
152
153
device->GL_LoadLibrary = NULL;
device->GL_GetProcAddress = NULL;
154
#endif /* HAVE_OPENGL */
155
156
device->free = ph_DeleteDevice;
157
158
159
160
return device;
}
161
VideoBootStrap ph_bootstrap = {
162
163
"photon", "QNX Photon video output",
ph_Available, ph_CreateDevice
164
165
166
167
};
static void ph_DeleteDevice(SDL_VideoDevice *device)
{
168
169
170
171
if (device)
{
if (device->hidden)
{
172
173
174
free(device->hidden);
device->hidden = NULL;
}
175
176
if (device->gl_data)
{
177
178
179
180
181
182
183
184
free(device->gl_data);
device->gl_data = NULL;
}
free(device);
device = NULL;
}
}
185
186
187
188
static PtWidget_t *ph_CreateWindow(_THIS)
{
PtWidget_t *widget;
189
widget = PtCreateWidget(PtWindow, NULL, 0, NULL);
190
191
192
193
194
195
196
197
return widget;
}
static int ph_SetupWindow(_THIS, int w, int h, int flags)
{
PtArg_t args[32];
PhPoint_t pos = {0, 0};
198
PhDim_t* olddim;
199
PhDim_t dim = {w, h};
200
PhRect_t desktopextent;
201
int nargs = 0;
202
203
204
const char* windowpos;
const char* iscentered;
int x, y;
205
206
207
208
209
210
211
/* check if window size has been changed by Window Manager */
PtGetResource(window, Pt_ARG_DIM, &olddim, 0);
if ((olddim->w!=w) || (olddim->h!=h))
{
PtSetArg(&args[nargs++], Pt_ARG_DIM, &dim, 0);
}
212
213
214
if ((flags & SDL_RESIZABLE) == SDL_RESIZABLE)
{
215
216
217
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_CLOSE);
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_RESIZE);
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_RESIZE | Ph_WM_MOVE | Ph_WM_CLOSE | Ph_WM_MAX | Ph_WM_RESTORE);
218
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN);
219
PtSetArg(&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, Pt_RESIZE_XY_AS_REQUIRED);
220
221
222
}
else
{
223
224
225
226
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_CLOSE);
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE);
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_MOVE | Ph_WM_CLOSE);
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN);
227
PtSetArg(&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED);
228
229
230
231
}
if (((flags & SDL_NOFRAME)==SDL_NOFRAME) || ((flags & SDL_FULLSCREEN)==SDL_FULLSCREEN))
{
232
233
234
235
236
237
238
239
240
if ((flags & SDL_RESIZABLE) != SDL_RESIZABLE)
{
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Pt_TRUE);
}
else
{
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Pt_TRUE);
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_BORDER);
}
241
242
243
244
}
else
{
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_BORDER | Ph_WM_RENDER_TITLE |
245
Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_MENU | Ph_WM_RENDER_MIN);
246
247
}
248
if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN)
249
250
{
PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
251
PtSetArg(&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, Pt_BASIC_PREVENT_FILL);
252
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_FFRONT | Ph_WM_MAX | Ph_WM_TOFRONT | Ph_WM_CONSWITCH);
253
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISFOCUS | Ph_WM_STATE_ISALTKEY);
254
255
256
}
else
{
257
if (!currently_maximized)
258
{
259
260
261
262
windowpos = getenv("SDL_VIDEO_WINDOW_POS");
iscentered = getenv("SDL_VIDEO_CENTERED");
if ((iscentered) || ((windowpos) && (strcmp(windowpos, "center")==0)))
263
{
264
265
PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, 0, &desktopextent);
if (desktop_mode.width>w)
266
{
267
268
269
270
271
pos.x = (desktop_mode.width - w)/2;
}
if (desktop_mode.height>h)
{
pos.y = (desktop_mode.height - h)/2;
272
273
}
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
pos.x+=desktopextent.ul.x;
pos.y+=desktopextent.ul.y;
PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
}
else
{
if (windowpos)
{
if (sscanf(windowpos, "%d,%d", &x, &y) == 2)
{
if ((x<desktop_mode.width) && (y<desktop_mode.height))
{
PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, 0, &desktopextent);
pos.x=x+desktopextent.ul.x;
pos.y=y+desktopextent.ul.y;
}
PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
}
}
}
}
295
296
PtSetArg(&args[nargs++], Pt_ARG_FILL_COLOR, Pg_BLACK, 0);
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
/* if window is maximized render it as maximized */
if (currently_maximized)
{
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISMAX);
}
else
{
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISMAX);
}
/* do not grab the keyboard by default */
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISALTKEY);
/* bring the focus to the window */
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFOCUS);
/* allow to catch hide events */
315
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_HIDE);
316
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_HIDE);
317
318
319
320
}
PtSetResources(window, nargs, args);
PtRealizeWidget(window);
321
PtWindowToFront(window);
322
323
324
325
return 0;
}
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
static const struct ColourMasks* ph_GetColourMasks(int bpp)
{
/* The alpha mask doesn't appears to be needed */
static const struct ColourMasks phColorMasks[5] = {
/* 8 bit */ {0, 0, 0, 0, 8},
/* 15 bit ARGB */ {0x7C00, 0x03E0, 0x001F, 0x8000, 15},
/* 16 bit RGB */ {0xF800, 0x07E0, 0x001F, 0x0000, 16},
/* 24 bit RGB */ {0xFF0000, 0x00FF00, 0x0000FF, 0x000000, 24},
/* 32 bit ARGB */ {0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000, 32},
};
switch (bpp)
{
case 8:
return &phColorMasks[0];
case 15:
return &phColorMasks[1];
case 16:
return &phColorMasks[2];
case 24:
return &phColorMasks[3];
case 32:
return &phColorMasks[4];
}
return NULL;
}
353
354
static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat)
{
355
PgHWCaps_t my_hwcaps;
356
int i;
357
358
window=NULL;
359
desktoppal=SDLPH_PAL_NONE;
360
361
362
#ifdef HAVE_OPENGL
oglctx=NULL;
363
364
oglflags=0;
oglbpp=0;
365
#endif /* HAVE_OPENGL */
366
367
368
old_video_mode=-1;
old_refresh_rate=-1;
369
370
371
if (NULL == (event = malloc(EVENT_SIZE)))
{
372
373
SDL_OutOfMemory();
return -1;
374
}
375
memset(event, 0x00, EVENT_SIZE);
376
377
378
379
window = ph_CreateWindow(this);
if (window == NULL)
{
380
SDL_SetError("ph_VideoInit(): Couldn't create video window !\n");
381
382
383
return -1;
}
384
385
386
387
388
389
390
/* Create the blank cursor */
SDL_BlankCursor = this->CreateWMCursor(this, blank_cdata, blank_cmask,
(int)BLANK_CWIDTH, (int)BLANK_CHEIGHT,
(int)BLANK_CHOTX, (int)BLANK_CHOTY);
if (SDL_BlankCursor == NULL)
{
391
return -1;
392
393
394
395
}
if (PgGetGraphicsHWCaps(&my_hwcaps) < 0)
{
396
397
398
SDL_SetError("ph_VideoInit(): GetGraphicsHWCaps function failed !\n");
this->FreeWMCursor(this, SDL_BlankCursor);
return -1;
399
400
}
401
if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &desktop_mode) < 0)
402
{
403
404
405
SDL_SetError("ph_VideoInit(): PgGetVideoModeInfo function failed !\n");
this->FreeWMCursor(this, SDL_BlankCursor);
return -1;
406
407
408
}
/* We need to return BytesPerPixel as it in used by CreateRGBsurface */
409
410
411
vformat->BitsPerPixel = desktop_mode.bits_per_pixel;
vformat->BytesPerPixel = desktop_mode.bytes_per_scanline/desktop_mode.width;
desktopbpp = desktop_mode.bits_per_pixel;
412
413
414
/* save current palette */
if (desktopbpp==8)
415
{
416
417
PgGetPalette(savedpal);
PgGetPalette(syspalph);
418
}
419
420
421
422
423
424
425
426
else
{
for(i=0; i<_Pg_MAX_PALETTE; i++)
{
savedpal[i]=PgRGB(0, 0, 0);
syspalph[i]=PgRGB(0, 0, 0);
}
}
427
428
currently_fullscreen = 0;
429
currently_hided = 0;
430
currently_maximized = 0;
431
432
433
434
435
436
437
438
439
current_overlay = NULL;
OCImage.direct_context = NULL;
OCImage.offscreen_context = NULL;
OCImage.offscreen_backcontext = NULL;
OCImage.oldDC = NULL;
OCImage.CurrentFrameData = NULL;
OCImage.FrameData0 = NULL;
OCImage.FrameData1 = NULL;
440
441
442
this->info.wm_available = 1;
443
444
445
446
447
448
return 0;
}
static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
int width, int height, int bpp, Uint32 flags)
{
449
const struct ColourMasks* mask;
450
451
452
453
/* Lock the event thread, in multi-threading environments */
SDL_Lock_EventThread();
454
455
current->flags = flags;
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
/* if we do not have desired fullscreen mode, then fallback into window mode */
if (((current->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) && (ph_GetVideoMode(width, height, bpp)==0))
{
current->flags &= ~SDL_FULLSCREEN;
current->flags &= ~SDL_NOFRAME;
current->flags &= ~SDL_RESIZABLE;
}
ph_SetupWindow(this, width, height, current->flags);
mask = ph_GetColourMasks(bpp);
if (mask != NULL)
{
SDL_ReallocFormat(current, mask->bpp, mask->red, mask->green, mask->blue, 0);
}
else
{
SDL_SetError("ph_SetVideoMode(): desired bpp is not supported by photon !\n");
return NULL;
}
476
477
#ifdef HAVE_OPENGL
478
if ((current->flags & SDL_OPENGL)==SDL_OPENGL)
479
{
480
#else
481
if ((current->flags & SDL_OPENGL)==SDL_OPENGL) /* if no built-in OpenGL support */
482
{
483
SDL_SetError("ph_SetVideoMode(): no OpenGL support, try to recompile library.\n");
484
current->flags &= ~SDL_OPENGL;
485
return NULL;
486
#endif /* HAVE_OPENGL */
487
}
488
489
else
{
490
491
/* Initialize internal variables */
if ((current->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN)
492
{
493
494
495
496
if (bpp==8)
{
desktoppal=SDLPH_PAL_SYSTEM;
}
497
498
current->flags &= ~SDL_RESIZABLE; /* no resize for Direct Context */
499
current->flags |= SDL_HWSURFACE;
500
}
501
502
else
{
503
504
505
506
507
/* remove this if we'll support non-fullscreen sw/hw+doublebuf */
current->flags &= ~SDL_DOUBLEBUF;
/* Use offscreen memory if SDL_HWSURFACE flag is set */
if ((current->flags & SDL_HWSURFACE) == SDL_HWSURFACE)
508
{
509
510
511
512
513
if (desktopbpp!=bpp)
{
current->flags &= ~SDL_HWSURFACE;
}
514
}
515
516
517
518
519
520
/* using palette emulation code in window mode */
if (bpp==8)
{
if (desktopbpp>=15)
{
521
desktoppal = SDLPH_PAL_EMULATE;
522
523
524
}
else
{
525
desktoppal = SDLPH_PAL_SYSTEM;
526
527
528
}
}
else
529
{
530
desktoppal = SDLPH_PAL_NONE;
531
}
532
}
533
534
535
536
}
current->w = width;
current->h = height;
537
538
539
540
541
if (desktoppal==SDLPH_PAL_SYSTEM)
{
current->flags|=SDL_HWPALETTE;
}
542
543
544
/* Must call at least once for setup image planes */
if (ph_SetupUpdateFunction(this, current, current->flags)==-1)
545
546
547
{
return NULL;
}
548
549
550
551
552
553
/* finish window drawing, if we are not in fullscreen, of course */
if ((current->flags & SDL_FULLSCREEN) != SDL_FULLSCREEN)
{
PtFlush();
}
554
555
556
557
else
{
PgFlush();
}
558
559
560
561
SDL_Unlock_EventThread();
/* We're done! */
562
return (current);
563
564
565
566
}
static void ph_VideoQuit(_THIS)
{
567
568
/* restore palette */
if (desktopbpp==8)
569
{
570
571
572
PgSetPalette(syspalph, 0, -1, 0, 0, 0);
PgSetPalette(savedpal, 0, 0, _Pg_MAX_PALETTE, Pg_PALSET_GLOBAL | Pg_PALSET_FORCE_EXPOSE, 0);
PgFlush();
573
}
574
575
576
ph_DestroyImage(this, SDL_VideoSurface);
577
578
579
580
581
582
583
if (window)
{
PtUnrealizeWidget(window);
PtDestroyWidget(window);
window=NULL;
}
584
585
586
587
588
if (event!=NULL)
{
free(event);
event=NULL;
}
589
}
590
591
592
static int ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
{
593
int i;
594
595
596
597
598
SDL_Rect updaterect;
updaterect.x = updaterect.y = 0;
updaterect.w = this->screen->w;
updaterect.h = this->screen->h;
599
600
601
602
603
604
605
606
/* palette emulation code, using palette of the PhImage_t struct */
if (desktoppal==SDLPH_PAL_EMULATE)
{
if ((SDL_Image) && (SDL_Image->palette))
{
for (i=firstcolor; i<firstcolor+ncolors; i++)
{
607
608
syspalph[i] = PgRGB(colors[i-firstcolor].r, colors[i-firstcolor].g, colors[i-firstcolor].b);
SDL_Image->palette[i] = syspalph[i];
609
}
610
611
612
/* image needs to be redrawn */
this->UpdateRects(this, 1, &updaterect);
613
}
614
}
615
616
617
else
{
if (desktoppal==SDLPH_PAL_SYSTEM)
618
{
619
620
for (i=firstcolor; i<firstcolor+ncolors; i++)
{
621
syspalph[i] = PgRGB(colors[i-firstcolor].r, colors[i-firstcolor].g, colors[i-firstcolor].b);
622
623
624
625
}
if ((this->screen->flags & SDL_FULLSCREEN) != SDL_FULLSCREEN)
{
626
/* window mode must use soft palette */
627
PgSetPalette(&syspalph[firstcolor], 0, firstcolor, ncolors, Pg_PALSET_GLOBAL, 0);
628
629
/* image needs to be redrawn */
this->UpdateRects(this, 1, &updaterect);
630
631
632
633
}
else
{
/* fullscreen mode must use hardware palette */
634
PgSetPalette(&syspalph[firstcolor], 0, firstcolor, ncolors, Pg_PALSET_GLOBAL, 0);
635
}
636
}
637
else
638
{
639
/* SDLPH_PAL_NONE do nothing */
640
}
641
642
643
}
return 1;
644
645
}
646
#ifdef HAVE_OPENGL
647
648
static void ph_GL_SwapBuffers(_THIS)
649
{
650
PgSetRegion(PtWidgetRid(window));
651
PdOpenGLContextSwapBuffers(oglctx);
652
653
}
654
static int ph_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
655
{
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
switch (attrib)
{
case SDL_GL_DOUBLEBUFFER:
*value=this->gl_config.double_buffer;
break;
case SDL_GL_STENCIL_SIZE:
*value=this->gl_config.stencil_size;
break;
case SDL_GL_DEPTH_SIZE:
*value=this->gl_config.depth_size;
break;
default:
*value=0;
return(-1);
}
return 0;
672
}
673
674
static int ph_GL_LoadLibrary(_THIS, const char* path)
675
{
676
/* if code compiled with HAVE_OPENGL, that mean that library already linked */
677
678
679
680
681
this->gl_config.driver_loaded = 1;
return 0;
}
682
static void* ph_GL_GetProcAddress(_THIS, const char* proc)
683
684
685
686
{
return NULL;
}
687
static int ph_GL_MakeCurrent(_THIS)
688
{
689
PgSetRegion(PtWidgetRid(window));
690
691
if (oglctx!=NULL)
692
{
693
PhDCSetCurrent(oglctx);
694
695
}
696
return 0;
697
}
698
699
#endif /* HAVE_OPENGL */