简体   繁体   English

如何在Mono中访问Linux Framebuffer(Mono.Cairo / GTK#)?

[英]How to access a Linux Framebuffer in Mono (Mono.Cairo / GTK#)?

I'm starting to write a small application for Linux under the Mono framework, the application will essentially be a small kiosk front-end with very minimal user interaction. 我开始在Mono框架下为Linux编写一个小应用程序,该应用程序本质上是一个小型的kiosk前端,用户交互非常少。 This is to replace a previous version of the same application which was 100% text / console based. 这是为了替换基于100%文本/控制台的同一应用程序的先前版本。

As this will run on a Raspberry Pi, I want to avoid running X and have my application talk to the Framebuffer directly. 由于这将在Raspberry Pi上运行,我想避免运行X并让我的应用程序直接与Framebuffer通信。 I'm set on using the Mono framework and C# as my development language since I know C# very well. 我开始使用Mono框架和C#作为我的开发语言,因为我非常了解C#。 Portability is not an issue in this instance. 在这种情况下,可移植性不是问题。

I'm having some trouble finding appropriate libraries and bindings to let me access the Framebuffer from Mono however. 我在查找适当的库和绑定时遇到了一些麻烦,让我从Mono访问Framebuffer。 The GTK# libraries all bind explicitly to the X11 interface, and in any case, there don't appear to be pre-built GtkFB libraries in Debian Wheezy for the ARM Soft-Float (armel) architecture. GTK#库都明确绑定到X11接口,无论如何,在Debian Wheezy中似乎没有为ARM Soft-Float(armel)架构预构建的GtkFB库。

The Mono.Cairo library exposes a DirectFBSurface type, however the constructor for that surface takes two IntPtr arguments and is not documented so I don't know what should be passed into the constructor to properly initialise the Framebuffer as a Cairo Surface. Mono.Cairo库公开了一个DirectFBSurface类型,但是该表面的构造函数需要两个IntPtr参数并且没有记录,因此我不知道应该将哪些内容传递给构造函数以正确初始化Framebuffer作为Cairo Surface。

Has anyone worked with Mono and C# to talk to the Linux Framebuffer, and if so, can you provide basic examples to initialise and start drawing onto the FB, or point to online documentation to assist? 有没有人使用Mono和C#与Linux Framebuffer交谈,如果有的话,你能提供基本的例子来初始化并开始绘制到FB,还是指向在线文档来提供帮助?

Update 1 更新1

I thought I'd try instantiating the DirectFBSurface with null for both constructor parameters, with the following code: 我以为我会尝试使用null为两个构造函数参数实例化DirectFBSurface,使用以下代码:

public static void Main(string[] args)
{
    // ...
    DirectFBSurface surface = new DirectFBSurface(((IntPtr)null), ((IntPtr)null));
    // ...
}

I expected this to generate an exception indicating that null parameter values were not permitted, however it instead looks as if the DirectFBSurface is either not implemented in Mono.Cairo or is not compiled into the library shipped with Debian Wheezy (armel): 我希望这会产生一个异常,表明不允许使用null参数值,但是它看起来好像DirectFBSurface没有在Mono.Cairo实现,或者没有编译到Debian Wheezy(armel)附带的库中:

Unhandled Exception: System.EntryPointNotFoundException: cairo_directfb_surface_create
  at (wrapper managed-to-native) Cairo.NativeMethods:cairo_directfb_surface_create (intptr,intptr)
  at Cairo.DirectFBSurface..ctor (IntPtr dfb, IntPtr dfb_surface) [0x00000] in <filename unknown>:0
  at Info.Insch.SandBox.TestCairo.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

So it appears that the Mono.Cairo approach probably won't work for my needs, and as noted above, GTK# Framebuffer library doesn't seem to be part of Debian Wheezy for armel. 因此看起来Mono.Cairo方法可能无法满足我的需求,如上所述, GTK# Framebuffer库似乎不是Mono.Cairo的Debian Wheezy的一部分。 Is there another set of libraries which I could use to access the Linux Framebuffer from Mono? 是否有另一组库可用于从Mono访问Linux Framebuffer?

The EntryPointNotFoundException you get, means that the symbol cairo_directfb_surface_create with (IntPtr, IntPtr) as arguments was not found in your libcairo.so.2 library from debian. 你得到的EntryPointNotFoundException意味着在debian的libcairo.so.2库中cairo_directfb_surface_create带有(IntPtr,IntPtr)作为参数的符号cairo_directfb_surface_create This can likely be the case, if directfb was not enabled at compile time in cairo. 如果在cairo的编译时没有启用directfb,情况可能就是这种情况。 You can check for directfb support in cairo by doing: 您可以通过以下方式检查cairo中的directfb支持:

readelf -Ws /usr/lib/libcairo.so.2 | grep directfb

If the result (output) is empty, you lack directfb support. 如果结果(输出)为空,则缺少directfb支持。 In this case you must recompile cairo with --enable-directfb argument passed to the configure script. 在这种情况下,您必须使用传递给configure脚本的--enable-directfb参数重新编译cairo。

I've tested on an openSUSE 12.1 and Fedora 17 box, and both do not seem to ship directfb enabled cairo by default. 我已经在openSUSE 12.1和Fedora 17上测试了盒子,默认情况下两者似乎都没有发布directfb启用的cairo。 I don't know about debian though, you will have to test yourself. 我不知道debian,你将不得不测试自己。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM