Firstly, I just want to say thanks to all previous replyer for their expertise 
help.

Secondly, I need more help from you guys.

Actually, I found the true issues is the glWindow->Redraw() . it doesn't
force refreshing. It only refresh sometime(like when mouse moving around). It 
only refresh on Window.

I try the code below. It refresh on windows. but doesn't on MacOSX( I had move 
my mouse to let them refresh.)

Actually, I really fltk to refresh whenever I do Redraw(),or if there are 
alternative way which can make me force fltk to refresh.

Thanks first.



/////////////////////////////



#include <FL/Fl.H>
#include <FL/Fl_Gl_Window.H>
#include <FL/gl.h>
#include <memory.h>
//
// Simple resizable 2D GL window
// erco 10/08/05
//

class MyGlWindow : public Fl_Gl_Window {
    // DRAW METHOD
    //      OpenGL window: (w,h) is upper right, (-w,-h) is lower left, (0,0) 
is center
    //
public:
        char*           m_pFrameData;

    void draw() {
                static int cc=0;
                if(cc>w())
                        cc=0;

        // First time? init viewport, etc.
        if (!valid()) {
            valid(1);
            glLoadIdentity();
            glViewport(0,0,w(),h());
            glOrtho(-w(),w(),-h(),h(),-1,1);
        }

        // Clear screen
        glClear(GL_COLOR_BUFFER_BIT);
        // Draw white 'X'
        glColor3f(1.0, 1.0, 1.0);
        glBegin(GL_LINE_STRIP); glVertex2f(w()-cc, h()); 
glVertex2f(-w()-cc,-h()); glEnd();
        glBegin(GL_LINE_STRIP); glVertex2f(w()-cc,-h()); glVertex2f(-w()-cc, 
h()); glEnd();
        Fl_Gl_Window::draw(); // Aha!
    }
    // HANDLE WINDOW RESIZING
    //    If window reshaped, need to readjust viewport/ortho
    //
    void resize(int X,int Y,int W,int H) {
        Fl_Gl_Window::resize(X,Y,W,H);
        glLoadIdentity();
        glViewport(0,0,W,H);
        glOrtho(-W,W,-H,H,-1,1);
        redraw();
    }
public:
    // CONSTRUCTOR
    MyGlWindow(int X,int Y,int W,int H,const char*L=0) : 
Fl_Gl_Window(X,Y,W,H,L) {
                m_pFrameData=new char[1024*1024*3];
    }
};
// MAIN
int main() {
     Fl_Window win(512, 512);
     MyGlWindow mygl(0, 0, win.w(), win.h(),"viewer");
     win.resizable(mygl);
     win.show();
        while(1)
        {
//              memset(mygl.m_pFrameData,cc++,m_nWidth*m_nHeight*3);
                mygl.redraw();
                Fl::wait();
        }

     return(Fl::run());
}
_______________________________________________
fltk-opengl mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-opengl

Reply via email to