Example #1
0
main()
{
    FBDEV fbdev;
    memset(&fbdev,0,sizeof(FBDEV));
    strcpy(fbdev.dev,"/dev/fb0");
    if (fb_open(&fbdev)==FALSE) 
    {
        printf("open frame buffer error\n");
        return;
    }
    fb_memset((void *)(fbdev.fb_mem + fbdev.fb_mem_offset),0,fbdev.fb_fix.smem_len);
//    fb_drawpixel(&fbdev,512,384,0x00ff0000);
//    fb_drawpixel(&fbdev,512,385,0x00ff0000);
//    fb_drawpixel(&fbdev,513,384,0x00ff0000);
//    fb_drawpixel(&fbdev,513,385,0x00ff0000);
    //画垂直方向的直线
//    fb_drawvline(&fbdev,512,384,0x0000ff00);
//    fb_drawwline(&fbdev,512,384,0x0000ff00);
//    fb_drawfpage(&fbdev,100,384,0x0000ff00);
    fb_drawxline(&fbdev,100,100,0x00ff0000);
    fb_close(&fbdev);
    getchar();
}
Example #2
0
void main(void)
{
    FBDEV fbdev;
    memset(&fbdev,0,sizeof(FBDEV));
    strcpy(fbdev.dev,"/dev/fb0");
    if (fb_open(&fbdev) == FALSE) 
    {
        printf("open frame buffer error\n");
        return ;
    }
    fb_memset((void *)(fbdev.fb_mem + fbdev.fb_mem_offset),0,fbdev.fb_fix.smem_len);
    //画点得函数:
    fb_drawpixel(&fbdev,512,384,0x00ff0000);
    fb_drawpixel(&fbdev,513,384,0x00ff0000);
    fb_drawpixel(&fbdev,512,385,0x00ff0000);
    fb_drawpixel(&fbdev,513,385,0x00ff0000);
    //画直线得函数:
    //fb_drawline(&fbdev,200,100,0x0000ff00);
    fb_line(&fbdev,100,200,300,500,0x000000ff);
    fb_circle(&fbdev,512,348,50,0x00ff0000);
    fb_close(&fbdev);
    getchar();
}
Example #3
0
File: fb.c Project: CurlyMoo/Splash
void fb_init(void) {

	unsigned long page_mask;
    struct vt_stat vts;
	
	fb_setvt();
	
	if(ioctl(tty, VT_GETSTATE, &vts) == -1) {
		logprintf(LOG_ERR, "ioctl VT_GETSTATE: %s (not a linux console?)\n", strerror(errno));
		exit(EXIT_FAILURE);
    }
	
	fbfd = open(DEFAULT_FB, O_RDWR);
	if (fbfd == -1) {
        logprintf(LOG_ERR, "cannot open framebuffer device");
        exit(EXIT_FAILURE);
    }	

    if(ioctl(fbfd, FBIOGET_VSCREENINFO, &ovinfo) == -1) {
        logprintf(LOG_ERR, "cannnot read variable screen information");
        exit(EXIT_FAILURE);
    }

    if(ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo) == -1) {
        logprintf(LOG_ERR, "cannot read fixed screen information");
        exit(EXIT_FAILURE);
    }		
	
	if(ovinfo.bits_per_pixel == 8 || finfo.visual == FB_VISUAL_DIRECTCOLOR) {
		if(ioctl(fbfd, FBIOGETCMAP, &ocmap) == -1) {
			logprintf(LOG_ERR, "ioctl FBIOGETCMAP");
			exit(EXIT_FAILURE);
		}
    }
	
	if(ioctl(tty, KDGETMODE, &kd_mode) == -1) {
		logprintf(LOG_ERR, "ioctl KDGETMODE");
		exit(EXIT_FAILURE);
	}
    if(ioctl(tty, VT_GETMODE, &vt_omode) == -1) {
		logprintf(LOG_ERR, "ioctl VT_GETMODE");
		exit(EXIT_FAILURE);
    }

    tcgetattr(tty, &term);

    if(ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo) == -1) {
		logprintf(LOG_ERR,"ioctl FBIOGET_VSCREENINFO");
		exit(EXIT_FAILURE);
    }
 
    if(ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo) == -1) {
		logprintf(LOG_ERR, "ioctl FBIOGET_FSCREENINFO");
		exit(EXIT_FAILURE);
    }

    screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;

	page_mask = (unsigned long)getpagesize()-1;
	fb_mem_offset = (unsigned long)(finfo.smem_start) & page_mask;
    fbp = (char *)mmap(0, finfo.smem_len+fb_mem_offset, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);

	if((int)fbp == -1) {
        logprintf(LOG_ERR, "failed to map framebuffer device to memory");
        exit(EXIT_FAILURE);
    }
 
	if(ioctl(tty, KDSETMODE, KD_GRAPHICS) == -1) {
		logprintf(LOG_ERR, "ioctl KDSETMODE");
		fb_cleanup();
		exit(EXIT_FAILURE);
    }

	fb_memset(fbp+fb_mem_offset, 0, finfo.line_length * vinfo.yres);
	
	fb_init_zmap();
}
Example #4
0
File: fb.c Project: CurlyMoo/Splash
void fb_clear_screen(void) {
	fb_memset(fbp, 0, finfo.line_length * vinfo.yres);
}
Example #5
0
File: fb.c Project: CurlyMoo/Splash
void fb_clear_mem(void) {
	fb_memset(fbp, 0, finfo.smem_len);
}
Example #6
0
void fb_drawhline(PFBDEV pFbdev,int x,int y,u32_t color)
{
    int i;
    for (i = 0; i < pFbdev->fb_var.xres; i++) 
    {
        fb_drawpixel(pFbdev,i,y,color);
    }
    return;
int fb_line(int x1,int y1,int x2,int y2,u32_t color)
{

    int dx=x2-x1;
    int dy=y2-y1;
    int p=0;
    int inc=((dx*dy<0)?-1:1);
    if(abs(dx)>abs(dy))
    {
       if(dx<0)
        {
           swap(&x1,&x2);
           swap(&y1,&y2);
           dx=-dx;
           dy=-dy;
        }
        dy=abs(dy);
        p=2*dy-dx;
        while(x1<=x2)
        {
            fb_one_pixel(x1,y1,color);
            x1++;
            if(p<0)
            {
              p+=2*dy;
            }
            else
            {                                                                                y1+=inc;                                                                      p+=2*(dy-dx);
            }                                                                          }                                                                            }
       else                                                                           {                                                                                 if(dy<0)
            {                                                                                swap(&x1,&x2);                                                                swap(&y1,&y2);
               dx=-dx;                                                                       dy=-dy;
            }                                                                             dx=abs(dx);                                                                   p=2*dx-dy;
            while(y1<=y2)                                                                {                                                                               fb_one_pixel(x1,y1,color);
             y1++;
             if(p<0)
             {
              p+=2*dx;
             }
             else
             {
              x1+=inc;
              p+=2*(dx-dy);
             }
                                                                                            }                                                               }
                                                                                                     return 0;




int main(void)
{
    FBDEV fbdev;
    memset(&fbdev,0,sizeof(FBDEV));
    strcpy(fbdev.dev,"/dev/fb0");
    if (fb_open(&fbdev)==FALSE) 
    {
        printf("open frame buffer error\n");
        return;
    }
    fb_memset((void *)(fbdev.fb_mem + fbdev.fb_mem_offset),0,fbdev.fb_fix.smem_len);
    //画点
    fb_drawpixel(&fbdev,512,384,0x00FF0000);
    fb_drawpixel(&fbdev,513,384,0x00FF0000);
    fb_drawpixel(&fbdev,512,385,0x00FF0000);
    fb_drawpixel(&fbdev,513,385,0x00FF0000);
    //画垂直线
    fb_drawvline(&fbdev,511,380,0x0000ff00);
    fb_drawhline(&fbdev,380,200,0x000000ff);
    fb_close(&fbdev);
        getchar();
}