More fixes to the NT OpenGL overlays

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1058 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Bill Spitzak
2000-04-07 16:55:46 +00:00
parent bf34ed8ca7
commit 177e3cd076
2 changed files with 46 additions and 35 deletions
+11 -13
View File
@@ -1,5 +1,5 @@
// //
// "$Id: Fl_Gl_Overlay.cxx,v 1.5.2.6 2000/03/24 08:55:34 bill Exp $" // "$Id: Fl_Gl_Overlay.cxx,v 1.5.2.7 2000/04/07 16:55:45 bill Exp $"
// //
// OpenGL overlay code for the Fast Light Tool Kit (FLTK). // OpenGL overlay code for the Fast Light Tool Kit (FLTK).
// //
@@ -34,7 +34,7 @@
#if HAVE_GL_OVERLAY #if HAVE_GL_OVERLAY
#ifndef WIN32 #ifndef _WIN32
// Methods on Fl_Gl_Window that create an overlay window. Because // Methods on Fl_Gl_Window that create an overlay window. Because
// many programs don't need the overlay, this is seperated into this // many programs don't need the overlay, this is seperated into this
@@ -101,14 +101,14 @@ int Fl_Gl_Window::can_do_overlay() {
return fl_find_overlay_visual() != 0; return fl_find_overlay_visual() != 0;
} }
#else // WIN32: #else // _WIN32:
int Fl_Gl_Window::can_do_overlay() { int Fl_Gl_Window::can_do_overlay() {
Fl_Gl_Choice* choice = Fl_Gl_Choice::find(0,0); Fl_Gl_Choice* choice = Fl_Gl_Choice::find(0,0);
return (choice && (choice->pfd.bReserved & 15)); return (choice && (choice->pfd.bReserved & 15));
} }
int fl_overlay_depth = 0; extern int fl_overlay_depth;
#endif #endif
@@ -121,12 +121,10 @@ int Fl_Gl_Window::can_do_overlay() {return 0;}
void Fl_Gl_Window::make_overlay() { void Fl_Gl_Window::make_overlay() {
if (!overlay) { if (!overlay) {
#if HAVE_GL_OVERLAY #if HAVE_GL_OVERLAY
#ifdef WIN32 #ifdef _WIN32
HDC hdc = fl_private_dc(this, mode_,&g); HDC hdc = fl_private_dc(this, mode_,&g);
GLXContext context = wglCreateLayerContext(hdc, 1); GLXContext context = wglCreateLayerContext(hdc, 1);
if (!context) { if (context) { // we found a usable overlay context
; // no overlay hardware
} else {
if (fl_first_context) wglShareLists(fl_first_context, context); if (fl_first_context) wglShareLists(fl_first_context, context);
else fl_first_context = context; else fl_first_context = context;
overlay = context; overlay = context;
@@ -172,7 +170,7 @@ void Fl_Gl_Window::make_overlay() {
void Fl_Gl_Window::redraw_overlay() { void Fl_Gl_Window::redraw_overlay() {
if (!shown()) return; if (!shown()) return;
make_overlay(); make_overlay();
#ifndef WIN32 #ifndef _WIN32
if (overlay != this) if (overlay != this)
((Fl_Gl_Window*)overlay)->redraw(); ((Fl_Gl_Window*)overlay)->redraw();
else else
@@ -184,10 +182,10 @@ void Fl_Gl_Window::make_overlay_current() {
make_overlay(); make_overlay();
#if HAVE_GL_OVERLAY #if HAVE_GL_OVERLAY
if (overlay != this) { if (overlay != this) {
#ifdef WIN32 #ifdef _WIN32
fl_set_gl_context(this, (GLXContext)overlay); fl_set_gl_context(this, (GLXContext)overlay);
if (fl_overlay_depth) if (fl_overlay_depth)
wglRealizeLayerPalette(fl_private_dc(this, mode_,&g), 1, TRUE); wglRealizeLayerPalette(Fl_X::i(this)->private_dc, 1, TRUE);
#else #else
((Fl_Gl_Window*)overlay)->make_current(); ((Fl_Gl_Window*)overlay)->make_current();
#endif #endif
@@ -198,7 +196,7 @@ void Fl_Gl_Window::make_overlay_current() {
void Fl_Gl_Window::hide_overlay() { void Fl_Gl_Window::hide_overlay() {
#if HAVE_GL_OVERLAY #if HAVE_GL_OVERLAY
#ifdef WIN32 #ifdef _WIN32
// nothing needs to be done? Or should it be erased? // nothing needs to be done? Or should it be erased?
#else #else
if (overlay && overlay!=this) ((Fl_Gl_Window*)overlay)->hide(); if (overlay && overlay!=this) ((Fl_Gl_Window*)overlay)->hide();
@@ -209,5 +207,5 @@ void Fl_Gl_Window::hide_overlay() {
#endif #endif
// //
// End of "$Id: Fl_Gl_Overlay.cxx,v 1.5.2.6 2000/03/24 08:55:34 bill Exp $". // End of "$Id: Fl_Gl_Overlay.cxx,v 1.5.2.7 2000/04/07 16:55:45 bill Exp $".
// //
+35 -22
View File
@@ -1,5 +1,5 @@
// //
// "$Id: Fl_Gl_Window.cxx,v 1.12.2.9 2000/03/24 08:42:02 bill Exp $" // "$Id: Fl_Gl_Window.cxx,v 1.12.2.10 2000/04/07 16:55:46 bill Exp $"
// //
// OpenGL window code for the Fast Light Tool Kit (FLTK). // OpenGL window code for the Fast Light Tool Kit (FLTK).
// //
@@ -66,7 +66,7 @@ int Fl_Gl_Window::can_do(int a, const int *b) {
} }
void Fl_Gl_Window::show() { void Fl_Gl_Window::show() {
#ifndef WIN32 #ifndef _WIN32
if (!shown()) { if (!shown()) {
if (!g) { if (!g) {
g = Fl_Gl_Choice::find(mode_,alist); g = Fl_Gl_Choice::find(mode_,alist);
@@ -81,7 +81,7 @@ void Fl_Gl_Window::show() {
void Fl_Gl_Window::invalidate() { void Fl_Gl_Window::invalidate() {
valid(0); valid(0);
#ifndef WIN32 #ifndef _WIN32
if (overlay) ((Fl_Gl_Window*)overlay)->valid(0); if (overlay) ((Fl_Gl_Window*)overlay)->valid(0);
#endif #endif
} }
@@ -89,7 +89,7 @@ void Fl_Gl_Window::invalidate() {
int Fl_Gl_Window::mode(int m, const int *a) { int Fl_Gl_Window::mode(int m, const int *a) {
if (m == mode_ && a == alist) return 0; if (m == mode_ && a == alist) return 0;
mode_ = m; alist = a; mode_ = m; alist = a;
#ifdef WIN32 #ifdef _WIN32
// destroy context and g: // destroy context and g:
if (shown()) {hide(); show();} if (shown()) {hide(); show();}
#else #else
@@ -107,7 +107,7 @@ int Fl_Gl_Window::mode(int m, const int *a) {
void Fl_Gl_Window::make_current() { void Fl_Gl_Window::make_current() {
if (!context) { if (!context) {
#ifdef WIN32 #ifdef _WIN32
context = wglCreateContext(fl_private_dc(this, mode_,&g)); context = wglCreateContext(fl_private_dc(this, mode_,&g));
if (fl_first_context) wglShareLists(fl_first_context, (GLXContext)context); if (fl_first_context) wglShareLists(fl_first_context, (GLXContext)context);
else fl_first_context = (GLXContext)context; else fl_first_context = (GLXContext)context;
@@ -118,7 +118,7 @@ void Fl_Gl_Window::make_current() {
valid(0); valid(0);
} }
fl_set_gl_context(this, (GLXContext)context); fl_set_gl_context(this, (GLXContext)context);
#if defined(WIN32) && USE_COLORMAP #if defined(_WIN32) && USE_COLORMAP
if (fl_palette) { if (fl_palette) {
fl_GetDC(fl_xid(this)); fl_GetDC(fl_xid(this));
SelectPalette(fl_gc, fl_palette, FALSE); SelectPalette(fl_gc, fl_palette, FALSE);
@@ -144,27 +144,33 @@ void Fl_Gl_Window::ortho() {
} }
void Fl_Gl_Window::swap_buffers() { void Fl_Gl_Window::swap_buffers() {
#ifdef WIN32 #ifdef _WIN32
SwapBuffers(Fl_X::i(this)->private_dc); SwapBuffers(Fl_X::i(this)->private_dc);
#else #else
glXSwapBuffers(fl_display, fl_xid(this)); glXSwapBuffers(fl_display, fl_xid(this));
#endif #endif
} }
#if defined(_WIN32) && HAVE_GL_OVERLAY #if HAVE_GL_OVERLAY && defined(_WIN32)
uchar fl_overlay; // changes how fl_color() works uchar fl_overlay; // changes how fl_color() works
int fl_overlay_depth = 0;
#endif #endif
void Fl_Gl_Window::flush() { void Fl_Gl_Window::flush() {
uchar save_valid = valid_; uchar save_valid = valid_;
#if defined(_WIN32) && HAVE_GL_OVERLAY #if HAVE_GL_OVERLAY && defined(_WIN32)
bool fixcursor = false;
if (overlay && overlay != this && if (overlay && overlay != this &&
((damage()&(FL_DAMAGE_OVERLAY|FL_DAMAGE_ALL|FL_DAMAGE_EXPOSE)) ((damage()&(FL_DAMAGE_OVERLAY|FL_DAMAGE_ALL|FL_DAMAGE_EXPOSE))
|| !save_valid)) { || !save_valid)) {
// SGI 320 messes up overlay over singlebuffer
fixcursor = !g->d;
if (fixcursor) SetCursor(0);
// Draw into hardware overlay planes // Draw into hardware overlay planes
if (!g->d) SetCursor(0); // SGI 320 messes up overlay over singlebuffer
fl_set_gl_context(this, (GLXContext)overlay); fl_set_gl_context(this, (GLXContext)overlay);
if (fl_overlay_depth)
wglRealizeLayerPalette(Fl_X::i(this)->private_dc, 1, TRUE);
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
fl_overlay = 1; fl_overlay = 1;
@@ -173,10 +179,9 @@ void Fl_Gl_Window::flush() {
valid(save_valid); valid(save_valid);
if (damage() == FL_DAMAGE_OVERLAY) { if (damage() == FL_DAMAGE_OVERLAY) {
wglSwapLayerBuffers(Fl_X::i(this)->private_dc,WGL_SWAP_OVERLAY1); wglSwapLayerBuffers(Fl_X::i(this)->private_dc,WGL_SWAP_OVERLAY1);
if (!g->d) SetCursor(Fl_X::i(this)->cursor); if (fixcursor) SetCursor(Fl_X::i(this)->cursor);
return; return;
} }
if (!g->d) SetCursor(Fl_X::i(this)->cursor);
} }
#endif #endif
@@ -207,12 +212,13 @@ void Fl_Gl_Window::flush() {
static GLXContext ortho_context = 0; static GLXContext ortho_context = 0;
static Fl_Gl_Window* ortho_window = 0; static Fl_Gl_Window* ortho_window = 0;
int init = !ortho_context; int init = !ortho_context;
#ifdef WIN32 if (init) {
if (init) ortho_context = wglCreateContext(Fl_X::i(this)->private_dc); #ifdef _WIN32
ortho_context = wglCreateContext(Fl_X::i(this)->private_dc);
#else #else
if (init)
ortho_context = glXCreateContext(fl_display,g->vis,fl_first_context,1); ortho_context = glXCreateContext(fl_display,g->vis,fl_first_context,1);
#endif #endif
}
fl_set_gl_context(this, ortho_context); fl_set_gl_context(this, ortho_context);
if (init || !save_valid || ortho_window != this) { if (init || !save_valid || ortho_window != this) {
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
@@ -256,7 +262,9 @@ void Fl_Gl_Window::flush() {
draw(); draw();
if (overlay == this) draw_overlay(); if (overlay == this) draw_overlay();
glFlush(); glFlush();
#if HAVE_GL_OVERLAY && defined(_WIN32)
if (fixcursor) SetCursor(Fl_X::i(this)->cursor);
#endif
} }
valid(1); valid(1);
@@ -270,19 +278,24 @@ void Fl_Gl_Window::resize(int X,int Y,int W,int H) {
void Fl_Gl_Window::hide() { void Fl_Gl_Window::hide() {
if (context) { if (context) {
fl_no_gl_context(); fl_no_gl_context();
#ifdef WIN32 if (context != fl_first_context) {
if (context && context != fl_first_context) #ifdef _WIN32
wglDeleteContext((GLXContext)context); wglDeleteContext((GLXContext)context);
g = 0;
#else #else
if (context != fl_first_context)
glXDestroyContext(fl_display, (GLXContext)context); glXDestroyContext(fl_display, (GLXContext)context);
#endif
}
#ifdef GLX_MESA_release_buffers #ifdef GLX_MESA_release_buffers
glXReleaseBuffersMESA(fl_display, fl_xid(this)); glXReleaseBuffersMESA(fl_display, fl_xid(this));
#endif
#endif #endif
context = 0; context = 0;
} }
#if HAVE_GL_OVERLAY && defined(_WIN32)
if (overlay && overlay != this && (GLXContext)overlay != fl_first_context) {
wglDeleteContext((GLXContext)overlay);
overlay = 0;
}
#endif
Fl_Window::hide(); Fl_Window::hide();
} }
@@ -307,5 +320,5 @@ void Fl_Gl_Window::draw_overlay() {}
#endif #endif
// //
// End of "$Id: Fl_Gl_Window.cxx,v 1.12.2.9 2000/03/24 08:42:02 bill Exp $". // End of "$Id: Fl_Gl_Window.cxx,v 1.12.2.10 2000/04/07 16:55:46 bill Exp $".
// //