[GRASS-dev] nviz python thoughts

Glynn Clements glynn at gclements.plus.com
Sun Dec 21 13:14:34 EST 2008


William Kyngesburye wrote:

> > 1. It's not trying to draw into a window, but a pixmap or similar
> > off-screen surface, so that the image can be saved into a file,
> > without any of the crud (tooltips, mouse cursor, etc) which you might
> > get from drawing to a window then grabbing it.
> >
> Ah, so it's not really a replacement for the togl-based interactive  
> nviz.  But still renders to a window?  After poking around with stuff  
> below, I wonder if this can work on OSX - I get the impression that a  
> window must be attached to a Mac application somehow, not just a  
> faceless CLI program.

lib/nviz/render.c is a replacement for nviz/src/do_zoom.c. It creates
an off-screen context, e.g. for when you want to save the output to an
image file. It could be used as part of an interactive application
(e.g. nviz2), or as part of a command-line application (e.g. 
nviz_cmd).

> ... oh, AGL seems to be Carbon-based.  Here's something about AGL in  
> Leopard which has some references to non-carbon alternatives:
> 
> http://developer.apple.com/qa/qa2007/qa1523.html

That could be useful for actually getting it to work, but for now we
just need to get render.c to compile on OSX. It doesn't actually need
to work for normal use of nviz2, it just needs to not prevent lib/nviz
from compiling.

> ... Some sample code from Apple - it's about using surface textures,  
> but the window parts could be useful:

Using OpenGL in a window should be taken care of by wxGLCanvas. It's
getting off-screen contexts which we (probably) have to do ourselves.

The situation is the same with the existing nviz; Togl provides a
canvas on which OpenGL can be used. The only glX/wgl/agl functions
outside of Togl are the code in do_zoom.c to get an off-screen context
for saving output to files.

> > 4. I still don't know what the *actual* error is.
> >
> I forgot I could make a subdir ;)
> 
> render.c:204: error: �mac_win� undeclared (first use in this function)
> render.c:204: error: (Each undeclared identifier is reported only once
> render.c:204: error: for each function it appears in.)
> 
> Looks like mac_win is just a placeholder here.  For now, comment this  
> line and have Nviz_make_current_render_window return 0 for OPENGL_AQUA?

In that case, just:

     /* TODO: mac_win */
-    aglMakeCurrent((AGLDrawable) mac_win, rwin->contextId);
+    aglMakeCurrent((AGLDrawable) 0, rwin->contextId);

should get it to compile (which is all we're after for now).

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list