FLTK 1.3.2

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

Fl_Gl_Choice.H

    00001 //
    00002 // "$Id: Fl_Gl_Choice.H 8864 2011-07-19 04:49:30Z greg.ercolano $"
    00003 //
    00004 // OpenGL definitions for the Fast Light Tool Kit (FLTK).
    00005 //
    00006 // Copyright 1998-2010 by Bill Spitzak and others.
    00007 //
    00008 // This library is free software. Distribution and use rights are outlined in
    00009 // the file "COPYING" which should have been included with this file.  If this
    00010 // file is missing or damaged, see the license at:
    00011 //
    00012 //     http://www.fltk.org/COPYING.php
    00013 //
    00014 // Please report all bugs and problems on the following page:
    00015 //
    00016 //     http://www.fltk.org/str.php
    00017 //
    00018
    00019 // Internal interface to set up OpenGL.
    00020 //
    00021 // A "Fl_Gl_Choice" is created from an OpenGL mode and holds information
    00022 // necessary to create a window (on X) and to create an OpenGL "context"
    00023 // (on both X and Win32).
    00024 //
    00025 // fl_create_gl_context takes a window (necessary only on Win32) and an
    00026 // Fl_Gl_Choice and returns a new OpenGL context. All contexts share
    00027 // display lists with each other.
    00028 //
    00029 // On X another fl_create_gl_context is provided to create it for any
    00030 // X visual.
    00031 //
    00032 // fl_set_gl_context makes the given OpenGL context current and makes
    00033 // it draw into the passed window. It tracks the current one context
    00034 // to avoid calling the context switching code when the same context
    00035 // is used, though it is a mystery to me why the GLX/WGL libraries
    00036 // don't do this themselves...
    00037 //
    00038 // fl_no_gl_context clears that cache so the next fl_set_gl_context is
    00039 // guaranteed to work.
    00040 //
    00041 // fl_delete_gl_context destroys the context.
    00042 //
    00043 // This code is used by Fl_Gl_Window, gl_start(), and gl_visual()
    00044
    00045 #ifndef Fl_Gl_Choice_H
    00046 #define Fl_Gl_Choice_H
    00047
    00048 // Warning: whatever GLContext is defined to must take exactly the same
    00049 // space in a structure as a void*!!!
    00050 #ifdef WIN32
    00051 #  include <FL/gl.h>
    00052 #  define GLContext HGLRC
    00053 #elif defined(__APPLE_QUARTZ__)
    00054 // warning: the Quartz version should probably use Core GL (CGL) instead of AGL
    00055 #  include <OpenGL/gl.h>
    00056 #  include <AGL/agl.h>
    00057 #  define GLContext AGLContext
    00058 #else
    00059 #  include <GL/glx.h>
    00060 #  define GLContext GLXContext
    00061 #endif
    00062
    00063 // Describes crap needed to create a GLContext.
    00064 class Fl_Gl_Choice {
    00065   int mode;
    00066   const int *alist;
    00067   Fl_Gl_Choice *next;
    00068 public:
    00069 #ifdef WIN32
    00070   int pixelformat;      // the visual to use
    00071   PIXELFORMATDESCRIPTOR pfd; // some wgl calls need this thing
    00072 #elif defined(__APPLE_QUARTZ__)
    00073   // warning: the Quartz version should probably use Core GL (CGL) instead of AGL
    00074   AGLPixelFormat pixelformat;
    00075 #else
    00076   XVisualInfo *vis;     // the visual to use
    00077   Colormap colormap;    // a colormap for that visual
    00078 #endif
    00079   // Return one of these structures for a given gl mode.
    00080   // The second argument is a glX attribute list, and is used if mode is
    00081   // zero.  This is not supported on Win32:
    00082   static Fl_Gl_Choice *find(int mode, const int *);
    00083 };
    00084
    00085 class Fl_Window;
    00086
    00087 #ifdef WIN32
    00088
    00089 GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0);
    00090
    00091 #elif defined(__APPLE_QUARTZ__)
    00092 // warning: the Quartz version should probably use Core GL (CGL) instead of AGL
    00093
    00094 GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0);
    00095
    00096 #else
    00097
    00098 GLContext fl_create_gl_context(XVisualInfo* vis);
    00099
    00100 static inline
    00101 GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice* g) {
    00102   return fl_create_gl_context(g->vis);
    00103 }
    00104
    00105 #endif
    00106
    00107 void fl_set_gl_context(Fl_Window*, GLContext);
    00108 void fl_no_gl_context();
    00109 void fl_delete_gl_context(GLContext);
    00110
    00111 #endif
    00112
    00113 //
    00114 // End of "$Id: Fl_Gl_Choice.H 8864 2011-07-19 04:49:30Z greg.ercolano $".
    00115 //