Exemple #1
0
    void configInit()
    {
        initializeFrame();
        initializeRenderer();

        Window* window = static_cast< Window* >( _channel->getWindow( ));
        _glWidgetPtr->setGLContext( GLContextPtr( new EqContext( window )));
    }
Exemple #2
0
RenderArea::RenderArea(RenderAreaPtr theContext) : AbstractRenderWindow(jslib::JSApp::ShellErrorReporter),
    _myContextRefCount(0),
    _isFirstFrame(true)
{
    GdkGLConfig * myGLConfig = gdk_gl_config_new_by_mode(
                GdkGLConfigMode(GDK_GL_MODE_RGBA | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE | GDK_GL_MODE_ALPHA));
    if (myGLConfig == 0) {
        throw asl::Exception("can't init GL",PLUS_FILE_LINE);
    }

    // If another render area is supplied as constructor paramter, this render area is uses as
    // source for a shared y60-gl-context and gdk-gl-context.
    GdkGLContext * myGdkGLContext = 0;
    if (theContext) {
        myGdkGLContext = theContext->getGdkGlContext();
        if (!myGdkGLContext) {
            throw asl::Exception("RenderArea: Failed to get gdk GL context from shared render area.", PLUS_FILE_LINE);
        }
        setGLContext(theContext->getGLContext());
    } else {
        setGLContext(GLContextPtr(new GLContext()));
    }

    /* Set OpenGL-capability to the widget. */
    DB(cerr << "RenderArea::RenderArea() sharing with " << myGdkGLContext << endl);
    if (!gtk_widget_set_gl_capability (GTK_WIDGET(gobj()),
                myGLConfig,
                myGdkGLContext,
                true,
                GDK_GL_RGBA_TYPE))
    {
        throw asl::Exception("RenderArea: could not create GL context!", PLUS_FILE_LINE);
    }

    // enable mouse events
    Gdk::EventMask flags = get_events();
    flags |= Gdk::BUTTON_PRESS_MASK;
    flags |= Gdk::POINTER_MOTION_MASK;
    flags |= Gdk::BUTTON_RELEASE_MASK;
    flags |= Gdk::SCROLL_MASK;
    flags |= Gdk::ENTER_NOTIFY_MASK;
    flags |= Gdk::LEAVE_NOTIFY_MASK;
    set_events(flags);

    y60::EventDispatcher::get().addSource(&_myEventAdapter);
    y60::EventDispatcher::get().addSink(this);
    // TODO: createRenderer(theOtherRenderer);

    ShaderLibrary::setGLisReadyFlag(true);
}