Re: Cairo context creation problem
Espen S Johnsen <[email protected]> 01 Feb 2008 14:47:15 +0100
| Newsgroups | gmane.lisp.clg.devel |
|---|---|
| Message-ID | <[email protected]> |
"Jianshi Huang" <[email protected]> writes: > The code I used below is a little bit different to the testcairo > examples. In testcairo, cairo context is created within the callback > of expose-event, while in my code, I want to initialize the context > and set it to a global variable, so that I don't need to pass it > around. You could just as well use the with-cairo-context macro to bind a fresh context to special variable when you need to do some rendering. This will ensure that the context is valid every time you use it. On the down side, you'll have to initialize it with the correct attributes on every expose event (or user invocation in an interactive system), but the overhead in doing so would be very small. > But running the program, there were errors told me that The slot > GTK:WINDOW is unbound in the drawing-area object. > > After an hour of debugging, I finally found that if I place > gdk:cairo-create after gtk:widget-show-all, then it works. > > So I'm wondering if it's caused by the initialization sequences in clg. Yes, this has to do with the internal workings of Gtk+ it self. > And do you have any suggestions for using cairo efficiently in clg > (like being a graphics editor within a scrolled-window) I am not sure what exactly you mean by using cairo efficiently. A general advice if rendering speed is of concern, is to do as much polygon simplification and clipping as possible in Lisp. This tends to give some speedup, as Cairo is not as fast as it probably could be. This is at least my experience and may change in the future as more optimization is done in Cairo. -- Espen ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/