FLTK
Fl_Gl_Choice.H
1 //
2 // OpenGL definitions for the Fast Light Tool Kit (FLTK).
3 //
4 // Copyright 1998-2018 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 // Internal interface to set up OpenGL.
18 //
19 // A "Fl_Gl_Choice" is created from an OpenGL mode and holds information
20 // necessary to create a window (on X) and to create an OpenGL "context"
21 // (on both X and Win32).
22 //
23 // create_gl_context takes a window (necessary only on Win32) and an
24 // Fl_Gl_Choice and returns a new OpenGL context. All contexts share
25 // display lists with each other.
26 //
27 // On X another create_gl_context is provided to create it for any
28 // X visual.
29 //
30 // set_gl_context makes the given OpenGL context current and makes
31 // it draw into the passed window. It tracks the current one context
32 // to avoid calling the context switching code when the same context
33 // is used, though it is a mystery to me why the GLX/WGL libraries
34 // don't do this themselves...
35 //
36 // delete_gl_context destroys the context.
37 //
38 // This code is used by Fl_Gl_Window, gl_start(), and gl_visual()
39 
40 #ifndef Fl_Gl_Choice_H
41 #define Fl_Gl_Choice_H
42 
43 #ifdef FL_CFG_GFX_QUARTZ
44 # include <OpenGL/gl.h>
45 # define FL_GL_CHOICE_PLATFORM_SPECIFIC_MEMBERS void* pixelformat;
46 #endif // FL_CFG_GFX_QUARTZ
47 
48 
49 #ifdef FL_CFG_GFX_XLIB
50 # include <GL/glx.h>
51 # if ! defined(GLX_VERSION_1_3)
52 # typedef void *GLXFBConfig;
53 # endif
54 # define FL_GL_CHOICE_PLATFORM_SPECIFIC_MEMBERS \
55  XVisualInfo *vis; /* the visual to use */ \
56  Colormap colormap; /* a colormap for that visual */ \
57  GLXFBConfig best_fb;
58 #endif // FL_CFG_GFX_XLIB*/
59 
60 
61 #ifdef FL_CFG_GFX_GDI
62 # include <FL/gl.h>
63 # define FL_GL_CHOICE_PLATFORM_SPECIFIC_MEMBERS \
64  int pixelformat; /* the visual to use */ \
65  PIXELFORMATDESCRIPTOR pfd; // some wgl calls need this thing
66 #endif // FL_CFG_GFX_GDI
67 
68 
69 // Describes crap needed to create a GLContext.
70 class Fl_Gl_Choice {
71  friend class Fl_Gl_Window_Driver;
72  int mode;
73  const int *alist;
74  Fl_Gl_Choice *next;
75 public:
76  Fl_Gl_Choice(int m, const int *alistp, Fl_Gl_Choice *n) : mode(m), alist(alistp), next(n) {}
77  FL_GL_CHOICE_PLATFORM_SPECIFIC_MEMBERS
78 };
79 
80 #undef FL_GL_CHOICE_PLATFORM_SPECIFIC_MEMBERS
81 
82 #endif // Fl_Gl_Choice_H
Definition: Fl_Gl_Choice.H:70
This file defines wrapper functions for OpenGL in FLTK.