• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

Fl_Gl_Choice.H

00001 //
00002 // "$Id$"
00003 //
00004 // OpenGL definitions for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2018 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 #  include <OpenGL/gl.h>
00055 #ifdef __OBJC__
00056 @class NSOpenGLPixelFormat;
00057 @class NSOpenGLContext;
00058 #else
00059 class NSOpenGLPixelFormat;
00060 class NSOpenGLContext;
00061 #endif // __OBJC__
00062 typedef NSOpenGLContext* FLOpenGLContextPtr;
00063 #  define GLContext FLOpenGLContextPtr
00064 #else
00065 #  include <GL/glx.h>
00066 #  define GLContext GLXContext
00067 #  if ! defined(GLX_VERSION_1_3)
00068 #    typedef void *GLXFBConfig;
00069 #  endif
00070 #endif
00071 
00072 // Describes crap needed to create a GLContext.
00073 class Fl_Gl_Choice {
00074   int mode;
00075   const int *alist;
00076   Fl_Gl_Choice *next;
00077 public:
00078 #ifdef WIN32
00079   int pixelformat;      // the visual to use
00080   PIXELFORMATDESCRIPTOR pfd; // some wgl calls need this thing
00081 #elif defined(__APPLE_QUARTZ__)
00082   NSOpenGLPixelFormat* pixelformat;
00083 #else
00084   XVisualInfo *vis;     // the visual to use
00085   Colormap colormap;    // a colormap for that visual
00086   GLXFBConfig best_fb;
00087 #endif
00088   // Return one of these structures for a given gl mode.
00089   // The second argument is a glX attribute list, and is used if mode is
00090   // zero.  This is not supported on Win32:
00091   static Fl_Gl_Choice *find(int mode, const int *);
00092 };
00093 
00094 class Fl_Window;
00095 
00096 #ifdef WIN32
00097 
00098 GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0);
00099 
00100 #elif defined(__APPLE_QUARTZ__)
00101 
00102 GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0);
00103 
00104 #else
00105 
00106 GLContext fl_create_gl_context(XVisualInfo* vis);
00107 
00108 //static inline
00109  GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice* g);/* {
00110   return fl_create_gl_context(g->vis);
00111 }*/
00112 
00113 #endif
00114 
00115 void fl_set_gl_context(Fl_Window*, GLContext);
00116 void fl_no_gl_context();
00117 void fl_delete_gl_context(GLContext);
00118 
00119 #endif
00120 
00121 //
00122 // End of "$Id$".
00123 //
  • © 1998-2016 by Bill Spitzak and others.     FLTK

  • © 1998-2016 by Bill Spitzak and others.     FLTK

    Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.