screen_window_t create_bar_window(const char *group, const char *id, int dims[2])
{
	screen_window_t screen_win;
	screen_create_window_type(&screen_win, screen_ctx, SCREEN_CHILD_WINDOW);
	screen_join_window_group(screen_win, group);
	screen_set_window_property_cv(screen_win, SCREEN_PROPERTY_ID_STRING, strlen(id), id);

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

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

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

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

	int pos[2] = { -rect[2], -rect[3] };
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SOURCE_POSITION, pos);
	pos[0] = pos[1] = 0;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_POSITION, pos);
	int size[2] = {barwidth,dims[1]};
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SIZE, size);


	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;
}
Пример #2
0
void QQnxWindow::setBufferSize(const QSize &size)
{
    qWindowDebug() << Q_FUNC_INFO << "window =" << window() << "size =" << size;

    // Set window buffer size
    errno = 0;

    // libscreen fails when creating empty buffers
    const QSize nonEmptySize = size.isEmpty() ? QSize(1, 1) : size;

    int val[2] = { nonEmptySize.width(), nonEmptySize.height() };
    int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, val);
    if (result != 0)
        qFatal("QQnxWindow: failed to set window buffer size, errno=%d", errno);

    // Create window buffers if they do not exist
    if (m_bufferSize.isEmpty()) {
        val[0] = m_screen->nativeFormat();
#if !defined(QT_NO_OPENGL)
        // Get pixel format from EGL config if using OpenGL;
        // otherwise inherit pixel format of window's screen
        if (m_platformOpenGLContext != 0)
            val[0] = platformWindowFormatToNativeFormat(m_platformOpenGLContext->format());
#endif

        errno = 0;
        result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_FORMAT, val);
        if (result != 0)
            qFatal("QQnxWindow: failed to set window pixel format, errno=%d", errno);

        errno = 0;
        result = screen_create_window_buffers(m_window, MAX_BUFFER_COUNT);
        if (result != 0)
            qWarning() << "QQnxWindow: Buffer size was" << size;
        qFatal("QQnxWindow: failed to create window buffers, errno=%d", errno);

        // check if there are any buffers available
        int bufferCount = 0;
        result = screen_get_window_property_iv(m_window, SCREEN_PROPERTY_RENDER_BUFFER_COUNT, &bufferCount);

        if (result != 0)
            qFatal("QQnxWindow: failed to query window buffer count, errno=%d", errno);

        if (bufferCount != MAX_BUFFER_COUNT) {
            qFatal("QQnxWindow: invalid buffer count. Expected = %d, got = %d. You might experience problems.",
                   MAX_BUFFER_COUNT, bufferCount);
        }
    }

    // Cache new buffer size
    m_bufferSize = nonEmptySize;

    // Buffers were destroyed; reacquire them
    m_currentBufferIndex = -1;
    m_previousDirty = QRegion();
    m_scrolled = QRegion();

    const QMutexLocker locker(&m_mutex);
    m_requestedBufferSize = QSize();
}
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;
}
Пример #4
0
static void bb10display_createWindow(BB10Display *d) {
    screen_window_t window;

    if (d->window_created) {
        ms_warning("[bb10_display] window is already created, skipping...");
        return;
    }

    screen_create_window_type(&window, d->context, SCREEN_CHILD_WINDOW);

    int usage = SCREEN_USAGE_NATIVE;
    screen_set_window_property_iv(window, SCREEN_PROPERTY_USAGE, &usage);

    int wdims[2] = { d->wsize.width, d->wsize.height };
    screen_set_window_property_iv(window, SCREEN_PROPERTY_BUFFER_SIZE, wdims);
    screen_set_window_property_iv(window, SCREEN_PROPERTY_SOURCE_SIZE, wdims);

    int zorder = -5;
    screen_set_window_property_iv(window, SCREEN_PROPERTY_ZORDER, &zorder);

    screen_create_window_buffers(window, 1);
    ms_debug("[bb10_display] bb10display_createWindow window created with size %i,%i", wdims[0], wdims[1]);

    if (!d->pixmap_created) {
        bb10display_createPixmap(d);
    }

    d->window = window;
    d->window_created = TRUE;

    if (d->window_id != NULL && d->window_group != NULL) {
        bb10display_set_window_id_and_group(d);
    }
}
Пример #5
0
ButtonMap::ButtonMap(screen_context_t screen_ctx, QString groupId, int coid)
{
   this->screen_cxt = screen_ctx;
   this->groupId = groupId;
   this->coid = coid;

   const int usage = SCREEN_USAGE_NATIVE | SCREEN_USAGE_WRITE | SCREEN_USAGE_READ;
   int rc;

   if(screen_create_window_type(&screen_win, screen_cxt, SCREEN_CHILD_WINDOW))
   {
      RARCH_ERR("ButtonMap: screen_create_window_type failed.\n");
   }

   screen_join_window_group(screen_win, (const char *)groupId.toAscii().constData());
   int format = SCREEN_FORMAT_RGBA8888;
   screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_FORMAT, &format);

   screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage);

   screen_display_t screen_disp;
   if (screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&screen_disp))
   {
      RARCH_ERR("screen_get_window_property_pv [SCREEN_PROPERTY_DISPLAY] failed.\n");
   }

   if (screen_get_display_property_iv(screen_disp, SCREEN_PROPERTY_SIZE, screen_resolution))
   {
      RARCH_ERR("screen_get_window_property_iv [SCREEN_PROPERTY_SIZE] failed.\n");
   }

   rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, screen_resolution);
   if (rc) {
      perror("screen_set_window_property_iv");
   }

   int z = -10;
   if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ZORDER, &z) != 0) {
      return;
   }

   rc = screen_create_window_buffers(screen_win, 1);
   if (rc) {
      perror("screen_create_window_buffers");
   }

   screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf);

   int bg[] = { SCREEN_BLIT_COLOR, 0x00000000,
                SCREEN_BLIT_GLOBAL_ALPHA, 0x80,
                SCREEN_BLIT_END };
   screen_fill(screen_cxt, screen_buf, bg);

   screen_post_window(screen_win, screen_buf, 1, screen_resolution, 0);

   buttonDataModel = new ArrayDataModel();

   refreshButtonMap(0);
}
screen_window_t create_hg_window(const char *group, const char *id, int dims[2])
{
	int i, j;

	screen_window_t screen_win;
	screen_create_window_type(&screen_win, screen_ctx, SCREEN_CHILD_WINDOW);
	screen_join_window_group(screen_win, group);
	screen_set_window_property_cv(screen_win, SCREEN_PROPERTY_ID_STRING, strlen(id), id);

	int flag = 1;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_STATIC, &flag);

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

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

	int format = SCREEN_FORMAT_RGBA8888;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_FORMAT, &format);

	int usage = SCREEN_USAGE_WRITE;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage);

	int transparency = SCREEN_TRANSPARENCY_SOURCE_OVER;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_TRANSPARENCY, &transparency);

	int rect[4] = { 0, 0, 100, 100 };
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, rect+2);
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SIZE, &rect[2]);

	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);

	char *ptr = NULL;
	screen_get_buffer_property_pv(screen_buf, SCREEN_PROPERTY_POINTER, (void **)&ptr);

	int stride = 0;
	screen_get_buffer_property_iv(screen_buf, SCREEN_PROPERTY_STRIDE, &stride);

	for (i = 0; i < rect[3]; i++, ptr += stride) {
		for (j = 0; j < rect[2]; j++) {
			ptr[j*4] = 0xa0;
			ptr[j*4+1] = 0xa0;
			ptr[j*4+2] = 0xa0;
			ptr[j*4+3] = ((j >= i && j <= rect[3]-i) || (j <= i && j >= rect[3]-i)) ? 0xff : 0;
		}
	}

	screen_post_window(screen_win, screen_buf, 1, rect, 0);

	return screen_win;
}
Пример #7
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;
}
Пример #8
0
int _glfwPlatformCreateWindow(_GLFWwindow* window,
                              const _GLFWwndconfig* wndconfig,
                              const _GLFWctxconfig* ctxconfig,
                              const _GLFWfbconfig* fbconfig)
{
    int rc;
    int nbuffers = fbconfig->doublebuffer ? 2 : 1;
    int format = SCREEN_FORMAT_RGBX8888; // TODO: check fbconfig
    int usage = SCREEN_USAGE_OPENGL_ES2|SCREEN_USAGE_OVERLAY; // TODO: check context config
    int size[2] = { wndconfig->width, wndconfig->height };
    int pos[2] = { 0, 0 };
    int interval = 1;

    if (!_glfwCreateContext(window, ctxconfig, fbconfig))
        return GL_FALSE;

    rc = screen_create_window(&window->screen.window, _glfw.screen.context);
    if (rc)
    {
    	_glfwInputError(GLFW_PLATFORM_ERROR,
    	                    "screen: Error creating window %s", strerror(errno));
    	return GL_FALSE;
    }

    if (wndconfig->monitor)
    {
    	rc = screen_set_window_property_pv(window->screen.window, SCREEN_PROPERTY_DISPLAY, (void**)&wndconfig->monitor->screen.display);
    	if (rc)
    	{
    		_glfwInputError(GLFW_PLATFORM_ERROR,
    	                    "screen: Error set window property %s", strerror(errno));
    		return GL_FALSE;
    	}
    }

    rc = screen_set_window_property_iv(window->screen.window, SCREEN_PROPERTY_FORMAT, &format);
    if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Failed to set format property: %s", strerror(errno)); return GL_FALSE; }
    rc = screen_set_window_property_iv(window->screen.window, SCREEN_PROPERTY_USAGE, &usage);
    if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Failed to set usage property: %s", strerror(errno)); return GL_FALSE; }
    rc = screen_set_window_property_iv(window->screen.window, SCREEN_PROPERTY_SWAP_INTERVAL, &interval);
    if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Failed to set swap interval property: %s", strerror(errno)); return GL_FALSE; }
    rc = screen_set_window_property_iv(window->screen.window, SCREEN_PROPERTY_SIZE, size);
    if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Failed to set size property: %s", strerror(errno)); return GL_FALSE; }
    rc = screen_set_window_property_iv(window->screen.window, SCREEN_PROPERTY_POSITION, pos);
    if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Failed to set position property: %s", strerror(errno)); return GL_FALSE; }
    rc = screen_create_window_buffers(window->screen.window, nbuffers);
    if (rc) { _glfwInputError(GLFW_PLATFORM_ERROR, "screen: Failed to create window buffers: %s", strerror(errno)); return GL_FALSE; }

    return GL_TRUE;
}
Пример #9
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;
}
Пример #10
0
void QQnxRootWindow::makeTranslucent()
{
    if (m_translucent)
        return;

    int result;

    errno = 0;
    result = screen_destroy_window_buffers(m_window);
    if (result != 0) {
        qFatal("QQnxRootWindow: failed to destroy window buffer, errno=%d", errno);
    }

    QRect geometry = m_screen->geometry();
    errno = 0;
    int val[2];
    val[0] = geometry.width();
    val[1] = geometry.height();
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, val);
    if (result != 0) {
        qFatal("QQnxRootWindow: failed to set window buffer size, errno=%d", errno);
    }

    errno = 0;
    result = screen_create_window_buffers(m_window, 1);
    if (result != 0) {
        qFatal("QQNX: failed to create window buffer, errno=%d", errno);
    }

    // Install an alpha channel on the root window.
    //
    // This is necessary in order to avoid interfering with any particular
    // toplevel widget's QQnxWindow window instance from showing transparent
    // if it desires.
    errno = 0;
    val[0] = SCREEN_TRANSPARENCY_SOURCE_OVER;
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_TRANSPARENCY, val);
    if (result != 0) {
        qFatal("QQnxRootWindow: failed to set window transparency, errno=%d", errno);
    }

    m_translucent = true;
    post();
}
Пример #11
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;
}
Пример #12
0
void BlackberryMain::realiseDisplay(int idx) {
	const EGLint egl_surfaceAttr[] = { EGL_RENDER_BUFFER, EGL_BACK_BUFFER, EGL_NONE };
	int size[2] = { atoi(getenv("WIDTH")), atoi(getenv("HEIGHT")) };
	if (idx != 0)
		screen_get_display_property_iv(screen_dpy[idx], SCREEN_PROPERTY_SIZE, size);

	displays[idx].width = size[0];
	displays[idx].height = size[1];
	screen_set_window_property_iv(screen_win[idx], SCREEN_PROPERTY_BUFFER_SIZE, size);
	screen_create_window_buffers(screen_win[idx], 2); // Double buffered
	fprintf(stderr, "Display %i realised with %ix%i\n", idx, size[0], size[1]);

	egl_surf[idx] = eglCreateWindowSurface(egl_disp[idx], egl_conf, screen_win[idx], egl_surfaceAttr);

	// Only enable for devices with hardware QWERTY, 1:1 aspect ratio
	if ((pixel_xres == pixel_yres) && displays[idx].type != SCREEN_DISPLAY_TYPE_INTERNAL)
	{
		screen_emu = idx;
		if (emulating)
			switchDisplay(idx);
	}

	displays[idx].realised = true;
}
Пример #13
0
int InitQNX(const char *Title,int Width,int Height)
{
  /* Initialize variables */
  AppTitle    = Title;
  XSize       = Width;
  YSize       = Height;
  TimerON     = 0;
  TimerReady  = 0;
  JoyState    = 0;
  LastKey     = 0;
  KeyModes    = 0;
  FrameCount  = 0;
  FrameRate   = 0;

  /* Get initial timestamp */
  gettimeofday(&TimeStamp,0);

	screen_create_context(&ctxt, SCREEN_APPLICATION_CONTEXT);

	int dispCount;
	screen_get_context_property_iv(ctxt, SCREEN_PROPERTY_DISPLAY_COUNT, &dispCount);
	screen_display_t* displays = new screen_display_t[dispCount];
	screen_get_context_property_pv(ctxt, SCREEN_PROPERTY_DISPLAYS, (void**)displays);
	int resolution[2] = { 0, 0 };
	screen_get_display_property_iv(displays[0], SCREEN_PROPERTY_SIZE, resolution);
	delete[] displays;
	actualSize_x = resolution[0];
	actualSize_y = resolution[1];
	double scaleY;
	if (isPhysicalKeyboardDevice)
		scaleY = ((double)resolution[1]) / 600.0;
	else
		scaleY = ((double)resolution[1]) / 1024.0;
	double scaleX = ((double)resolution[0]) / 600.0;
	scaleTouchMap(scaleX, scaleY);

	if (BPS_SUCCESS != screen_request_events(ctxt))
	{
		screen_destroy_context(ctxt);
		return 0;
	}

#ifdef __BBTEN__
	screen_create_window_type(&window, ctxt, SCREEN_CHILD_WINDOW);
	screen_join_window_group(window, windowGroup);
	screen_set_window_property_cv(window, SCREEN_PROPERTY_ID_STRING, windowIdLength, "AlmostTIAppID");
	int vis = 1;
	screen_set_window_property_iv(window, SCREEN_PROPERTY_VISIBLE, &vis);
	int z = -5;
	screen_set_window_property_iv(window, SCREEN_PROPERTY_ZORDER, &z);
	if (isPhysicalKeyboardDevice)
		virtualkeyboard_request_events(0);
#else
	screen_create_window(&window, ctxt);

	int usage = SCREEN_USAGE_WRITE | SCREEN_USAGE_NATIVE;
	screen_set_window_property_iv(window, SCREEN_PROPERTY_USAGE, &usage);
#endif
	screen_create_window_buffers(window, 1);
	screen_get_window_property_iv(window, SCREEN_PROPERTY_BUFFER_SIZE, rect+2);

  /* Done */
  return(1);
}
Пример #14
0
// Video
int init_GLES2(screen_context_t ctx) {
	int usage = SCREEN_USAGE_ROTATION | SCREEN_USAGE_OPENGL_ES2;
	int format = SCREEN_FORMAT_RGBX8888;
	int num_configs;

	EGLint attrib_list[]= {
				EGL_RED_SIZE,        8,
				EGL_GREEN_SIZE,      8,
				EGL_BLUE_SIZE,       8,
				EGL_DEPTH_SIZE,	     24,
				EGL_STENCIL_SIZE,    8,
				EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,
				EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
				EGL_NONE};

	const EGLint attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
	const EGLint egl_surfaceAttr[] = { EGL_RENDER_BUFFER, EGL_BACK_BUFFER, EGL_NONE };

	screen_ctx = ctx;
	screen_create_window(&screen_win, screen_ctx);
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_FORMAT, &format);
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage);
	screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&screen_disp);

	// This must be landscape.
	int screen_resolution[2];
	screen_get_display_property_iv(screen_disp, SCREEN_PROPERTY_SIZE, screen_resolution);
	int angle = atoi(getenv("ORIENTATION"));
	pixel_xres = screen_resolution[0]; pixel_yres = screen_resolution[1];

	screen_display_mode_t screen_mode;
	screen_get_display_property_pv(screen_disp, SCREEN_PROPERTY_MODE, (void**)&screen_mode);

	int size[2];
	screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);

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

	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];
			pixel_yres = screen_resolution[0];
			pixel_xres = screen_resolution[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];
			pixel_yres = screen_resolution[0];
			pixel_xres = screen_resolution[1];
		}
	}
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size);
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &angle);

	screen_create_window_buffers(screen_win, 2); // Double buffered
	egl_disp = eglGetDisplay(EGL_DEFAULT_DISPLAY);
	eglInitialize(egl_disp, NULL, NULL);

	eglChooseConfig(egl_disp, attrib_list, &egl_conf, 1, &num_configs);
	egl_ctx = eglCreateContext(egl_disp, egl_conf, EGL_NO_CONTEXT, attributes);

	egl_surf = eglCreateWindowSurface(egl_disp, egl_conf, screen_win, egl_surfaceAttr);

	eglMakeCurrent(egl_disp, egl_surf, egl_surf, egl_ctx);
	eglSwapInterval(egl_disp, 1);

	return 0;
}
Пример #15
0
bool Game::InitDisplay()
{
   /*
   * Here specify the attributes of the desired configuration.
   * Below, we select an EGLConfig with at least 8 bits per color
   * component compatible with on-screen windows
   */
   const EGLint attribs[] =
   {
      EGL_RED_SIZE,        8,
      EGL_GREEN_SIZE,      8,
      EGL_BLUE_SIZE,       8,
      EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,
      EGL_DEPTH_SIZE,      24,
      EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, //Maybe EGL_CONFORMANT for windows and Android?
      EGL_NONE
   };
   EGLint attrib_list[]= { EGL_RED_SIZE,        8,
                           EGL_GREEN_SIZE,      8,
                           EGL_BLUE_SIZE,       8,
                           EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,
                           EGL_RENDERABLE_TYPE, 0,
                           EGL_NONE};

   EGLint w, h, format;
   EGLint numConfigs;
   EGLConfig config[64];
   EGLSurface surface;
   EGLContext context;

   EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);

   int maj;
   int min;
   eglInitialize(display, &maj, &min);
   Log::Debug("EGLInitialise", "EGL Major:%d Minor:%d", maj, min);

   /* Here, the application chooses the configuration it desires. In this
   * sample, we have a very simplified selection process, where we pick
   * the first EGLConfig that matches our criteria */
   eglChooseConfig(display, attribs, &config[0], 64, &numConfigs);

   for(int i = 0; i < numConfigs; i++)
   {
      int val[1];
      eglGetConfigAttrib(display, config[i], EGL_CONFORMANT, &val[0]);
      Log::Debug("EGLInitialise", "EGL_CONFORMANT: %d", val[0]);
      Log::Debug("EGLInitialise", "GL2: %d", val[0] & EGL_OPENGL_ES2_BIT);
      Log::Debug("EGLInitialise", "GL1: %d", val[0] & EGL_OPENGL_ES_BIT);
   }

   if(numConfigs == 0)
   {
      Log::Error("EGLInitialise", "No EGL configs were returned.");
      return true;
   }

   /* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
   * guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
   * As soon as we picked a EGLConfig, we can safely reconfigure the
   * ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */
   eglGetConfigAttrib(display, config[0], EGL_NATIVE_VISUAL_ID, &format);

#ifdef ANDROID
   ANativeWindow_setBuffersGeometry(mDisplay.app->window, 0, 0, format); //TODO!
   surface = eglCreateWindowSurface(display, config[0], mDisplay.app->window, NULL);
#endif
#ifdef _WIN32
   mDisplay.WindowHandle = create_window(mDisplay.Width, mDisplay.Height);
   surface = EGL_CHECK(eglCreateWindowSurface(display, config[0], (EGLNativeWindowType)mDisplay.WindowHandle, NULL));
#endif
#ifdef __QNX__
   int screen_format = SCREEN_FORMAT_RGBX8888;
   int usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION;
   int screen_resolution[2];
   screen_display_mode_t screen_mode;
   int size[2];
   int angle = std::atoi(std::getenv("ORIENTATION"));

   screen_create_window(&mDisplay.qnx_screen_win, mDisplay.qnx_screen_context);
   screen_set_window_property_iv(mDisplay.qnx_screen_win, SCREEN_PROPERTY_FORMAT, &screen_format);
   screen_set_window_property_iv(mDisplay.qnx_screen_win, SCREEN_PROPERTY_USAGE, &usage);
   screen_get_window_property_pv(mDisplay.qnx_screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&mDisplay.qnx_screen_disp);
   screen_get_display_property_iv(mDisplay.qnx_screen_disp, SCREEN_PROPERTY_SIZE, screen_resolution);
   screen_get_display_property_pv(mDisplay.qnx_screen_disp, SCREEN_PROPERTY_MODE, (void**)&screen_mode);
   screen_get_window_property_iv(mDisplay.qnx_screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);

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

   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 {
        return true;
   }

   screen_set_window_property_iv(mDisplay.qnx_screen_win, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size);
   screen_set_window_property_iv(mDisplay.qnx_screen_win, SCREEN_PROPERTY_ROTATION, &angle);
   screen_create_window_buffers(mDisplay.qnx_screen_win, 2);

   surface = EGL_CHECK(eglCreateWindowSurface(display, config[0], (EGLNativeWindowType)mDisplay.qnx_screen_win, NULL));
#endif

   if(surface == EGL_NO_SURFACE) {
      Log::Error("EGLInitialise", "EGL Surface creation failed.");
      return true;
   }

   const EGLint attribs2[] =
   {
      EGL_CONTEXT_CLIENT_VERSION, 2,
      EGL_NONE
   };
   context = eglCreateContext(display, config[0], NULL, attribs2);

   if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) {
      Log::Error("EGLInitialise", "Unable to eglMakeCurrent");
      return true;
   }

#ifdef __QNX__
   eglSwapInterval(display, 1);
#endif

   eglQuerySurface(display, surface, EGL_WIDTH, &w);
   eglQuerySurface(display, surface, EGL_HEIGHT, &h);

   mDisplay.Display = display;
   mDisplay.Context = context;
   mDisplay.Surface = surface;
   mDisplay.Width = w;
   mDisplay.Height = h;
   mTP->camera->SetResolution(Vector2f((float)mDisplay.Width, (float)mDisplay.Height));

   // Initialize GL state.
   GL_CHECK(glViewport(0, 0, w, h));
   GL_CHECK(glEnable(GL_DEPTH_TEST));
   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   GL_CHECK(glEnable(GL_BLEND));
   GL_CHECK(glEnable(GL_ALPHA));


   Effect::CacheTick(*mTP, EffectClearLevel::Initialise);
   Texture::CacheTick(*mTP, TextureClearLevel::Initialise);
   Font::CacheTick(*mTP, FontClearLevel::Initialise);
   //Initialise graphics
   for(std::vector<GameObject*>::iterator it = mGO.begin(); it != mGO.end(); ++it)
   {
      (*it)->InitialiseGraphics(*mTP);
   }

   return false;
}
Пример #16
0
int create_gles_window(const char *group, const char *id, int dims[2])
{
	int i, j;

	screen_window_t screen_win;
	screen_create_window_type(&screen_win, screen_ctx, SCREEN_CHILD_WINDOW);
	screen_join_window_group(screen_win, group);
	screen_set_window_property_cv(screen_win, SCREEN_PROPERTY_ID_STRING, strlen(id), id);

	int flag = 1;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_STATIC, &flag);

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

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

	int format = SCREEN_FORMAT_RGBA8888;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_FORMAT, &format);

    int usage = SCREEN_USAGE_OPENGL_ES2;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage);

	int transparency = SCREEN_TRANSPARENCY_SOURCE_OVER;
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_TRANSPARENCY, &transparency);

	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, dims);
	screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SIZE, dims);

	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);

	int rect[4] = { 0, 0, dims[0], dims[1] }; // OpenGL window covers all display
	screen_post_window(screen_win, screen_buf, 1, rect, 0);

	// EGL initialization stuff starts here
	EGLint surface_width, surface_height;
	GLuint rendering_program;
	EGLConfig egl_conf;

    EGLint interval = 1;
    int rc, num_configs;

    EGLint attrib_list[]= { EGL_RED_SIZE,        8,
                            EGL_GREEN_SIZE,      8,
                            EGL_BLUE_SIZE,       8,
                            EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,
                            EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
                            EGL_NONE};
    EGLint attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };

    //EGL initialization
    egl_disp = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    if (egl_disp == EGL_NO_DISPLAY) {
        egl_perror("bbutil_init_egl: eglGetDisplay");
        gl_terminate(&screen_win);
        return EXIT_FAILURE;
    }

    rc = eglInitialize(egl_disp, NULL, NULL);
    if (rc != EGL_TRUE) {
        egl_perror("bbutil_init_egl: eglInitialize");
        gl_terminate(&screen_win);
        return EXIT_FAILURE;
    }

    rc = eglBindAPI(EGL_OPENGL_ES_API);
    if (rc != EGL_TRUE) {
        egl_perror("bbutil_init_egl: eglBindApi");
        gl_terminate(&screen_win);
        return EXIT_FAILURE;
    }

    if(!eglChooseConfig(egl_disp, attrib_list, &egl_conf, 1, &num_configs)) {
        gl_terminate(&screen_win);
        return EXIT_FAILURE;
    }

    egl_ctx = eglCreateContext(egl_disp, egl_conf, EGL_NO_CONTEXT, attributes);
    if (egl_ctx == EGL_NO_CONTEXT) {
        egl_perror("bbutil_init_egl: eglCreateContext");
        gl_terminate(&screen_win);
        return EXIT_FAILURE;
    }

    // Bound EGL serface to our Native Window
    egl_surf = eglCreateWindowSurface(egl_disp, egl_conf, screen_win, NULL);
    if (egl_surf == EGL_NO_SURFACE) {
        egl_perror("eglCreateWindowSurface");
        gl_terminate(&screen_win);
        return 1;
    }

    rc = eglMakeCurrent(egl_disp, egl_surf, egl_surf, egl_ctx);
    if (rc != EGL_TRUE) {
        egl_perror("eglMakeCurrent");
        gl_terminate(&screen_win);
        return 1;
    }

    rc = eglSwapInterval(egl_disp, interval);
    if (rc != EGL_TRUE) {
        egl_perror("eglSwapInterval");
        gl_terminate(&screen_win);
        return 1;
    }

	glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Last byte is 'transparency', it's important to have it 0.0f
    glEnable(GL_CULL_FACE);

    // Enable 2d
    eglQuerySurface(egl_disp, egl_surf, EGL_WIDTH, &surface_width);
    eglQuerySurface(egl_disp, egl_surf, EGL_HEIGHT, &surface_height);

    EGLint err = eglGetError();
    if (err != 0x3000) {
        fprintf(stderr, "Unable to query EGL surface dimensions\n");
        return EXIT_FAILURE;
    }
    glViewport(0, 0, surface_width, surface_height);

    // Create shaders
    const char *v_source =
    		"attribute vec4 vPosition;\n"
    		"void main()\n"
    		"{\n"
			"gl_Position = vPosition;\n"
			"}";
    const char *f_source =
    		"precision mediump float; \n"
    		"void main()\n"
    		"{\n"
    		"gl_FragColor = vec4(1.0, 0.0, 0.0, 0.7); \n" // 0.7 means we make it 'a bit' transparent
    		"}	\n";

    // Compile the vertex shader
    GLint status;
    GLuint vs = glCreateShader(GL_VERTEX_SHADER);
    if (!vs) {
        fprintf(stderr, "Failed to create vertex shader: %d\n", glGetError());
        return EXIT_FAILURE;
    } else {
        glShaderSource(vs, 1, &v_source, 0);
        glCompileShader(vs);
        glGetShaderiv(vs, GL_COMPILE_STATUS, &status);
        if (GL_FALSE == status) {
            GLchar log[256];
            glGetShaderInfoLog(vs, 256, NULL, log);

            fprintf(stderr, "Failed to compile vertex shader: %s\n", log);

            glDeleteShader(vs);
            return EXIT_FAILURE;
        }
    }

    // Compile the fragment shader
    GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
    if (!fs) {
        fprintf(stderr, "Failed to create fragment shader: %d\n", glGetError());
        return EXIT_FAILURE;
    } else {
        glShaderSource(fs, 1, &f_source, 0);
        glCompileShader(fs);
        glGetShaderiv(fs, GL_COMPILE_STATUS, &status);
        if (GL_FALSE == status) {
            GLchar log[256];
            glGetShaderInfoLog(fs, 256, NULL, log);

            fprintf(stderr, "Failed to compile fragment shader: %s\n", log);

            glDeleteShader(vs);
            glDeleteShader(fs);

            return EXIT_FAILURE;
        }
    }

    // Create and link the program
    rendering_program = glCreateProgram();
    if (rendering_program)
    {
        glAttachShader(rendering_program, vs);
        glAttachShader(rendering_program, fs);
        glLinkProgram(rendering_program);

        glGetProgramiv(rendering_program, GL_LINK_STATUS, &status);
        if (status == GL_FALSE){
            GLchar log[256];
            glGetProgramInfoLog(fs, 256, NULL, log);

            fprintf(stderr, "Failed to link text rendering shader program: %s\n", log);

            glDeleteProgram(rendering_program);
            rendering_program = 0;

            return EXIT_FAILURE;
        }
    } else {
        fprintf(stderr, "Failed to create a shader program\n");

        glDeleteShader(vs);
        glDeleteShader(fs);
        return EXIT_FAILURE;
    }
    // We don't need the shaders anymore - the program is enough
    glDeleteShader(fs);
    glDeleteShader(vs);

    glUseProgram(rendering_program); // In this example we use only one rendering program, so we can call this function once

    screen_gles_win = screen_win;

    return EXIT_SUCCESS;
}
Пример #17
0
int
bbutil_init_egl(screen_context_t ctx, enum RENDERING_API api) {
    int usage;
    int format = SCREEN_FORMAT_RGBX8888;
    EGLint interval = 1;
    int rc, num_configs;
    EGLint attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };

    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};

    if (api == GL_ES_1) {
        usage = SCREEN_USAGE_OPENGL_ES1 | SCREEN_USAGE_ROTATION;
    } else if (api == GL_ES_2) {
    	attrib_list[11] = EGL_OPENGL_ES2_BIT;
        usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION;
    } else if (api == VG) {
    	attrib_list[11] = EGL_OPENVG_BIT;
        usage = SCREEN_USAGE_OPENVG | SCREEN_USAGE_ROTATION;
    } else {
        fprintf(stderr, "invalid api setting\n");
        return EXIT_FAILURE;
    }

    //Simple egl initialization
    screen_ctx = ctx;

    egl_disp = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    if (egl_disp == EGL_NO_DISPLAY) {
        bbutil_egl_perror("eglGetDisplay");
        bbutil_terminate();
        return EXIT_FAILURE;
    }

    rc = eglInitialize(egl_disp, NULL, NULL);
    if (rc != EGL_TRUE) {
        bbutil_egl_perror("eglInitialize");
        bbutil_terminate();
        return EXIT_FAILURE;
    }

    if ((api == GL_ES_1) || (api == GL_ES_2)) {
        rc = eglBindAPI(EGL_OPENGL_ES_API);
    } else if (api == VG) {
        rc = eglBindAPI(EGL_OPENVG_API);
    }

    if (rc != EGL_TRUE) {
        bbutil_egl_perror("eglBindApi");
        bbutil_terminate();
        return EXIT_FAILURE;
    }

    if(!eglChooseConfig(egl_disp, attrib_list, &egl_conf, 1, &num_configs)) {
        bbutil_terminate();
        return EXIT_FAILURE;
    }

    if (api == GL_ES_2) {
        egl_ctx = eglCreateContext(egl_disp, egl_conf, EGL_NO_CONTEXT, attributes);
    } else {
        egl_ctx = eglCreateContext(egl_disp, egl_conf, EGL_NO_CONTEXT, NULL);
    }

    if (egl_ctx == EGL_NO_CONTEXT) {
        bbutil_egl_perror("eglCreateContext");
        bbutil_terminate();
        return EXIT_FAILURE;
    }

    rc = screen_create_window(&screen_win, screen_ctx);
    if (rc) {
        perror("screen_create_window");
        bbutil_terminate();
        return EXIT_FAILURE;
    }

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

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

    rc = screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&screen_disp);
    if (rc) {
        perror("screen_get_window_property_pv");
        bbutil_terminate();
        return EXIT_FAILURE;
    }

    int angle = atoi(getenv("ORIENTATION"));

	screen_display_mode_t screen_mode;
	rc = screen_get_display_property_pv(screen_disp, SCREEN_PROPERTY_MODE, (void**)&screen_mode);
	if (rc) {
		perror("screen_get_display_property_pv");
		bbutil_terminate();
		return EXIT_FAILURE;
	}

	int size[2];
	rc = screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);
	if (rc) {
		perror("screen_get_window_property_iv");
		bbutil_terminate();
		return EXIT_FAILURE;
	}

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

	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 {
		 fprintf(stderr, "Navigator returned an unexpected orientation angle.\n");
		 bbutil_terminate();
		 return EXIT_FAILURE;
	}

	rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size);
    if (rc) {
        perror("screen_set_window_property_iv");
        bbutil_terminate();
        return EXIT_FAILURE;
    }

    rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &angle);
    if (rc) {
        perror("screen_set_window_property_iv");
        bbutil_terminate();
        return EXIT_FAILURE;
    }

    rc = screen_create_window_buffers(screen_win, nbuffers);
    if (rc) {
        perror("screen_create_window_buffers");
        bbutil_terminate();
        return EXIT_FAILURE;
    }

    egl_surf = eglCreateWindowSurface(egl_disp, egl_conf, screen_win, NULL);
    if (egl_surf == EGL_NO_SURFACE) {
        bbutil_egl_perror("eglCreateWindowSurface");
        bbutil_terminate();
        return EXIT_FAILURE;
    }

    rc = eglMakeCurrent(egl_disp, egl_surf, egl_surf, egl_ctx);
    if (rc != EGL_TRUE) {
        bbutil_egl_perror("eglMakeCurrent");
        bbutil_terminate();
        return EXIT_FAILURE;
    }

    rc = eglSwapInterval(egl_disp, interval);
    if (rc != EGL_TRUE) {
        bbutil_egl_perror("eglSwapInterval");
        bbutil_terminate();
        return EXIT_FAILURE;
    }

    initialized = 1;

    return EXIT_SUCCESS;
}
bool CIrrDeviceBB10::createWindow()
{
	if ( Close )
		return false;

	int rc = screen_create_window(&bspScreenWindow, bspScreenCtx);
	if(rc)
	{
		os::Printer::log("Screen create window failed!");
		return false;
	}

	if(video::EDT_OGLES1 != CreationParams.DriverType && video::EDT_OGLES2 !=CreationParams.DriverType)
		return false;

	bspformat = SCREEN_FORMAT_RGBX8888;
	if(CreationParams.Bits==16)
		bspformat = SCREEN_FORMAT_RGBX4444;

	bspUsage = SCREEN_USAGE_OPENGL_ES1 | SCREEN_USAGE_ROTATION;
	if(video::EDT_OGLES2 ==CreationParams.DriverType)
		bspUsage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION;

	//window properties
	rc = screen_set_window_property_iv(bspScreenWindow, SCREEN_PROPERTY_FORMAT, &bspformat);

	rc = screen_set_window_property_iv(bspScreenWindow, SCREEN_PROPERTY_USAGE, &bspUsage);

	screen_display_t screenDisplay;
	rc = screen_get_window_property_pv(bspScreenWindow, SCREEN_PROPERTY_DISPLAY, (void **)&screenDisplay);

	int screenResolution[2];
	rc = screen_get_display_property_iv(screenDisplay, SCREEN_PROPERTY_SIZE, screenResolution);

	int angle = atoi(getenv("ORIENTATION"));

	screen_display_mode_t screenDisplayMode;
	rc = screen_get_display_property_pv(screenDisplay, SCREEN_PROPERTY_MODE, (void**)&screenDisplayMode);

	int bufferSize[2];
	rc = screen_get_window_property_iv(bspScreenWindow, SCREEN_PROPERTY_BUFFER_SIZE, bufferSize);

	int newBufferSize[2] = {bufferSize[0], bufferSize[1]};
	if ((angle == 0) || (angle == 180)) 
	{
		if (((screenDisplayMode.width > screenDisplayMode.height) && (bufferSize[0] < bufferSize[1])) 
			|| ((screenDisplayMode.width < screenDisplayMode.height) && (bufferSize[0] > bufferSize[1])))
		{
			newBufferSize[1] = bufferSize[0];
			newBufferSize[0] = bufferSize[1];
		}
	}
	else if ((angle == 90) || (angle == 270))
	{
		if (((screenDisplayMode.width > screenDisplayMode.height) && (bufferSize[0] > bufferSize[1]))
			|| ((screenDisplayMode.width < screenDisplayMode.height && bufferSize[0] < bufferSize[1]))) 
		{
			newBufferSize[1] = bufferSize[0];
			newBufferSize[0] = bufferSize[1];
		}
	} 
	else
	{
		os::Printer::log("Navigator returned an unexpected orientation angle.\n");
		return false;
	}

	rc = screen_set_window_property_iv(bspScreenWindow, SCREEN_PROPERTY_BUFFER_SIZE, newBufferSize);

	rc = screen_set_window_property_iv(bspScreenWindow, SCREEN_PROPERTY_ROTATION, &angle);

	rc = screen_create_window_buffers(bspScreenWindow, 2);
	return true;
}
Пример #19
0
bool CCEGLView::initGL()
{
    int rc = 0;
    int screenFormat = SCREEN_FORMAT_RGBA8888;
#ifdef __X86__
    int screenUsage = SCREEN_USAGE_OPENGL_ES2;
#else
    int screenUsage = SCREEN_USAGE_DISPLAY|SCREEN_USAGE_OPENGL_ES2; // Physical device copy directly into physical display
#endif
//    int screenSwapInterval = WINDOW_VSYNC ? 1 : 0;
    int screenTransparency = SCREEN_TRANSPARENCY_NONE;
    int angle = atoi(getenv("ORIENTATION"));

    // Hard-coded to (0,0).
    int windowPosition[] =
    {
        0, 0
    };

    EGLint eglConfigCount;
    EGLConfig config;

    // Hard-coded to 32-bit/OpenGL ES 2.0.
    const EGLint eglConfigAttrs[] =
    {
        EGL_RED_SIZE,           8,
        EGL_GREEN_SIZE,         8,
        EGL_BLUE_SIZE,          8,
        EGL_ALPHA_SIZE,         8,
        EGL_DEPTH_SIZE,         24,
        EGL_STENCIL_SIZE,       8,
        EGL_SURFACE_TYPE,       EGL_WINDOW_BIT,
        EGL_RENDERABLE_TYPE,    EGL_OPENGL_ES2_BIT,
        EGL_NONE
    };

    const EGLint eglContextAttrs[] =
    {
        EGL_CONTEXT_CLIENT_VERSION,    2,
        EGL_NONE
    };

    const EGLint eglSurfaceAttrs[] =
    {
        EGL_RENDER_BUFFER,    EGL_BACK_BUFFER,
        EGL_NONE
    };

    // Create the screen context.
    rc = screen_create_context(&m_screenContext, 0);
    if (rc)
    {
        perror("screen_create_context");
        return false;
    }

    // Create the screen window.
    rc = screen_create_window(&m_screenWindow, m_screenContext);
    if (rc)
    {
        perror("screen_create_window");
        return false;
    }

    // Set/get any window prooperties.
    rc = screen_set_window_property_iv(m_screenWindow, SCREEN_PROPERTY_FORMAT, &screenFormat);
    if (rc)
    {
        perror("screen_set_window_property_iv(SCREEN_PROPERTY_FORMAT)");
        return false;
    }

    rc = screen_set_window_property_iv(m_screenWindow, SCREEN_PROPERTY_USAGE, &screenUsage);
    if (rc)
    {
        perror("screen_set_window_property_iv(SCREEN_PROPERTY_USAGE)");
        return false;
    }


	char *width_str = getenv("WIDTH");
	char *height_str = getenv("HEIGHT");

	if (width_str && height_str)
	{
		int screen_res[2];
		screen_res[0] = atoi(width_str);
		screen_res[1] = atoi(height_str);

		int rc = screen_set_window_property_iv(m_screenWindow, SCREEN_PROPERTY_BUFFER_SIZE, screen_res);
		if (rc)
		{
			fprintf(stderr, "screen_set_window_property_iv(SCREEN_PROPERTY_BUFFER_SIZE)");
			return false;
		}
	}
	else
	{

	    screen_display_t screen_display;
	    rc = screen_get_window_property_pv(m_screenWindow, SCREEN_PROPERTY_DISPLAY, (void **)&screen_display);
	    if (rc)
	    {
	        perror("screen_get_window_property_pv(SCREEN_PROPERTY_DISPLAY)");
	        return false;
	    }

	    screen_display_mode_t screen_mode;
	    rc = screen_get_display_property_pv(screen_display, SCREEN_PROPERTY_MODE, (void**)&screen_mode);
	    if (rc)
	    {
	        perror("screen_get_display_property_pv(SCREEN_PROPERTY_MODE)");
	        return false;
	    }

	    int size[2];
	    rc = screen_get_window_property_iv(m_screenWindow, SCREEN_PROPERTY_BUFFER_SIZE, size);
	    if (rc)
	    {
	        perror("screen_get_window_property_iv(SCREEN_PROPERTY_BUFFER_SIZE)");
	        return false;
	    }

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

		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
		{
			perror("Navigator returned an unexpected orientation angle.");
			return false;
		}

	    rc = screen_set_window_property_iv(m_screenWindow, SCREEN_PROPERTY_ROTATION, &angle);
	    if (rc)
	    {
	        perror("screen_set_window_property_iv(SCREEN_PROPERTY_ROTATION)");
	        return false;
	    }

	    rc = screen_set_window_property_iv(m_screenWindow, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size);
	    if (rc)
	    {
	        perror("screen_set_window_property_iv(SCREEN_PROPERTY_BUFFER_SIZE)");
	        return false;
	    }
	}

    if (windowPosition[0] != 0 || windowPosition[1] != 0)
    {
        rc = screen_set_window_property_iv(m_screenWindow, SCREEN_PROPERTY_POSITION, windowPosition);
        if (rc)
        {
            perror("screen_set_window_property_iv(SCREEN_PROPERTY_POSITION)");
            return false;
        }
    }

    rc = screen_set_window_property_iv(m_screenWindow, SCREEN_PROPERTY_TRANSPARENCY, &screenTransparency);
    if (rc)
    {
        perror("screen_set_window_property_iv(SCREEN_PROPERTY_TRANSPARENCY)");
        return false;
    }

    // Double buffered.
    rc = screen_create_window_buffers(m_screenWindow, 2);
    if (rc)
    {
        perror("screen_create_window_buffers");
        return false;
    }

    // Create screen event object.
    rc = screen_create_event(&m_screenEvent);
    if (rc)
    {
        perror("screen_create_event");
        return false;
    }

    // Request screen events.
    screen_request_events(m_screenContext);

    // Get the EGL display and initialize.
    m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    if (m_eglDisplay == EGL_NO_DISPLAY)
    {
        perror("eglGetDisplay");
        return false;
    }
    if (eglInitialize(m_eglDisplay, NULL, NULL) != EGL_TRUE)
    {
        perror("eglInitialize");
        return false;
    }

    if (eglChooseConfig(m_eglDisplay, eglConfigAttrs, &config, 1, &eglConfigCount) != EGL_TRUE || eglConfigCount == 0)
    {
        checkErrorEGL("eglChooseConfig");
        return false;
    }

    m_eglContext = eglCreateContext(m_eglDisplay, config, EGL_NO_CONTEXT, eglContextAttrs);
    if (m_eglContext == EGL_NO_CONTEXT)
    {
        checkErrorEGL("eglCreateContext");
        return false;
    }

    m_eglSurface = eglCreateWindowSurface(m_eglDisplay, config, m_screenWindow, eglSurfaceAttrs);
    if (m_eglSurface == EGL_NO_SURFACE)
    {
        checkErrorEGL("eglCreateWindowSurface");
        return false;
    }

    if (eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext) != EGL_TRUE)
    {
        checkErrorEGL("eglMakeCurrent");
        return false;
    }

    EGLint width, height;

    if ((m_eglDisplay == EGL_NO_DISPLAY) || (m_eglSurface == EGL_NO_SURFACE) )
    	return EXIT_FAILURE;

	eglQuerySurface(m_eglDisplay, m_eglSurface, EGL_WIDTH, &width);
    eglQuerySurface(m_eglDisplay, m_eglSurface, EGL_HEIGHT, &height);

    m_obScreenSize.width = width;
    m_obScreenSize.height = height;

    // Set vsync.
//    eglSwapInterval(m_eglDisplay, screenSwapInterval);

    return true;
}
Пример #20
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;
}
Пример #21
0
int
main (int argc, char **argv)
{
    int     card = -1;
    int     dev = 0;
    snd_pcm_t *pcm_handle;
    FILE   *file;
    wave_hdr wav_header;
    int     samples;
    int     sample_rate;
    int     sample_channels;
    int     sample_bits;
    char   *sample_buffer;
    int     fragsize = -1;
    int     verbose = 0;

    int     rtn;
    int     final_return_code = -1;
    snd_pcm_channel_info_t pi;
    snd_mixer_t *mixer_handle;
    snd_mixer_group_t group;
    snd_pcm_channel_params_t pp;
    snd_pcm_channel_setup_t setup;
    int     bsize, bytes_read, total_written = 0;
    fd_set  rfds, wfds;
    uint32_t voice_mask[] = { 0, 0, 0, 0 };
    snd_pcm_voice_conversion_t voice_conversion;
    int     voice_override = 0;
    int     num_frags = -1;
    char input_file[PATH_MAX];
    char cwd[PATH_MAX];
    screen_context_t screen_cxt;
    screen_window_t screen_win;
    screen_buffer_t screen_buf;
    int screen_fill_attribs[] = { SCREEN_BLIT_COLOR, COLOR_PURPLE, SCREEN_BLIT_END };
    int screen_dirty[4] = { 0, 0, 1024, 600 }; //start with sane default values

    int idle_mode = SCREEN_IDLE_MODE_KEEP_AWAKE;
    int usage = SCREEN_USAGE_NATIVE;

    if (screen_create_context(&screen_cxt, 0) != 0)
    {
    	return err("failed to create context");
    }

    if (screen_create_window(&screen_win, screen_cxt) != 0)
    {
    	err("failed to create window");
    	goto fail1;
    }

    if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage) != 0)
    {
    	err("failed to set native usage mode");
    	goto fail2;
    }

    if (screen_create_window_buffers(screen_win, 1) != 0)
    {
    	err("failed to set native usage mode");
    	goto fail2;
    }

    if(screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf) != 0)
    {
    	err("failed to get screen buffer");
    	goto fail2;
    }

    if (screen_fill(screen_cxt, screen_buf, screen_fill_attribs) != 0) {
    	err("failed to fill the screen");
    	goto fail3;
    }

    if (screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, screen_dirty+2) != 0) {
    	err("failed to get window size");
    	goto fail3;
    }

    if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_IDLE_MODE, &idle_mode) != 0)
    {
    	err("failed to set idle mode");
    	goto fail3;
    }

    if (screen_post_window(screen_win, screen_buf, 1, screen_dirty, 0) != 0) {
    	err("failed to post the window");
    	goto fail3;
    }

    if ((rtn = snd_pcm_open_preferred (&pcm_handle, &card, &dev, SND_PCM_OPEN_PLAYBACK)) < 0)
    {
        err ("device open");
        goto fail3;
    }

    getcwd(cwd, PATH_MAX);
    rtn = snprintf(input_file, PATH_MAX, "%s%s", cwd, WAV_RELATIVE_PATH);
    if (rtn > PATH_MAX - 1)
    {
    	err ("File name and path too long");
    	goto fail4;
    }

    if ((file = fopen (input_file, "r")) == 0)
    {
    	err ("File open failed");
    	goto fail4;
    }

    if (check_hdr (file) == -1) {
        err ("check_hdr failed");
        goto fail5;
    }

    samples = find_tag (file, "fmt ");
    fread (&wav_header, sizeof (wav_header), 1, file);
    fseek (file, (samples - sizeof (wave_hdr)), SEEK_CUR);

    sample_rate = ENDIAN_LE32 (wav_header.samples_per_sec);
    sample_channels = ENDIAN_LE16 (wav_header.channels);
    sample_bits = ENDIAN_LE16 (wav_header.bits_per_sample);

    printf ("SampleRate = %d, channels = %d, SampleBits = %d\n", sample_rate, sample_channels,
        sample_bits);

    /* disabling mmap is not actually required in this example but it is included to
     * demonstrate how it is used when it is required.
     */
    if ((rtn = snd_pcm_plugin_set_disable (pcm_handle, PLUGIN_DISABLE_MMAP)) < 0)
    {
        fprintf (stderr, "snd_pcm_plugin_set_disable failed: %s\n", snd_strerror (rtn));
        goto fail5;
    }

    memset (&pi, 0, sizeof (pi));
    pi.channel = SND_PCM_CHANNEL_PLAYBACK;
    if ((rtn = snd_pcm_plugin_info (pcm_handle, &pi)) < 0)
    {
        fprintf (stderr, "snd_pcm_plugin_info failed: %s\n", snd_strerror (rtn));
        goto fail5;
    }

    memset (&pp, 0, sizeof (pp));

    pp.mode = SND_PCM_MODE_BLOCK;
    pp.channel = SND_PCM_CHANNEL_PLAYBACK;
    pp.start_mode = SND_PCM_START_FULL;
    pp.stop_mode = SND_PCM_STOP_STOP;
    pp.buf.block.frag_size = pi.max_fragment_size;

    if (fragsize != -1)
    {
        pp.buf.block.frag_size = fragsize;
    }
    pp.buf.block.frags_max = num_frags;
    pp.buf.block.frags_min = 1;

    pp.format.interleave = 1;
    pp.format.rate = sample_rate;
    pp.format.voices = sample_channels;

    if (ENDIAN_LE16 (wav_header.format_tag) == 6)
        pp.format.format = SND_PCM_SFMT_A_LAW;
    else if (ENDIAN_LE16 (wav_header.format_tag) == 7)
        pp.format.format = SND_PCM_SFMT_MU_LAW;
    else if (sample_bits == 8)
        pp.format.format = SND_PCM_SFMT_U8;
    else if (sample_bits == 24)
        pp.format.format = SND_PCM_SFMT_S24;
    else
        pp.format.format = SND_PCM_SFMT_S16_LE;

    strcpy (pp.sw_mixer_subchn_name, "Wave playback channel");
    if ((rtn = snd_pcm_plugin_params (pcm_handle, &pp)) < 0)
    {
        fprintf (stderr, "snd_pcm_plugin_params failed: %s\n", snd_strerror (rtn));
        goto fail5;
    }

    if ((rtn = snd_pcm_plugin_prepare (pcm_handle, SND_PCM_CHANNEL_PLAYBACK)) < 0) {
        fprintf (stderr, "snd_pcm_plugin_prepare failed: %s\n", snd_strerror (rtn));
        goto fail5;
    }

    if (voice_override)
    {
        snd_pcm_plugin_get_voice_conversion (pcm_handle, SND_PCM_CHANNEL_PLAYBACK,
            &voice_conversion);
        voice_conversion.matrix[0] = voice_mask[0];
        voice_conversion.matrix[1] = voice_mask[1];
        voice_conversion.matrix[2] = voice_mask[2];
        voice_conversion.matrix[3] = voice_mask[3];
        snd_pcm_plugin_set_voice_conversion (pcm_handle, SND_PCM_CHANNEL_PLAYBACK,
            &voice_conversion);
    }

    memset (&setup, 0, sizeof (setup));
    memset (&group, 0, sizeof (group));
    setup.channel = SND_PCM_CHANNEL_PLAYBACK;
    setup.mixer_gid = &group.gid;

    if ((rtn = snd_pcm_plugin_setup (pcm_handle, &setup)) < 0)
    {
        fprintf (stderr, "snd_pcm_plugin_setup failed: %s\n", snd_strerror (rtn));
        goto fail5;
    }

    printf ("Format %s \n", snd_pcm_get_format_name (setup.format.format));
    printf ("Frag Size %d \n", setup.buf.block.frag_size);
    printf ("Total Frags %d \n", setup.buf.block.frags);
    printf ("Rate %d \n", setup.format.rate);
    printf ("Voices %d \n", setup.format.voices);
    bsize = setup.buf.block.frag_size;

    if (group.gid.name[0] == 0)
    {
        fprintf (stderr, "Mixer Pcm Group [%s] Not Set \n", group.gid.name);
        goto fail5;
    }

    printf ("Mixer Pcm Group [%s]\n", group.gid.name);
    if ((rtn = snd_mixer_open (&mixer_handle, card, setup.mixer_device)) < 0)
    {
        fprintf (stderr, "snd_mixer_open failed: %s\n", snd_strerror (rtn));
        goto fail5;
    }

    samples = find_tag (file, "data");
    sample_buffer = malloc (bsize);
    FD_ZERO (&rfds);
    FD_ZERO (&wfds);
    bytes_read = 1;
    while (total_written < samples && bytes_read > 0)
    {
        if (tcgetpgrp (0) == getpid ())
            FD_SET (STDIN_FILENO, &rfds);
        FD_SET (snd_mixer_file_descriptor (mixer_handle), &rfds);
        FD_SET (snd_pcm_file_descriptor (pcm_handle, SND_PCM_CHANNEL_PLAYBACK), &wfds);

        rtn = max (snd_mixer_file_descriptor (mixer_handle),
            snd_pcm_file_descriptor (pcm_handle, SND_PCM_CHANNEL_PLAYBACK));

        if (select (rtn + 1, &rfds, &wfds, NULL, NULL) == -1)
        {
        	err ("select");
        	goto fail6;
        }

        if (FD_ISSET (snd_pcm_file_descriptor (pcm_handle, SND_PCM_CHANNEL_PLAYBACK), &wfds))
        {
            snd_pcm_channel_status_t status;
            int     written = 0;

            if ((bytes_read = fread (sample_buffer, 1, min (samples - total_written, bsize), file)) <= 0)
                continue;
            written = snd_pcm_plugin_write (pcm_handle, sample_buffer, bytes_read);
            if (verbose)
                printf ("bytes written = %d \n", written);

            if (written < bytes_read)
            {
                memset (&status, 0, sizeof (status));
                status.channel = SND_PCM_CHANNEL_PLAYBACK;
                if (snd_pcm_plugin_status (pcm_handle, &status) < 0)
                {
                    fprintf (stderr, "underrun: playback channel status error\n");
                    goto fail6;
                }

                if (status.status == SND_PCM_STATUS_READY ||
                    status.status == SND_PCM_STATUS_UNDERRUN)
                {
                    if (snd_pcm_plugin_prepare (pcm_handle, SND_PCM_CHANNEL_PLAYBACK) < 0)
                    {
                        fprintf (stderr, "underrun: playback channel prepare error\n");
                        goto fail6;
                    }
                }
                if (written < 0)
                    written = 0;
                written += snd_pcm_plugin_write (pcm_handle, sample_buffer + written, bytes_read - written);
            }
            total_written += written;
        }
    }

    bytes_read = snd_pcm_plugin_flush (pcm_handle, SND_PCM_CHANNEL_PLAYBACK);
    final_return_code = 0;

fail6:
    rtn = snd_mixer_close (mixer_handle);
fail5:
    fclose (file);
fail4:
    rtn = snd_pcm_close (pcm_handle);
fail3:
    screen_destroy_buffer(screen_buf);
fail2:
    screen_destroy_window(screen_win);
fail1:
    screen_destroy_context(screen_cxt);
    return final_return_code;
}
int OpenGLView::initGL()
{
    int numberDisplays;
    int numberModes;
    int returnCode;
    EGLBoolean status;
    int type;
    EGLint attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
    EGLint attrib_list[]= { EGL_RED_SIZE,        8,
                            EGL_GREEN_SIZE,      8,
                            EGL_BLUE_SIZE,       8,
                            EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,
                            EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
                            EGL_NONE};

    // try this first as it will fail if an HDMI display is not attached
    if (m_api == GL_ES_2) {
        m_egl_ctx = eglCreateContext(m_egl_disp, m_egl_conf, EGL_NO_CONTEXT, attributes);
    } else {
        m_egl_ctx = eglCreateContext(m_egl_disp, m_egl_conf, EGL_NO_CONTEXT, NULL);
    }
    if (m_egl_ctx == EGL_NO_CONTEXT) {
        perror("eglCreateContext");
        return EXIT_FAILURE;
    }

	screen_get_context_property_iv(m_screen_ctx, SCREEN_PROPERTY_DISPLAY_COUNT, &numberDisplays);

	m_screen_dpy = (screen_display_t *)calloc(numberDisplays, sizeof(screen_display_t));
	screen_get_context_property_pv(m_screen_ctx, SCREEN_PROPERTY_DISPLAYS, (void **)m_screen_dpy);


	for (int index = 0; index < numberDisplays; index++) {
		int displayID;

        returnCode = screen_get_display_property_iv(m_screen_dpy[index], SCREEN_PROPERTY_ID,  (int *)&displayID);
    	if (returnCode) {
    		perror("display ID");
    		return EXIT_FAILURE;
    	} else {
			if (displayID == m_display) {
			    screen_get_display_property_iv(m_screen_dpy[index], SCREEN_PROPERTY_TYPE,  &type);
			    if (type == SCREEN_DISPLAY_TYPE_HDMI) {
			    	returnCode = screen_create_window(&m_screen_win, m_screen_ctx);
			    	if (returnCode) {
			            perror("screen_create_window");
			            return EXIT_FAILURE;
			        }
			    } else {
			    	returnCode = screen_create_window_type(&m_screen_win, m_screen_ctx, SCREEN_CHILD_WINDOW);
			    	if (returnCode) {
			            perror("screen_create_window (child window)");
			            return EXIT_FAILURE;
			        }
			    }
			    if (type == SCREEN_DISPLAY_TYPE_HDMI) {
					returnCode = screen_set_window_property_pv(m_screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&(m_screen_dpy[index]));
					if (returnCode) {
						perror("window display");
						return EXIT_FAILURE;
					}
		        }
			}
        }
	}

	qDebug()  << "OpenGLView::initialize: "<< m_screen_ctx << ":" << m_egl_disp << ":" << m_egl_conf << ":" << m_egl_ctx << ":" << m_screen_win;


	int format = SCREEN_FORMAT_RGBA8888;
	returnCode = screen_set_window_property_iv(m_screen_win, SCREEN_PROPERTY_FORMAT, &format);
	if (returnCode) {
		perror("screen_set_window_property_iv(SCREEN_PROPERTY_FORMAT)");
		return EXIT_FAILURE;
	}

	if (m_transparency > 0) {
		returnCode = setWindowTransparency(m_transparency);
		if (returnCode) {
			perror("transparency");
			return EXIT_FAILURE;
		}
	}

	returnCode = screen_get_window_property_pv(m_screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&m_screen_disp);
	if (returnCode) {
		perror("screen_get_window_property_pv");
		return EXIT_FAILURE;
	}

	int angle = atoi(getenv("ORIENTATION"));

	screen_get_display_property_iv(m_screen_disp, SCREEN_PROPERTY_MODE_COUNT, &numberModes);

	m_screen_modes = (screen_display_mode_t *)calloc(numberModes, sizeof(screen_display_mode_t));
	returnCode = screen_get_display_property_pv(m_screen_disp, SCREEN_PROPERTY_MODE, (void**)m_screen_modes);
	if (returnCode) {
		perror("screen modes");
		return EXIT_FAILURE;
	}

    int dpi = calculateDPI();
    if (dpi == EXIT_FAILURE) {
        fprintf(stderr, "Unable to calculate dpi\n");
        return EXIT_FAILURE;
    }

	returnCode = setWindowPosition(m_x, m_y);
	if (returnCode) {
		perror("window position");
		return EXIT_FAILURE;
	}

	returnCode = setWindowSize(m_width, m_height);
	if (returnCode) {
		perror("window size");
		return EXIT_FAILURE;
	}

	returnCode = setWindowZ(m_z);
	if (returnCode) {
		perror("z order");
		return EXIT_FAILURE;
	}

	returnCode = setWindowBufferSize(m_width, m_height);
	if (returnCode) {
		perror("buffer size");
		return EXIT_FAILURE;
	}

	returnCode = setWindowAngle(m_angle);
	if (returnCode) {
		perror("angle");
		return EXIT_FAILURE;
	}

	returnCode = screen_create_window_buffers(m_screen_win, m_nbuffers);
	if (returnCode) {
		perror("screen_create_window_buffers");
		return EXIT_FAILURE;
	}


    if (m_api == GL_ES_1) {
        m_usage = SCREEN_USAGE_OPENGL_ES1 | SCREEN_USAGE_ROTATION;
    } else if (m_api == GL_ES_2) {
    	attrib_list[9] = EGL_OPENGL_ES2_BIT;
    	m_usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION;
    } else if (m_api == VG) {
    	attrib_list[9] = EGL_OPENVG_BIT;
    	m_usage = SCREEN_USAGE_OPENVG | SCREEN_USAGE_ROTATION;
    } else {
        fprintf(stderr, "invalid api setting\n");
        return EXIT_FAILURE;
    }

	returnCode = setWindowUsage(m_usage);
	if (returnCode) {
		perror("screen_set_window_property_iv(window usage)");
		return EXIT_FAILURE;
	}

	qDebug()  << "OpenGLView::initGL:eglCreateContext "<< m_egl_ctx;
	m_egl_surf = eglCreateWindowSurface(m_egl_disp, m_egl_conf, m_screen_win, NULL);
	if (m_egl_surf == EGL_NO_SURFACE) {
		OpenGLThread::eglPrintError("eglCreateWindowSurface");
		return EXIT_FAILURE;
	}

	getGLContext();

    EGLint interval = 1;
    status = eglSwapInterval(m_egl_disp, interval);
	if (status != EGL_TRUE) {
		OpenGLThread::eglPrintError("eglSwapInterval");
		return EXIT_FAILURE;
	}

    status = eglQuerySurface(m_egl_disp, m_egl_surf, EGL_WIDTH, &m_surface_width);
	if (status != EGL_TRUE) {
		perror("query surface width");
		return EXIT_FAILURE;
	}

    status = eglQuerySurface(m_egl_disp, m_egl_surf, EGL_HEIGHT, &m_surface_height);
	if (status != EGL_TRUE) {
		perror("query surface height");
		return EXIT_FAILURE;
	}

	returnCode = joinWindowGroup(m_group);
	if (returnCode) {
		perror("window group");
		return EXIT_FAILURE;
	}

	returnCode = setScreenWindowID(m_id);
	if (returnCode) {
		perror("window ID");
		return EXIT_FAILURE;
	}

	qDebug()  << "OpenGLView::initGL: "<< angle << ":" << numberModes << ":" << m_screen_modes[0].width << ":" << m_screen_modes[0].height << ":" << m_egl_disp << ":" << dpi;

	setInitialized(true);

	return EXIT_SUCCESS;
}
Пример #23
0
QQnxRootWindow::QQnxRootWindow(const QQnxScreen *screen)
    : m_screen(screen),
      m_window(0),
      m_windowGroupName(),
      m_translucent(false)
{
    qRootWindowDebug() << Q_FUNC_INFO;
    // Create one top-level QNX window to act as a container for child windows
    // since navigator only supports one application window
    errno = 0;
    int result = screen_create_window(&m_window, m_screen->nativeContext());
    int val[2];
    if (result != 0)
        qFatal("QQnxRootWindow: failed to create window, errno=%d", errno);

    // Move window to proper display
    errno = 0;
    screen_display_t display = m_screen->nativeDisplay();
    result = screen_set_window_property_pv(m_window, SCREEN_PROPERTY_DISPLAY, (void **)&display);
    if (result != 0)
        qFatal("QQnxRootWindow: failed to set window display, errno=%d", errno);

    // Make sure window is above navigator but below keyboard if running as root
    // since navigator won't automatically set our z-order in this case
    if (getuid() == 0) {
        errno = 0;
        val[0] = MAGIC_ZORDER_FOR_NO_NAV;
        result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ZORDER, val);
        if (result != 0)
            qFatal("QQnxRootWindow: failed to set window z-order, errno=%d", errno);
    }

    // Window won't be visible unless it has some buffers so make one dummy buffer that is 1x1
    errno = 0;
    val[0] = SCREEN_USAGE_NATIVE;
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_USAGE, val);
    if (result != 0)
        qFatal("QQnxRootWindow: failed to set window buffer usage, errno=%d", errno);

    errno = 0;
    val[0] = m_screen->nativeFormat();
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_FORMAT, val);
    if (result != 0)
        qFatal("QQnxRootWindow: failed to set window pixel format, errno=%d", errno);

    errno = 0;
    val[0] = 1;
    val[1] = 1;
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, val);
    if (result != 0)
        qFatal("QQnxRootWindow: failed to set window buffer size, errno=%d", errno);

    errno = 0;
    result = screen_create_window_buffers(m_window, 1);
    if (result != 0)
        qFatal("QQNX: failed to create window buffer, errno=%d", errno);

    // Window is always the size of the display
    errno = 0;
    QRect geometry = m_screen->geometry();
    val[0] = geometry.width();
    val[1] = geometry.height();
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, val);
    if (result != 0)
        qFatal("QQnxRootWindow: failed to set window size, errno=%d", errno);

    // Fill the window with solid black. Note that the LSB of the pixel value
    // 0x00000000 just happens to be 0x00, so if and when this root window's
    // alpha blending mode is changed from None to Source-Over, it will then
    // be interpreted as transparent.
    errno = 0;
    val[0] = 0;
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_COLOR, val);
    if (result != 0)
        qFatal("QQnxRootWindow: failed to set window colour, errno=%d", errno);

    // Make the window opaque
    errno = 0;
    val[0] = SCREEN_TRANSPARENCY_NONE;
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_TRANSPARENCY, val);
    if (result != 0)
        qFatal("QQnxRootWindow: failed to set window transparency, errno=%d", errno);

    // Set the swap interval to 1
    errno = 0;
    val[0] = 1;
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SWAP_INTERVAL, val);
    if (result != 0)
        qFatal("QQnxRootWindow: failed to set window swap interval, errno=%d", errno);

    // Set viewport size equal to window size but move outside buffer so the fill colour is used exclusively
    errno = 0;
    val[0] = geometry.width();
    val[1] = geometry.height();
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_SIZE, val);
    if (result != 0)
        qFatal("QQnxRootWindow: failed to set window source size, errno=%d", errno);

    errno = 0;
    val[0] = 0;
    val[1] = 0;
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_POSITION, val);
    if (result != 0)
        qFatal("QQnxRootWindow: failed to set window source position, errno=%d", errno);

    // Optionally disable the screen power save
    bool ok = false;
    const int disablePowerSave = qgetenv("QQNX_DISABLE_POWER_SAVE").toInt(&ok);
    if (ok && disablePowerSave) {
        const int mode = SCREEN_IDLE_MODE_KEEP_AWAKE;
        result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_IDLE_MODE, &mode);
        if (result != 0)
            qWarning("QQnxRootWindow: failed to disable power saving mode");
    }

    createWindowGroup();

    // Don't post yet. This will be lazily done from QQnxScreen upon first posting of
    // a child window. Doing it now pre-emptively would create a flicker if one of
    // the QWindow's about to be created sets its Qt::WA_TranslucentBackground flag
    // and immediately triggers the buffer re-creation in makeTranslucent().
}
Пример #24
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;
}
Пример #25
0
int QNX_InitGL(void)
{
    int usage = SCREEN_USAGE_OPENGL_ES1;
	int transp = SCREEN_TRANSPARENCY_NONE;
	EGLint interval = 1;
	int size[2] = { -1, -1 };
	int pos[2] = { 0, 0 };
	int nbuffers = 2;
	int format;
	EGLConfig config;
    EGLint           err;

    config = choose_config(eglDisplay, "rgb565");
    if (config == (EGLConfig)0) {
        Com_Printf( "Demo Thread Init: failed to find config!" );
        return FALSE;
	}

    // Create EGL rendering context
    eglContext = eglCreateContext( eglDisplay, config, EGL_NO_CONTEXT, NULL );
    err = eglGetError( );
    if ( eglContext == EGL_NO_CONTEXT ) {
        Com_Printf( "Demo Thread Init: can't create gles2 context!" );
        PrintEglError( err );
		return FALSE;
    }

    err = screen_create_context(&screen_ctx, 0);
	if (err) {
		Com_Printf("screen_create_context");
		return FALSE;
	}

    err = screen_create_window(&screen_win, screen_ctx);
	if (err) {
		Com_Printf("screen_create_window");
		return FALSE;
	}

	format = choose_format(eglDisplay, config);
	err = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_FORMAT, &format);
	if (err) {
		Com_Printf("screen_set_window_property_iv(SCREEN_PROPERTY_FORMAT)");
		return FALSE;
	}



	err = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage);
	if (err) {
		Com_Printf("screen_set_window_property_iv(SCREEN_PROPERTY_USAGE)");
		return FALSE;
	}

	size[0]=1024;
	size[1]=768;

	err = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);
	if (err) {
		Com_Printf("screen_set_window_property_iv(screen_set_window_property_iv)");
		return FALSE;
	}

	if (size[0] > 0 && size[1] > 0) {
		err = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SIZE, size);
		if (err) {
			Com_Printf("screen_set_window_property_iv(SCREEN_PROPERTY_SIZE)");
			return FALSE;
		}
	} else {
		err = screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_SIZE, size);
		if (err) {
			Com_Printf("screen_get_window_property_iv(SCREEN_PROPERTY_SIZE)");
			return FALSE;
		}
	}

	glConfig.vidWidth = size[0];
	glConfig.vidHeight = size[1];

	InitControls();

	bz[0] = size[0];
	bz[1] = size[1];

	if (pos[0] != 0 || pos[1] != 0) {
		err = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_POSITION, pos);
		if (err) {
			Com_Printf("screen_set_window_property_iv(SCREEN_PROPERTY_POSITION)");
			return FALSE;
		}
	}

	err = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_TRANSPARENCY, &transp);
	if (err) {
		Com_Printf("screen_set_window_property_iv(SCREEN_PROPERTY_TRANSPARENCY)");
		return FALSE;
	}

	err = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SWAP_INTERVAL, &interval);
	if (err) {
		Com_Printf("screen_set_window_property_iv(SCREEN_PROPERTY_SWAP_INTERVAL)");
		return FALSE;
	}

	err = screen_create_window_buffers(screen_win, nbuffers);
	if (err) {
		Com_Printf("screen_create_window_buffers");
		return FALSE;
	}

	size[0] = 1024;
	size[1] = 600;
	err = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SIZE, size);
	if (err) {
		Com_Printf("screen_set_window_property_iv(SCREEN_PROPERTY_SIZE)");
		return FALSE;
	}

	err = screen_create_event(&screen_ev);
	if (err) {
		Com_Printf("screen_create_event");
		return FALSE;
	}

	eglSurface = eglCreateWindowSurface(eglDisplay, config, screen_win, NULL);
	if (eglSurface == EGL_NO_SURFACE) {
        Com_Printf( "Demo Thread Init: can't create surface!" );
        PrintEglError( err );
        return FALSE;
	}

	err = eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);
	if (err != EGL_TRUE) {
        Com_Printf( "Demo Thread Init: can't make current!" );
		return FALSE;
	}

	pps_decoder_init(&decoder, NULL, 0);
	ppsfd = open("/pps/services/navigator/control", O_RDWR);
	if (ppsfd == -1) {
		Com_Printf("warning: failed to open PPS\n");
	}
    return TRUE;
}
Пример #26
0
gceSTATUS
gcoOS_CreateWindow(
    IN HALNativeDisplayType Display,
    IN gctINT X,
    IN gctINT Y,
    IN gctINT Width,
    IN gctINT Height,
    OUT HALNativeWindowType * Window
    )
{
    gctINT pos[2];
    gctINT size[2];
    gctINT screen_format = SCREEN_FORMAT_RGBX8888;
    gctINT screen_transparency = SCREEN_TRANSPARENCY_NONE;
    gctINT screen_usage = SCREEN_USAGE_OPENGL_ES1 | SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_OPENVG
            ;
    /* Use 0 for no-vsync, and 1 for vsync limited. */
    gctINT screen_swap_interval = 0;
    gctINT rc;
    gceSTATUS status = gcvSTATUS_OK;
    gcmHEADER_ARG("Display=0x%x X=%d Y=%d Width=%d Height=%d", Display, X, Y, Width, Height);

    /* Create window strcture. */
    rc = screen_create_window((struct _screen_window **)Window, screen_ctx);
    if (rc)
    {
        fprintf(stderr, "screen_create_window failed with error %d (0x%08x)\n", errno, errno);
        status = gcvSTATUS_OUT_OF_RESOURCES;
        gcmFOOTER();
        return status;
    }

    /* Set window pximap format. */
    rc = screen_set_window_property_iv(*Window, SCREEN_PROPERTY_FORMAT, &screen_format);
    if (rc)
    {
        fprintf(stderr, "screen_set_window_property_iv(SCREEN_PROPERTY_FORMAT) failed with error %d (0x%08x)\n", errno, errno);
        screen_destroy_window(*Window);
        status = gcvSTATUS_OUT_OF_RESOURCES;
        gcmFOOTER();
        return status;
    }

    /* Set window usage. */
    rc = screen_set_window_property_iv(*Window, SCREEN_PROPERTY_USAGE, &screen_usage);
    if (rc)
    {
        fprintf(stderr, "screen_set_window_property_iv(SCREEN_PROPERTY_USAGE) failed with error %d (0x%08x)\n", errno, errno);
        screen_destroy_window(*Window);
        status = gcvSTATUS_OUT_OF_RESOURCES;
        gcmFOOTER();
        return status;
    }

    /* Get fullscreen window size. */
    rc = screen_get_window_property_iv(*Window, SCREEN_PROPERTY_SIZE, size);
    if (rc)
    {
        fprintf(stderr, "screen_get_window_property_iv(SCREEN_PROPERTY_SIZE) failed with error %d (0x%08x)\n", errno, errno);
        screen_destroy_window(*Window);
        status = gcvSTATUS_OUT_OF_RESOURCES;
        gcmFOOTER();
        return status;
    }

    /* Disable transparency. Due to a bug in Screen, this must be set after format. */
    rc = screen_set_window_property_iv(*Window, SCREEN_PROPERTY_TRANSPARENCY, &screen_transparency);
    if (rc)
    {
        fprintf(stderr, "screen_get_window_property_iv(SCREEN_PROPERTY_TRANSPARENCY) failed with error %d (0x%08x)\n", errno, errno);
        screen_destroy_window(*Window);
        status = gcvSTATUS_OUT_OF_RESOURCES;
        gcmFOOTER();
        return status;
    }

    /* Set swap interval. */
    rc = screen_set_window_property_iv(*Window, SCREEN_PROPERTY_SWAP_INTERVAL, &screen_swap_interval);
    if (rc)
    {
        fprintf(stderr, "screen_get_window_property_iv(SCREEN_PROPERTY_SWAP_INTERVAL) failed with error %d (0x%08x)\n", errno, errno);
        screen_destroy_window(*Window);
        status = gcvSTATUS_OUT_OF_RESOURCES;
        gcmFOOTER();
        return status;
    }

    /* Test for zero width. */
    if (Width == 0)
    {
        Width = size[0];
    }

    /* Test for zero height. */
    if (Height == 0)
    {
        Height = size[1];
    }

    /* Test for auto-center X coordinate. */
    if (X == -1)
    {
        X = (size[0] - Width) / 2;
    }

    /* Test for auto-center X coordinate. */
    if (Y == -1)
    {
        Y = (size[1] - Height) / 2;
    }

    /* Resize the window. */
    size[0] = Width;
    size[1] = Height;

    rc = screen_set_window_property_iv(*Window, SCREEN_PROPERTY_SIZE, size);
    if (rc)
    {
        fprintf(stderr, "screen_set_window_property_iv(SCREEN_PROPERTY_SIZE) failed with error %d (0x%08x)\n", errno, errno);
        screen_destroy_window(*Window);
        status = gcvSTATUS_OUT_OF_RESOURCES;
        gcmFOOTER();
        return status;
    }

    /* Create window buffer. */
    /* Second argument is the number of back buffers to be used. */
    rc = screen_create_window_buffers(*Window, gcdDISPLAY_BACK_BUFFERS);
    if (rc)
    {
        fprintf(stderr, "screen_create_window_buffers failed with error %d (0x%08x)\n", errno, errno);
        screen_destroy_window(*Window);
        status = gcvSTATUS_OUT_OF_RESOURCES;
        gcmFOOTER();
        return status;
    }

    /* Move window position. */
    pos[0] = X;
    pos[1] = Y;

    rc = screen_set_window_property_iv(*Window, SCREEN_PROPERTY_POSITION, pos);
    if (rc) {
        fprintf(stderr, "screen_set_window_property_iv(SCREEN_PROPERTY_POSITION) failed with error %d (0x%08x)\n", errno, errno);
        screen_destroy_window(*Window);
        status = gcvSTATUS_OUT_OF_RESOURCES;
        gcmFOOTER();
        return status;
    }

    gcmFOOTER_ARG("*Window=0x%x", *Window);
    return status;
}
Пример #27
0
static bool gfx_ctx_qnx_init(void *data)
{
   /* Create a screen context that will be used to 
    * create an EGL surface to receive libscreen events */

   RARCH_LOG("Initializing screen context...\n");
   if (!screen_ctx)
   {
      screen_create_context(&screen_ctx, 0);

      if (screen_request_events(screen_ctx) != BPS_SUCCESS)
      {
         RARCH_ERR("screen_request_events failed.\n");
         goto screen_error;
      }

      if (navigator_request_events(0) != BPS_SUCCESS)
      {
         RARCH_ERR("navigator_request_events failed.\n");
         goto screen_error;
      }

      if (navigator_rotation_lock(false) != BPS_SUCCESS)
      {
         RARCH_ERR("navigator_location_lock failed.\n");
         goto screen_error;
      }
   }

   const EGLint attribs[] = {
      EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
      EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
      EGL_BLUE_SIZE, 8,
      EGL_GREEN_SIZE, 8,
      EGL_RED_SIZE, 8,
      EGL_NONE
   };
   EGLint num_config;
   EGLint egl_version_major, egl_version_minor;
   int format = SCREEN_FORMAT_RGBX8888;

   EGLint context_attributes[] = {
      EGL_CONTEXT_CLIENT_VERSION, 2,
      EGL_NONE
   };
   int usage;

   usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION;

   RARCH_LOG("Initializing context\n");

   if ((g_egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY)
   {
      RARCH_ERR("eglGetDisplay failed.\n");
      goto error;
   }

   if (!eglInitialize(g_egl_dpy, &egl_version_major, &egl_version_minor))
   {
      RARCH_ERR("eglInitialize failed.\n");
      goto error;
   }

   if (!eglBindAPI(EGL_OPENGL_ES_API))
   {
      RARCH_ERR("eglBindAPI failed.\n");
      goto error;
   }

   RARCH_LOG("[BLACKBERRY QNX/EGL]: EGL version: %d.%d\n", egl_version_major, egl_version_minor);

   if (!eglChooseConfig(g_egl_dpy, attribs, &egl_config, 1, &num_config))
   {
      RARCH_ERR("eglChooseConfig failed.\n");
      goto error;
   }

   if ((g_egl_ctx = eglCreateContext(g_egl_dpy, egl_config, 0, context_attributes)) == EGL_NO_CONTEXT)
   {
      RARCH_ERR("eglCreateContext failed.\n");
      goto error;
   }

   if(!screen_win)
   {
      if (screen_create_window(&screen_win, screen_ctx))
      {
	     RARCH_ERR("screen_create_window failed:.\n");
	     goto error;
      }
   }

   if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_FORMAT, &format))
   {
      RARCH_ERR("screen_set_window_property_iv [SCREEN_PROPERTY_FORMAT] failed.\n");
      goto error;
   }

   if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage))
   {
      RARCH_ERR("screen_set_window_property_iv [SCREEN_PROPERTY_USAGE] failed.\n");
      goto error;
   }

   if (screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&screen_disp))
   {
      RARCH_ERR("screen_get_window_property_pv [SCREEN_PROPERTY_DISPLAY] failed.\n");
      goto error;
   }

   int screen_resolution[2];

   if (screen_get_display_property_iv(screen_disp, SCREEN_PROPERTY_SIZE, screen_resolution))
   {
      RARCH_ERR("screen_get_window_property_iv [SCREEN_PROPERTY_SIZE] failed.\n");
      goto error;
   }

#ifndef HAVE_BB10
   int angle = atoi(getenv("ORIENTATION"));

   screen_display_mode_t screen_mode;
   if (screen_get_display_property_pv(screen_disp, SCREEN_PROPERTY_MODE, (void**)&screen_mode))
   {
      RARCH_ERR("screen_get_display_property_pv [SCREEN_PROPERTY_MODE] failed.\n");
      goto error;
   }

   int size[2];
   if (screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size))
   {
      RARCH_ERR("screen_get_window_property_iv [SCREEN_PROPERTY_BUFFER_SIZE] failed.\n");
      goto error;
   }

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

   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 {
      RARCH_ERR("Navigator returned an unexpected orientation angle.\n");
      goto error;
   }


   if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size))
   {
      RARCH_ERR("screen_set_window_property_iv [SCREEN_PROPERTY_BUFFER_SIZE] failed.\n");
      goto error;
   }

   if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &angle))
   {
      RARCH_ERR("screen_set_window_property_iv [SCREEN_PROPERTY_ROTATION] failed.\n");
      goto error;
   }
#endif

   if (screen_create_window_buffers(screen_win, WINDOW_BUFFERS))
   {
      RARCH_ERR("screen_create_window_buffers failed.\n");
      goto error;
   }

   if (!(g_egl_surf = eglCreateWindowSurface(g_egl_dpy, egl_config, screen_win, 0)))
   {
      RARCH_ERR("eglCreateWindowSurface failed.\n");
      goto error;
   }


   if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx))
   {
      RARCH_ERR("eglMakeCurrent failed.\n");
      goto error;
   }

   return true;

error:
   RARCH_ERR("EGL error: %d.\n", eglGetError());
   gfx_ctx_qnx_destroy(data);
screen_error:
   screen_stop_events(screen_ctx);
   return false;
}
Пример #28
0
void ScreenWindow::setVideoMode(int width, int height)
{
	if (m_window) {
		screen_destroy_window(m_window);
		m_window = 0;
	}
	if (!m_window) {
		screen_create_window_type(&m_window, m_context, SCREEN_CHILD_WINDOW);
		char groupName[256];
		snprintf(groupName, 256, "screen-%d", getpid());
		screen_join_window_group(m_window, groupName);
	} else {
		screen_destroy_window_buffers(m_window);
	}

	m_width = width;
	m_height = height;

//#define NOSTRETCH
#define STRETCH_PRESERVE_ASPECT
#ifdef NOSTRETCH
	int position[2] = {ceil((1024-width)/2), ceil((600-height)/2)};
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_POSITION, position);

	int sizeOfWindow[2] = {width, height};
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, sizeOfWindow);

	int sizeOfBuffer[2] = {width, height};
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, sizeOfBuffer);
#elif defined(STRETCH_PRESERVE_ASPECT)
	width = ceil(width * 600 / height);
	height = 600;

	int position[2] = {ceil((1024-width)/2), ceil((600-height)/2)};
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_POSITION, position);

	int sizeOfWindow[2] = {width, height};
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, sizeOfWindow);

	int sizeOfBuffer[2] = {m_width, m_height}; // OLD DIMS
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, sizeOfBuffer);
#else
	int sizeOfWindow[2] = {1024, 600};
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, sizeOfWindow);

	int sizeOfBuffer[2] = {width, height};
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, sizeOfBuffer);
#endif

	int zOrder = 1;
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ZORDER, &zOrder);

	int format = SCREEN_FORMAT_RGBX8888;
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_FORMAT, &format);

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

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

	int visible = 1;
	screen_set_window_property_iv(m_window, SCREEN_PROPERTY_VISIBLE, &visible);

	screen_create_window_buffers(m_window, 1);
}
Пример #29
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;
}
Пример #30
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);
}