FLTK 1.4.0
Loading...
Searching...
No Matches
Fl_Gl_Window_Driver.H
1//
2// Definition of class Fl_Gl_Window_Driver, and of its platform-specific derived classes
3// for the Fast Light Tool Kit (FLTK).
4//
5// Copyright 2016-2018 by Bill Spitzak and others.
6//
7// This library is free software. Distribution and use rights are outlined in
8// the file "COPYING" which should have been included with this file. If this
9// file is missing or damaged, see the license at:
10//
11// https://www.fltk.org/COPYING.php
12//
13// Please see the following page on how to report bugs and issues:
14//
15// https://www.fltk.org/bugs.php
16//
17
24#ifndef Fl_Gl_Window_Driver_H
25#define Fl_Gl_Window_Driver_H
26
27#include <FL/Fl_Gl_Window.H>
28#include <FL/gl.h> // for GLint
29
30class Fl_Gl_Choice;
31class Fl_Font_Descriptor;
32
33/* The constructor of each Fl_Gl_Window object creates also an object from a
34 platform-specific derived class from this class.
35 */
36class Fl_Gl_Window_Driver {
37protected:
38 GLint current_prog;
39 Fl_Gl_Window *pWindow;
40public:
41 static Fl_Window* cached_window;
42 static int nContext;
43 static GLContext *context_list;
44 static Fl_Gl_Choice *first;
45 static int copy;
46 static float gl_scale;
47 static GLContext gl_start_context;
48 Fl_Gl_Choice* g() {return pWindow->g;}
49 void g(Fl_Gl_Choice *c) {pWindow->g = c;}
50 int mode() {return pWindow->mode_;}
51 void mode(int m) { pWindow->mode_ = m;}
52 const int *alist() {return pWindow->alist;}
53 void alist(const int *l) { pWindow->alist = l;}
54 void* overlay() {return pWindow->overlay;}
55 void draw_overlay() {pWindow->draw_overlay();}
56
57 Fl_Gl_Window_Driver(Fl_Gl_Window *win) : pWindow(win) {current_prog=0;}
58 virtual ~Fl_Gl_Window_Driver() {}
59 static Fl_Gl_Window_Driver *newGlWindowDriver(Fl_Gl_Window *w);
60 static Fl_Gl_Window_Driver *global();
61 virtual float pixels_per_unit() {return 1;}
62 virtual void before_show(int&) {}
63 virtual void after_show() {}
64 virtual void invalidate();
65 virtual int mode_(int /*m*/, const int * /*a*/) {return 0;}
66 virtual void make_current_before() {}
67 virtual void make_current_after() {}
68 virtual void swap_buffers() {}
69 virtual void resize(int /*is_a_resize*/, int /*w*/, int /*h*/) {}
70 virtual char swap_type();
71 virtual void swap_interval(int) { }
72 virtual int swap_interval() const { return -1; }
73 virtual int flush_begin(char&) {return 0;}
74 virtual void gl_hide_before(void *&) {} // the default implementation may be enough
75 static Fl_Gl_Choice *find_begin(int m, const int *alistp);
76 static void add_context(GLContext ctx);
77 static void del_context(GLContext ctx);
78 // Return one of these structures for a given gl mode.
79 // The second argument is a glX attribute list, and is used if mode is zero.
80 // This is not supported on Win32:
81 virtual Fl_Gl_Choice *find(int /*mode*/, const int * /*alistp*/) {return NULL;}
82 virtual GLContext create_gl_context(Fl_Window*, const Fl_Gl_Choice*) {return 0;}
83 virtual void set_gl_context(Fl_Window*, GLContext) {}
84 virtual void delete_gl_context(GLContext) {}
85 virtual void make_overlay(void* &o);
86 virtual void hide_overlay() {} // the default implementation may be enough
87 virtual void make_overlay_current() {}
88 virtual void redraw_overlay() {}
89 virtual int can_do_overlay() {return 0;}
90 virtual void waitGL() {} // support for gl_finish() function
91 virtual void gl_visual(Fl_Gl_Choice*); // support for Fl::gl_visual() function
92 virtual void gl_start() {} // support for gl_start() function
93 virtual void* GetProcAddress(const char *procName); // support for glutGetProcAddress()
94 virtual void draw_string_legacy(const char* str, int n); // support for gl_draw()
95 void draw_string_legacy_get_list(const char* str, int n); // support for gl_draw()
96 static void draw_string_legacy_glut(const char* str, int n); // support for gl_draw()
97 virtual void get_list(Fl_Font_Descriptor*, int) {} // support for gl_draw() without textures
98 virtual void gl_bitmap_font(Fl_Font_Descriptor *) {} // support for gl_font() without textures
99 virtual int overlay_color(Fl_Color) {return 0;} // support for gl_color() with HAVE_GL_OVERLAY
100 static void draw_string_with_texture(const char* str, int n); // cross-platform
101 // support for gl_draw(). The cross-platform version may be enough.
102 virtual char *alpha_mask_for_string(const char *str, int n, int w, int h, Fl_Fontsize fs);
103 virtual int genlistsize() { return 0; } // support for gl_draw()
104 virtual Fl_Font_Descriptor** fontnum_to_fontdescriptor(int fnum);
105 virtual Fl_RGB_Image* capture_gl_rectangle(int x, int y, int w, int h);
106 static inline Fl_Gl_Window_Driver* driver(const Fl_Gl_Window *win) {return win->pGlWindowDriver;}
107 // true means the platform uses glScissor() to make sure GL subwindows
108 // don't leak outside their parent window
109 virtual bool need_scissor() { return false; }
110 virtual void switch_to_GL1();
111 virtual void switch_back();
112};
113
114#endif /* Fl_Gl_Window_Driver_H */
115
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition Enumerations.H:1101
int Fl_Fontsize
Size of a font in pixels.
Definition Enumerations.H:1073
Definition Fl_Gl_Choice.H:44
The Fl_Gl_Window widget sets things up so OpenGL works.
Definition Fl_Gl_Window.H:56
The Fl_RGB_Image class supports caching and drawing of full-color images with 1 to 4 channels of colo...
Definition Fl_Image.H:339
This widget produces an actual window.
Definition Fl_Window.H:55
This file defines wrapper functions for OpenGL in FLTK.
void gl_start()
Creates an OpenGL context.
Definition gl_start.cxx:58
struct opaque * GLContext
Pointer to a platform-specific structure representing the window's OpenGL rendering context.
Definition platform_types.h:66