Move private_dc from Fl_X for WIN32 platform to Fl_WinAPI_Window_Driver.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11664 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2016-04-19 19:37:49 +00:00
parent 4aa388d4ff
commit 1e8a53ecc4
7 changed files with 17 additions and 12 deletions

View File

@ -53,7 +53,6 @@ public:
Fl_Window* w;
Fl_Region region;
Fl_X *next;
HDC private_dc; // used for OpenGL
// static variables, static functions and member functions
static Fl_X* first;
static Fl_X* i(const Fl_Window* w) {return (Fl_X*)w->i;}

View File

@ -29,6 +29,7 @@
# include <FL/fl_utf8.h>
#if defined(WIN32)
#include "drivers/WinAPI/Fl_WinAPI_Window_Driver.H"
#elif defined(__APPLE__) // PORTME: platform OpenGL management
#include "drivers/Cocoa/Fl_Cocoa_Screen_Driver.H"
#elif defined(FL_PORTING)
@ -227,9 +228,9 @@ GLContext fl_create_gl_context(XVisualInfo* vis) {
GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer) {
Fl_X* i = Fl_X::i(window);
HDC hdc = i->private_dc;
HDC hdc = Fl_WinAPI_Window_Driver::driver(window)->private_dc;
if (!hdc) {
hdc = i->private_dc = GetDCEx(i->xid, 0, DCX_CACHE);
hdc = Fl_WinAPI_Window_Driver::driver(window)->private_dc = GetDCEx(i->xid, 0, DCX_CACHE);
fl_save_dc(i->xid, hdc);
SetPixelFormat(hdc, g->pixelformat, (PIXELFORMATDESCRIPTOR*)(&g->pfd));
# if USE_COLORMAP
@ -273,7 +274,7 @@ void fl_set_gl_context(Fl_Window* w, GLContext context) {
# if defined(USE_X11)
glXMakeCurrent(fl_display, fl_xid(w), context);
# elif defined(WIN32)
wglMakeCurrent(Fl_X::i(w)->private_dc, context);
wglMakeCurrent(Fl_WinAPI_Window_Driver::driver(w)->private_dc, context);
# elif defined(__APPLE__) // PORTME: platform OpenGL management
Fl_Cocoa_Screen_Driver::GLcontext_makecurrent(context);
# else

View File

@ -25,7 +25,9 @@
#include <FL/Fl_Gl_Window.H>
#include <stdlib.h>
#if defined(WIN32) || defined(__APPLE__) // PORTME: platform OpenGL management
#if defined(WIN32) // PORTME: platform OpenGL management
#include "drivers/WinAPI/Fl_WinAPI_Window_Driver.H"
#elif defined(__APPLE__)
#elif defined(FL_PORTING)
# pragma message "FL_PORTING: implement OpenGL hardware overlays if they are availbale in a compatible way. This is rarely needed."
#else
@ -148,7 +150,7 @@ void Fl_Gl_Window::make_overlay() {
GLContext context = fl_create_gl_context(this, g, 1);
if (!context) {overlay = this; return;} // fake the overlay
HDC hdc = Fl_X::i(this)->private_dc;
HDC hdc = Fl_WinAPI_Window_Driver::driver(this)->private_dc;
overlay = context;
LAYERPLANEDESCRIPTOR pfd;
wglDescribeLayerPlane(hdc, g->pixelformat, 1, sizeof(pfd), &pfd);

View File

@ -32,6 +32,8 @@ extern int fl_gl_load_plugin;
#include <OpenGL/OpenGL.h>
#include "drivers/Cocoa/Fl_Cocoa_Window_Driver.H"
#include "drivers/Cocoa/Fl_Cocoa_Screen_Driver.H"
#elif defined(WIN32)
#include "drivers/WinAPI/Fl_WinAPI_Window_Driver.H"
#endif
#include <FL/Fl_Gl_Window.H>
#include <FL/Fl_Device.H>
@ -257,10 +259,10 @@ void Fl_Gl_Window::swap_buffers() {
#elif defined(WIN32)
# if HAVE_GL_OVERLAY
// Do not swap the overlay, to match GLX:
BOOL ret = wglSwapLayerBuffers(Fl_X::i(this)->private_dc, WGL_SWAP_MAIN_PLANE);
BOOL ret = wglSwapLayerBuffers(Fl_WinAPI_Window_Driver::driver(this)->private_dc, WGL_SWAP_MAIN_PLANE);
DWORD err = GetLastError();;
# else
SwapBuffers(Fl_X::i(this)->private_dc);
SwapBuffers(Fl_WinAPI_Window_Driver::driver(this)->private_dc);
# endif
#elif defined(__APPLE_QUARTZ__) // PORTME: platform OpenGL management
if(overlay != NULL) {
@ -322,14 +324,14 @@ void Fl_Gl_Window::flush() {
&& (damage()&(FL_DAMAGE_OVERLAY|FL_DAMAGE_EXPOSE) || !save_valid)) {
fl_set_gl_context(this, (GLContext)overlay);
if (fl_overlay_depth)
wglRealizeLayerPalette(Fl_X::i(this)->private_dc, 1, TRUE);
wglRealizeLayerPalette(Fl_WinAPI_Window_Driver::driver(this)->private_dc, 1, TRUE);
glDisable(GL_SCISSOR_TEST);
glClear(GL_COLOR_BUFFER_BIT);
fl_overlay = 1;
draw_overlay();
fl_overlay = 0;
valid_f_ = save_valid_f;
wglSwapLayerBuffers(Fl_X::i(this)->private_dc, WGL_SWAP_OVERLAY1);
wglSwapLayerBuffers(Fl_WinAPI_Window_Driver::driver(this)->private_dc, WGL_SWAP_OVERLAY1);
// if only the overlay was damaged we are done, leave main layer alone:
if (damage() == FL_DAMAGE_OVERLAY) {
return;

View File

@ -1801,7 +1801,7 @@ Fl_X* Fl_WinAPI_Window_Driver::makeWindow() {
x->w = w;
i(x);
x->region = 0;
x->private_dc = 0;
Fl_WinAPI_Window_Driver::driver(w)->private_dc = 0;
cursor = LoadCursor(NULL, IDC_ARROW);
custom_cursor = 0;
if (!fl_codepage) fl_get_codepage();

View File

@ -69,6 +69,7 @@ public:
Fl_WinAPI_Window_Driver(Fl_Window*);
~Fl_WinAPI_Window_Driver();
static inline Fl_WinAPI_Window_Driver* driver(Fl_Window *w) {return (Fl_WinAPI_Window_Driver*)w->driver();}
HDC private_dc; // used for OpenGL
struct icon_data *icon_;
HCURSOR cursor;

View File

@ -431,7 +431,7 @@ void Fl_WinAPI_Window_Driver::hide() {
fl_clipboard_notify_retarget(ip->xid);
// Send a message to myself so that I'll get out of the event loop...
PostMessage(ip->xid, WM_APP, 0, 0);
if (ip->private_dc) fl_release_dc(ip->xid, ip->private_dc);
if (private_dc) fl_release_dc(ip->xid, private_dc);
if (ip->xid == fl_window && fl_graphics_driver->gc()) {
fl_release_dc(fl_window, (HDC)fl_graphics_driver->gc());
fl_window = (HWND)-1;