FLTK 1.3.8

Fl_Gl_Choice.H
1//
2// "$Id$"
3//
4// OpenGL definitions for the Fast Light Tool Kit (FLTK).
5//
6// Copyright 1998-2018 by Bill Spitzak and others.
7//
8// This library is free software. Distribution and use rights are outlined in
9// the file "COPYING" which should have been included with this file. If this
10// file is missing or damaged, see the license at:
11//
12// http://www.fltk.org/COPYING.php
13//
14// Please report all bugs and problems on the following page:
15//
16// http://www.fltk.org/str.php
17//
18
19// Internal interface to set up OpenGL.
20//
21// A "Fl_Gl_Choice" is created from an OpenGL mode and holds information
22// necessary to create a window (on X) and to create an OpenGL "context"
23// (on both X and Win32).
24//
25// fl_create_gl_context takes a window (necessary only on Win32) and an
26// Fl_Gl_Choice and returns a new OpenGL context. All contexts share
27// display lists with each other.
28//
29// On X another fl_create_gl_context is provided to create it for any
30// X visual.
31//
32// fl_set_gl_context makes the given OpenGL context current and makes
33// it draw into the passed window. It tracks the current one context
34// to avoid calling the context switching code when the same context
35// is used, though it is a mystery to me why the GLX/WGL libraries
36// don't do this themselves...
37//
38// fl_no_gl_context clears that cache so the next fl_set_gl_context is
39// guaranteed to work.
40//
41// fl_delete_gl_context destroys the context.
42//
43// This code is used by Fl_Gl_Window, gl_start(), and gl_visual()
44
45#ifndef Fl_Gl_Choice_H
46#define Fl_Gl_Choice_H
47
48// Warning: whatever GLContext is defined to must take exactly the same
49// space in a structure as a void*!!!
50#ifdef WIN32
51# include <FL/gl.h>
52# define GLContext HGLRC
53#elif defined(__APPLE_QUARTZ__)
54# include <OpenGL/gl.h>
55#ifdef __OBJC__
56@class NSOpenGLPixelFormat;
57@class NSOpenGLContext;
58#else
59 class NSOpenGLPixelFormat;
60 class NSOpenGLContext;
61#endif // __OBJC__
62 typedef NSOpenGLContext* FLOpenGLContextPtr;
63# define GLContext FLOpenGLContextPtr
64#else
65# include <GL/glx.h>
66# define GLContext GLXContext
67# if ! defined(GLX_VERSION_1_3)
68# typedef void *GLXFBConfig;
69# endif
70#endif
71
72// Describes crap needed to create a GLContext.
73 class Fl_Gl_Choice {
74 int mode;
75 const int *alist;
76 Fl_Gl_Choice *next;
77 public:
78#ifdef WIN32
79 int pixelformat; // the visual to use
80 PIXELFORMATDESCRIPTOR pfd; // some wgl calls need this thing
81#elif defined(__APPLE_QUARTZ__)
82 NSOpenGLPixelFormat* pixelformat;
83#else
84 XVisualInfo *vis; // the visual to use
85 Colormap colormap; // a colormap for that visual
86 GLXFBConfig best_fb;
87#endif
88 // Return one of these structures for a given gl mode.
89 // The second argument is a glX attribute list, and is used if mode is
90 // zero. This is not supported on Win32:
91 static Fl_Gl_Choice *find(int mode, const int *);
92};
93
94 class Fl_Window;
95
96#ifdef WIN32
97
98GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0);
99
100#elif defined(__APPLE_QUARTZ__)
101
102GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0);
103
104#else
105
106GLContext fl_create_gl_context(XVisualInfo* vis);
107
108//static inline
109 GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice* g);/* {
110 return fl_create_gl_context(g->vis);
111}*/
112
113#endif
114
115 void fl_set_gl_context(Fl_Window*, GLContext);
116 void fl_no_gl_context();
117 void fl_delete_gl_context(GLContext);
118
119#endif
120
121//
122// End of "$Id$".
123//
Fl_Gl_Choice
Definition: Fl_Gl_Choice.H:73
Fl_Window
This widget produces an actual window.
Definition: Fl_Window.H:57
gl.h
This file defines wrapper functions for OpenGL in FLTK.
- Copyright © 1998-2021 by Bill Spitzak and others.