C++ OpenGL rendering, wxPython GUI?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tobfon@gmail.com

    #1

    C++ OpenGL rendering, wxPython GUI?

    I'm creating a scientific visualization application with rather high
    demands on performance. I've created a nice rendering engine for it in
    C++/OpenGL and a python interface to the rendering engine. Now I'm
    looking to build a GUI in python with the rendering engine as an
    integrated window. I will most likely use wxPython for the GUI and I
    know it has support for adding an OpenGL canvas.

    After looking around in these groups and others it seems to me that
    most people doing 3D-applications simply opt to use PyOpenGL. Since my
    application uses VBOs, shader programs and similar things this is not
    an option for me.

    My rendering engine currently uses GLUT for window handling, but what I
    want to do is to create the canvas in python for use with wxPython and
    then somehow toss it down to C++ for rendering and avoid using GLUT at
    all. I've yet to come across an example of how this could be done.

    Maybe including wxWidgets in the C++ program and just using the
    wxPython-created canvas ID there will somehow be possible? I'll look
    into that but any help or ideas are most welcome.

    Tobias Forslöw

  • Carl Banks

    #2
    Re: C++ OpenGL rendering, wxPython GUI?

    tobfon@gmail.co m wrote:[color=blue]
    > I'm creating a scientific visualization application with rather high
    > demands on performance. I've created a nice rendering engine for it in
    > C++/OpenGL and a python interface to the rendering engine. Now I'm
    > looking to build a GUI in python with the rendering engine as an
    > integrated window. I will most likely use wxPython for the GUI and I
    > know it has support for adding an OpenGL canvas.
    >
    > After looking around in these groups and others it seems to me that
    > most people doing 3D-applications simply opt to use PyOpenGL. Since my
    > application uses VBOs, shader programs and similar things this is not
    > an option for me.
    >
    > My rendering engine currently uses GLUT for window handling, but what I
    > want to do is to create the canvas in python for use with wxPython and
    > then somehow toss it down to C++ for rendering and avoid using GLUT at
    > all. I've yet to come across an example of how this could be done.
    >
    > Maybe including wxWidgets in the C++ program and just using the
    > wxPython-created canvas ID there will somehow be possible? I'll look
    > into that but any help or ideas are most welcome.[/color]

    You should be able to create and realize the OpenGL canvas (which will
    create an OpenGL context), then make the OpenGL calls from C++ without
    any worries. Realizing (i.e., creating the window for) the canvas
    would create the OpenGL context, and somewhere along the way the
    context gets bound (probably during the canvas's draw callback).

    BTW, though you can't use PyOpenGL for the VBO stuff, it might be
    useful to install it anyways to do high-level stuff (set up flags,
    position the camera, etc.). Calls from C and PyOpenGL can be freely
    mixed.

    I've done similar things in GTK on Linux. I had a gtkglarea canvas,
    PyOpenGL, and my own C extension all making OpenGL calls.



    Carl Banks

    Comment

    • Michael Ekstrand

      #3
      Re: C++ OpenGL rendering, wxPython GUI?

      On 28 Feb 2006 01:14:15 -0800
      tobfon@gmail.co m wrote:[color=blue]
      > I'm creating a scientific visualization application with rather high
      > demands on performance. I've created a nice rendering engine for it in
      > C++/OpenGL and a python interface to the rendering engine. Now I'm
      > looking to build a GUI in python with the rendering engine as an
      > integrated window. I will most likely use wxPython for the GUI and I
      > know it has support for adding an OpenGL canvas.[/color]
      [color=blue]
      > Maybe including wxWidgets in the C++ program and just using the
      > wxPython-created canvas ID there will somehow be possible? I'll look
      > into that but any help or ideas are most welcome.[/color]

      I banged my head on this for quite a while trying to integrate
      OpenInventor and wxPython (and later PyGTKGLext). Basically, the OpenGL
      callers don't need to know what the current canvas is. You tell the
      canvas to activate itself, it tells OpenGL "hey, I'm the current canvas
      now". Then OpenGL commands draw themselves on that canvas. It's really
      much simpler than I initially thought. You just have to make sure that
      there's a Python function somewhere in your begin-rendering sequence
      that activates the canvas before OpenGL calls begin.

      - Michael

      --
      mouse, n: a device for pointing at the xterm in which you want to type.
      -- Fortune

      Comment

      • John M. Gabriele

        #4
        Re: C++ OpenGL rendering, wxPython GUI?

        tobfon@gmail.co m wrote:[color=blue]
        > [snip] Now I'm
        > looking to build a GUI in python with the rendering engine as an
        > integrated window. I will most likely use wxPython for the GUI and I
        > know it has support for adding an OpenGL canvas.
        >
        >[/color]

        You might look into PyFLTK (which I think was just recently
        mentioned on the announce list):

        Python bindings for the FLTK cross-platform GUI toolkit.


        I haven't used it. Just something to maybe look into. I think
        fltk does indeed have support for OpenGL. And I hear it's a
        fast and light toolkit. ;)

        ---John


        --
        (remove zeez if demunging email address)

        Comment

        • Tobias Forslöw

          #5
          Re: C++ OpenGL rendering, wxPython GUI?

          Thanks for all the quick help! After reading your posts about how the
          canvases actually work it was fairly easy to make my C++ code work
          within a wxPython frame.

          Now I only have to decide If I'm actually going to use wxPython or if
          there is a better alternative but there seem to be plenty of threads on
          that subject already.

          Comment

          Working...