Python from C/SDL

Gib Bogle bogle at ihug.co.nz
Sat Sep 7 20:40:55 EDT 2002


Mike,

Thanks very much for such a detailed response.  My programming skills
are a bit out of date (little OO experience, no C++, no Python) so what
is required here might be a bit of a stretch.  I have sent a message to
Warren Delano (pymol author) to see if he is interested in giving some
assistance.  If not I'll probably put this on the back burner until I
have the time to teach myself the basics of Python.  I have been aware
of it for a couple of years now, and if I was 20 years younger ...

regards
Gib

"Mike C. Fletcher" wrote:
> 
> I'll just deal with the OpenGL stuff.  Basically, PyOpenGL-based apps
> should be able to work like this:
> 
> c draw():
>         context = new MyContext;
>         context.set_current();
>         err = Py*_Call*( size );
> 
>         python:
>                 def render( dimensions ):
>                         do_your_rendering_here()
>                         return
> 
> c:
>         swap_buffers();
>         context.unset_current();
> 
> So, you'd likely need to find, somewhere in pymol, a function to call
> which is _after_ the Python context setup and set_current() which you
> can call.  Depending on the architecture of pymol, that's likely to
> require at least sub-classing, and possibly some re-writing, as most
> rendering libs go out of their way to be sure they're using the "right"
> context before any attempt to render, and most apps assume they'll be
> using a context they set up.  You'll likely need to pass size of the
> window from your code, as some renderers assume they know the current
> size of the rendering context (which they won't if they aren't getting
> their resize events).
> 
> For example, in OpenGLContext, you'd subclass a Context and override
> setCurrent and unsetCurrent to do nothing (or more professionally, you'd
> create C "extending" functions that set the appropriate context for your
> app, which would allow the Python system to have its own contexts
> alongside yours if you wished).  In other frameworks those calls aren't
> actually split out into easily overridable methods (it's only required
> if you're targetting multiple GUI libs), so you might have to re-write
> anywhere you see "set current" methods called.    Would suggest
> contacting the creator of PyMol for suggestions where to apply your lever.
> 
> For a "full" job of creating a PyOpenGL embedded system, you'd also
> provide initialisation/creation functions to allow Python code to create
> a context within your app (e.g. setting display modes).
> 
> There are similar questions asked once in a while, but not particularly
> with pymol AFAIK.  "How do I embed PyOpenGL apps" is the basic template.
>   Suppose I should create a tutorial for it, but I've never done it
> directly myself (though conceptually every context in OpenGLContext is
> "embedded" in the GUI library it uses, since those are all C libs, it's
> just that I do the "calling into Python" from the libs own Python wrappers).
> 
> HTH,
> Mike
> BTW: out of town in a few minutes, so won't be available to clarify
> anything 'til Monday, sorry.
> 
> Chris Gonnerman wrote:
> > ----- Original Message -----
> > From: "Gib Bogle" <bogle at ihug.co.nz>
> >
> >
> >>Hi,
> >>
> >>I am a complete beginner with Python.  My interest in it is focussed on
> >>a great piece of open-source software called pymol, a system for
> >>visualization of molecules that uses Python and OpenGL.  I'd like to get
> >>access to pymol's graphical functions from my own program, which is
> >>built from C, SDL and OpenGL.
> >
> ...
> >>I will not want to use the GUI at all.  SDL would
> >>create the surface(s), and handle the buffer swapping.  My goal is to be
> >>able to send a request to the pymol API asking for a frustum view to be
> >>rendered on the provided surface.
> >>
> >>Sorry if my question is one that gets asked and answered frequently.  If
> >>there is a place where this has been dealt with please direct me.
> >
> >
> > Never heard this one before...
> >
> > Good luck!
> >
> >
> > Chris Gonnerman -- chris.gonnerman at newcenturycomputers.net
> > http://newcenturycomputers.net
> >
> >
> 
> --
> _______________________________________
>    Mike C. Fletcher
>    Designer, VR Plumber, Coder
>    http://members.rogers.com/mcfletch/

-- 
--------------------------------------------
Gib Bogle              bogle at ihug.co.nz
1/44 Arthur St         Tel: (64-9) 525-6878
Ellerslie, N.Z.        Fax: (64-9) 525-6878
--------------------------------------------



More information about the Python-list mailing list