Mercurial > sdl-ios-xcode
comparison src/video/photon/SDL_photon.c @ 3185:44d5474c2c8a
Continue working on QNX GF and Photon support.
author | Mike Gorchak <lestat@i.com.ua> |
---|---|
date | Wed, 10 Jun 2009 08:09:04 +0000 |
parents | 7f684f249ec9 |
children | 51750b7a966f |
comparison
equal
deleted
inserted
replaced
3184:68d3b48a6002 | 3185:44d5474c2c8a |
---|---|
59 #include "../qnxgf/SDL_gf_opengles.c" | 59 #include "../qnxgf/SDL_gf_opengles.c" |
60 #endif /* SDL_VIDEO_DRIVER_QNXGF */ | 60 #endif /* SDL_VIDEO_DRIVER_QNXGF */ |
61 #endif /* SDL_VIDEO_OPENGL_ES */ | 61 #endif /* SDL_VIDEO_OPENGL_ES */ |
62 | 62 |
63 /* Low level device graphics driver names, which they are reporting */ | 63 /* Low level device graphics driver names, which they are reporting */ |
64 Photon_DeviceCaps photon_devicename[] = { | 64 static const Photon_DeviceCaps photon_devicename[] = { |
65 /* ATI Rage 128 graphics driver (devg-ati_rage128) */ | 65 /* ATI Rage 128 graphics driver (devg-ati_rage128) */ |
66 {"ati_rage128", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} | 66 {"ati_rage128", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} |
67 , | 67 , |
68 /* Fujitsu Carmine graphics driver (devg-carmine.so) */ | 68 /* Fujitsu Carmine graphics driver (devg-carmine.so) */ |
69 {"carmine", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} | 69 {"carmine", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} |
382 didata->device_id = it; | 382 didata->device_id = it; |
383 | 383 |
384 /* Query photon about graphics hardware caps and current video mode */ | 384 /* Query photon about graphics hardware caps and current video mode */ |
385 status = PgGetGraphicsHWCaps(&hwcaps); | 385 status = PgGetGraphicsHWCaps(&hwcaps); |
386 if (status != 0) { | 386 if (status != 0) { |
387 SDL_SetError("Photon: Can't get graphics capabilities"); | 387 PhRect_t extent; |
388 SDL_free(didata->cursor); | 388 PdOffscreenContext_t* curctx; |
389 SDL_free(didata); | 389 |
390 return -1; | 390 /* If error happens, this also could mean, that photon is working */ |
391 } | 391 /* under custom (not listed by photon) video mode */ |
392 | 392 status=PhWindowQueryVisible(Ph_QUERY_GRAPHICS, 0, 0, &extent); |
393 /* Get current video mode details */ | 393 if (status != 0) { |
394 status = PgGetVideoModeInfo(hwcaps.current_video_mode, &modeinfo); | 394 SDL_SetError("Photon: Can't get graphics driver region"); |
395 if (status != 0) { | 395 SDL_free(didata->cursor); |
396 SDL_SetError("Photon: Can't get current video mode information"); | 396 SDL_free(didata); |
397 SDL_free(didata->cursor); | 397 return -1; |
398 SDL_free(didata); | 398 } |
399 return -1; | 399 modeinfo.width=extent.lr.x+1; |
400 modeinfo.height=extent.lr.y+1; | |
401 /* Hardcode 60Hz, as the base refresh rate frequency */ | |
402 hwcaps.current_rrate=60; | |
403 /* Clear current video driver name, no way to get it somehow */ | |
404 hwcaps.chip_name[0]=0x00; | |
405 | |
406 /* Create offscreen context from video memory, which is currently */ | |
407 /* displayed on the screen */ | |
408 curctx=PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY); | |
409 if (curctx==NULL) | |
410 { | |
411 SDL_SetError("Photon: Can't get display area capabilities"); | |
412 SDL_free(didata->cursor); | |
413 SDL_free(didata); | |
414 return -1; | |
415 } | |
416 /* Retrieve current bpp */ | |
417 modeinfo.type=curctx->format; | |
418 PhDCRelease(curctx); | |
419 } else { | |
420 /* Get current video mode details */ | |
421 status = PgGetVideoModeInfo(hwcaps.current_video_mode, &modeinfo); | |
422 if (status != 0) { | |
423 SDL_SetError("Photon: Can't get current video mode information"); | |
424 SDL_free(didata->cursor); | |
425 SDL_free(didata); | |
426 return -1; | |
427 } | |
400 } | 428 } |
401 | 429 |
402 /* Setup current desktop mode for SDL */ | 430 /* Setup current desktop mode for SDL */ |
403 SDL_zero(current_mode); | 431 SDL_zero(current_mode); |
404 current_mode.w = modeinfo.width; | 432 current_mode.w = modeinfo.width; |
525 mode.h = modeinfo.height; | 553 mode.h = modeinfo.height; |
526 mode.refresh_rate = modeinfo.refresh_rates[jt]; | 554 mode.refresh_rate = modeinfo.refresh_rates[jt]; |
527 mode.format = photon_image_to_sdl_pixelformat(modeinfo.type); | 555 mode.format = photon_image_to_sdl_pixelformat(modeinfo.type); |
528 mode.driverdata = NULL; | 556 mode.driverdata = NULL; |
529 SDL_AddDisplayMode(_this->current_display, &mode); | 557 SDL_AddDisplayMode(_this->current_display, &mode); |
558 | |
559 /* If mode is RGBA8888, add the same mode as RGBx888 */ | |
560 if (modeinfo.type == Pg_IMAGE_DIRECT_8888) { | |
561 mode.w = modeinfo.width; | |
562 mode.h = modeinfo.height; | |
563 mode.refresh_rate = modeinfo.refresh_rates[jt]; | |
564 mode.format = SDL_PIXELFORMAT_RGB888; | |
565 mode.driverdata = NULL; | |
566 SDL_AddDisplayMode(_this->current_display, &mode); | |
567 } | |
568 | |
569 /* If mode is RGBA1555, add the same mode as RGBx555 */ | |
570 if (modeinfo.type == Pg_IMAGE_DIRECT_1555) { | |
571 mode.w = modeinfo.width; | |
572 mode.h = modeinfo.height; | |
573 mode.refresh_rate = modeinfo.refresh_rates[jt]; | |
574 mode.format = SDL_PIXELFORMAT_RGB555; | |
575 mode.driverdata = NULL; | |
576 SDL_AddDisplayMode(_this->current_display, &mode); | |
577 } | |
578 | |
530 jt++; | 579 jt++; |
531 } else { | 580 } else { |
532 break; | 581 break; |
533 } | 582 } |
534 } while (1); | 583 } while (1); |
1451 | 1500 |
1452 /* Check if nothing has been found, try "don't care" settings */ | 1501 /* Check if nothing has been found, try "don't care" settings */ |
1453 if (configs == 0) { | 1502 if (configs == 0) { |
1454 int32_t it; | 1503 int32_t it; |
1455 int32_t jt; | 1504 int32_t jt; |
1456 GLint depthbits[4] = { 32, 24, 16, EGL_DONT_CARE }; | 1505 static const GLint depthbits[4] = { 32, 24, 16, EGL_DONT_CARE }; |
1457 | 1506 |
1458 for (it = 0; it < 4; it++) { | 1507 for (it = 0; it < 4; it++) { |
1459 for (jt = 16; jt >= 0; jt--) { | 1508 for (jt = 16; jt >= 0; jt--) { |
1460 /* Don't care about color buffer bits, use what exist */ | 1509 /* Don't care about color buffer bits, use what exist */ |
1461 /* Replace previous set data with EGL_DONT_CARE */ | 1510 /* Replace previous set data with EGL_DONT_CARE */ |