先列出一些比较重要资源:
经 tar -zvxf microwindows-0.89.tar.gz
在 microwin-0.89/src/ 下 执行xconfigure进行简单的编译配置
进入图形配置界面后,根据具体软硬件情况设置如下:
Compiling options -> Optimize
Platform -> Linux (native)
Platform -> Linux (native) -> Options -> Screen driver -> X11 (点击options 设定分辨率)
Platform -> Linux (native) -> Options -> Mouse driver -> GPM mouse (确定你需要鼠标吗)
Platform -> Linux (native) -> Options -> Keyboard driver -> TTY (键盘)
I/O -> Have File I/O
I/O -> Have bmp support
I/O -> Have jpeg support
I/O -> Have freetype support (truetype fonts) (我的linux是英文的,不需要)
Libraries to compile -> NanoX (我们用的是 NanoX, 所以 Microwindows 不用选)
Libraries to compile -> Libraries to Shared libs (如果要移值"porting"到嵌入式设备的话,需要这个)
Libraries to compile -> NanoX -> Options -> Enable shared mem support
Libraries to compile -> NanoX -> Options -> Compile demos (还是把demo编译进入吧,里面有个小游戏.)
接下来 microwin-0.89/src/ 执行 make 进行编译 然后来个make install 吧,把没用的东西都去掉.
最后将nano-x server 启动起来,在microwin-0.89/src/ bin 下 执行 nano-X & sleep 1
然后把窗口管理器启动起来:,在microwin-0.89/src/ bin 下 执行 nanowm & sleep 1
最后 ./demo & 一下 看看效果吧. ls /bin下面的demo,有很多,都试试吧,不知道为什么,程序相应有些慢.
还是给一段代码吧,官方网站上有的:
#include <stdio.h>
#include <microwin/nano-X.h>
GR_WINDOW_ID wid;
GR_GC_ID gc;
void event_handler (GR_EVENT *event);
int main (void)
{
if (GrOpen() < 0) {
fprintf (stderr, "GrOpen failed");
exit (1);
}
gc = GrNewGC();
GrSetGCForeground (gc, 0xFF0000);
wid = GrNewWindowEx(GR_WM_PROPS_APPFRAME |
GR_WM_PROPS_CAPTION |
GR_WM_PROPS_CLOSEBOX,
"jollen.org",
GR_ROOT_WINDOW_ID,
0, 0, 200, 200, 0xFFFFFF);
GrSelectEvents(wid, GR_EVENT_MASK_CLOSE_REQ | GR_EVENT_MASK_EXPOSURE);
GrMapWindow(wid);
GrMainLoop(event_handler);
}
void event_handler (GR_EVENT *event)
{
switch (event->type)
{
case GR_EVENT_TYPE_EXPOSURE:
GrText(wid, gc, 50, 50, "Hello World", -1, GR_TFASCII);
break;
case GR_EVENT_TYPE_CLOSE_REQ:
GrClose();
exit (0);
default: break;
}
}
编译一下: gcc -o hello hello.c -l nano-X