Mercurial > sdl-ios-xcode
comparison src/video/photon/SDL_ph_video.c @ 370:ba72f259bc88
Date: Sat, 18 May 2002 17:40:53 +0300
From: Mike Gorchak <mike@malva.ua>
Subject: New QNX patches
- Added more error check to avoid SEGFAULTS;
- Fixed bug in update function for SDL_HWSURFACE. BTW: update is much
faster than before.
- Added checks for SDL_HWSURFACE flag, chosen bpp must be equal to
desktop bpp for SDL_HWSURFACE.
- Fixed overlay bug, no more SEGFAULTS.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 19 May 2002 19:54:01 +0000 |
parents | 66f815c147ed |
children | bce7171e7a85 |
comparison
equal
deleted
inserted
replaced
369:e405cf8bf580 | 370:ba72f259bc88 |
---|---|
253 | 253 |
254 /* create window if no OpenGL support selected */ | 254 /* create window if no OpenGL support selected */ |
255 if ((flags & SDL_OPENGL)!=SDL_OPENGL) | 255 if ((flags & SDL_OPENGL)!=SDL_OPENGL) |
256 { | 256 { |
257 pargc=0; | 257 pargc=0; |
258 | |
259 // prevent using HWSURFACE in window mode if desktop bpp != chosen bpp | |
260 if ((flags & SDL_HWSURFACE) && (!(flags & SDL_FULLSCREEN))) | |
261 { | |
262 if (desktopbpp!=bpp) | |
263 { | |
264 fprintf(stderr, "ph_SetVideoMode(): SDL_HWSURFACE available only with chosen bpp equal desktop bpp !\n"); | |
265 return NULL; | |
266 } | |
267 } | |
258 | 268 |
259 PtSetArg(&arg[pargc++], Pt_ARG_DIM, &dim, 0); | 269 PtSetArg(&arg[pargc++], Pt_ARG_DIM, &dim, 0); |
260 PtSetArg(&arg[pargc++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED); | 270 PtSetArg(&arg[pargc++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED); |
261 | 271 |
262 /* enable window minimizing */ | 272 /* enable window minimizing */ |
315 current->flags=(flags & (~SDL_OPENGL)); | 325 current->flags=(flags & (~SDL_OPENGL)); |
316 } | 326 } |
317 #else | 327 #else |
318 if (flags & SDL_OPENGL) /* if no built-in OpenGL support */ | 328 if (flags & SDL_OPENGL) /* if no built-in OpenGL support */ |
319 { | 329 { |
320 fprintf(stderr, "error: no OpenGL support, try to recompile library.\n"); | 330 fprintf(stderr, "ph_SetVideoMode(): no OpenGL support, try to recompile library.\n"); |
321 current->flags=(flags & (~SDL_OPENGL)); | 331 current->flags=(flags & (~SDL_OPENGL)); |
322 return NULL; | 332 return NULL; |
323 #endif /* HAVE_OPENGL */ | 333 #endif /* HAVE_OPENGL */ |
324 } | 334 } |
325 else | 335 else |
330 /* Get the video mode and set it */ | 340 /* Get the video mode and set it */ |
331 if (flags & SDL_ANYFORMAT) | 341 if (flags & SDL_ANYFORMAT) |
332 { | 342 { |
333 if ((mode = get_mode_any_format(width, height, bpp)) == 0) | 343 if ((mode = get_mode_any_format(width, height, bpp)) == 0) |
334 { | 344 { |
335 fprintf(stderr,"error: get_mode_any_format failed\n"); | 345 fprintf(stderr,"ph_SetVideoMode(): get_mode_any_format failed !\n"); |
336 exit(1); | 346 exit(1); |
337 } | 347 } |
338 } | 348 } |
339 else | 349 else |
340 { | 350 { |
341 if ((mode = get_mode(width, height, bpp)) == 0) | 351 if ((mode = get_mode(width, height, bpp)) == 0) |
342 { | 352 { |
343 fprintf(stderr,"error: get_mode failed\n"); | 353 fprintf(stderr,"ph_SetVideoMode(): get_mode failed !\n"); |
344 exit(1); | 354 exit(1); |
345 } | 355 } |
346 } | 356 } |
347 | 357 |
348 if (bpp==8) | 358 if (bpp==8) |
360 settings.refresh = 0; | 370 settings.refresh = 0; |
361 settings.flags = 0; | 371 settings.flags = 0; |
362 | 372 |
363 if (PgSetVideoMode(&settings) < 0) | 373 if (PgSetVideoMode(&settings) < 0) |
364 { | 374 { |
365 fprintf(stderr,"error: PgSetVideoMode failed\n"); | 375 fprintf(stderr,"ph_SetVideoMode(): PgSetVideoMode failed !\n"); |
366 } | 376 } |
367 | 377 |
368 current->flags = (flags & (~SDL_RESIZABLE)); /* no resize for Direct Context */ | 378 current->flags = (flags & (~SDL_RESIZABLE)); /* no resize for Direct Context */ |
369 | 379 |
370 /* Begin direct mode */ | 380 /* Begin direct mode */ |
422 current->w = width; | 432 current->w = width; |
423 current->h = height; | 433 current->h = height; |
424 current->format->BitsPerPixel = bpp; | 434 current->format->BitsPerPixel = bpp; |
425 current->format->BytesPerPixel = (bpp+7)/8; | 435 current->format->BytesPerPixel = (bpp+7)/8; |
426 current->pitch = SDL_CalculatePitch(current); | 436 current->pitch = SDL_CalculatePitch(current); |
437 | |
427 /* Must call at least once it setup image planes */ | 438 /* Must call at least once it setup image planes */ |
428 ph_ResizeImage(this, current, flags); | 439 rtnval = ph_ResizeImage(this, current, flags); |
440 | |
441 if (rtnval==-1) | |
442 { | |
443 fprintf(stderr,"ph_SetVideoMode(): ph_ResizeImage failed !\n"); | |
444 return NULL; | |
445 } | |
429 | 446 |
430 /* delayed set caption call */ | 447 /* delayed set caption call */ |
431 if (captionflag) | 448 if (captionflag) |
432 { | 449 { |
433 ph_SetCaption(this, this->wm_title, NULL); | 450 ph_SetCaption(this, this->wm_title, NULL); |
510 SDL_Image->palette[i] = 0x00000000UL; | 527 SDL_Image->palette[i] = 0x00000000UL; |
511 SDL_Image->palette[i] |= colors[i-firstcolor].r<<16; | 528 SDL_Image->palette[i] |= colors[i-firstcolor].r<<16; |
512 SDL_Image->palette[i] |= colors[i-firstcolor].g<<8; | 529 SDL_Image->palette[i] |= colors[i-firstcolor].g<<8; |
513 SDL_Image->palette[i] |= colors[i-firstcolor].b; | 530 SDL_Image->palette[i] |= colors[i-firstcolor].b; |
514 } | 531 } |
515 } | 532 |
516 /* image needs to be redrawed, very slow method */ | 533 /* image needs to be redrawed, very slow method */ |
517 PgDrawPhImage(&point, SDL_Image, 0); | 534 PgDrawPhImage(&point, SDL_Image, 0); |
535 } | |
518 } | 536 } |
519 else | 537 else |
520 { | 538 { |
521 if (desktoppal==SDLPH_PAL_SYSTEM) | 539 if (desktoppal==SDLPH_PAL_SYSTEM) |
522 { | 540 { |
531 if ((this->screen->flags & SDL_FULLSCREEN) != SDL_FULLSCREEN) | 549 if ((this->screen->flags & SDL_FULLSCREEN) != SDL_FULLSCREEN) |
532 { | 550 { |
533 /* window mode must use soft palette */ | 551 /* window mode must use soft palette */ |
534 PgSetPalette((PgColor_t*)&syspalph[firstcolor], 0, firstcolor, ncolors, Pg_PALSET_SOFT, 0); | 552 PgSetPalette((PgColor_t*)&syspalph[firstcolor], 0, firstcolor, ncolors, Pg_PALSET_SOFT, 0); |
535 /* image needs to be redrawed, very slow method */ | 553 /* image needs to be redrawed, very slow method */ |
536 PgDrawPhImage(&point, SDL_Image, 0); | 554 if (SDL_Image) |
555 { | |
556 PgDrawPhImage(&point, SDL_Image, 0); | |
557 } | |
537 } | 558 } |
538 else | 559 else |
539 { | 560 { |
540 /* fullscreen mode must use hardware palette */ | 561 /* fullscreen mode must use hardware palette */ |
541 PgSetPalette((PgColor_t*)&syspalph[firstcolor], 0, firstcolor, ncolors, Pg_PALSET_GLOBAL, 0); | 562 PgSetPalette((PgColor_t*)&syspalph[firstcolor], 0, firstcolor, ncolors, Pg_PALSET_GLOBAL, 0); |
600 oglctx=PdCreateOpenGLContext(1, &dim, 0, OGLAttrib); | 621 oglctx=PdCreateOpenGLContext(1, &dim, 0, OGLAttrib); |
601 } | 622 } |
602 | 623 |
603 if (oglctx==NULL) | 624 if (oglctx==NULL) |
604 { | 625 { |
605 fprintf(stderr,"ph_SetupOpenGLContext: cannot create OpenGL context.\n"); | 626 fprintf(stderr,"ph_SetupOpenGLContext(): cannot create OpenGL context.\n"); |
606 return (-1); | 627 return (-1); |
607 } | 628 } |
608 | 629 |
609 PhDCSetCurrent(oglctx); | 630 PhDCSetCurrent(oglctx); |
610 | 631 |