Example #1
0
void videotest(void)
{

    drv_video_window_t *w = drv_video_window_create( WXS, WYS, 300, 300, COLOR_BLACK, "Test Window", WFLAG_WIN_DECORATED );

    drv_video_winblt( w );
    drv_win_screen_update();
    getchar();



    w_draw_line( w, 0, 0, WXS, WYS, COLOR_RED );
    w_fill_ellipse( w, 30, 30, 15, 27, COLOR_BLUE );

    w_font_draw_string( w, &drv_video_8x16san_font, "Test font", COLOR_BLACK, COLOR_GREEN, 0, 0 );

    w_fill_box( w,  40, 32, 33, 10, COLOR_RED );


    drv_video_winblt( w );
    drv_win_screen_update();
    getchar();

}
void phantom_init_console_window()
{
    hal_mutex_init( &buf_mutex, "console" );

    console_fg = COLOR_LIGHTGRAY;
    console_bg = COLOR_BLACK;

    int xsize = 620, ysize = 300;
    int cw_x = 50, cw_y = 450;
    if( scr_get_ysize() < 600 )
    {
        cw_x = cw_y = 0;
    }

    drv_video_window_t *w = drv_video_window_create( xsize, ysize,
                        cw_x, cw_y, console_bg, "Console", WFLAG_WIN_DECORATED|WFLAG_WIN_DOUBLEBUF );

    phantom_console_window = w;

    w->owner = get_current_tid();

    phantom_set_console_ops( &win_ops );
    phantom_console_window_puts("Phantom console window\n");


    phantom_debug_window = drv_video_window_create(
                        DEBWIN_XS, DEBWIN_YS,
                        DEBWIN_X, DEBWIN_Y, console_bg, "Threads", WFLAG_WIN_DECORATED|WFLAG_WIN_DOUBLEBUF|WFLAG_WIN_FULLPAINT );

    //phantom_debug_window->flags |= WFLAG_WIN_DOUBLEBUF|WFLAG_WIN_FULLPAINT;
    //w_update( phantom_debug_window ); // For dbl buf flags to start working ok

    phantom_debug_window_puts("Phantom debug window\n\nt - threads\nw - windows\ns - stats\np - profiler\n");
    w_update( phantom_debug_window );
    //hal_sleep_msec(4000);

    hal_start_kernel_thread(phantom_debug_window_loop);


    // -------------------------------------------------------------------
    // Launcher window
    // -------------------------------------------------------------------

    color_t la_bg = { 0x19, 0x19, 0x19, 0xFF };
    color_t la_b1 = { 68, 66, 62, 0xFF  };
    color_t la_b2 = { 88, 84, 79, 0xFF  };

    color_t la_txt = { 0x11, 0xd5, 0xff, 0xFF };
//#define BTEXT_COLOR COLOR_YELLOW
#define BTEXT_COLOR la_txt

    phantom_launcher_window = drv_video_window_create( scr_get_xsize(), 32,
                                                       0, 0, console_bg, "Launcher", WFLAG_WIN_ONTOP );

    phantom_launcher_window->inKernelEventProcess = phantom_launcher_event_process;
    w_fill( phantom_launcher_window, la_bg );

    int lb_x = scr_get_xsize();

    lb_x -= power_button_sm_bmp.xsize + 5;
    w_add_button( phantom_launcher_window, -1, lb_x, 2, &power_button_sm_bmp, &power_button_pressed_sm_bmp, BUTTON_FLAG_NOBORDER );

    pool_handle_t bh;


    lb_x = 5;

    int nwin = 0;
    for( nwin = 0; nwin < MAX_LAUNCH_BUTTONS; nwin++ )
    {
        char * wname = "win1";

        // crashes in some configurations??
        //wname[3] = '0' + nwin;

        bh = w_add_button( phantom_launcher_window, nwin, lb_x, 5, &task_button_bmp, &task_button_bmp, BUTTON_FLAG_NOBORDER );
        w_button_set_text( phantom_launcher_window, bh, wname, BTEXT_COLOR );
        lb_x += 5+task_button_bmp.xsize;

        taskbuttons[nwin] = bh;
    }



    w_draw_line( phantom_launcher_window, 0, 31, scr_get_xsize(), 31, la_b1 );
    w_draw_line( phantom_launcher_window, 0, 30, scr_get_xsize(), 30, la_b2 );


    w_update( phantom_launcher_window );

    //hal_start_kernel_thread(phantom_launcher_window_loop);
}
Example #3
0
void videotest()
{

    //int ysize = 60;
    //int xsize = 80;
    //char win[ysize*xsize*3];

#if 0
    const char *bpm = "../../plib/resources/backgrounds/phantom_dz_large.pbm";

    {
        FILE *f = fopen(bpm, "r" );
        if(f == NULL )
        {
            printf("can't open %s\n", bpm );
            exit(33);
        }

        fseek( f, 0, SEEK_END );
        long size = ftell( f );
        fseek( f, 0, SEEK_SET );

        printf("Size of %s is %ld\n", bpm, size );

        char *data = malloc(size);

        fread( data, size, 1, f );
        fclose(f);

        struct drv_video_bitmap_t *bmp;
        int result = bmp_ppm_load( &bmp, data );

        free(data);

        if(result)
            printf("can't parse %s: %d\n", bpm, result );
        else
        {
            drv_video_bitblt(bmp->pixel, 0, 0, bmp->xsize, bmp->ysize, 0xFF );
        }

        bmp_pixels = bmp->pixel;
        bmpxs = bmp->xsize;
        bmpys = bmp->ysize;


    }
#endif

    int i;

    for( i = 0; i < 10; i++ )
    {
        fillw( (i+2)*10, (i+2)*20, (i+4)*10 );

//#if VIDEO_ZBUF
        drv_video_bitblt(win, 0, i*10, wxsize, wysize, i & 1 ? 0xFF : 0x55 );
//#else
//        drv_video_bitblt(win, 0, i*10, wxsize, wysize );
//#endif
        //drv_win_screen_update();
        //drv_video_update();
    }


    //drv_video_window_t *w = malloc(drv_video_window_bytes(140,80));
    //w->xsize = 140;
    //w->ysize = 80;

    drv_video_window_t *w = drv_video_window_create( 140,80, 200, 200, COLOR_LIGHTGRAY, "Test Window" );

    //drv_video_window_clear( w );
    //drv_video_window_fill( w, COLOR_LIGHTGRAY );
    drv_video_winblt( w );

    //flame(w);

    drv_video_window_draw_line( w, 1, 1, 110, 20, COLOR_RED );
    drv_video_window_draw_line( w, 110, 1, 110, 20, COLOR_RED );
    drv_video_window_draw_line( w, 1, 20, 110, 20, COLOR_GREEN );

    drv_video_window_fill_ellipse( w, 30, 30, 15, 27, COLOR_BLUE );

    drv_video_window_fill_box( w,  40, 32, 33, 10, COLOR_RED );

    drv_video_window_draw_box( w, 45, 37, 33, 12, COLOR_BLACK );

    drv_video_winblt( w );

    getchar();

//#if VIDEO_ZBUF
    video_zbuf_reset();

    fillw( 0xFF, 0, 0 );
    drv_video_bitblt(win, 550, 100, wxsize, wysize, 0xEF );

    //video_zbuf_dump();

    fillw( 0, 0xFF, 0 );
    drv_video_bitblt(win, 575, 120, wxsize, wysize, 0xEE );
    drv_video_bitblt(win, 700, 400, wxsize, wysize, 0xEE );
//#endif
    video_zbuf_reset();

//getchar();

#if 1
    drv_video_font_scroll_line( w, &drv_video_8x16san_font, COLOR_DARKGRAY );
    drv_video_font_draw_string( w, &drv_video_8x16san_font, "Test font", COLOR_BLACK, 0, 0 );
    drv_video_font_scroll_line( w, &drv_video_8x16san_font, COLOR_LIGHTGRAY );
    drv_video_font_draw_string( w, &drv_video_8x16san_font, "Line 2 ok", COLOR_BLACK, 0, 0 );
    drv_video_font_scroll_line( w, &drv_video_8x16san_font, COLOR_DARKGRAY );
    drv_video_font_draw_string( w, &drv_video_8x16san_font, "GIMME THAT", COLOR_BLACK, 0, 0 );
#else
    int ttx = 0, tty = 0;
    drv_video_font_tty_string( w, &drv_video_8x16san_font,
                               "Just a little bit long text\nFrom a new line",
                               //"Just a little bit long ",
                               COLOR_BLACK, COLOR_LIGHTGRAY,
                               &ttx, &tty );
#endif
    drv_video_winblt( w );
//getchar();
}