[GtkGLExt] Multiple view problem



Hi all,

  First of all thanks to the original developer and current maintainers of this project. It is really helpful.

  And now the problem: I have multiple GL widgets derived from Gtk::GL::DrawingArea and added into a Paned hierarchy that can resize them. See the attached image. The user interface is dynamic: the views can be split and merged like in Blender. My problem is that only one of the views works, and the funny thing is that it depends on how you resize the main window: if i enlarge it to the left, the right GL widget works, if i shrink it the right, the one in the left works.

  It might be somethin like the last one receiving the resize event is the one that keeps working. The other one doesn react to events or refresh (it is usually black, not like in the image).

  I haven't done much in the widget: it is based in one of the samples:

[code] --------------------------------------------------

GLView::GLView( GLView* aSharedContext )
: Gtk::GL::DrawingArea( aSharedContext->get_gl_config(), aSharedContext->get_gl_context(), true )
{

      // Add events.
    set_events(Gdk::EXPOSURE_MASK|
             Gdk::VISIBILITY_NOTIFY_MASK|
             Gdk::BUTTON_MOTION_MASK|
             Gdk::BUTTON_PRESS_MASK|
             Gdk::BUTTON_RELEASE_MASK|
             //Gdk::POINTER_MOTION_MASK |
             //Gdk::POINTER_MOTION_HINT_MASK |
             Gdk::KEY_PRESS_MASK|
             Gdk::KEY_RELEASE_MASK );
 
}


GLView::GLView()
{
    // Configure OpenGL-capable visual.
    Glib::RefPtr<Gdk::GL::Config> glconfig;

    // Try double-buffered visual
    glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB    |
                                       Gdk::GL::MODE_DEPTH  |
                                       Gdk::GL::MODE_DOUBLE);
    if (!glconfig)
    {
        std::cerr << "*** Cannot find the double-buffered visual.\n"
                  << "*** Trying single-buffered visual.\n";

        // Try single-buffered visual
        glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB   |
                                           Gdk::GL::MODE_DEPTH);
        if (!glconfig)
        {
            std::cerr << "*** Cannot find any OpenGL-capable visual.\n";
            std::exit(1);
        }
    }

    // print frame buffer attributes.
    GLConfigUtil::examine_gl_attrib(glconfig);

    // Set OpenGL-capability to the widget.
    set_gl_capability(glconfig);

      // Add events.
    set_events(Gdk::EXPOSURE_MASK|
             Gdk::VISIBILITY_NOTIFY_MASK|
             Gdk::BUTTON_MOTION_MASK|
             Gdk::BUTTON_PRESS_MASK|
             Gdk::BUTTON_RELEASE_MASK|
             //Gdk::POINTER_MOTION_MASK |
             //Gdk::POINTER_MOTION_HINT_MASK |
             Gdk::KEY_PRESS_MASK|
             Gdk::KEY_RELEASE_MASK );
 
}


GLView::~GLView()
{
    std::cerr<<"GL view destroyed. "<<std::endl;
}


void GLView::on_realize()
{
    // We need to call the base on_realize()
    Gtk::DrawingArea::on_realize();

    // Get GL::Drawable.
    Glib::RefPtr<Gdk::GL::Drawable> gldrawable = get_gl_drawable();

    // GL calls.
    Init();
}


bool GLView::on_configure_event(GdkEventConfigure* event)
{
    // Get GL::Drawable.
    Glib::RefPtr<Gdk::GL::Drawable> gldrawable = get_gl_drawable();

    // GL calls.

    // *** OpenGL BEGIN ***
    if (!gldrawable->gl_begin(get_gl_context()))
        return false;

    glViewport(0, 0, get_width(), get_height());

    Resize();

    gldrawable->gl_end();
    // *** OpenGL END ***

    return true;
}

bool GLView::on_expose_event(GdkEventExpose* event)
{
    // Get GL::Drawable.
    Glib::RefPtr<Gdk::GL::Drawable> gldrawable = get_gl_drawable();

    // GL calls.
    Render();

    // Swap buffers.
    if (gldrawable->is_double_buffered())
        gldrawable->swap_buffers();
    else
        glFlush();

    gldrawable->gl_end();
    // *** OpenGL END ***
   
    return true;
}

bool GLView::on_map_event(GdkEventAny* event)
{
  return true;
}

bool GLView::on_unmap_event(GdkEventAny* event)
{
  return true;
}

bool GLView::on_visibility_notify_event(GdkEventVisibility* event)
{
  return true;
}

[/code] --------------------------------------------------

  Any ideas on what the problem is would be really welcome.

 Regards,

j.

Attachment: taula1.png
Description: PNG image



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]