From: Eloy D. <elo...@gm...> - 2007-12-30 11:01:28
|
Hi, I have no experience with this at all, but let me try to help you further a little bit anyways :) Reading through the cairo maillinglist of february (http://lists.cairographics.org/archives/cairo/2007-February.txt.gz ), I think that what you want to do is something like this guy uses in objc: >> 1) fetch the class named NSGraphicsContext >> 2) id nsGC = [NSGraphicsContext graphicsContextWithWindow: >> myNSWindow]; >> 3) cgCtx = [nsGC graphicPort]; >> 4) cairo_nquartz_surface_create_for_cg_context (cgCtx, 200, >> 200, 1); He then complains that the drawing will only show up if he hides and shows the window. I think it's because he's drawing outside of for instance #drawRect, which is the method which is called when it's time for you NSView subclass to start drawing. So translating this to RubyCocoa would be something like: class MyCairoWindow < OSX::NSWindow def cairo_cg_surface(rect) # get the CG context context = OSX::NSGraphicsContext.currentContext.graphicsPort # don't know what the ruby way of calling this function is, so I'll just use the C one cairo_nquartz_surface_create_for_cg_context(context, rect.size.width, rect.size.height, 1) end def drawRect(rect) # you can use `rect` which is passed as a param to draw only parts of the view which are marked `dirty` # or you can get the complete rectangle of the window with: self.bounds # or you can of course just draw on any size you like :) surface = cairo_cg_surface(bounds) # your drawing code end end I have no idea if this would work :) But it's just how I would get started playing with this. You might also want to ask these questions on the (r)cario maillinglists, because the code for this to work, which is the quartz code, is in cairo itself. So I presume people there have experience using it. Good luck! Cheers, Eloy On 30 dec 2007, at 10:37, Jarosia Hope wrote: > Hello :) > > > So I have got rcairo working and rubycocoa working, > > and i've been reading http://cairographics.org/OpenGL/ > > It says to create your cairo surface as a context normally > like > surface = Cairo::ImageSurface.new(width, height) > context = Cairo:: Context.new(surface) > > and then i get to > Copy the cairo-surface into an OpenGL-texture with glTexImage2D(). > Use this texture to map your OpenGL-primitives with. > > Im looking at the CocoaGL example and i dont see a texture? > > something to do with drawRect ... but im not sure how thats getting > called and how I can make it a texture image? > > Any solutions? > > Thanks in advance! > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________ > Rubycocoa-talk mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk |