Sunday 15 April 2012

c++ - How to draw the graph in framebuffer using c language..? -


I'm new so linux framebuffer anyone guide me to draw graph line framebuffer. And I have the code to draw the graph in Turbo C but now in Linux. So please help me out

Thank you, Rahul

Use / dev (eg. / dev / fb0 ) in to the correct file, then map it into memory Manpages for these syscalls If you do not know how to use them, then

Then there are some in and some structures and constants; Linux / FB J & gt; . Like many kernel headers, you can learn a lot by just browsing the file.

Particularly interesting is with ioctl FBIOGET_VSCREENINFO struct fb_var_screeninfo . Note that there are xres , yres (resolution) and bits_per_pixel in it. Then there's the FBIOGET_FSCREENINFO and struct fb_fix_screeninfo which type and line_length .

For more information or so (x, y) is to be on a pixel mmap_base_address + x * bits_per_pixel / 8 + y * line_length . The exact form of pixels will depend on the structures you receive by ioctl;

It's been a while since I worked with it, so I'm a little blurred on more information ..

Here's a quick and dirty code sample just described To do this how it has been done ... I have not tested it.

  #include & lt; Sys / types.h & gt; # Include & lt; Sys / ioctl.h & gt; # Include & lt; Sys / mman.h & gt; #include & lt; Linux / fb.h & gt; # Include & lt; Unistd.h & gt; # Include & lt; Fcntl.h & gt; # Include & lt; Stdio.h & gt; Int main () {struct fb_var_screeninfo screen_info; Struct fb_fix_screeninfo fixed_info; Char * buffer = null; Size_t buflen; Int fd = -1; Int r = 1; FD = Open ("/ dev / fb0", O_RDWR); If (FD & gt; = 0) {if (ioctl (FD, FBIOGET_VSCREENINFO, & amp ;! screen_info) & amp; & amp ;! ioctl (FD,; fixed_info) FBIOGET_FSCREENINFO, & amp) {buflen = screen_info.yres_virtual * Fixed_info.line_length; Buffer = MMAP (faucet, buffron, PROT_READ | PROT_WRITE, MAP_SHARED, FD, 0); If (buffer! = MAP_FAILED) {/ * * TODO: here is something interesting * "buffer" is now pointing to the screen pixel * can be on each individual pixel: buffer + x * screen_info.bits_per_pixel / 8 * + y * Fixed_info.line_length * You can then type pixels at that place like * / R = 0; / * Indicate success * /} other {properties ("mmip"); }} And {property ("ioctl"); }} And {false ("open"); } / * * Clear * / if (buffer & buffer! = Mp_filld) munmap (buffer, buffron); If (FD> = 0) closed (FD); Return r; }  

No comments:

Post a Comment