Hi created a small example code reproducing my problem...

With my understanding, This code is suppose to create one windows called "Test 
Window" contianing 2 OpenGL Windows.

At each draw of the openGl window, it prints out "GL Draw".
But when running my code, I only see 2 "GL_Draw" print outs, comming from 
GL1->draw(); and GL2->draw();.
In any case, nothing is drawn on the "Test Window".

I likeli miss an important point here,
I checked over the documentation but didn't find obvious things...
So you help is really welcome here...

Loic,



class WIN_GL : public Fl_Gl_Window {
public:

        WIN_GL(int x,int y,int w,int h,const char *l=0) : 
Fl_Gl_Window(x,y,w,h,l){}

    void Perspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble 
zFar) {
        GLdouble xmin, xmax, ymin, ymax;
        ymax = zNear * tan(fovy * 3.141516 / 360.0);
        ymin = -ymax;
        xmin = ymin * aspect;
        xmax = ymax * aspect;
        glFrustum(xmin, xmax, ymin, ymax, zNear, zFar);
    }

        void draw(){
                std::cout << "GL DRAW\n";
                if ( !valid() ) {
                        valid(1);

                        // Viewport
                        glViewport(0, 0, w(), h());
                        // Projection
                        glMatrixMode(GL_PROJECTION);
                        glLoadIdentity();
                        GLfloat ratio = w() / h();
                        Perspective(30.0f, 1.0f*ratio, 1.0f, 30.0f);
                        glTranslatef(0.0, 0.0, -8.0);
                        // Model view
                        glMatrixMode(GL_MODELVIEW);
                        glLoadIdentity();
                }


                glClearColor(.9,.9,.9, 1.0);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        // Setup model matrix
        glLoadIdentity();
                static float spin = 0.0f;
                spin+=0.5f;
        glRotatef(spin, 0.5f, 1.0f, 0.0f); // show all sides of cube
        // Draw cube with texture assigned to each face
        glBegin(GL_QUADS);
          // Front Face
          glColor3f(1.0, 0.0, 0.0); // red
              glVertex3f(-1.0,  1.0,  1.0); // Top Left Of The Texture and Quad
              glVertex3f( 1.0,  1.0,  1.0); // Top Right Of The Texture and Quad
              glVertex3f( 1.0, -1.0,  1.0); // Bottom Right Of The Texture and 
Quad
              glVertex3f(-1.0, -1.0,  1.0); // Bottom Left Of The Texture and 
Quad
          // Back Face
          glColor3f(0.0, 1.0, 1.0); // cyn
              glVertex3f( 1.0,  1.0, -1.0); // Top Left Of The Texture and Quad
              glVertex3f(-1.0,  1.0, -1.0); // Top Right Of The Texture and Quad
              glVertex3f(-1.0, -1.0, -1.0); // Bottom Right Of The Texture and 
Quad
              glVertex3f( 1.0, -1.0, -1.0); // Bottom Left Of The Texture and 
Quad
          // Top Face
          glColor3f(0.0, 1.0, 0.0); // grn
              glVertex3f(-1.0,  1.0, -1.0); // Top Left Of The Texture and Quad
              glVertex3f( 1.0,  1.0, -1.0); // Top Right Of The Texture and Quad
              glVertex3f( 1.0,  1.0,  1.0); // Bottom Right Of The Texture and 
Quad
              glVertex3f(-1.0,  1.0,  1.0); // Bottom Left Of The Texture and 
Quad
          // Bottom Face
          glColor3f(1.0, 0.0, 1.0); // mag
              glVertex3f( 1.0, -1.0, -1.0); // Top Left Of The Texture and Quad
              glVertex3f(-1.0, -1.0, -1.0); // Top Right Of The Texture and Quad
              glVertex3f(-1.0, -1.0,  1.0); // Bottom Right Of The Texture and 
Quad
              glVertex3f( 1.0, -1.0,  1.0); // Bottom Left Of The Texture and 
Quad
          // Right face
          glColor3f(0.0, 0.0, 1.0); // blu
              glVertex3f( 1.0,  1.0,  1.0); // Top Left Of The Texture and Quad
              glVertex3f( 1.0,  1.0, -1.0); // Top Right Of The Texture and Quad
              glVertex3f( 1.0, -1.0, -1.0); // Bottom Right Of The Texture and 
Quad
              glVertex3f( 1.0, -1.0,  1.0); // Bottom Left Of The Texture and 
Quad
          // Left Face
          glColor3f(1.0, 1.0, 0.0); // yel
              glVertex3f(-1.0,  1.0, -1.0); // Top Left Of The Texture and Quad
              glVertex3f(-1.0,  1.0,  1.0); // Top Right Of The Texture and Quad
              glVertex3f(-1.0, -1.0,  1.0); // Bottom Right Of The Texture and 
Quad
              glVertex3f(-1.0, -1.0, -1.0); // Bottom Left Of The Texture and 
Quad
        glEnd();
        }

        int handle(int e){
                return Fl_Gl_Window::handle(e);
        }
};


class WIN_MAIN : public Fl_Double_Window {
public:
        WIN_GL*                                 GL1;
        WIN_GL*                                 GL2;

        WIN_MAIN(int x,int y,int w,int h,const char *l=0) : 
Fl_Double_Window(x,y,w,h,l)
        {
                this->begin();
                GL1 = new WIN_GL(10,10,(w-30)/2, (y-20));
                GL1->end();
                GL1->show();
                GL1->draw();
                GL1->resizable(this);

                this->begin();
                GL2 = new WIN_GL(20+(w-30)/2,10,(w-30)/2, (y-20));
                GL2->end();
                GL2->show();
                GL2->draw();
                GL2->resizable(this);

                this->end();
        }
};

int main (int argc, char *argv[])
{
        WIN_MAIN* test = new WIN_MAIN(0,0,800,600,"Test Window");
        test->resizable(test);
        test->show();

        while(test->shown()){
                Fl::check();
                //test->damage(FL_DAMAGE_ALL);
                test->redraw();
        }
        return 0;
}

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to