FLTK OpenGl



  • ch habe folgendes Problem: ich habe unter FLTK eine GUI implentiert, indem geometrische Objekte aus OpenGl dargestellt werden.
    Mein Problem ist, wenn ich einen Button drücke um ein anderes Objekt hochzuladen, das neue Objekt nicht sofort sichtbar wird, sondern nur dann, wenn ich mein GUI minimiere und wieder öffne.

    Ich habe dazu ein Button mit Load:

    void  Button_callback(Fl_Widget *w)
    {
        if(round1->value()==1)
        {
             test=ellipse;
        }
        else if (round2->value()==1)
        {
            test = cube;
        }
    }
    

    dazu die draw() Funktion:

    void MyWindow::draw()
    //========================================================================
    {
    
      static bool firstTime = true; // Flag to control whether this is first time
      if (firstTime)   { // The first time, we need to set up the necessary GL parameters
        InitializeGL();
        firstTime = false;
      }
        // clear the color and depth buffer
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);      
    
      // Set up the projection transformation
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glFrustum(-1, 1, -1, 1, 1, 100);
    
        // Set up the Model view transformation
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      gluLookAt(0, 0, 3, 0, 0, 0, 0, 1, 0);
    
        // Do the rotation
        glRotatef(rotation, 0, 1, 0);
    
            switch(test)
            {
            case ellipse:
    
                    sqSolidEllipsoid();
                    glutIdleFunc(idleFunction);
                    redraw();
                    break;
            case cube:
    
                    DrawCube();
                    glutIdleFunc(idleFunction);
                    redraw();
                    break;
            }    
    
    init();
    }
    

    Kann mir einer helfen bitte ?

    Grüße



  • Hi elturco,
    probier mal jeweils ein redraw() o.ä. in die Callbackfunktion einzufügen.

    void  Button_callback(Fl_Widget *w)
    {
        if(round1->value()==1)
        {
             test=ellipse;
             redraw(); //so heißt es zumindest in FLTK 2.x
        }
        else if (round2->value()==1)
        {
            test = cube;
            redraw();
        }
    }
    

    Gruß Hazzel


Anmelden zum Antworten