我正在按照文档教程,使用屏幕窗口系统为带有 QNX CAR 2.0 的 Neutrino 6.5.0 编写 C++ (qcc) 的 GUI。没有生成可见的输出,并且/dev/screen/{pid}/win-{n}/win-{n}
具有status = WIN_STATUS_INVISIBLE
.
(使用{n}
和{pid}
表示运行时/动态变量值的替换)
我已经尝试按照教程进行操作,但结果相同。特别是window_group_name
(mainwindowgroup
或veryuniquewgn
) 的值没有区别;前者是本教程建议的值,后者是我自己的值。
我已经构建了一个 MCVE:
#include <cstdlib> // for EXIT_ constants
#include <stdio.h> // for printf(), getchar()
#include <process.h> // for getpid()
#include <screen.h>
#define screen_err(desc) \
if(screen_res != 0) { \
printf("ERR screen: failed to %s\n", desc); \
return EXIT_FAILURE; \
}
int main_withwindow(screen_context_t scr_ctx, screen_window_t scr_win) {
static const char *window_group_name = "veryuniquewgn";
// Dummy to pass as ptr to enum values
int prop;
int screen_res;
screen_res = screen_create_window_group(scr_win, window_group_name);
screen_err("create window group");
prop = SCREEN_FORMAT_RGBA8888;
screen_res = screen_set_window_property_iv(scr_win, SCREEN_PROPERTY_FORMAT,
&prop);
screen_err("set window property: format -> RGBA");
prop = SCREEN_USAGE_NATIVE;
screen_res = screen_set_window_property_iv(scr_win, SCREEN_PROPERTY_USAGE,
&prop);
screen_err("set window property: usage -> native");
screen_res = screen_create_window_buffers(scr_win, 1);
screen_err("create window buffers");
int win_buf_rect[4] = { 0, 0 };
screen_res = screen_get_window_property_iv(scr_win,
SCREEN_PROPERTY_BUFFER_SIZE, win_buf_rect + 2);
screen_err("get window property: buffer_size");
// Array type to easily support multi-buffering in future
screen_buffer_t scr_buf[1];
screen_res = screen_get_window_property_pv(scr_win,
SCREEN_PROPERTY_RENDER_BUFFERS, (void **)scr_buf);
screen_err("get window property: render_buffers");
int bg[] = { SCREEN_BLIT_COLOR, 0xffffff00, SCREEN_BLIT_END };
screen_res = screen_fill(scr_ctx, scr_buf[0], bg);
screen_err("fill buffer with yellow");
screen_res = screen_post_window(scr_win, scr_buf[0], 1, win_buf_rect, 0);
screen_err("post window");
prop = 255;
screen_res = screen_set_window_property_iv(scr_win,
SCREEN_PROPERTY_ZORDER, &prop);
screen_err("set window property: zorder -> 255");
prop = 1;
screen_res = screen_set_window_property_iv(scr_win,
SCREEN_PROPERTY_VISIBLE, &prop);
screen_err("set window property: visible -> true");
screen_res = screen_flush_context(scr_ctx, SCREEN_WAIT_IDLE);
screen_err("flush context to idle");
getchar();
return EXIT_SUCCESS;
}
int main_withcontext(screen_context_t scr_ctx) {
screen_window_t scr_win;
int ret;
int screen_res;
screen_res = screen_create_window(&scr_win, scr_ctx);
screen_err("create window");
ret = main_withwindow(scr_ctx, scr_win);
screen_res = screen_destroy_window(scr_win);
screen_err("destroy window");
return ret;
}
int main(int argc, char *argv[]) {
printf("%d\n", getpid());
screen_context_t scr_ctx;
int ret;
int screen_res;
screen_res = screen_create_context(&scr_ctx, SCREEN_APPLICATION_CONTEXT);
screen_err("create context");
ret = main_withcontext(scr_ctx);
screen_res = screen_destroy_context(scr_ctx);
screen_err("destroy context");
return ret;
}
由于使用了screen_err()
定义,没有输出(除了printf
pid 的第一个输出)表明screen_...()
调用没有错误。这正是我运行它时所看到的。
在 中/dev/screen/{pid}
,我看到了一个ctx-{n}/ctx-{n}
和一个win-{n}/win-{n}
文件,正如预期的那样。前者不是人类可读的,但后者,以及它与工作 nto 6.5.0 + CAR 2.0 + libscreen 应用程序中的对应物的差异,产生了一些见解。
工作应用程序是一个 HMI,我没有它的源代码,并/etc/ro
以 root 身份启动,而我的应用程序是从 ksh 启动的,以 root 身份登录。
它们都是 98 行文件,所以我制作了一个差异 -win-{n}
左侧是工作应用程序,右侧是我的 - 不包括指标:(垂直比较超过 39 个字符的行)
autonomous = 0 autonomous = 1
status = WIN_STATUS_FULLSCREEN status = WIN_STATUS_INVISIBLE
id string = DPY_HMI id string =
insert id = 1 insert id = 3
reclip = 0 reclip = 1
flags = WIN_FLAG_VISIBLE WIN_FLAG_FLOATING
flags = WIN_FLAG_FLOATING
usage = SCREEN_USAGE_OPENGL_ES2 usage = SCREEN_USAGE_NATIVE
order = 240 order = 0
regions = (0,0;800,480) regions = (none)
clipped source viewport = (0,0;800,480 800x480)
clipped source viewport = (0,0;0,0 0x0)
clipped destination rectangle = (0,0;800,480 800x480)
clipped destination rectangle = (0,0;0,0 0x0)
transform = [[1 0 0],[0 1 0],[0 0 1]] transform = [[0 0 0],[0 0 0],[0 0 0]]
在这些差异usage
中,只有一个具有我期望的值,考虑到它反映了相关调用的参数screen_set_window_property_iv(...)
。对于所有其他人,尤其是regions
和flags
,我不明白为什么它们的值与工作应用程序的值不同。
目标显示器的原始分辨率为 800x480。