summaryrefslogtreecommitdiff
path: root/src/drivers/WinAPI
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/WinAPI')
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.H64
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx35
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx11
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx9
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx6
-rw-r--r--src/drivers/WinAPI/fl_WinAPI_gl_platform_init.cxx24
-rw-r--r--src/drivers/WinAPI/fl_WinAPI_platform_init.cxx69
7 files changed, 158 insertions, 60 deletions
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.H
new file mode 100644
index 000000000..efece9d19
--- /dev/null
+++ b/src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.H
@@ -0,0 +1,64 @@
+//
+// Class Fl_Wayland_Gl_Window_Driver for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 2021-2022 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
+// file is missing or damaged, see the license at:
+//
+// https://www.fltk.org/COPYING.php
+//
+// Please see the following page on how to report bugs and issues:
+//
+// https://www.fltk.org/bugs.php
+//
+
+#ifndef FL_WINAPI_GL_WINDOW_DRIVER_H
+#define FL_WINAPI_GL_WINDOW_DRIVER_H
+
+#include <config.h>
+#if HAVE_GL
+#include <FL/platform.H>
+#include "../../Fl_Gl_Window_Driver.H"
+#include <FL/gl.h>
+
+/* Implementation note about OpenGL drawing on the Wayland platform
+
+After eglCreateWindowSurface() with attributes {EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER, EGL_NONE},
+eglQueryContext() reports that EGL_RENDER_BUFFER equals EGL_BACK_BUFFER.
+This experiment suggests that the platform only supports double-buffer drawing.
+Consequently, FL_DOUBLE is enforced in all Fl_Gl_Window::mode_ values under Wayland.
+*/
+
+class Fl_WinAPI_Gl_Window_Driver : public Fl_Gl_Window_Driver {
+ friend class Fl_Gl_Window_Driver;
+ Fl_WinAPI_Gl_Window_Driver(Fl_Gl_Window *win) : Fl_Gl_Window_Driver(win) {}
+ virtual float pixels_per_unit();
+ virtual int mode_(int m, const int *a);
+ virtual void make_current_after();
+ virtual void swap_buffers();
+ virtual void invalidate() {}
+ virtual int flush_begin(char& valid_f);
+ virtual Fl_Gl_Choice *find(int m, const int *alistp);
+ virtual GLContext create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer = 0);
+ virtual void set_gl_context(Fl_Window* w, GLContext context);
+ virtual void delete_gl_context(GLContext);
+ virtual void make_overlay_current();
+ virtual void redraw_overlay();
+ virtual void* GetProcAddress(const char *procName);
+ virtual void draw_string_legacy(const char* str, int n);
+ virtual void gl_bitmap_font(Fl_Font_Descriptor *fl_fontsize);
+ virtual void get_list(Fl_Font_Descriptor *fd, int r);
+ virtual int genlistsize();
+#if HAVE_GL_OVERLAY
+ virtual void gl_hide_before(void *& overlay);
+ virtual int can_do_overlay();
+ virtual int overlay_color(Fl_Color i);
+ void make_overlay(void*&overlay);
+#endif
+};
+
+#endif // HAVE_GL
+
+#endif // FL_WINAPI_GL_WINDOW_DRIVER_H
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx
index 1dbc9f77d..cd6e98646 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx
+++ b/src/drivers/WinAPI/Fl_WinAPI_Gl_Window_Driver.cxx
@@ -19,7 +19,7 @@
#include <FL/platform.H>
#include "../../Fl_Screen_Driver.H"
#include <FL/gl.h>
-#include "../../Fl_Gl_Window_Driver.H"
+#include "Fl_WinAPI_Gl_Window_Driver.H"
#include "../../Fl_Gl_Choice.H"
#include "Fl_WinAPI_Window_Driver.H"
#include "../GDI/Fl_Font.H"
@@ -36,34 +36,6 @@ extern void fl_save_dc(HWND, HDC);
#define DEBUG_PFD (0) // 1 = PFD selection debug output, 0 = no debug output
-class Fl_WinAPI_Gl_Window_Driver : public Fl_Gl_Window_Driver {
- friend class Fl_Gl_Window_Driver;
- Fl_WinAPI_Gl_Window_Driver(Fl_Gl_Window *win) : Fl_Gl_Window_Driver(win) {}
- virtual float pixels_per_unit();
- virtual int mode_(int m, const int *a);
- virtual void make_current_after();
- virtual void swap_buffers();
- virtual void invalidate() {}
- virtual int flush_begin(char& valid_f);
- virtual Fl_Gl_Choice *find(int m, const int *alistp);
- virtual GLContext create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer = 0);
- virtual void set_gl_context(Fl_Window* w, GLContext context);
- virtual void delete_gl_context(GLContext);
- virtual void make_overlay_current();
- virtual void redraw_overlay();
- virtual void* GetProcAddress(const char *procName);
- virtual void draw_string_legacy(const char* str, int n);
- virtual void gl_bitmap_font(Fl_Font_Descriptor *fl_fontsize);
- virtual void get_list(Fl_Font_Descriptor *fd, int r);
- virtual int genlistsize();
-#if HAVE_GL_OVERLAY
- virtual void gl_hide_before(void *& overlay);
- virtual int can_do_overlay();
- virtual int overlay_color(Fl_Color i);
- void make_overlay(void*&overlay);
-#endif
-};
-
// Describes crap needed to create a GLContext.
class Fl_WinAPI_Gl_Choice : public Fl_Gl_Choice {
friend class Fl_WinAPI_Gl_Window_Driver;
@@ -292,11 +264,6 @@ int Fl_WinAPI_Gl_Window_Driver::overlay_color(Fl_Color i) {
#endif // HAVE_GL_OVERLAY
-Fl_Gl_Window_Driver *Fl_Gl_Window_Driver::newGlWindowDriver(Fl_Gl_Window *w)
-{
- return new Fl_WinAPI_Gl_Window_Driver(w);
-}
-
float Fl_WinAPI_Gl_Window_Driver::pixels_per_unit()
{
int ns = Fl_Window_Driver::driver(pWindow)->screen_num();
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx
index 489e7fe8d..be9dac6bd 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx
+++ b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx
@@ -39,17 +39,6 @@ extern const char *fl_bg2;
#endif // !HMONITOR_DECLARED && _WIN32_WINNT < 0x0500
-/*
- Creates a driver that manages all screen and display related calls.
-
- This function must be implemented once for every platform.
- */
-Fl_Screen_Driver *Fl_Screen_Driver::newScreenDriver()
-{
- return new Fl_WinAPI_Screen_Driver();
-}
-
-
int Fl_WinAPI_Screen_Driver::visual(int flags)
{
fl_GetDC(0);
diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx
index e88ac8e9b..18f6b3e3e 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx
+++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx
@@ -144,15 +144,6 @@ static char *wchar_to_utf8(const wchar_t *wstr, char *&utf8) {
return utf8;
}
-/*
- Creates a driver that manages all system related calls.
-
- This function must be implemented once for every platform.
- */
-Fl_System_Driver *Fl_System_Driver::newSystemDriver() {
- return new Fl_WinAPI_System_Driver();
-}
-
void Fl_WinAPI_System_Driver::warning(const char *format, va_list args) {
// Show nothing for warnings under Windows...
}
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
index a3bf07a82..52116778c 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
+++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
@@ -35,12 +35,6 @@ extern HPALETTE fl_select_palette(void); // in fl_color_win32.cxx
#endif
-Fl_Window_Driver *Fl_Window_Driver::newWindowDriver(Fl_Window *w)
-{
- return new Fl_WinAPI_Window_Driver(w);
-}
-
-
Fl_WinAPI_Window_Driver::Fl_WinAPI_Window_Driver(Fl_Window *win)
: Fl_Window_Driver(win)
{
diff --git a/src/drivers/WinAPI/fl_WinAPI_gl_platform_init.cxx b/src/drivers/WinAPI/fl_WinAPI_gl_platform_init.cxx
new file mode 100644
index 000000000..f5b26be64
--- /dev/null
+++ b/src/drivers/WinAPI/fl_WinAPI_gl_platform_init.cxx
@@ -0,0 +1,24 @@
+//
+// Wayland-specific code to initialize wayland support.
+//
+// Copyright 2022 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
+// file is missing or damaged, see the license at:
+//
+// https://www.fltk.org/COPYING.php
+//
+// Please see the following page on how to report bugs and issues:
+//
+// https://www.fltk.org/bugs.php
+//
+
+
+#include "Fl_WinAPI_Gl_Window_Driver.H"
+
+
+Fl_Gl_Window_Driver *Fl_Gl_Window_Driver::newGlWindowDriver(Fl_Gl_Window *w)
+{
+ return new Fl_WinAPI_Gl_Window_Driver(w);
+}
diff --git a/src/drivers/WinAPI/fl_WinAPI_platform_init.cxx b/src/drivers/WinAPI/fl_WinAPI_platform_init.cxx
new file mode 100644
index 000000000..bf5e34d36
--- /dev/null
+++ b/src/drivers/WinAPI/fl_WinAPI_platform_init.cxx
@@ -0,0 +1,69 @@
+//
+// Windows-specific code to initialize Windows support.
+//
+// Copyright 2022 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
+// file is missing or damaged, see the license at:
+//
+// https://www.fltk.org/COPYING.php
+//
+// Please see the following page on how to report bugs and issues:
+//
+// https://www.fltk.org/bugs.php
+//
+
+
+#include "../GDI/Fl_GDI_Copy_Surface_Driver.H"
+#include "../GDI/Fl_GDI_Graphics_Driver.H"
+#include "Fl_WinAPI_Screen_Driver.H"
+#include "Fl_WinAPI_System_Driver.H"
+#include "Fl_WinAPI_Window_Driver.H"
+#include "../GDI/Fl_GDI_Image_Surface_Driver.H"
+
+
+Fl_Copy_Surface_Driver *Fl_Copy_Surface_Driver::newCopySurfaceDriver(int w, int h)
+{
+ return new Fl_GDI_Copy_Surface_Driver(w, h);
+}
+
+
+Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver()
+{
+#if USE_GDIPLUS
+ // Initialize GDI+.
+ static Gdiplus::GdiplusStartupInput gdiplusStartupInput;
+ if (Fl_GDIplus_Graphics_Driver::gdiplusToken == 0) {
+ GdiplusStartup(&Fl_GDIplus_Graphics_Driver::gdiplusToken, &gdiplusStartupInput, NULL);
+ }
+ Fl_Graphics_Driver *driver = new Fl_GDIplus_Graphics_Driver();
+ return driver;
+#else
+ return new Fl_GDI_Graphics_Driver();
+#endif
+}
+
+
+Fl_Screen_Driver *Fl_Screen_Driver::newScreenDriver()
+{
+ return new Fl_WinAPI_Screen_Driver();
+}
+
+
+Fl_System_Driver *Fl_System_Driver::newSystemDriver()
+{
+ return new Fl_WinAPI_System_Driver();
+}
+
+
+Fl_Window_Driver *Fl_Window_Driver::newWindowDriver(Fl_Window *w)
+{
+ return new Fl_WinAPI_Window_Driver(w);
+}
+
+
+Fl_Image_Surface_Driver *Fl_Image_Surface_Driver::newImageSurfaceDriver(int w, int h, int high_res, Fl_Offscreen off)
+{
+ return new Fl_GDI_Image_Surface_Driver(w, h, high_res, off);
+}