FLTK 1.4.4

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
25 class Fl_Gl_Choice; // structure to hold result of glXChooseVisual
26 class Fl_Gl_Window_Driver;
56 class 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();
74 protected:
75 void draw_begin();
76 void draw() FL_OVERRIDE;
77 void draw_end();
78
79 public:
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_;}
186 int mode(int a) {return mode(a,0);}
198 int mode(const int *a) {return mode(0, a);}
202 GLContext context() const {return context_;}
203 void context(GLContext, int destroy_flag = 0);
204 void make_current();
205 void swap_buffers();
206 void swap_interval(int);
207 int swap_interval() const;
208 void ortho();
209
210 int can_do_overlay();
211 void redraw_overlay();
212 void hide_overlay();
213 void make_overlay_current();
214
215 // Note: Doxygen docs in Fl_Widget.H to avoid redundancy.
216 Fl_Gl_Window* as_gl_window() FL_OVERRIDE { return this; }
217 Fl_Gl_Window const* as_gl_window() const FL_OVERRIDE { return this; }
218
219 float pixels_per_unit();
229 int pixel_w() { return int(pixels_per_unit() * w() + 0.5f); }
239 int pixel_h() { return int(pixels_per_unit() * h() + 0.5f); }
240
241 ~Fl_Gl_Window();
246 Fl_Gl_Window(int W, int H, const char *l=0) : Fl_Window(W,H,l) {init();}
252
253 Fl_Gl_Window(int X, int Y, int W, int H, const char *l=0)
254 : Fl_Window(X,Y,W,H,l) {init();}
255};
256
257#endif // Fl_Gl_Window_H
Fl_Mode
Fl_Mode
visual types and Fl_Gl_Window::mode() (values match Glut)
Definition Enumerations.H:1319
Fl_Window.H
Fl_Window widget .
Fl_Gl_Choice
Definition Fl_Gl_Choice.H:44
Fl_Gl_Window
The Fl_Gl_Window widget sets things up so OpenGL works.
Definition Fl_Gl_Window.H:56
Fl_Gl_Window::context_valid
char context_valid() const
Will only be set if the OpenGL context is created or recreated.
Definition Fl_Gl_Window.H:125
Fl_Gl_Window::pixel_h
int pixel_h()
Gives the window height in OpenGL pixels.
Definition Fl_Gl_Window.H:239
Fl_Gl_Window::draw_end
void draw_end()
To be used as a match for a previous call to Fl_Gl_Window::draw_begin().
Definition Fl_Gl_Window.cxx:421
Fl_Gl_Window::draw_begin
void draw_begin()
Supports drawing to an Fl_Gl_Window with the FLTK 2D drawing API.
Definition Fl_Gl_Window.cxx:382
Fl_Gl_Window::context
GLContext context() const
Returns a pointer to the window's OpenGL rendering context.
Definition Fl_Gl_Window.H:202
Fl_Gl_Window::pixels_per_unit
float pixels_per_unit()
The number of pixels per FLTK unit of length for the window.
Definition Fl_Gl_Window.cxx:528
Fl_Gl_Window::can_do
int can_do()
Returns non-zero if the hardware supports the current OpenGL mode.
Definition Fl_Gl_Window.H:137
Fl_Gl_Window::can_do
static int can_do(int m)
Returns non-zero if the hardware supports the given OpenGL mode.
Definition Fl_Gl_Window.H:132
Fl_Gl_Window::mode
int mode(const int *a)
Set the OpenGL capabilities of the window using platform-specific data.
Definition Fl_Gl_Window.H:198
Fl_Gl_Window::as_gl_window
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:216
Fl_Gl_Window::show
void show(int a, char **b)
Same as Fl_Window::show(int a, char **b).
Definition Fl_Gl_Window.H:82
Fl_Gl_Window::Fl_Gl_Window
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:253
Fl_Gl_Window::pixel_w
int pixel_w()
Gives the window width in OpenGL pixels.
Definition Fl_Gl_Window.H:229
Fl_Gl_Window::can_do
static int can_do(const int *m)
Returns non-zero if the hardware supports the given OpenGL mode.
Definition Fl_Gl_Window.H:135
Fl_Gl_Window::context_valid
void context_valid(char v)
See char Fl_Gl_Window::context_valid() const.
Definition Fl_Gl_Window.H:129
Fl_Gl_Window::Fl_Gl_Window
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:246
Fl_Gl_Window::valid
char valid() const
Is turned off when FLTK creates a new context for this window or when the window resizes,...
Definition Fl_Gl_Window.H:112
Fl_Gl_Window::mode
int mode(int a)
Set or change the OpenGL capabilities of the window.
Definition Fl_Gl_Window.H:186
Fl_Gl_Window::valid
void valid(char v)
See char Fl_Gl_Window::valid() const.
Definition Fl_Gl_Window.H:116
Fl_Gl_Window::mode
Fl_Mode mode() const
Returns the current OpenGL capabilities of the window.
Definition Fl_Gl_Window.H:141
Fl_Widget::as_gl_window
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:1243
Fl_Widget::h
int h() const
Gets the widget height.
Definition Fl_Widget.H:376
Fl_Widget::w
int w() const
Gets the widget width.
Definition Fl_Widget.H:371
Fl_Window::flush
virtual void flush()
Forces the window to be drawn, this window is also made current and calls draw().
Definition Fl_Window.cxx:481
Fl_Window::make_current
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:534
Fl_Window::draw
void draw() FL_OVERRIDE
Draws the widget.
Definition Fl_Window.cxx:491
Fl_Window::show
void show() FL_OVERRIDE
Puts the window on the screen.
Definition Fl_Window.cxx:546
FL_OVERRIDE
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46
GLContext
struct opaque * GLContext
Pointer to a platform-specific structure representing the window's OpenGL rendering context.
Definition platform_types.h:66