jack3 wrote:
> Hi,
> 
> Basically, my way is inherit a class glCanvas from GLWindow and override the 
> function of draw_overlay and draw.
> then, I have a thread to continuely read image from network and call 
> redraw_overlay.

        That should be fine, I think a good way to do that would be
        to make your own application loop (instead of calling Fl::run() in 
main())
        eg:

while ( 1 ) {
     WaitForPixelData();              // wait for thread to be done putting 
data into memory
     yourwidget->redraw();     // tell fltk to schedule a redraw of your widget
     Fl::wait();               // fltk redraws your widget
}

        ..or something to that effect.

        Another approach would be to just call Fl:run(), and set up an
        fltk timer to trigger the redraw()s, similar to this technique:
        See: http://seriss.com/people/erco/fltk/#Animate

> Finally,draw_overlay should be called to refresh the image on the window.

> void VTGLCanvas::draw_overlay()
> {
>       // the valid() property may be used to avoid reinitializing your
>       // GL transformation for each redraw:
>       if (!valid())
>       {
>               valid(1);
>               glLoadIdentity();
>               glViewport(0,0,w(),h());
>       }
>       glClearColor(0,0,0,0);
>       glClear(GL_COLOR_BUFFER_BIT);
>       CAVAutoLock lock(&m_CritSecData);
>       
> glDrawPixels(m_nWidth,m_nHeight,GL_BGR_EXT,GL_UNSIGNED_BYTE,m_pFrameData);
>       swap_buffers();
> }
> 

        Hmm, not sure why you're using  draw_overlay() instead of draw().

        I would think draw_overlay() puts a requirement on overlay hardware,
        and is probably slow.

        Try moving all your draw pixels code to draw() instead, and don't use
        draw_overlay() at all.

        I don't think you need to call swap_buffers().. FLTK's draw() function
        should handle that. You /may/ need a glFlush() if you want to ensure
        the glDrawPixels() function has finished before your lock gets released
        at the closing brace (when the 'lock' instance goes out of scope)

        Once that's working, focus on optimizing the glDrawPixels() transfer
        flags so that the video data is moved as quickly as possible to the 
screen.

        Also, not sure why glClear() should need to be called each frame;
        I would think just clearing both buffers during the !valid() section
        should prevent the need to clear the screen each frame, unless your
        width/height values are changing for the glDrawPixels() call, in which
        case maybe only do the glClear() if the width/height values change.
_______________________________________________
fltk-opengl mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-opengl

Reply via email to