Before you can render an animation or display video, you must create a window for your application. There are a number of different window types. The following procedure describes how to create a window that can be used to display video.
screen_context_t screen_context = 0; screen_window_t screen_window = 0; static const char *window_group_name = "mainwindowgroup";
if (screen_create_context(&screen_context, SCREEN_APPLICATION_CONTEXT) != 0) { return EXIT_FAILURE; }
if (screen_create_window(&screen_window, screen_context) != 0) { screen_destroy_context(screen_context); return EXIT_FAILURE; }
if (screen_create_window_group(screen_window, window_group_name) != 0) { return EXIT_FAILURE; }
int format = SCREEN_FORMAT_RGBA8888; if (screen_set_window_property_iv(screen_window, SCREEN_PROPERTY_FORMAT, &format) != 0) { return EXIT_FAILURE; } int usage = SCREEN_USAGE_NATIVE; if (screen_set_window_property_iv(screen_window, SCREEN_PROPERTY_USAGE, &usage) != 0) { return EXIT_FAILURE; }
if (screen_create_window_buffers(screen_window, 1) != 0) { return EXIT_FAILURE; }}
Be sure to always create and destroy any window and context instances that you create. The following code snippet is included at the end of the application above. When the application exits, the window and context instance are destroyed.
if (screen_destroy_window(screen_window) != 0) { return EXIT_FAILURE; } if (screen_destroy_context(screen_context) != 0) { return EXIT_FAILURE; }