Ejemplo n.º 1
0
screen_window_t create_bg_window(const char *group, int dims[2])
{
	/* Start by creating the application window and window group. */
	screen_window_t screen_win;
	screen_create_window(&screen_win, screen_ctx);
	screen_create_window_group(screen_win, group);

	int vis = 1;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_VISIBLE, &vis);

	int color = 0xffffff00;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_COLOR, &color);

	int zorder = 0;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ZORDER, &zorder);

	int rect[4] = { 0, 0, 1, 1 };
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, rect+2);
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SOURCE_SIZE, dims);
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SIZE, dims);

	int pos[2] = { -dims[0], -dims[1] };
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SOURCE_POSITION, pos);

	screen_buffer_t screen_buf;
	screen_create_window_buffers(screen_win, 1);
	screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf);
	screen_post_window(screen_win, screen_buf, 1, rect, 0);

	return screen_win;
}
Ejemplo n.º 2
0
void QQnxRootWindow::createWindowGroup()
{
    // Generate a random window group name
    m_windowGroupName = QUuid::createUuid().toString().toLatin1();

    // Create window group so child windows can be parented by container window
    errno = 0;
    int result = screen_create_window_group(m_window, m_windowGroupName.constData());
    if (result != 0)
        qFatal("QQnxRootWindow: failed to create app window group, errno=%d", errno);
}
Ejemplo n.º 3
0
int
main(int argc, char **argv)
{
    const int usage = SCREEN_USAGE_NATIVE;

    screen_window_t screen_win;
    screen_buffer_t screen_buf = NULL;
    int rect[4] = { 0, 0, 0, 0 };

    // create an application window which will just act as a background
    screen_create_context(&screen_ctx, 0);
    screen_create_window(&screen_win, screen_ctx);
    screen_create_window_group(screen_win, vf_group);
    screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage);
    screen_create_window_buffers(screen_win, 1);
    screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf);
    screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, rect+2);

    // fill the window with black
    int attribs[] = { SCREEN_BLIT_COLOR, 0x00000000, SCREEN_BLIT_END };
    screen_fill(screen_ctx, screen_buf, attribs);
    screen_post_window(screen_win, screen_buf, 1, rect, 0);
    // position the window at an arbitrary z-order
    int i = APP_ZORDER;
    screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ZORDER, &i);

    // Signal bps library that navigator and screen events will be requested
    bps_initialize();
    screen_request_events(screen_ctx);
    navigator_request_events(0);

    // open camera and configure viewfinder
    if (init_camera() == EOK) {
        // our main loop just runs a state machine and handles input
        while (!shutdown) {
            run_state_machine();
            // Handle user input
            handle_event();
        }

        if (state == STATE_VIEWFINDER) {
            // clean up camera
            camera_stop_photo_viewfinder(handle);
            camera_close(handle);
        }
    }

    // Clean up
    screen_stop_events(screen_ctx);
    bps_shutdown();
    screen_destroy_window(screen_win);
    screen_destroy_context(screen_ctx);
    return 0;
}
Ejemplo n.º 4
0
int setup_screen()
{
    /*
     * Create the window.
     */
    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;

    // Get the render buffer
    screen_buffer_t temp_buffer[1];
    if (screen_get_window_property_pv( screen_window, SCREEN_PROPERTY_RENDER_BUFFERS, (void**)temp_buffer) != 0)
        return EXIT_FAILURE;

    // Fill the buffer with a solid color (green)
    int fill_attributes[3] = {SCREEN_BLIT_COLOR, 0x00C000, SCREEN_BLIT_END};
    if (screen_fill(screen_context, temp_buffer[0], fill_attributes) != 0)
        return EXIT_FAILURE;

    // Make the window visible
    if (screen_get_window_property_iv(screen_window, SCREEN_PROPERTY_SIZE, screen_size) != 0)
        return EXIT_FAILURE;

    int temp_rectangle[4] = {0,0,screen_size[0],screen_size[1]};
    if (screen_post_window(screen_window, temp_buffer[0], 1, temp_rectangle, 0) != 0)
        return EXIT_FAILURE;

    return EXIT_SUCCESS;
}
Ejemplo n.º 5
0
int NativeWindow::joinWindowGroup(const QString &group)
{
	int returnCode = EXIT_SUCCESS;

	if (_screenWindow != NULL) {
		if (_createGroup) {
			returnCode = screen_create_window_group(_screenWindow, group.toAscii().data());
			qDebug()  << "NativeWindow::joinWindowGroup: create group: " << group << ":" << returnCode;
		}

		if (!returnCode) {
			returnCode = screen_join_window_group(_screenWindow, group.toAscii().data());
			qDebug()  << "NativeWindow::joinWindowGroup: join group: " << group << ":" << returnCode;
		}
	}

	return returnCode;
}
Ejemplo n.º 6
0
/**
 * Set up a basic screen, so that the navigator will
 * send window state events when the window state changes.
 *
 * @return @c EXIT_SUCCESS or @c EXIT_FAILURE
 */
int
setup_screen()
{
    if (screen_create_context(&screen_ctx, SCREEN_APPLICATION_CONTEXT) != 0) {
        return EXIT_FAILURE;
    }

    if (screen_create_window(&screen_win, screen_ctx) != 0) {
        screen_destroy_context(screen_ctx);
        return EXIT_FAILURE;
    }

    int usage = SCREEN_USAGE_NATIVE;
    if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage) != 0) goto fail;

    if (screen_create_window_buffers(screen_win, 1) != 0) goto fail;

    if (screen_create_window_group(screen_win, get_window_group_id()) != 0) goto fail;

    screen_buffer_t buff;
    if (screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void*)&buff) != 0) goto fail;

    int buffer_size[2];
    if (screen_get_buffer_property_iv(buff, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size) != 0) goto fail;

    int attribs[1] = {SCREEN_BLIT_END};
    if (screen_fill(screen_ctx, buff, attribs) != 0) goto fail;

    int dirty_rects[4] = {0, 0, buffer_size[0], buffer_size[1]};
    if (screen_post_window(screen_win, buff, 1, (const int*)dirty_rects, 0) != 0) goto fail;

    return EXIT_SUCCESS;

fail:
    screen_destroy_window(screen_win);
    screen_destroy_context(screen_ctx);
    return EXIT_FAILURE;
}
Ejemplo n.º 7
0
int main(int argc, char *argv[])
{
    int rc;
    int exit_application = 0;

    // Screen variables
    screen_context_t    screen_context = 0;
    screen_window_t     screen_window = 0;

    int screen_size[2] = {0,0};

    // Renderer variables
    mmr_connection_t*     mmr_connection = 0;
    mmr_context_t*        mmr_context = 0;
    strm_dict_t*          dict = NULL;

    // I/O variables
    int                    video_device_output_id = -1;
    int                    audio_device_output_id = -1;

    bps_initialize();

    /*
     * Create the window used for video output.
     */
    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;
    }

    /*
     * Configure mm-renderer.
     */
    mmr_connection = mmr_connect(NULL);
    if (mmr_connection == NULL) {
        return EXIT_FAILURE;
    }

    mmr_context = mmr_context_create(mmr_connection, video_context_name, 0, S_IRWXU|S_IRWXG|S_IRWXO);
    if (mmr_context == NULL) {
        return EXIT_FAILURE;
    }

    /*
     * Configure video and audio output.
     */
    video_device_output_id = mmr_output_attach(mmr_context, video_device_url, "video");
    if (video_device_output_id == -1) {
        return EXIT_FAILURE;
    }

    audio_device_output_id = mmr_output_attach(mmr_context, audio_device_url, "audio");
    if (audio_device_output_id == -1) {
        return EXIT_FAILURE;
    }

    // Get the render buffer
    screen_buffer_t temp_buffer[1];
    if (screen_get_window_property_pv( screen_window, SCREEN_PROPERTY_RENDER_BUFFERS, (void**)temp_buffer) != 0) {
        return EXIT_FAILURE;
    }

    // Fill the buffer with a solid color (black)
    int fill_attributes[3] = {SCREEN_BLIT_COLOR, 0x0, SCREEN_BLIT_END};
    if (screen_fill(screen_context, temp_buffer[0], fill_attributes) != 0) {
        return EXIT_FAILURE;
    }

    // Make the window visible
    if (screen_get_window_property_iv(screen_window, SCREEN_PROPERTY_SIZE, screen_size) != 0) {
        return EXIT_FAILURE;
    }

    int temp_rectangle[4] = {0, 0, screen_size[0], screen_size[1]};
    if (screen_post_window(screen_window, temp_buffer[0], 1, temp_rectangle, 0) != 0) {
        return EXIT_FAILURE;
    }

    // Prevent the backlight from going off
    int idle_mode = SCREEN_IDLE_MODE_KEEP_AWAKE;
    if (screen_set_window_property_iv(screen_window, SCREEN_PROPERTY_IDLE_MODE, &idle_mode) != 0) {
        return EXIT_FAILURE;
    }

    // Build up the path where our bundled resource is.
    char cwd[PATH_MAX];
    char media_file[PATH_MAX];
    getcwd(cwd,PATH_MAX);

    rc = snprintf(media_file, PATH_MAX, "file://%s/app/native/pb_sample.mp4", cwd);
    if ((rc == -1) || (rc >= PATH_MAX)) {
        return EXIT_FAILURE;
    }

    /*
     * Start the playback.
     */
    if (mmr_input_attach(mmr_context, media_file, "track") != 0) {
        return EXIT_FAILURE;
    }

    if (mmr_play(mmr_context) != 0) {
        return EXIT_FAILURE;
    }

    /* Do some work to make the aspect ratio correct.
     */
    dict = calculate_rect(screen_size[0], screen_size[1]);
    if (NULL == dict) {
        return EXIT_FAILURE;
    }

    if (mmr_output_parameters(mmr_context, video_device_output_id, dict) != 0) {
        return EXIT_FAILURE;
    }

     /* Note that we allocated memory for the dictionary, but the call to 
      * mmr_output_parameters() deallocates that memory even on failure.
      */  
    dict = NULL;

    screen_request_events(screen_context);
    navigator_request_events(0);

    /*
     * Handle keyboard events and stop playback upon user request.
     */
    for (;;) {
        bps_event_t *event = NULL;
        if (bps_get_event(&event, -1) != BPS_SUCCESS) {
            return EXIT_FAILURE;
        }

        if (event) {

            if (bps_event_get_domain(event) == navigator_get_domain() &&
                bps_event_get_code(event) == NAVIGATOR_EXIT) {

                exit_application = 1;
            }

            if (exit_application) {
                break;
            }
        }
    }

    screen_stop_events(screen_context);

    if (mmr_stop(mmr_context) != 0) {
        return EXIT_FAILURE;
    }

    if (mmr_output_detach(mmr_context, audio_device_output_id) != 0) {
        return EXIT_FAILURE;
    }

    if (mmr_output_detach(mmr_context, video_device_output_id) != 0) {
        return EXIT_FAILURE;
    }

    if (mmr_context_destroy(mmr_context) != 0) {
        return EXIT_FAILURE;
    }

    mmr_context = 0;
    video_device_output_id = -1;
    audio_device_output_id = -1;

    mmr_disconnect(mmr_connection);
    mmr_connection = 0;

    bps_shutdown();

    if (screen_destroy_window(screen_window) != 0) {
        return EXIT_FAILURE;
    }

    if (screen_destroy_context(screen_context) != 0) {
        return EXIT_FAILURE;
    }

    screen_context = 0;
    screen_window = 0;

    return EXIT_SUCCESS;
}
Ejemplo n.º 8
0
void ScreenWindow::init()
{
	int rc;
	rc = screen_create_context(&m_context, 0);
//	if (rc) fprintf(stderr, "Fail at %d: %s\n", __LINE__, strerror(errno));

	rc = screen_create_window(&m_appWindow, m_context);

	char groupName[256];
	snprintf(groupName, 256, "screen-%d", getpid());
	rc = screen_create_window_group(m_appWindow, groupName);

	int sizeOfWindow[2] = {1024, 600};
	rc = screen_set_window_property_iv(m_appWindow, SCREEN_PROPERTY_SIZE, sizeOfWindow);


	int sizeOfBuffer[2] = {1024, 600};
	rc = screen_set_window_property_iv(m_appWindow, SCREEN_PROPERTY_BUFFER_SIZE, sizeOfBuffer);

	int format = SCREEN_FORMAT_RGBX8888;
	rc = screen_set_window_property_iv(m_appWindow, SCREEN_PROPERTY_FORMAT, &format);


	int usage = SCREEN_USAGE_NATIVE | SCREEN_USAGE_READ | SCREEN_USAGE_WRITE;
	rc = screen_set_window_property_iv(m_appWindow, SCREEN_PROPERTY_USAGE, &usage);


	int angle = 0;
	char *orientation = getenv("ORIENTATION");
	if (orientation) {
		 angle = atoi(orientation);
	}
	rc = screen_set_window_property_iv(m_appWindow, SCREEN_PROPERTY_ROTATION, &angle);


	rc = screen_create_window_buffers(m_appWindow, 1);


	screen_buffer_t windowBuffer[1];
	rc = screen_get_window_property_pv(m_appWindow,
				SCREEN_PROPERTY_RENDER_BUFFERS, (void**)&windowBuffer);

	int attribs[] = {SCREEN_BLIT_DESTINATION_X, 0,
					SCREEN_BLIT_DESTINATION_Y, 0,
					SCREEN_BLIT_DESTINATION_WIDTH, 1024,
					SCREEN_BLIT_DESTINATION_HEIGHT, 600,
					SCREEN_BLIT_COLOR, 0xff30ffff,
					SCREEN_BLIT_END};
	rc = screen_fill(m_context, windowBuffer[0], attribs);


	rc = screen_get_window_property_pv(m_appWindow,
					SCREEN_PROPERTY_RENDER_BUFFERS, (void**)&windowBuffer);


	int rect[4] = {0, 0, 1024, 600};
	rc = screen_post_window(m_appWindow, windowBuffer[0], 1, rect, 0);


	screen_request_events(m_context);
	navigator_request_events(0);
}
Ejemplo n.º 9
0
int
initialize_egl_window(screen_context_t ctx, char * window_group_name) {
    int usage = SCREEN_USAGE_OPENGL_ES1;
    int format = SCREEN_FORMAT_RGBA8888;
    int sensitivity = SCREEN_SENSITIVITY_ALWAYS;
    int rc, num_configs;

    // must be 2 for RGBA8888
    const int num_window_buffers = 2;

    EGLint attrib_list[]= { EGL_RED_SIZE,        8,
                            EGL_GREEN_SIZE,      8,
                            EGL_BLUE_SIZE,       8,
                            EGL_BLUE_SIZE,       8,
                            EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,
                            EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
                            EGL_NONE};

    // Simple egl initialization
    g_screen_ctx = ctx;

    g_egl_disp = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    if (g_egl_disp == EGL_NO_DISPLAY) {
        egl_perror("eglGetDisplay");
        terminate_egl_window();
        return EXIT_FAILURE;
    }

    rc = eglInitialize(g_egl_disp, NULL, NULL);
    if (rc != EGL_TRUE) {
        egl_perror("eglInitialize");
        terminate_egl_window();
        return EXIT_FAILURE;
    }

    rc = eglBindAPI(EGL_OPENGL_ES_API);
    if (rc != EGL_TRUE) {
        egl_perror("eglBindApi");
        terminate_egl_window();
        return EXIT_FAILURE;
    }

    if(!eglChooseConfig(g_egl_disp, attrib_list, &g_egl_conf, 1, &num_configs)) {
        terminate_egl_window();
        fprintf(stderr, "eglChooseConfig failed\n");
        return EXIT_FAILURE;
    }

    g_egl_ctx = eglCreateContext(g_egl_disp, g_egl_conf, EGL_NO_CONTEXT, NULL);
    if (g_egl_ctx == EGL_NO_CONTEXT) {
        egl_perror("eglCreateContext");
        terminate_egl_window();
        return EXIT_FAILURE;
    }

    rc = screen_create_window(&g_screen_win, g_screen_ctx);
    if (rc) {
        perror("screen_create_window");
        terminate_egl_window();
        return EXIT_FAILURE;
    }

    /* Create the window group for our window, this is important, as we pass
     * the group name to MMR which uses it to 'parent' it's CHILD_WINDOW
     * which contains the video.
     */
    if (screen_create_window_group(g_screen_win, window_group_name) != 0) {
        perror("screen_create_window_group");
        return EXIT_FAILURE;
    }

    rc = screen_set_window_property_iv(g_screen_win, SCREEN_PROPERTY_FORMAT, &format);
    if (rc) {
        perror("screen_set_window_property_iv(SCREEN_PROPERTY_FORMAT)");
        terminate_egl_window();
        return EXIT_FAILURE;
    }

    rc = screen_set_window_property_iv(g_screen_win, SCREEN_PROPERTY_USAGE, &usage);
    if (rc) {
        perror("screen_set_window_property_iv(SCREEN_PROPERTY_USAGE)");
        terminate_egl_window();
        return EXIT_FAILURE;
    }

    rc = screen_set_window_property_iv(g_screen_win, SCREEN_PROPERTY_SENSITIVITY, &sensitivity);
    if (rc) {
        perror("screen_set_window_property_iv(SCREEN_PROPERTY_SENSITIVITY)");
        terminate_egl_window();
        return EXIT_FAILURE;
    }


    rc = screen_get_window_property_pv(g_screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&g_screen_disp);
    if (rc) {
        perror("screen_get_window_property_pv");
        terminate_egl_window();
        return EXIT_FAILURE;
    }

    const char *env = getenv("WIDTH");
    if (0 == env) {
        perror("failed getenv for WIDTH");
        terminate_egl_window();
        return EXIT_FAILURE;
    }
    int width = atoi(env);

    env = getenv("HEIGHT");
    if (0 == env) {
        perror("failed getenv for HEIGHT");
        terminate_egl_window();
        return EXIT_FAILURE;
    }
    int height = atoi(env);

    int size[2] = { width, height };
    rc = screen_set_window_property_iv(g_screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);
    if (rc) {
        perror("screen_set_window_property_iv");
        terminate_egl_window();
        return EXIT_FAILURE;
    }

    rc = screen_create_window_buffers(g_screen_win, num_window_buffers);
    if (rc) {
        perror("screen_create_window_buffers");
        terminate_egl_window();
        return EXIT_FAILURE;
    }

    g_egl_surf = eglCreateWindowSurface(g_egl_disp, g_egl_conf, g_screen_win, NULL);
    if (g_egl_surf == EGL_NO_SURFACE) {
        egl_perror("eglCreateWindowSurface");
        terminate_egl_window();
        return EXIT_FAILURE;
    }

    rc = eglMakeCurrent(g_egl_disp, g_egl_surf, g_egl_surf, g_egl_ctx);
    if (rc != EGL_TRUE) {
        egl_perror("eglMakeCurrent");
        terminate_egl_window();
        return EXIT_FAILURE;
    }

    // Set the clear color to be transparent
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    return EXIT_SUCCESS;
}
Ejemplo n.º 10
0
int
setup_screen()
{
    if (screen_create_context(&screen_ctx, SCREEN_APPLICATION_CONTEXT) != 0) {
        return EXIT_FAILURE;
    }

    //Signal BPS library that navigator orientation is to be locked
    if (BPS_SUCCESS != navigator_rotation_lock(true)) {
        screen_destroy_context(screen_ctx);
        return EXIT_FAILURE;
    }

    if (screen_create_window(&screen_win, screen_ctx) != 0) {
        screen_destroy_context(screen_ctx);
        return EXIT_FAILURE;
    }

    if (screen_create_window_group(screen_win, get_window_group_id()) != 0) goto fail;

    int usage = SCREEN_USAGE_NATIVE;
    if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage) != 0) goto fail;

    int size[2];
    if (screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0) goto fail;

    screen_display_t screen_disp;
    screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&screen_disp);

    screen_display_mode_t screen_mode;
    if (screen_get_display_property_pv(screen_disp, SCREEN_PROPERTY_MODE, (void**)&screen_mode) != 0) goto fail;

    int buffer_size[2] = {size[0], size[1]};

    int angle = atoi(getenv("ORIENTATION"));
    if ((angle == 0) || (angle == 180)) {
       if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) ||
          ((screen_mode.width < screen_mode.height) && (size[0] > size[1]))) {
            buffer_size[1] = size[0];
        buffer_size[0] = size[1];
       }
    } else if ((angle == 90) || (angle == 270)){
       if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) ||
          ((screen_mode.width < screen_mode.height && size[0] < size[1]))) {
        buffer_size[1] = size[0];
        buffer_size[0] = size[1];
        }
    } else {
        goto fail;
    }

    if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size) != 0) goto fail;

    if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &angle) != 0) goto fail;

    if (screen_create_window_buffers(screen_win, 1) != 0) goto fail;

    screen_buffer_t buff;
    if (screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void*)&buff) != 0) goto fail;

    int attribs[1] = {SCREEN_BLIT_END};
    if (screen_fill(screen_ctx, buff, attribs) != 0) goto fail;

    int dirty_rects[4] = {0, 0, buffer_size[0], buffer_size[1]};
    if (screen_post_window(screen_win, buff, 1, (const int*)dirty_rects, 0) != 0) goto fail;

    return EXIT_SUCCESS;

fail:
    perror(NULL);
    cleanup_screen();
    return EXIT_FAILURE;
}
Ejemplo n.º 11
0
int main(int argc, char *argv[]) {
    char windowGroupId[64] = {0};
    //Create a screen context that will be used to create an EGL surface to to receive libscreen events
    screen_create_context(&screen_cxt, 0);

    // Get the application's window group id so that it can be passed the identity library in cases
    // where a user may need to be interacted with on the application's behalf.
    screen_create_window(&screen_wnd, screen_cxt);
    screen_create_window_group( screen_wnd, NULL );
    screen_get_window_property_cv( screen_wnd, SCREEN_PROPERTY_GROUP, sizeof( windowGroupId ), windowGroupId );

    //Initialize BPS library
    bps_initialize();

    //Use utility code to initialize EGL for rendering with GL ES 1.1
    if (EXIT_SUCCESS != bbutil_init_egl(screen_cxt)) {
        fprintf(stderr, "bbutil_init_egl failed\n");
        bbutil_terminate();
        screen_destroy_window(screen_wnd);
        screen_destroy_context(screen_cxt);
        return 0;
    }

    //Initialize application logic
    if (EXIT_SUCCESS != initialize()) {
        fprintf(stderr, "initialize failed\n");
        bbutil_terminate();
        screen_destroy_window(screen_wnd);
        screen_destroy_context(screen_cxt);
        return 0;
    }

    //Signal BPS library that navigator and screen events will be requested
    if (BPS_SUCCESS != screen_request_events(screen_cxt)) {
        fprintf(stderr, "screen_request_events failed\n");
        bbutil_terminate();
        screen_destroy_window(screen_wnd);
        screen_destroy_context(screen_cxt);
        return 0;
    }

    if (BPS_SUCCESS != navigator_request_events(0)) {
        fprintf(stderr, "navigator_request_events failed\n");
        bbutil_terminate();
        screen_destroy_window(screen_wnd);
        screen_destroy_context(screen_cxt);
        return 0;
    }



    if( EXIT_SUCCESS != identity_initialize( windowGroupId ) ) {
        fprintf(stderr, "Initialization of IDS Library failed\n");
        bbutil_terminate();
        screen_destroy_window(screen_wnd);
        screen_destroy_context(screen_cxt);
        return 0;
    }

    identity_trigger_get_username();

    // ENTER APPLICATION EVENT LOOP
    while (!shutdown) {
        // Handle bps events, includes input and fd changes
        handle_events();
    }

    identity_shutdown();

    //Stop requesting events from libscreen
    screen_stop_events(screen_cxt);

    //Use utility code to terminate EGL setup
    bbutil_terminate();

    //Shut down BPS library for this process
    bps_shutdown();

    screen_destroy_window(screen_wnd);
    //Destroy libscreen context
    screen_destroy_context(screen_cxt);
    return 0;
}