| 3487 | } |
| 3488 | |
| 3489 | static void demo_create_screen_window(struct demo *demo) { |
| 3490 | const char *idstr = APP_SHORT_NAME; |
| 3491 | int size[2]; |
| 3492 | int usage = SCREEN_USAGE_VULKAN; |
| 3493 | int rc; |
| 3494 | |
| 3495 | rc = screen_create_context(&demo->screen_context, 0); |
| 3496 | if (rc) { |
| 3497 | printf("Cannot create QNX Screen context!\n"); |
| 3498 | fflush(stdout); |
| 3499 | exit(EXIT_FAILURE); |
| 3500 | } |
| 3501 | rc = screen_create_window(&demo->screen_window, demo->screen_context); |
| 3502 | if (rc) { |
| 3503 | printf("Cannot create QNX Screen window!\n"); |
| 3504 | fflush(stdout); |
| 3505 | exit(EXIT_FAILURE); |
| 3506 | } |
| 3507 | rc = screen_create_event(&demo->screen_event); |
| 3508 | if (rc) { |
| 3509 | printf("Cannot create QNX Screen event!\n"); |
| 3510 | fflush(stdout); |
| 3511 | exit(EXIT_FAILURE); |
| 3512 | } |
| 3513 | |
| 3514 | /* Set window caption */ |
| 3515 | screen_set_window_property_cv(demo->screen_window, SCREEN_PROPERTY_ID_STRING, strlen(idstr), idstr); |
| 3516 | |
| 3517 | /* Setup VULKAN usage flags */ |
| 3518 | rc = screen_set_window_property_iv(demo->screen_window, SCREEN_PROPERTY_USAGE, &usage); |
| 3519 | if (rc) { |
| 3520 | printf("Cannot set SCREEN_USAGE_VULKAN flag!\n"); |
| 3521 | fflush(stdout); |
| 3522 | exit(EXIT_FAILURE); |
| 3523 | } |
| 3524 | |
| 3525 | /* Setup window size */ |
| 3526 | if ((demo->width == 0) || (demo->height == 0)) { |
| 3527 | /* Obtain automatically set window size provided by WM */ |
| 3528 | rc = screen_get_window_property_iv(demo->screen_window, SCREEN_PROPERTY_SIZE, size); |
| 3529 | if (rc) { |
| 3530 | printf("Cannot obtain current window size!\n"); |
| 3531 | fflush(stdout); |
| 3532 | exit(EXIT_FAILURE); |
| 3533 | } |
| 3534 | demo->width = size[0]; |
| 3535 | demo->height = size[1]; |
| 3536 | } else { |
| 3537 | size[0] = demo->width; |
| 3538 | size[1] = demo->height; |
| 3539 | rc = screen_set_window_property_iv(demo->screen_window, SCREEN_PROPERTY_SIZE, size); |
| 3540 | if (rc) { |
| 3541 | printf("Cannot set window size!\n"); |
| 3542 | fflush(stdout); |
| 3543 | exit(EXIT_FAILURE); |
| 3544 | } |
| 3545 | } |
| 3546 | } |