FLTK 1.3.0
Fl_Gl_Window.H
1 //
2 // "$Id: Fl_Gl_Window.H 8157 2011-01-01 14:01:53Z AlbrechtS $"
3 //
4 // OpenGL header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2010 by Bill Spitzak and others.
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
17 //
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 // USA.
22 //
23 // Please report all bugs and problems on the following page:
24 //
25 // http://www.fltk.org/str.php
26 //
27 
28 /* \file
29  Fl_Gl_Window widget . */
30 
31 #ifndef Fl_Gl_Window_H
32 #define Fl_Gl_Window_H
33 
34 #include "Fl_Window.H"
35 
36 #ifndef GLContext
37 
40 typedef void* GLContext; // actually a GLXContext or HGLDC
41 #endif
42 
43 class Fl_Gl_Choice; // structure to hold result of glXChooseVisual
44 
65 class FL_EXPORT Fl_Gl_Window : public Fl_Window {
66 
67  int mode_;
68  const int *alist;
69  Fl_Gl_Choice *g;
70  GLContext context_;
71  char valid_f_;
72  char damage1_; // damage() of back buffer
73  virtual void draw_overlay();
74  void init();
75 
76  void *overlay;
77  void make_overlay();
78  friend class _Fl_Gl_Overlay;
79 
80  static int can_do(int, const int *);
81  int mode(int, const int *);
82 
83 public:
84 
85  void show();
86  void show(int a, char **b) {Fl_Window::show(a,b);}
87  void flush();
88  void hide();
89  void resize(int,int,int,int);
90  int handle(int);
91 
116  char valid() const {return valid_f_ & 1;}
120  void valid(char v) {if (v) valid_f_ |= 1; else valid_f_ &= 0xfe;}
121  void invalidate();
122 
129  char context_valid() const {return valid_f_ & 2;}
133  void context_valid(char v) {if (v) valid_f_ |= 2; else valid_f_ &= 0xfd;}
134 
136  static int can_do(int m) {return can_do(m,0);}
138  static int can_do(const int *m) {return can_do(0, m);}
140  int can_do() {return can_do(mode_,alist);}
174  Fl_Mode mode() const {return (Fl_Mode)mode_;}
176  int mode(int a) {return mode(a,0);}
178  int mode(const int *a) {return mode(0, a);}
180  void* context() const {return context_;}
181  void context(void*, int destroy_flag = 0);
182  void make_current();
183  void swap_buffers();
184  void ortho();
185 
191  int can_do_overlay();
198  void redraw_overlay();
199  void hide_overlay();
207  void make_overlay_current();
208 
209  // Note: Doxygen docs in Fl_Widget.H to avoid redundancy.
210  virtual Fl_Gl_Window* as_gl_window() {return this;}
211 
212  ~Fl_Gl_Window();
217  Fl_Gl_Window(int W, int H, const char *l=0) : Fl_Window(W,H,l) {init();}
224  Fl_Gl_Window(int X, int Y, int W, int H, const char *l=0)
225  : Fl_Window(X,Y,W,H,l) {init();}
226 
227 protected:
233  virtual void draw();
234 };
235 
236 #endif
237 
238 //
239 // End of "$Id: Fl_Gl_Window.H 8157 2011-01-01 14:01:53Z AlbrechtS $".
240 //