Exemplo n.º 1
0
nsfb_t *
framebuffer_initialise(const char *fename, int width, int height, int bpp)
{
    enum nsfb_frontend_e fetype;

    fetype = nsfb_frontend_from_name(fename);
    if (fetype == NSFB_FRONTEND_NONE) {
        LOG(("The %s frontend is not available from libnsfb\n", fename));
        return NULL;
    }

    nsfb = nsfb_init(fetype);
    if (nsfb == NULL) {
        LOG(("Unable to initialise nsfb with %s frontend\n", fename));
        return NULL;
    }
    
    if (nsfb_set_geometry(nsfb, width, height, bpp) == -1) {
        LOG(("Unable to set geometry\n"));
        nsfb_finalise(nsfb);
        return NULL;
    }

    nsfb_cursor_init(nsfb);
    
    if (nsfb_init_frontend(nsfb) == -1) {
        LOG(("Unable to initialise nsfb frontend\n"));
        nsfb_finalise(nsfb);
        return NULL;
    }

    return nsfb;

}
Exemplo n.º 2
0
nsfb_t *
framebuffer_initialise(const char *fename, int width, int height, int bpp)
{
    enum nsfb_type_e fbtype;
    enum nsfb_format_e fbfmt;

    /* bpp is a proxy for the framebuffer format */
    if (framebuffer_format_from_bpp(bpp, &fbfmt) == false) {
        return NULL;
    }

    fbtype = nsfb_type_from_name(fename);
    if (fbtype == NSFB_SURFACE_NONE) {
        LOG("The %s surface is not available from libnsfb\n", fename);
        return NULL;
    }

    nsfb = nsfb_new(fbtype);
    if (nsfb == NULL) {
        LOG("Unable to create %s fb surface\n", fename);
        return NULL;
    }

    if (nsfb_set_geometry(nsfb, width, height, fbfmt) == -1) {
        LOG("Unable to set surface geometry\n");
        nsfb_free(nsfb);
        return NULL;
    }

    nsfb_cursor_init(nsfb);

    if (nsfb_init(nsfb) == -1) {
        LOG("Unable to initialise nsfb surface\n");
        nsfb_free(nsfb);
        return NULL;
    }

    return nsfb;

}
Exemplo n.º 3
0
nsfb_t *
framebuffer_initialise(const char *fename, int width, int height, int bpp)
{
    enum nsfb_type_e fbtype;
    enum nsfb_format_e fbfmt;

    /* bpp is a proxy for the framebuffer format */
    switch (bpp) {
    case 32:
	    fbfmt = NSFB_FMT_XRGB8888;
	    break;

    case 24:
	    fbfmt = NSFB_FMT_RGB888;
	    break;

    case 16:
	    fbfmt = NSFB_FMT_RGB565;
	    break;

    case 8:
	    fbfmt = NSFB_FMT_I8;
	    break;

    case 4:
	    fbfmt = NSFB_FMT_I4;
	    break;

    case 1:
	    fbfmt = NSFB_FMT_I1;
	    break;

    default:
        LOG(("Bad bits per pixel (%d)\n", bpp));
        return NULL;	    
    }

    fbtype = nsfb_type_from_name(fename);
    if (fbtype == NSFB_SURFACE_NONE) {
        LOG(("The %s surface is not available from libnsfb\n", fename));
        return NULL;
    }

    nsfb = nsfb_new(fbtype);
    if (nsfb == NULL) {
        LOG(("Unable to create %s fb surface\n", fename));
        return NULL;
    }
    
    if (nsfb_set_geometry(nsfb, width, height, fbfmt) == -1) {
        LOG(("Unable to set surface geometry\n"));
        nsfb_free(nsfb);
        return NULL;
    }

    nsfb_cursor_init(nsfb);
    
    if (nsfb_init(nsfb) == -1) {
        LOG(("Unable to initialise nsfb surface\n"));
        nsfb_free(nsfb);
        return NULL;
    }

    return nsfb;

}