Create a window
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.
To create a window:
Create a variable for the context and window instances and create a variable
and allocate memory to
store the name of the window group.
screen_context_t screen_context = 0; screen_window_t screen_window = 0; char *window_group_name; int MAX_WINGRP_NAME_LEN = 49; window_group_name = (char *)malloc(MAX_GRP_NAME_LEN)
Create a context. The context describes the relationship between the application
and the underlying windowing system.
Create a window. The screen_create_window() function takes
the window variable and the context variable that you created in the first
Create an optional window group. Pass NULL to screen_create_window_group()
as the name to have a unique group name generated.
Use screen_get_window_property_cv() to get the name of the group.
screen_create_window_group(screen_window, NULL); screen_get_window_property_cv(screen_window, SCREEN_PROPERTY_GROUP, MAX_WINGRP_NAME_LEN, window_group_name);
Set usage property for the window. In this example, the window will be used to
display a video.
int usage = SCREEN_USAGE_NATIVE; screen_set_window_property_iv(screen_window, SCREEN_PROPERTY_USAGE, &usage);
Create two window buffers. Applications should always create two buffers, which
is done by calling screen_create_window_buffers() and
specifying 2 as the number of buffers to create for the window.
Although any instances created are destroyed when the application exits, it is best practice to destroy any window and context instances that you created but no longer require. In some cases you must destroy windows and contexts. For example, when an app outlasts the lifespan of contexts and windows without destroying the process, then you must call the appropriate destroy functions.
In this example, you should destroy the window and the context once you have finished using them.
Last modified: 2015-03-31