이것은 사격형 그리고.....
하지만 실행해보면 fail 난다. 원인은 아직 찾고 있는 중이다.
http://blog.naver.com/PostView.nhn?blogId=buniel1&logNo=60065575973&categoryNo=1&parentCategoryNo=1&viewDate=¤tPage=1&postListTopCurrentPage=&isAfterWrite=true&userTopListOpen=true&userTopListCount=20&userTopListManageOpen=false&userTopListCurrentPage=1
하지만 실행해보면 fail 난다. 원인은 아직 찾고 있는 중이다.
http://blog.naver.com/PostView.nhn?blogId=buniel1&logNo=60065575973&categoryNo=1&parentCategoryNo=1&viewDate=¤tPage=1&postListTopCurrentPage=&isAfterWrite=true&userTopListOpen=true&userTopListCount=20&userTopListManageOpen=false&userTopListCurrentPage=1
#include <stdio.h>
#include <stdlib.h> /* for exit */
#include <unistd.h> /* for open/close .. */
#include <fcntl.h> /* for O_RDWR */
#include <sys/ioctl.h> /* for ioctl */
#include <sys/mman.h> /* for mmap */
#include <linux/fb.h> /* for fb_var_screeninfo, FBIOGET_VSCREENINFO */
#define FBDEVFILE "/dev/fb0" /* 자신의 모드에 맞게*/
typedef unsigned char ubyte;
void setbox(struct fb_var_screeninfo *fbvar, unsigned char *pfbdata, int color ,
int x, int y, int big);
void setpixel(struct fb_var_screeninfo* , unsigned char *pfbdata, int color, int x, int y);
unsigned char makepixel(ubyte r, ubyte g, ubyte b);
int main()
{
int fbfd = 0;
int ret = 0;
struct fb_var_screeninfo fbvar;
unsigned char *pfbdata;
long int screensize = 0;
fbfd = open(FBDEVFILE, O_RDWR);
if(fbfd < 0 )
{
perror("fbdev open");
exit(1);
}
ret = ioctl(fbfd, FBIOGET_VSCREENINFO, &fbvar);
if( ret <0)
{
perror("fbdev ioctl");
exit(1);
}
printf("bits_per_pixel %x\n", fbvar.bits_per_pixel);
/* Figure out the size of the screen in bytes */
screensize = fbvar.xres * fbvar.yres * fbvar.bits_per_pixel / 8;
printf("screensize %x\n", screensize);
pfbdata = (unsigned char *)mmap(0, screensize, PROT_READ|PROT_WRITE, MAP_SHARED,
fbfd, 0);
if((unsigned)pfbdata == (unsigned)-1)
{
perror("fbdev mmap");
exit(1);
}
else
printf("pfbdata %x\n", pfbdata);
setbox(&fbvar, pfbdata, 0,200, 200, 100);
munmap(pfbdata, screensize);
close(fbfd);
exit(0);
return 0;
}
unsigned char makepixel(ubyte r, ubyte g, ubyte b)
{
return (unsigned char)(((r>>3)<<11)|((g>>2)<<5)|(b>>3));
}
void setpixel(struct fb_var_screeninfo *fbvar, unsigned char *pfbdata, int color, int xpos, int ypos)
{
unsigned char *setpixel_fbdata = pfbdata ;
struct fb_var_screeninfo *setpixel_fbvar = fbvar;
int offset;
unsigned char pixel;
offset = ypos*(*setpixel_fbvar).xres+xpos;
pixel = makepixel(0, 255, 0);
*(setpixel_fbdata+offset) = pixel; /* draw pixel */
}
void setbox(struct fb_var_screeninfo *fbvar, unsigned char *pfbdata, int color, int xpos, int ypos, int k)
{
unsigned char *setdot_fbdata = pfbdata;
struct fb_var_screeninfo *setdot_fbvar = fbvar;
int offset;
unsigned char pixel;
int x, y;
for(x = 0; x < k ; x++)
{
for(y = 0; y < k; y++)
{
offset = (ypos+y)*(*setdot_fbvar).xres+(xpos+x);
pixel = makepixel(11,111,217);
*(setdot_fbdata+offset) = pixel; /* draw pixel */
}
}
}
'L I N U X' 카테고리의 다른 글
[PPT] embedded linux 관련 PPT 자료 모음 (0) | 2012.03.15 |
---|---|
리눅스 그래픽 프레임 버퍼 (0) | 2012.03.15 |
LCD에 점 찍기 (0) | 2012.03.15 |
Arm embedded linux porting (0) | 2012.03.09 |
Makefile ?? (0) | 2012.02.28 |