#include <stdlib.h>
#include <stdio.h>
#include <gf/gf.h>
int main(int argc, char *argv[]) {
printf("Starting Graphics test\n");
gf_dev_t gdev;
gf_dev_info_t gdev_info;
gf_display_t display;
gf_display_info_t display_info;
gf_layer_t layer;
gf_surface_t surface;
gf_context_t context;
if (gf_dev_attach(&gdev, GF_DEVICE_INDEX(0), &gdev_info) != GF_ERR_OK) {
printf("gf_dev_attach() failed\n");
return (-1);
}
printf("device attached\n");
if (gf_display_attach(&display, gdev, 0, &display_info) != GF_ERR_OK) {
printf("gf_display_attach() failed\n");
}
printf("display attached\n");
if (display != NULL) {
unsigned main_layer_index = display_info.main_layer_index;
if (gf_layer_attach(&layer, display, main_layer_index,
GF_LAYER_ATTACH_PASSIVE) != GF_ERR_OK) {
printf("gf_layer_attach() failed\n");
return EXIT_SUCCESS;
}
} else {
printf("Display is null \n");
return EXIT_SUCCESS;
}
printf("Layer attached \n");
//gf_surface_t surface;
int width = display_info.xres;
int height = display_info.yres;
int create_surface_result = gf_surface_create_layer(&surface, &layer, 1, 0,
width, height, display_info.format, NULL, 0);
if (create_surface_result == GF_ERR_OK) {
gf_layer_set_surfaces(layer, &surface, 1);
printf("attach to the surface , Done\n");
} else {
printf("attach to the surface , failed. Error: %d\n",
create_surface_result);
return EXIT_SUCCESS;
}
if (gf_context_create(&context) != GF_ERR_OK) {
fprintf(stderr, "gf_context_create failed\n");
}
if (gf_context_set_surface(context, surface) != GF_ERR_OK) {
fprintf(stderr, "gf_context_set_surface failed\n");
}
gf_draw_begin(context);
gf_context_set_fgcolor(context, 0xFFFFFF);
gf_draw_rect(context, 10, 10, 50, 50);
gf_context_set_fgcolor(context, 0x000000);
gf_draw_rect(context, 20, 20, 40, 40);
gf_draw_flush(context);
gf_draw_end(context);
gf_dev_detach(gdev);
return EXIT_SUCCESS;
}
QNX-Momentics.rar_QNX Momentics_qnx_qnx gf
版权申诉
5星 · 超过95%的资源 176 浏览量
2022-09-19
21:45:20
上传
评论
收藏 830B RAR 举报
weixin_42653672
- 粉丝: 93
- 资源: 1万+
评论1