I met a problem with Fl_Gl_window and Fl_Scroll.

My purpose is to display animation by Fl_Gl_window. And when window shrink and 
smaller than the animation size,scroolbar show up.

But when window shrink ,Fl_Gl_window will overlap with Fl_Scroll. In 
result,Fl_Scroll can't be able to seen.

Anyone met same problem before. Any suggestion also welcomed.

Thanks first,

Jack
//////////////////////////////////
#include "config.h"
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Hor_Slider.H>
#include <FL/Fl_Toggle_Button.H>
#include <FL/math.h>
#include <stdio.h>
#include <FL/gl.h>
#include <FL/Fl_Gl_Window.H>

class shape_window : public Fl_Gl_Window {
  void draw();
  void draw_overlay();
public:
        char* m_pFrameData;
  int sides;
  int overlay_sides;
  shape_window(int x,int y,int w,int h,const char *l=0);
};

shape_window::shape_window(int x,int y,int w,int h,const char *l) :
Fl_Gl_Window(x,y,w,h,l) {
  sides = overlay_sides = 3;
  m_pFrameData=new char[w*h*40];
}

void shape_window::draw() {
// 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());
  }
// draw an amazing but slow graphic:
  glClear(GL_COLOR_BUFFER_BIT);
  //  for (int j=1; j<=1000; j++) {
    glBegin(GL_POLYGON);
    for (int i=0; i<sides; i++) {
      double ang = i*2*M_PI/sides;
      glColor3f(float(i)/sides,float(i)/sides,float(i)/sides);
      glVertex3f(cos(ang),sin(ang),0);
    }
    glEnd();

        static int cc=0;
        printf("w=%u:h=%u\n",w(),h());
        memset(m_pFrameData,cc++,w()*h()*3);
        glDrawPixels(w(),h(),GL_BGR_EXT,GL_UNSIGNED_BYTE,m_pFrameData);
        if(cc>255)
                cc=0;
  // }
}

void shape_window::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());
  }

        static int cc=0;
        memset(m_pFrameData,cc++,w()*h()*3);
        glDrawPixels(w(),h(),GL_BGR_EXT,GL_UNSIGNED_BYTE,m_pFrameData);
        if(cc>255)
                cc=0;
}

#include <stdio.h>
#include <Fl/Fl_Scroll.h>
int main(int argc, char **argv) {

  Fl_Window window(300, 370);
  Fl_Scroll src(0,0,300,370);
  shape_window sw(0, 0, 300-20, 370-20);
  window.resizable(&sw);
  window.show(argc,argv);
  return Fl::run();
}

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

Reply via email to