FLTK 1.3.0
|
00001 // 00002 // "$Id$" 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; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Library General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00021 // USA. 00022 // 00023 // Please report all bugs and problems on the following page: 00024 // 00025 // http://www.fltk.org/str.php 00026 // 00027 00028 // Internal interface to set up OpenGL. 00029 // 00030 // A "Fl_Gl_Choice" is created from an OpenGL mode and holds information 00031 // necessary to create a window (on X) and to create an OpenGL "context" 00032 // (on both X and Win32). 00033 // 00034 // fl_create_gl_context takes a window (necessary only on Win32) and an 00035 // Fl_Gl_Choice and returns a new OpenGL context. All contexts share 00036 // display lists with each other. 00037 // 00038 // On X another fl_create_gl_context is provided to create it for any 00039 // X visual. 00040 // 00041 // fl_set_gl_context makes the given OpenGL context current and makes 00042 // it draw into the passed window. It tracks the current one context 00043 // to avoid calling the context switching code when the same context 00044 // is used, though it is a mystery to me why the GLX/WGL libraries 00045 // don't do this themselves... 00046 // 00047 // fl_no_gl_context clears that cache so the next fl_set_gl_context is 00048 // guaranteed to work. 00049 // 00050 // fl_delete_gl_context destroys the context. 00051 // 00052 // This code is used by Fl_Gl_Window, gl_start(), and gl_visual() 00053 00054 #ifndef Fl_Gl_Choice_H 00055 #define Fl_Gl_Choice_H 00056 00057 // Warning: whatever GLContext is defined to must take exactly the same 00058 // space in a structure as a void*!!! 00059 #ifdef WIN32 00060 # include <FL/gl.h> 00061 # define GLContext HGLRC 00062 #elif defined(__APPLE_QUARTZ__) 00063 // warning: the Quartz version should probably use Core GL (CGL) instead of AGL 00064 # include <OpenGL/gl.h> 00065 # include <AGL/agl.h> 00066 # define GLContext AGLContext 00067 #else 00068 # include <GL/glx.h> 00069 # define GLContext GLXContext 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 // warning: the Quartz version should probably use Core GL (CGL) instead of AGL 00083 AGLPixelFormat pixelformat; 00084 #else 00085 XVisualInfo *vis; // the visual to use 00086 Colormap colormap; // a colormap for that visual 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 // warning: the Quartz version should probably use Core GL (CGL) instead of AGL 00102 00103 GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0); 00104 00105 #else 00106 00107 GLContext fl_create_gl_context(XVisualInfo* vis); 00108 00109 static inline 00110 GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice* g) { 00111 return fl_create_gl_context(g->vis); 00112 } 00113 00114 #endif 00115 00116 void fl_set_gl_context(Fl_Window*, GLContext); 00117 void fl_no_gl_context(); 00118 void fl_delete_gl_context(GLContext); 00119 00120 #endif 00121 00122 // 00123 // End of "$Id$". 00124 //