STS*_*STS 5 c linux framebuffer doublebuffered
我正在尝试为 Linux 创建一个直接写入帧缓冲区 /dev/fb0 的应用程序。为了使其成为双缓冲,我尝试使虚拟屏幕成为屏幕大小的两倍。这是我写的程序:
struct fb_var_screeninfo screeninfo_var;
struct fb_fix_screeninfo screeninfo_fixed;
unsigned int* screenbuffer;
void gfx_init()
{
fb0 = open("/dev/fb0", O_RDWR);
if(fb0 == 0)
error("Could not open framebuffer located in /dev/fb0!");
if (ioctl(fb0, FBIOGET_FSCREENINFO, &screeninfo_fixed) == -1)
error("Could not retrive fixed screen info!");
if (ioctl(fb0, FBIOGET_VSCREENINFO, &screeninfo_var) == -1)
error("Could not retrive variable screen info!");
screeninfo_var.xres_virtual = screeninfo_var.xres;
screeninfo_var.yres_virtual = screeninfo_var.yres * 2;
screeninfo_var.width = screeninfo_var.xres;
screeninfo_var.height = screeninfo_var.yres;
screeninfo_var.xoffset = 0;
screeninfo_var.yoffset = 0;
if (ioctl(fb0, FBIOPUT_VSCREENINFO, &screeninfo_var) == -1)
error("Could not set variable screen info!");
info("Detected monitor of %ix%i pixels using %i bit colors.",screeninfo_var.xres, screeninfo_var.yres, screeninfo_var.bits_per_pixel);
screenbuffersize = screeninfo_var.xres_virtual * screeninfo_var.yres_virtual * screeninfo_var.bits_per_pixel/8;
screenbuffer = (unsigned int *)mmap(0, screenbuffersize, PROT_READ | PROT_WRITE, MAP_SHARED, fb0, 0);
if( (long)screenbuffer == 0 || (long)screenbuffer == -1 )
error("Failed to map framebuffer to device memory!");
}
Run Code Online (Sandbox Code Playgroud)
程序失败,ioctl(fb0, FBIOPUT_VSCREENINFO, &screeninfo_var)报告错误参数无效。当删除该行时,screeninfo_var.yres_virtual = screeninfo_var.yres * 2;它运行良好(但没有双缓冲)。
有人看到我在这里做错了什么吗?
这是一个常见问题,是由视频驱动程序的限制引起的。例如,Intel 的 810 芯片组仅允许 640x480 分辨率,而 Broadcom 则将宽度限制为不超过 1200 ( http://www.raspberrypi.org/phpBB3/viewtopic.php?f=66&t=29968 )。
您在这里无能为力,除非您更改驱动程序或显卡本身(如果可能)。
编辑:如果您使用的是 PC,请尝试使用 驱动程序vesafb,而不是英特尔的驱动程序。
这里有一个提示:http://www.mail-archive.com/debian-rusian@lists.debian.org/msg27725.html
| 归档时间: |
|
| 查看次数: |
3156 次 |
| 最近记录: |