Mercurial > sdl-ios-xcode
annotate src/video/photon/SDL_ph_video.c @ 204:62bad9a82022
Added photon fixes submitted by Luca Barbato
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 08 Oct 2001 18:54:06 +0000 |
parents | 8cc4dbfab9ab |
children | e8157fcb3114 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
3 Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga | |
4 | |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
20 slouken@devolution.com | |
21 */ | |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 #include <stdlib.h> | |
29 #include <stdio.h> | |
30 #include <unistd.h> | |
31 #include <string.h> | |
32 #include <sys/ioctl.h> | |
33 | |
34 #include "SDL.h" | |
35 #include "SDL_error.h" | |
36 #include "SDL_timer.h" | |
37 #include "SDL_thread.h" | |
38 #include "SDL_video.h" | |
39 #include "SDL_mouse.h" | |
40 #include "SDL_endian.h" | |
41 #include "SDL_sysvideo.h" | |
42 #include "SDL_pixels_c.h" | |
43 #include "SDL_events_c.h" | |
44 #include "SDL_ph_video.h" | |
45 #include "SDL_ph_modes_c.h" | |
46 #include "SDL_ph_image_c.h" | |
47 #include "SDL_ph_events_c.h" | |
48 #include "SDL_ph_mouse_c.h" | |
19
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
49 #include "SDL_ph_wm_c.h" |
0 | 50 #include "SDL_phyuv_c.h" |
51 #include "blank_cursor.h" | |
52 | |
53 static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat); | |
54 static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current, | |
55 int width, int height, int bpp, Uint32 flags); | |
56 static int ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); | |
57 static void ph_VideoQuit(_THIS); | |
58 static void ph_DeleteDevice(SDL_VideoDevice *device); | |
59 | |
60 static int ph_Available(void) | |
61 { | |
62 | |
63 return 1; | |
64 } | |
65 | |
66 static SDL_VideoDevice *ph_CreateDevice(int devindex) | |
67 { | |
68 SDL_VideoDevice *device; | |
69 | |
70 /* Initialize all variables that we clean on shutdown */ | |
71 device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); | |
72 if ( device ) { | |
73 memset(device, 0, (sizeof *device)); | |
74 device->hidden = (struct SDL_PrivateVideoData *) | |
75 malloc((sizeof *device->hidden)); | |
76 device->gl_data = NULL; | |
77 } | |
78 if ( (device == NULL) || (device->hidden == NULL) ) { | |
79 SDL_OutOfMemory(); | |
80 ph_DeleteDevice(device); | |
81 return(0); | |
82 } | |
83 memset(device->hidden, 0, (sizeof *device->hidden)); | |
84 | |
85 /* Set the driver flags */ | |
86 device->handles_any_size = 1; //JB not true for fullscreen | |
87 | |
88 /* Set the function pointers */ | |
89 device->CreateYUVOverlay = ph_CreateYUVOverlay; | |
90 device->VideoInit = ph_VideoInit; | |
91 device->ListModes = ph_ListModes; | |
92 device->SetVideoMode = ph_SetVideoMode; | |
93 device->ToggleFullScreen = ph_ToggleFullScreen; | |
94 device->UpdateMouse = NULL; | |
95 device->SetColors = ph_SetColors; | |
96 device->UpdateRects = NULL; //set in ph_ResizeImage | |
97 device->VideoQuit = ph_VideoQuit; | |
98 device->AllocHWSurface = ph_AllocHWSurface; | |
99 device->CheckHWBlit = NULL; | |
100 device->FillHWRect = NULL; | |
101 device->SetHWColorKey = NULL; | |
102 device->SetHWAlpha = NULL; | |
103 device->LockHWSurface = ph_LockHWSurface; | |
104 device->UnlockHWSurface = ph_UnlockHWSurface; | |
105 device->FlipHWSurface = ph_FlipHWSurface; | |
106 device->FreeHWSurface = ph_FreeHWSurface; | |
19
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
107 device->SetCaption = ph_SetCaption; |
0 | 108 device->SetIcon = NULL; |
19
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
109 device->IconifyWindow = ph_IconifyWindow; |
0 | 110 device->GrabInput = NULL; |
111 device->GetWMInfo = NULL; | |
112 device->FreeWMCursor = ph_FreeWMCursor; | |
113 device->CreateWMCursor = ph_CreateWMCursor; | |
114 device->ShowWMCursor = ph_ShowWMCursor; | |
115 device->WarpWMCursor = ph_WarpWMCursor; | |
116 device->CheckMouseMode = ph_CheckMouseMode; | |
117 device->InitOSKeymap = ph_InitOSKeymap; | |
118 device->PumpEvents = ph_PumpEvents; | |
119 | |
120 device->free = ph_DeleteDevice; | |
121 | |
122 return device; | |
123 } | |
124 | |
19
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
125 VideoBootStrap ph_bootstrap = { |
0 | 126 "photon", "QNX Photon video output", |
127 ph_Available, ph_CreateDevice | |
128 }; | |
129 | |
130 static void ph_DeleteDevice(SDL_VideoDevice *device) | |
131 { | |
132 | |
133 if ( device ) { | |
134 if ( device->hidden ) { | |
135 free(device->hidden); | |
136 device->hidden = NULL; | |
137 } | |
138 if ( device->gl_data ) { | |
139 free(device->gl_data); | |
140 device->gl_data = NULL; | |
141 } | |
142 free(device); | |
143 device = NULL; | |
144 } | |
145 } | |
146 | |
147 static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat) | |
148 { | |
149 PtArg_t arg[1]; | |
150 PhDim_t dim; | |
151 PgColor_t ph_palette[_Pg_MAX_PALETTE]; | |
152 int i; | |
153 unsigned long *tempptr; | |
154 int rtnval; | |
155 PgDisplaySettings_t mysettings; | |
156 PgVideoModeInfo_t my_mode_info; | |
204
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
157 PgHWCaps_t my_hwcaps; |
0 | 158 |
159 if( NULL == ( event = malloc( EVENT_SIZE ) ) ) | |
160 exit( EXIT_FAILURE ); | |
161 | |
162 /* Create a widget 'window' to capture events */ | |
163 dim.w=0; //JB test320; | |
164 dim.h=0; //JB test240; | |
165 //We need to return BytesPerPixel as it in used by CreateRGBsurface | |
166 | |
167 PtSetArg(&arg[0], Pt_ARG_DIM, &dim,0); | |
168 | |
169 /* | |
170 PtSetArg(&arg[1], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, Pt_RESIZE_XY_AS_REQUIRED); | |
171 PtSetArg(&arg[2], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | | |
172 Ph_WM_STATE_ISMAX | | |
173 Ph_WM_STATE_ISFOCUS); | |
174 | |
175 PtSetArg(&arg[3], Pt_ARG_WINDOW_RENDER_FLAGS,Pt_FALSE,~0); | |
176 PtSetArg(&arg[4], Pt_ARG_WINDOW_MANAGED_FLAGS,Pt_TRUE, | |
177 Ph_WM_FFRONT | | |
178 Ph_WM_CLOSE | | |
179 Ph_WM_TOFRONT | | |
180 Ph_WM_CONSWITCH); | |
181 */ | |
182 | |
183 | |
184 window=PtAppInit(NULL, NULL, NULL, 1, arg); | |
185 | |
186 if(window == NULL) | |
187 { | |
19
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
188 printf("Photon application init failed, probably Photon is not running.\n"); |
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
189 exit( EXIT_FAILURE ); |
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
190 // PtExit(EXIT_FAILURE); // Got SEGFAULT. |
0 | 191 } |
192 | |
193 //PgSetDrawBufferSize(16 *1024); | |
194 PgSetRegion(PtWidgetRid(window)); | |
195 PgSetClipping(0,NULL); | |
196 PtRealizeWidget(window); | |
197 | |
198 | |
199 /* Get the available video modes */ | |
200 // if(ph_GetVideoModes(this) < 0) | |
201 // return -1; | |
202 | |
203 /* Create the blank cursor */ | |
204 SDL_BlankCursor = this->CreateWMCursor(this, blank_cdata, blank_cmask, | |
205 (int)BLANK_CWIDTH, (int)BLANK_CHEIGHT, | |
206 (int)BLANK_CHOTX, (int)BLANK_CHOTY); | |
207 | |
208 if(SDL_BlankCursor == NULL) | |
209 printf("could not create blank cursor\n"); | |
210 /* Get the video mode */ | |
204
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
211 /* |
0 | 212 if (PgGetVideoMode( &mysettings ) < 0) |
213 { | |
204
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
214 fprintf(stderr,"ph_VideoInit: PgGetVideoMode failed patch A?? \n"); |
0 | 215 //QNX6/Patch A always fails return code even though call succeeds. fixed Patch B |
216 } | |
204
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
217 */ |
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
218 if (PgGetGraphicsHWCaps(&my_hwcaps) < 0) |
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
219 { |
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
220 fprintf(stderr,"ph_VideoInit: GetGraphicsHWCaps failed!! \n"); |
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
221 //that HAVE to work |
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
222 } |
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
223 if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &my_mode_info) < 0) |
0 | 224 { |
225 fprintf(stderr,"ph_VideoInit: PgGetVideoModeInfo failed\n"); | |
226 } | |
227 //We need to return BytesPerPixel as it in used by CreateRGBsurface | |
228 vformat->BitsPerPixel = my_mode_info.bits_per_pixel; | |
229 vformat->BytesPerPixel = vformat->BitsPerPixel/8; | |
230 | |
231 //return a palette if we are in 256 color mode | |
232 if(vformat->BitsPerPixel == 8) | |
233 { | |
234 vformat->palette = malloc(sizeof(SDL_Palette)); | |
235 memset(vformat->palette, 0, sizeof(SDL_Palette)); | |
236 vformat->palette->ncolors = 256; | |
237 vformat->palette->colors = (SDL_Color *)malloc(256 *sizeof(SDL_Color)); | |
238 | |
239 //fill the palette | |
240 rtnval = PgGetPalette(ph_palette); | |
241 if(rtnval < 0) | |
242 printf("ph_VideoInit: PgGetPalette failed\n"); | |
243 | |
244 tempptr = (unsigned long *)vformat->palette->colors; | |
245 | |
246 for(i=0;i<256; i++) | |
247 { | |
248 *tempptr = (((unsigned long)ph_palette[i]) << 8); | |
249 tempptr++; | |
250 | |
251 } | |
252 | |
253 } | |
254 | |
255 | |
19
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
256 currently_fullscreen = 0; |
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
257 |
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
258 this->info.wm_available = 1; |
8cc4dbfab9ab
Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
259 |
0 | 260 return 0; |
261 } | |
262 | |
263 static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current, | |
264 int width, int height, int bpp, Uint32 flags) | |
265 { | |
266 PhRegion_t region_info; | |
267 PgDisplaySettings_t settings; | |
204
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
268 PgHWCaps_t my_hwcaps; |
0 | 269 PgVideoModeInfo_t mode_info; |
270 int mode, actual_width, actual_height; | |
271 PtArg_t arg[5]; | |
272 PhDim_t dim; | |
273 int rtnval; | |
274 SDL_Rect ** mymodelist; | |
275 SDL_PixelFormat myformat; | |
276 PgColor_t ph_palette[_Pg_MAX_PALETTE]; | |
277 int i; | |
278 unsigned long *tempptr; | |
279 | |
280 actual_width = width; | |
281 actual_height = height; | |
282 | |
283 | |
284 /* Lock the event thread, in multi-threading environments */ | |
285 SDL_Lock_EventThread(); | |
286 | |
287 | |
288 /* Initialize the window */ | |
289 if (flags & SDL_FULLSCREEN) //Direct Context , assume SDL_HWSURFACE also set | |
290 { | |
291 | |
292 /* | |
293 if (old_video_mode==-1) | |
294 { | |
295 PgGetGraphicsHWCaps(&graphics_card_caps); | |
296 old_video_mode=graphics_card_caps.current_video_mode; | |
297 old_refresh_rate=graphics_card_caps.current_rrate; | |
298 } | |
299 */ | |
300 | |
301 | |
302 | |
303 /* Get the video mode and set it */ | |
304 if (bpp == 0) | |
305 { | |
204
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
306 /*again same issue, same solution |
0 | 307 if (PgGetVideoMode( &settings ) < 0) |
308 { | |
309 fprintf(stderr,"error: PgGetVideoMode failed\n"); | |
310 } | |
204
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
311 */ |
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
312 if (PgGetGraphicsHWCaps(&my_hwcaps) < 0) |
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
313 { |
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
314 fprintf(stderr,"ph_SetVideoMode: GetGraphicsHWCaps failed!! \n"); |
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
315 //that HAVE to work |
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
316 } |
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
317 if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &mode_info) < 0) |
0 | 318 { |
204
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
319 fprintf(stderr,"ph_SetVideoMode: PgGetVideoModeInfo failed\n"); |
0 | 320 } |
204
62bad9a82022
Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents:
19
diff
changeset
|
321 bpp = mode_info.bits_per_pixel; |
0 | 322 } |
323 if (flags & SDL_ANYFORMAT) | |
324 { | |
325 if ((mode = get_mode_any_format(width, height, bpp)) == 0) | |
326 { | |
327 fprintf(stderr,"error: get_mode_any_format failed\n"); | |
328 exit(1); | |
329 } | |
330 } | |
331 else | |
332 { | |
333 if ((mode = get_mode(width, height, bpp)) == 0) | |
334 { | |
335 fprintf(stderr,"error: get_mode failed\n"); | |
336 exit(1); | |
337 } | |
338 | |
339 | |
340 } | |
341 settings.mode = mode; | |
342 settings.refresh = 0; | |
343 settings.flags = 0; | |
344 | |
345 | |
346 if (PgSetVideoMode( &settings ) < 0) | |
347 { | |
348 fprintf(stderr,"error: PgSetVideoMode failed\n"); | |
349 } | |
350 | |
351 /* Get the true height and width */ | |
352 | |
353 current->flags = (flags|(~SDL_RESIZABLE)); //no resize for Direct Context | |
354 | |
355 /* Begin direct mode */ | |
356 ph_EnterFullScreen(this); | |
357 | |
358 | |
359 | |
360 } //end fullscreen flag | |
361 else if (flags & SDL_HWSURFACE) /* Use offscreen memory iff SDL_HWSURFACE flag is set */ | |
362 { | |
363 // Hardware surface is Offsceen Context. ph_ResizeImage handles the switch | |
364 current->flags = (flags|(~SDL_RESIZABLE)); //no stretch blit in offscreen context | |
365 } | |
366 else // must be SDL_SWSURFACE | |
367 { | |
368 current->flags = (flags|SDL_RESIZABLE); //yes we can resize as this is a software surface | |
369 } | |
370 | |
371 | |
372 //If we are setting video to use the palette make sure we have allocated memory for it | |
373 if(bpp == 8) | |
374 { | |
375 current->format->palette = malloc(sizeof(SDL_Palette)); | |
376 memset(current->format->palette, 0, sizeof(SDL_Palette)); | |
377 current->format->palette->ncolors = 256; | |
378 current->format->palette->colors = (SDL_Color *)malloc(256 *sizeof(SDL_Color)); | |
379 //fill the palette | |
380 rtnval = PgGetPalette(ph_palette); | |
381 | |
382 tempptr = (unsigned long *)current->format->palette->colors; | |
383 | |
384 for(i=0;i<256; i++) | |
385 { | |
386 *tempptr = (((unsigned long)ph_palette[i]) << 8); | |
387 tempptr++; | |
388 | |
389 } | |
390 } | |
391 | |
392 | |
393 //Current window dimensions | |
394 PtGetResource( window, Pt_ARG_DIM, &dim, 0 ); | |
395 | |
396 //If we need to resize the window | |
397 if((dim.w != width)||(dim.h != height)) | |
398 { | |
399 dim.w=width; | |
400 dim.h=height; | |
401 PtSetArg(&arg[0], Pt_ARG_DIM, &dim,0); | |
402 PtSetResources( window, 1, arg ); | |
403 current->w = width; | |
404 current->h = height; | |
405 current->format->BitsPerPixel = bpp; | |
406 current->format->BytesPerPixel = bpp/8; | |
407 current->pitch = SDL_CalculatePitch(current); | |
408 //Must call at least once it setup image planes | |
409 ph_ResizeImage(this, current, flags); | |
410 } | |
411 | |
412 | |
413 SDL_Unlock_EventThread(); | |
414 | |
415 /* We're done! */ | |
416 return(current); | |
417 } | |
418 | |
419 static void ph_VideoQuit(_THIS) | |
420 { | |
421 | |
422 if(SDL_Image != NULL) | |
423 { | |
424 ph_DestroyImage(this, SDL_VideoSurface); | |
425 | |
426 } | |
427 | |
428 if (currently_fullscreen) | |
429 { | |
430 PdDirectStop( directContext ); | |
431 PdReleaseDirectContext( directContext ); | |
432 directContext=0; | |
433 currently_fullscreen = 0; | |
434 } | |
435 | |
436 } | |
437 | |
438 | |
439 static int ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | |
440 { | |
441 PgColor_t *in, *out; | |
442 int i, j; | |
443 int alloct_all = 1; | |
444 | |
445 colors = this->screen->format->palette->colors; | |
446 | |
447 in = alloca( ncolors*sizeof(PgColor_t) ); | |
448 if ( in == NULL ) { | |
449 return 0; | |
450 } | |
451 memset(in,0,ncolors*sizeof(PgColor_t)); | |
452 | |
453 out = alloca( ncolors*sizeof(PgColor_t) ); | |
454 if ( out == NULL ) { | |
455 return 0; | |
456 } | |
457 | |
458 for (i=0,j=firstcolor;i<ncolors;i++,j++) | |
459 { | |
460 in[i] |= colors[j].r<<16 ; | |
461 in[i] |= colors[j].g<<8 ; | |
462 in[i] |= colors[j].b ; | |
463 } | |
464 | |
465 if ( (this->screen->flags & SDL_HWPALETTE) == SDL_HWPALETTE ) | |
466 { | |
467 if( PgSetPalette( in, 0, 0, ncolors, Pg_PALSET_HARD, 0) < 0 ) | |
468 { | |
469 fprintf(stderr,"error: PgSetPalette(..,Pg_PALSET_HARD) failed\n"); | |
470 return 0; | |
471 } | |
472 } | |
473 else | |
474 { | |
475 if ( PgColorMatch(ncolors, in, out) < 0 ) | |
476 { | |
477 fprintf(stderr,"error: PgColorMatch failed\n"); | |
478 return 0; | |
479 } | |
480 for (i=0;i<ncolors;i++) | |
481 { | |
482 if (memcmp(&in[i],&out[i],sizeof(PgColor_t))) | |
483 { | |
484 alloct_all = 0; | |
485 break; | |
486 } | |
487 } | |
488 if( PgSetPalette( out, 0, 0, ncolors, Pg_PALSET_SOFT, 0) < 0 ) | |
489 { | |
490 fprintf(stderr,"error: PgSetPalette(..,Pg_PALSET_SOFT) failed\n"); | |
491 return 0; | |
492 } | |
493 } | |
494 return alloct_all; | |
495 } | |
496 | |
497 static int ph_ResizeWindow(_THIS, | |
498 SDL_Surface *screen, int w, int h, Uint32 flags) | |
499 { | |
500 PhWindowEvent_t winevent; | |
501 | |
502 memset( &winevent, 0, sizeof(winevent) ); | |
503 winevent.event_f = Ph_WM_RESIZE; | |
504 winevent.size.w = w; | |
505 winevent.size.h = h; | |
506 winevent.rid = PtWidgetRid( window ); | |
507 if (PtForwardWindowEvent( &winevent ) < 0) | |
508 { | |
509 fprintf(stderr,"error: PtForwardWindowEvent failed.\n"); | |
510 } | |
511 current_w = w; | |
512 current_h = h; | |
513 return(0); | |
514 } | |
515 | |
516 |