summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Fl.cxx81
-rw-r--r--src/Fl_Gl_Window.cxx139
-rw-r--r--src/config_lib.h92
-rw-r--r--src/gl_draw.cxx3
4 files changed, 313 insertions, 2 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx
index db4e8de4e..3de2de770 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -21,7 +21,7 @@
// mostly to get around the single active context in QD and
// to implement clipping. This should be changed into pure
// Quartz calls in the near future.
-#include <config.h>
+#include "config_lib.h"
/* We require Windows 2000 features (e.g. VK definitions) */
#if defined(WIN32)
@@ -76,6 +76,85 @@ void fl_cleanup_dc_list(void);
extern double fl_mac_flush_and_wait(double time_to_wait);
#endif // WIN32
+
+//
+// Runtime configuartion flags
+//
+#ifdef FL_CFG_GFX_XLIB
+bool Fl::cfg_gfx_xlib = 1;
+#else
+bool Fl::cfg_gfx_xlib = 0;
+#endif
+#ifdef FL_CFG_GFX_QUARTZ
+bool Fl::cgf_gfx_quartz = 1;
+#else
+bool Fl::cgf_gfx_quartz = 0;
+#endif
+#ifdef FL_CFG_GFX_GDI
+bool Fl::cfg_gfx_gdi = 1;
+#else
+bool Fl::cfg_gfx_gdi = 0;
+#endif
+#ifdef FL_CFG_GFX_OPENGL
+bool Fl::cfg_gfx_opengl = 1;
+#else
+bool Fl::cfg_gfx_opengl = 0;
+#endif
+#ifdef FL_CFG_GFX_CAIRO
+bool Fl::cfg_gfx_cairo = 1;
+#else
+bool Fl::cfg_gfx_cairo = 0;
+#endif
+#ifdef FL_CFG_GFX_DIRECTX
+bool Fl::cfg_gfx_directx = 1;
+#else
+bool Fl::cfg_gfx_directx = 0;
+#endif
+
+#ifdef FL_CFG_PRN_PS
+bool Fl::cfg_prn_ps = 1;
+#else
+bool Fl::cfg_prn_ps = 0;
+#endif
+#ifdef FL_CFG_PRN_QUARTZ
+bool Fl::cgf_prn_quartz = 1;
+#else
+bool Fl::cgf_prn_quartz = 0;
+#endif
+#ifdef FL_CFG_PRN_GDI
+bool Fl::cfg_prn_gdi = 1;
+#else
+bool Fl::cfg_prn_gdi = 0;
+#endif
+
+#ifdef FL_CFG_WIN_X11
+bool Fl::cfg_win_x11 = 1;
+#else
+bool Fl::cfg_win_x11 = 0;
+#endif
+#ifdef FL_CFG_WIN_COCOA
+bool Fl::cgf_win_cocoa = 1;
+#else
+bool Fl::cgf_win_cocoa = 0;
+#endif
+#ifdef FL_CFG_WIN_WIN32
+bool Fl::cfg_win_win32 = 1;
+#else
+bool Fl::cfg_win_win32 = 0;
+#endif
+
+#ifdef FL_SYS_POSIX
+bool Fl::cfg_sys_posix = 1;
+#else
+bool Fl::cfg_sys_posix = 0;
+#endif
+#ifdef FL_SYS_WIN32
+bool Fl::cfg_sys_win32 = 1;
+#else
+bool Fl::cfg_sys_win32 = 0;
+#endif
+
+
//
// Globals...
//
diff --git a/src/Fl_Gl_Window.cxx b/src/Fl_Gl_Window.cxx
index 02d238332..4fe8ca13e 100644
--- a/src/Fl_Gl_Window.cxx
+++ b/src/Fl_Gl_Window.cxx
@@ -17,6 +17,7 @@
//
#include "flstring.h"
+#include "config_lib.h"
#if HAVE_GL
extern int fl_gl_load_plugin;
@@ -29,6 +30,7 @@ extern int fl_gl_load_plugin;
#include <OpenGL/OpenGL.h>
#endif
#include <FL/Fl_Gl_Window.H>
+#include <FL/Fl_Device.H>
#include <stdlib.h>
#include <FL/fl_utf8.h>
@@ -38,6 +40,123 @@ extern int fl_gl_load_plugin;
#else
#endif
+
+// ------ this should be in a separate file! -----------------------------------
+#ifdef FL_CFG_GFX_OPENGL
+
+#include <FL/Fl_Device.h>
+
+/**
+ \brief OpenGL pecific graphics class.
+ *
+ This class is implemented only on the Mac OS X platform.
+ */
+class FL_EXPORT Fl_OpenGL_Graphics_Driver : public Fl_Graphics_Driver {
+public:
+ static const char *class_id;
+ const char *class_name() {return class_id;};
+ void draw(const char* str, int n, int x, int y) {
+ gl_draw(str, n, x, y);
+ }
+ void color(Fl_Color c) {
+ gl_color(c);
+ }
+ void color(uchar r, uchar g, uchar b) {
+ unsigned int c = (r<<24)|(g<<16)|(b<<8);
+ gl_color(c);
+ }
+ void rectf(int x, int y, int w, int h) {
+ glBegin(GL_POLYGON);
+ glVertex2i(x, y);
+ glVertex2i(x+w-1, y);
+ glVertex2i(x+w-1, y+h-1);
+ glVertex2i(x, y+h-1);
+ glEnd();
+ }
+ void line(int x, int y, int x1, int y1) {
+ glBegin(GL_LINE_STRIP);
+ glVertex2i(x, y);
+ glVertex2i(x1, y1);
+ glEnd();
+ }
+ void xyline(int x, int y, int x1) {
+ glBegin(GL_LINE_STRIP);
+ glVertex2i(x, y);
+ glVertex2i(x1, y);
+ glEnd();
+ }
+ void xyline(int x, int y, int x1, int y2) {
+ glBegin(GL_LINE_STRIP);
+ glVertex2i(x, y);
+ glVertex2i(x1, y);
+ glVertex2i(x1, y2);
+ glEnd();
+ }
+ void xyline(int x, int y, int x1, int y2, int x3) {
+ glBegin(GL_LINE_STRIP);
+ glVertex2i(x, y);
+ glVertex2i(x1, y);
+ glVertex2i(x1, y2);
+ glVertex2i(x3, y2);
+ glEnd();
+ }
+ void yxline(int x, int y, int y1) {
+ glBegin(GL_LINE_STRIP);
+ glVertex2i(x, y);
+ glVertex2i(x, y1);
+ glEnd();
+ }
+ void yxline(int x, int y, int y1, int x2) {
+ glBegin(GL_LINE_STRIP);
+ glVertex2i(x, y);
+ glVertex2i(x, y1);
+ glVertex2i(x2, y1);
+ glEnd();
+ }
+ void yxline(int x, int y, int y1, int x2, int y3) {
+ glBegin(GL_LINE_STRIP);
+ glVertex2i(x, y);
+ glVertex2i(x, y1);
+ glVertex2i(x2, y1);
+ glVertex2i(x2, y3);
+ glEnd();
+ }
+
+ /*
+#ifdef __APPLE__
+ void draw(const char *str, int n, float x, float y);
+#endif
+ void draw(int angle, const char *str, int n, int x, int y);
+ void rtl_draw(const char* str, int n, int x, int y);
+ void font(Fl_Font face, Fl_Fontsize size);
+ void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
+ void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
+ void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy);
+ int draw_scaled(Fl_Image *img, int XP, int YP, int WP, int HP);
+ void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0);
+ void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3);
+ void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0);
+ void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1);
+ double width(const char *str, int n);
+ double width(unsigned int c);
+ void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h);
+ int height();
+ int descent();
+#if ! defined(FL_DOXYGEN)
+ static Fl_Offscreen create_offscreen_with_alpha(int w, int h);
+#endif
+ void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
+*/
+};
+
+const char *Fl_OpenGL_Graphics_Driver::class_id = "Fl_OpenGL_Graphics_Driver";
+
+Fl_OpenGL_Graphics_Driver fl_opengl_graphics_driver;
+
+#endif
+// ------ end of separate file! ------------------------------------------------
+
+
////////////////////////////////////////////////////////////////
// The symbol SWAP_TYPE defines what is in the back buffer after doing
@@ -539,7 +658,25 @@ void Fl_Gl_Window::draw_overlay() {}
buffers are swapped after this function is completed.
*/
void Fl_Gl_Window::draw() {
- Fl::fatal("Fl_Gl_Window::draw() *must* be overriden. Please refer to the documentation.");
+#ifdef FL_CFG_GFX_OPENGL
+ Fl_Graphics_Driver *prev_driver = fl_graphics_driver;
+ fl_graphics_driver = &fl_opengl_graphics_driver;
+ glPushAttrib(GL_ENABLE_BIT);
+ glDisable(GL_DEPTH_TEST);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(-0.5, w()-0.5, h()-0.5, -0.5, -1, 1);
+// glOrtho(0, w(), h(), 0, -1, 1);
+ glLineWidth(pixels_per_unit());
+
+ Fl_Window::draw();
+
+ glPopMatrix();
+ glPushAttrib(GL_ENABLE_BIT);
+ fl_graphics_driver = prev_driver;
+#else
+ Fl::fatal("Fl_Gl_Window::draw() *must* be overriden. Please refer to the documentation.");
+#endif
}
diff --git a/src/config_lib.h b/src/config_lib.h
new file mode 100644
index 000000000..6e5c8738b
--- /dev/null
+++ b/src/config_lib.h
@@ -0,0 +1,92 @@
+/*
+ * "$Id$"
+ *
+ * Configuration file for the Fast Light Tool Kit (FLTK).
+ *
+ * Copyright 1998-2011 by Bill Spitzak and others.
+ */
+
+#ifndef FL_CONFIG_LIB_H
+#define FL_CONFIG_LIB_H
+
+#include <config.h>
+
+
+// find the right graphics configuration
+#if !defined(FL_CFG_GFX_XLIB) && !defined(FL_CFG_GFX_QUARTZ) && !defined(FL_CFG_GFX_GDI)
+
+#ifdef __APPLE__
+# define FL_CFG_GFX_QUARTZ
+# ifdef HAVE_GL
+# define FL_CFG_GFX_OPENGL
+# endif
+#elif defined(WIN32)
+# define FL_CFG_GFX_GDI
+# ifdef HAVE_GL
+# define FL_CFG_GFX_OPENGL
+# endif
+#elif defined(FL_PORTING)
+# pragma message "FL_PORTING: please choose a core graphics library
+#else // X11
+# define FL_CFG_GFX_XLIB
+# ifdef HAVE_GL
+# define FL_CFG_GFX_OPENGL
+# endif
+#endif
+
+#endif
+
+
+// find the right printer driver configuration
+#if !defined(FL_CFG_PRN_PS) && !defined(FL_CFG_PRN_QUARTZ) && !defined(FL_CFG_PRN_WIN32)
+
+#ifdef __APPLE__
+# define FL_CFG_PRN_QUARTZ
+#elif defined(WIN32)
+# define FL_CFG_WIN_WIN32
+#elif defined(FL_PORTING)
+# pragma message "FL_PORTING: please choose a graphics driver library
+#else // X11
+# define FL_CFG_GFX_PS
+#endif
+
+#endif
+
+
+// find the right window manager configuration
+#if !defined(FL_CFG_WIN_X11) && !defined(FL_CFG_WIN_COCOA) && !defined(FL_CFG_WIN_WIN32)
+
+#ifdef __APPLE__
+# define FL_CFG_WIN_COCOA
+#elif defined(WIN32)
+# define FL_CFG_WIN_WIN32
+#elif defined(FL_PORTING)
+# pragma message "FL_PORTING: please choose a window management library
+#else // X11
+# define FL_CFG_GFX_X11
+#endif
+
+#endif
+
+
+// find the right system configuration
+#if !defined(FL_CFG_SYS_POSIX) && !defined(FL_CFG_SYS_WIN32)
+
+#ifdef __APPLE__
+# define FL_CFG_SYS_POSIX
+#elif defined(WIN32)
+# define FL_CFG_SYS_WIN32
+#elif defined(FL_PORTING)
+# pragma message "FL_PORTING: please choose a system library
+#else // X11
+# define FL_CFG_SYS_POSIX
+#endif
+
+#endif
+
+
+#endif
+
+/*
+ * End of "$Id$".
+ */
diff --git a/src/gl_draw.cxx b/src/gl_draw.cxx
index d8500ac75..2fa8f8380 100644
--- a/src/gl_draw.cxx
+++ b/src/gl_draw.cxx
@@ -469,6 +469,8 @@ void gl_texture_fifo::display_texture(int rank)
// pre-computes a string texture
int gl_texture_fifo::compute_texture(const char* str, int n)
{
+ Fl_Graphics_Driver *prev_driver = fl_graphics_driver;
+ fl_graphics_driver = Fl_Display_Device::display_device()->driver();
current = (current + 1) % size_;
if (current > last) last = current;
if ( fifo[current].utf8 ) free(fifo[current].utf8);
@@ -510,6 +512,7 @@ int gl_texture_fifo::compute_texture(const char* str, int n)
} else {
fifo[current].ratio = float(fifo[current].width)/glutStrokeLength(GLUT_STROKE_ROMAN, (uchar*)fifo[current].utf8);
}
+ fl_graphics_driver = prev_driver;
return current;
}