summaryrefslogtreecommitdiff
path: root/src/gl_start.cxx
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-05-08 06:42:57 +0000
committerManolo Gouy <Manolo>2016-05-08 06:42:57 +0000
commit300747225ca2de6db483287fa44ed24d18765b99 (patch)
tree6fb63553203032bc98f4dd84b3162c8e306ffc32 /src/gl_start.cxx
parent048bb2b0f6ea49d0a88eee879017949bbd1ac83d (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/gl_start.cxx')
-rw-r--r--src/gl_start.cxx86
1 files changed, 40 insertions, 46 deletions
diff --git a/src/gl_start.cxx b/src/gl_start.cxx
index a9da93f73..9ca2717ef 100644
--- a/src/gl_start.cxx
+++ b/src/gl_start.cxx
@@ -3,7 +3,7 @@
//
// OpenGL context routines 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
@@ -28,56 +28,31 @@
// be erased when the buffers are swapped (when double buffer hardware
// is being used)
-#if defined(WIN32) // PORTME: platform opengl
-#elif defined(__APPLE__)
-#include "drivers/Cocoa/Fl_Cocoa_Screen_Driver.H"
-#elif defined(FL_PORTING)
-# pragma message "FL_PORTING: if possible, add OpenGL rendering in non-OpenGL contexts"
-#else
-#endif
-
-#include <config.h>
+#include "config_lib.h"
#if HAVE_GL
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
-#include <FL/x.H>
#include <FL/fl_draw.H>
#include <FL/gl.h>
#include "Fl_Gl_Choice.H"
+#include <FL/Fl_Gl_Window.H>
+#include <FL/Fl_Gl_Window_Driver.H>
static GLContext context;
static int clip_state_number=-1;
static int pw, ph;
-#ifdef WIN32
-static Fl_Gl_Choice* gl_choice;
-#endif
-
-#ifdef __APPLE__
static Fl_Gl_Choice* gl_choice;
-#endif
/** Creates an OpenGL context */
void gl_start() {
if (!context) {
-#if defined(USE_X11)
- context = fl_create_gl_context(fl_visual);
-#elif defined(WIN32)
if (!gl_choice) Fl::gl_visual(0);
- context = fl_create_gl_context(Fl_Window::current(), gl_choice);
-#elif defined(__APPLE_QUARTZ__)
- context = fl_create_gl_context(Fl_Window::current(), gl_choice);
-#else
-# error Unsupported platform
-#endif
+ context = Fl_Gl_Window_Driver::global()->create_gl_context(Fl_Window::current(), gl_choice);
}
- fl_set_gl_context(Fl_Window::current(), context);
-#ifdef __APPLE__
- Fl_Cocoa_Screen_Driver::GLcontext_update(context); // supports window resizing
-#elif !defined(WIN32)
- glXWaitX();
-#endif
+ Fl_Gl_Window_Driver::global()->set_gl_context(Fl_Window::current(), context);
+ Fl_Gl_Window_Driver::global()->gl_start();
if (pw != Fl_Window::current()->w() || ph != Fl_Window::current()->h()) {
pw = Fl_Window::current()->w();
ph = Fl_Window::current()->h();
@@ -103,27 +78,46 @@ void gl_start() {
/** Releases an OpenGL context */
void gl_finish() {
glFlush();
-#if !defined(WIN32) && !defined(__APPLE__)
- glXWaitGL();
+ Fl_Gl_Window_Driver::global()->waitGL();
+}
+
+void Fl_Gl_Window_Driver::gl_visual(Fl_Gl_Choice *c) {
+ gl_choice = c;
+}
+
+#ifdef FL_CFG_GFX_QUARTZ
+#include "drivers/Cocoa/Fl_Cocoa_Screen_Driver.H"
+
+void Fl_Cocoa_Gl_Window_Driver::gl_start() {
+ Fl_Cocoa_Screen_Driver::GLcontext_update(context); // supports window resizing
+}
+
#endif
+
+
+#ifdef FL_CFG_GFX_XLIB
+#include <FL/x.H>
+
+void Fl_X11_Gl_Window_Driver::gl_visual(Fl_Gl_Choice *c) {
+ Fl_Gl_Window_Driver::gl_visual(c);
+ fl_visual = c->vis;
+ fl_colormap = c->colormap;
}
+void Fl_X11_Gl_Window_Driver::gl_start() {
+ glXWaitX();
+}
+
+#endif // FL_CFG_GFX_XLIB
+
int Fl::gl_visual(int mode, int *alist) {
- Fl_Gl_Choice *c = Fl_Gl_Choice::find(mode,alist);
+ Fl_Gl_Choice *c = Fl_Gl_Window_Driver::global()->find(mode,alist);
if (!c) return 0;
-#if defined(USE_X11)
- fl_visual = c->vis;
- fl_colormap = c->colormap;
-#elif defined(WIN32)
- gl_choice = c;
-#elif defined(__APPLE_QUARTZ__)
- gl_choice = c;
-#else
-# error Unsupported platform
-#endif
+ Fl_Gl_Window_Driver::global()->gl_visual(c);
return 1;
}
-#endif
+
+#endif // HAVE_GL
//
// End of "$Id$".