diff options
| author | Manolo Gouy <Manolo> | 2016-05-08 06:42:57 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2016-05-08 06:42:57 +0000 |
| commit | 300747225ca2de6db483287fa44ed24d18765b99 (patch) | |
| tree | 6fb63553203032bc98f4dd84b3162c8e306ffc32 /src/Fl_Gl_Choice.H | |
| parent | 048bb2b0f6ea49d0a88eee879017949bbd1ac83d (diff) | |
Rewrite OpenGL-related code under the driver model.
Class Fl_Gl_Window_Driver, with its platform-specific derived classes, is created
to hold platform-specific, OpenGL code.
File gl_draw.cxx still needs to be converted to the driver model.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11716 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Gl_Choice.H')
| -rw-r--r-- | src/Fl_Gl_Choice.H | 100 |
1 files changed, 42 insertions, 58 deletions
diff --git a/src/Fl_Gl_Choice.H b/src/Fl_Gl_Choice.H index a9de81b1f..8e1a6bc93 100644 --- a/src/Fl_Gl_Choice.H +++ b/src/Fl_Gl_Choice.H @@ -3,7 +3,7 @@ // // OpenGL definitions for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2010 by Bill Spitzak and others. +// Copyright 1998-2016 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -22,41 +22,29 @@ // necessary to create a window (on X) and to create an OpenGL "context" // (on both X and Win32). // -// fl_create_gl_context takes a window (necessary only on Win32) and an +// create_gl_context takes a window (necessary only on Win32) and an // Fl_Gl_Choice and returns a new OpenGL context. All contexts share // display lists with each other. // -// On X another fl_create_gl_context is provided to create it for any +// On X another create_gl_context is provided to create it for any // X visual. // -// fl_set_gl_context makes the given OpenGL context current and makes +// set_gl_context makes the given OpenGL context current and makes // it draw into the passed window. It tracks the current one context // to avoid calling the context switching code when the same context // is used, though it is a mystery to me why the GLX/WGL libraries // don't do this themselves... // -// fl_no_gl_context clears that cache so the next fl_set_gl_context is -// guaranteed to work. -// -// fl_delete_gl_context destroys the context. +// delete_gl_context destroys the context. // // This code is used by Fl_Gl_Window, gl_start(), and gl_visual() #ifndef Fl_Gl_Choice_H #define Fl_Gl_Choice_H -#if defined(WIN32) || defined(__APPLE__) // PORTME: platform OpenGL management -#elif defined(FL_PORTING) -# pragma message "FL_PORTING: add code to list and select OpenGL drawing contexts" -#else -#endif -// Warning: whatever GLContext is defined to must take exactly the same -// space in a structure as a void*!!! -#ifdef WIN32 -# include <FL/gl.h> -# define GLContext HGLRC -#elif defined(__APPLE_QUARTZ__) // PORTME: platform OpenGL management +#ifdef FL_CFG_GFX_QUARTZ + # include <OpenGL/gl.h> #ifdef __OBJC__ @class NSOpenGLPixelFormat; @@ -67,64 +55,60 @@ class NSOpenGLContext; #endif // __OBJC__ typedef NSOpenGLContext* FLOpenGLContextPtr; # define GLContext FLOpenGLContextPtr -#else -# include <GL/glx.h> -# define GLContext GLXContext -#endif -// Describes crap needed to create a GLContext. +// Describes crap needed to create a GLContext under Mac OS X. class Fl_Gl_Choice { + friend class Fl_Gl_Window_Driver; int mode; const int *alist; Fl_Gl_Choice *next; public: -#ifdef WIN32 - int pixelformat; // the visual to use - PIXELFORMATDESCRIPTOR pfd; // some wgl calls need this thing -#elif defined(__APPLE_QUARTZ__) // PORTME: platform OpenGL management + Fl_Gl_Choice(int m, const int *alistp, Fl_Gl_Choice *n) : mode(m), alist(alistp), next(n) {} NSOpenGLPixelFormat* pixelformat; -#elif defined(FL_PORTING) -# pragma message "FL_PORTING: define OpenGL pixel format containers" -#else - XVisualInfo *vis; // the visual to use - Colormap colormap; // a colormap for that visual -#endif - // Return one of these structures for a given gl mode. - // The second argument is a glX attribute list, and is used if mode is - // zero. This is not supported on Win32: - static Fl_Gl_Choice *find(int mode, const int *); }; -class Fl_Window; - -#ifdef WIN32 +#endif // FL_CFG_GFX_QUARTZ -GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0); +#ifdef FL_CFG_GFX_GDI -#elif defined(__APPLE_QUARTZ__) // PORTME: platform OpenGL management - -GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0); +# include <FL/gl.h> +# define GLContext HGLRC -#elif defined(FL_PORTING) +// Describes crap needed to create a GLContext under MSWindows. +class Fl_Gl_Choice { + friend class Fl_Gl_Window_Driver; + int mode; + const int *alist; + Fl_Gl_Choice *next; +public: + Fl_Gl_Choice(int m, const int *alistp, Fl_Gl_Choice *n) : mode(m), alist(alistp), next(n) {} + int pixelformat; // the visual to use + PIXELFORMATDESCRIPTOR pfd; // some wgl calls need this thing +}; -# pragma message "FL_PORTING: define fl_create_gl_context function" +#endif // FL_CFG_GFX_GDI -#else +#ifdef FL_CFG_GFX_XLIB -GLContext fl_create_gl_context(XVisualInfo* vis); +# include <GL/glx.h> +# define GLContext GLXContext -static inline -GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice* g) { - return fl_create_gl_context(g->vis); -} +// Describes crap needed to create a GLContext under X11. +class Fl_Gl_Choice { + friend class Fl_Gl_Window_Driver; + int mode; + const int *alist; + Fl_Gl_Choice *next; +public: + Fl_Gl_Choice(int m, const int *alistp, Fl_Gl_Choice *n) : mode(m), alist(alistp), next(n) {} + XVisualInfo *vis; // the visual to use + Colormap colormap; // a colormap for that visual +}; -#endif +#endif // FL_CFG_GFX_XLIB -void fl_set_gl_context(Fl_Window*, GLContext); -void fl_no_gl_context(); -void fl_delete_gl_context(GLContext); -#endif +#endif // Fl_Gl_Choice_H // // End of "$Id$". |
