[英]Cairo to Cairo-xlib: cairo_xlib_surface_create problems (C)
我正在嘗試從開羅圖像表面切換到xlib表面。 我的代碼在圖像表面上運行良好,但是我認為我沒有正確初始化xlib表面。 它可以編譯,但是會發出警告,並且不再顯示任何內容。
這是我當前用於初始化表面的代碼:
int width, height;
gdk_threads_enter();
gdk_drawable_get_size(pixmap, &width, &height);
gdk_threads_leave();
/*** Create surface to draw on ***/
cairo_surface_t *cst = cairo_xlib_surface_create(gdk_x11_drawable_get_xdisplay(pixmap),
gdk_x11_drawable_get_xid(pixmap),
gdk_x11_visual_get_xvisual(gvis),
width, height);
編譯時收到以下警告:
In function 'do_draw':
evis.c:112:11: warning: passing argument 1 of 'cairo_xlib_surface_create' makes pointer from integer without a cast [enabled by default]
width, height);
^
In file included from evis.c:6:0:
/usr/include/cairo/cairo-xlib.h:49:1: note: expected 'struct Display *' but argument is of type 'int'
cairo_xlib_surface_create (Display *dpy,
^
evis.c:112:11: warning: passing argument 3 of 'cairo_xlib_surface_create' makes pointer from integer without a cast [enabled by default]
width, height);
^
In file included from evis.c:6:0:
/usr/include/cairo/cairo-xlib.h:49:1: note: expected 'struct Visual *' but argument is of type 'int'
cairo_xlib_surface_create (Display *dpy,
^
我很確定這些警告會破壞代碼,並且不確定如何解決它們。 我嘗試將第一個參數和第三個參數分別轉換為(Display *)
和(Visual *)
但這也不起作用。 開始拋出其他警告。
* 編輯1 *試圖理解這一點,但到目前為止我對指針的理解僅限於不存在。 gdk_drawable_get_xdisplay()
返回Display*
但是我的函數正在尋找指向struct Display *
的指針。 2和從Display*
到Display *
的區別是什么?
編譯器認為函數返回int的“通常”原因(正在發生這種情況,因為它抱怨這兩個函數的結果)是因為它找不到該函數的原型,這意味着您在缺少#include。 (盡管我希望在這種情況下還能找到其他警告?)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.