Problem of programmation

"Bui Sy Phong" <[email protected]> Tue, 22 Aug 2006 11:29:01 +0200
Newsgroups gmane.linux.fbdev.user
Message-ID <[email protected]>
Hi everybody,

I'm a newbie on Framebuffer programmation and newbie also on this mailing
list.

Actually, i'm writing a little program witch will display a full-screen
windows in bleu.
But when i execute this program, my windows is always hiden by the console
or X11's windows. I dont understant how X11 communicates with Framebuffer so
i cannot do the same thing to display my windows in first plane.

This is my program in C and on Linux :

#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include <stropts.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <string.h>

    int main()
    {

    unsigned short int pcolor = 0x2858;
        int fbfd = 0;

        struct fb_var_screeninfo vinfo;
        struct fb_fix_screeninfo finfo;

    long int screensize = 0;
        char *fbp = 0;
        int x = 0, y = 0;
        long int location = 0;


        // Open the file for reading and writing
        fbfd = open("/dev/fb0", O_RDWR);
        if (!fbfd) {
            printf("Error: cannot open framebuffer device.\n");
            exit(1);
        }
        printf("The framebuffer device was opened successfully.\n");


        // Get fixed screen information
        if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) {
            printf("Error reading fixed information.\n");
            exit(2);
        }

        // Get variable screen information
        if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
            printf("Error reading variable information.\n");
            exit(3);
        }

        printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres,
vinfo.bits_per_pixel);

        // Figure out the size of the screen in bytes
        screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;

        // Map the device to memory

        fbp = (char *)mmap(0, finfo.smem_len, PROT_READ | PROT_WRITE ,
MAP_SHARED,
                           fbfd, 0);

        if ((int)fbp == -1) {
            printf("Error: failed to map framebuffer device to memory.\n");
            exit(4);
        }
        printf("The framebuffer device was mapped to memory
successfully.\n");

    x = 0; y = 0;       // Where we are going to put the pixel

        // Figure out where in memory to put the pixel

    for (y = 0; y < vinfo.yres; y++)
            for (x = 0; x < vinfo.xres; x++) {

                location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +
                           (y+vinfo.yoffset) * finfo.line_length;


    // Color conversion for 16 bit and 32 bit

    if ( vinfo.bits_per_pixel == 16 )
    {

    *((unsigned short int *)(fbp + location)) = pcolor;
    }
    else // 32 bit
    {
       *(fbp + location) = (pcolor & 0x001F)<<3;       // Blue
       *(fbp + location + 1) = (pcolor & 0x07E0)>>3;     // Green
       *(fbp + location + 2) = (pcolor & 0xF800)>>8;    // Red
       *(fbp + location + 3) = 0;      // No transparency
    }
    }
    munmap(fbp, screensize);
        close(fbfd);
        return 0;
    }

If someone can help me to fix this problem (means display my windows at the
first plane), it will be wanderful for me.

Thanks for yours helpful and sorry for my bad english.

Bui Sy Phong.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Linux-fbdev-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-fbdev-users