FLTK logo

Fl_Gl_Window flashes on context creation (Windows7)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.opengl  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Fl_Gl_Window flashes on context creation (Windows7) Ivan Nedrehagen Apr 02, 2013  
 
This was originally a FTGL question on stack overflow

http://stackoverflow.com/questions/15568520/fl-gl-window-flashes-on-creation

I have some simple fltk code:

#include <FL/Fl.H>
#include <FL/Fl_Gl_Window.H>
#include <FL/gl.h>

class MyWin : public Fl_Gl_Window {
  public:
  MyWin(int x,int y, int w,int h, const char*l = 0) :
    Fl_Gl_Window(x,y,w,h,l)
  {
  }
  void draw();
  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();
  }
};

void MyWin::draw() {
  ortho();
  glBegin(GL_QUADS);
    glColor3d(1,0,0);
    glVertex3f(10,10,0);
    glColor3d(0,1,0);
    glVertex3f(w()-10,10,0);
    glColor3d(0,0,1);
    glVertex3f(w()-10,h()-10,0);
    glColor3d(1,1,0);
    glVertex3f(10,h()-10,0);
  glEnd();
}

int main(int argc,char* argv[]) {
  Fl_Window win(500,500, "OpenGL");
  MyWin window(10,10,win.w()-20,win.h()-20);
  win.end();
  win.resizable(window);
  win.show(argc,argv);
  return Fl::run();
}

This example compiles and links perfectly for me on Windows 7 using mingw, but when I run it, it gets quite ugly. First the screen turns dark, and flashes with white. Then the screen is redrawn and my window appears. The same happens when I shut down the application.

I have tried to remove the drawing code, the same happens, then I removed the gl window from the outer window and it still happens. So it is not affected by the actual drawing. So my suspicion is that the opengl context creation causes this. Removing the creation of the gl window supports this hypothesis as the window now appears "quietly".

Does anyone know how I can get the Fl_Gl_Window to play nicely in windows?
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.