Create a context

You must create a context before you create a window. When you call screen_create_context(), memory is allocated to store the context state. The composition manager creates an event queue and associates it with the connecting process.

To create a context:
  1. Create and initialize the context variable.
    screen_context_t	screen_context = 0;
  2. Call screen_create_context() to create the context. The screen_create_context() function takes a reference to a variable of type screen_context_t, and a flag that represents the type of context. In the example below, the context is of type SCREEN_APPLICATION_CONTEXT indicating that the context can only create and modify windows within the scope of the current application.
    if (screen_create_context(&screen_context, SCREEN_APPLICATION_CONTEXT) != 0) {
       return EXIT_FAILURE;
You must destroy each context and free up the memory whenever your application is done with it. To destroy a context, call the screen_destroy_context() function.