FLTK 1.4.0
Loading...
Searching...
No Matches
Fl_Gl_Window.H
1//
2// OpenGL header file for the Fast Light Tool Kit (FLTK).
3//
4// Copyright 1998-2023 by Bill Spitzak and others.
5//
6// This library is free software. Distribution and use rights are outlined in
7// the file "COPYING" which should have been included with this file. If this
8// file is missing or damaged, see the license at:
9//
10// https://www.fltk.org/COPYING.php
11//
12// Please see the following page on how to report bugs and issues:
13//
14// https://www.fltk.org/bugs.php
15//
16
17/* \file
18 Fl_Gl_Window widget . */
19
20#ifndef Fl_Gl_Window_H
21#define Fl_Gl_Window_H
22
23#include "Fl_Window.H"
24
25class Fl_Gl_Choice; // structure to hold result of glXChooseVisual
26class Fl_Gl_Window_Driver;
56class FL_EXPORT Fl_Gl_Window : public Fl_Window {
57 friend class Fl_Gl_Window_Driver;
58 Fl_Gl_Window_Driver *pGlWindowDriver;
59
60 int mode_;
61 const int *alist;
62 Fl_Gl_Choice *g;
63 GLContext context_;
64 char valid_f_;
65 char damage1_; // damage() of back buffer
66 virtual void draw_overlay();
67 void init();
68
69 void *overlay;
70
71 static int can_do(int, const int *);
72 int mode(int, const int *);
73 static int gl_plugin_linkage();
74protected:
75 void draw_begin();
76 void draw() FL_OVERRIDE;
77 void draw_end();
78
79public:
80 void show() FL_OVERRIDE;
82 void show(int a, char **b) {Fl_Window::show(a,b);}
83 void flush() FL_OVERRIDE;
84 void hide() FL_OVERRIDE;
85 void resize(int,int,int,int) FL_OVERRIDE;
86 int handle(int) FL_OVERRIDE;
87
112 char valid() const {return valid_f_ & 1;}
116 void valid(char v) {if (v) valid_f_ |= 1; else valid_f_ &= 0xfe;}
117 void invalidate();
118
125 char context_valid() const {return valid_f_ & 2;}
129 void context_valid(char v) {if (v) valid_f_ |= 2; else valid_f_ &= 0xfd;}
130
132 static int can_do(int m) {return can_do(m,0);}
135 static int can_do(const int *m) {return can_do(0, m);}
137 int can_do() {return can_do(mode_,alist);}
141 Fl_Mode mode() const {return (Fl_Mode)mode_;}
182 int mode(int a) {return mode(a,0);}
194 int mode(const int *a) {return mode(0, a);}
198 GLContext context() const {return context_;}
199 void context(GLContext, int destroy_flag = 0);
200 void make_current();
201 void swap_buffers();
202 void swap_interval(int);
203 int swap_interval() const;
204 void ortho();
205
206 int can_do_overlay();
207 void redraw_overlay();
208 void hide_overlay();
209 void make_overlay_current();
210
211 // Note: Doxygen docs in Fl_Widget.H to avoid redundancy.
213 Fl_Gl_Window const* as_gl_window() const FL_OVERRIDE { return this; }
214
215 float pixels_per_unit();
225 int pixel_w() { return int(pixels_per_unit() * w() + 0.5f); }
235 int pixel_h() { return int(pixels_per_unit() * h() + 0.5f); }
236
242 Fl_Gl_Window(int W, int H, const char *l=0) : Fl_Window(W,H,l) {init();}
249 Fl_Gl_Window(int X, int Y, int W, int H, const char *l=0)
250 : Fl_Window(X,Y,W,H,l) {init();}
251};
252
253#endif // Fl_Gl_Window_H
Fl_Mode
visual types and Fl_Gl_Window::mode() (values match Glut)
Definition Enumerations.H:1297
Fl_Window widget .
Definition Fl_Gl_Choice.H:44
The Fl_Gl_Window widget sets things up so OpenGL works.
Definition Fl_Gl_Window.H:56
char context_valid() const
Will only be set if the OpenGL context is created or recreated.
Definition Fl_Gl_Window.H:125
int pixel_h()
Gives the window height in OpenGL pixels.
Definition Fl_Gl_Window.H:235
GLContext context() const
Returns a pointer to the window's OpenGL rendering context.
Definition Fl_Gl_Window.H:198
int can_do()
Returns non-zero if the hardware supports the current OpenGL mode.
Definition Fl_Gl_Window.H:137
static int can_do(int m)
Returns non-zero if the hardware supports the given OpenGL mode.
Definition Fl_Gl_Window.H:132
int mode(const int *a)
Set the OpenGL capabilities of the window using platform-specific data.
Definition Fl_Gl_Window.H:194
Fl_Gl_Window * as_gl_window() FL_OVERRIDE
Returns an Fl_Gl_Window pointer if this widget is an Fl_Gl_Window.
Definition Fl_Gl_Window.H:212
void show(int a, char **b)
Same as Fl_Window::show(int a, char **b)
Definition Fl_Gl_Window.H:82
Fl_Gl_Window(int X, int Y, int W, int H, const char *l=0)
Creates a new Fl_Gl_Window widget using the given position, size, and label string.
Definition Fl_Gl_Window.H:249
int pixel_w()
Gives the window width in OpenGL pixels.
Definition Fl_Gl_Window.H:225
static int can_do(const int *m)
Returns non-zero if the hardware supports the given OpenGL mode.
Definition Fl_Gl_Window.H:135
void context_valid(char v)
See char Fl_Gl_Window::context_valid() const.
Definition Fl_Gl_Window.H:129
Fl_Gl_Window(int W, int H, const char *l=0)
Creates a new Fl_Gl_Window widget using the given size, and label string.
Definition Fl_Gl_Window.H:242
int mode(int a)
Set or change the OpenGL capabilities of the window.
Definition Fl_Gl_Window.H:182
void valid(char v)
See char Fl_Gl_Window::valid() const.
Definition Fl_Gl_Window.H:116
Fl_Mode mode() const
Returns the current OpenGL capabilities of the window.
Definition Fl_Gl_Window.H:141
virtual class Fl_Gl_Window * as_gl_window()
Returns an Fl_Gl_Window pointer if this widget is an Fl_Gl_Window.
Definition Fl_Widget.H:1204
int h() const
Gets the widget height.
Definition Fl_Widget.H:368
int w() const
Gets the widget width.
Definition Fl_Widget.H:363
This widget produces an actual window.
Definition Fl_Window.H:55
virtual void flush()
Forces the window to be drawn, this window is also made current and calls draw().
Definition Fl_Window.cxx:481
void make_current()
Sets things up so that the drawing functions in <FL/fl_draw.H> will go into this window.
Definition Fl_Window.cxx:533
void draw() FL_OVERRIDE
Draws the widget.
Definition Fl_Window.cxx:491
void show() FL_OVERRIDE
Puts the window on the screen.
Definition Fl_Window.cxx:545
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46
struct opaque * GLContext
Pointer to a platform-specific structure representing the window's OpenGL rendering context.
Definition platform_types.h:66