summaryrefslogtreecommitdiff
path: root/src/Fl_Gl_Window.cxx
diff options
context:
space:
mode:
authorBill Spitzak <spitzak@gmail.com>2000-03-24 08:42:03 +0000
committerBill Spitzak <spitzak@gmail.com>2000-03-24 08:42:03 +0000
commiteeaa7f7ae036d0a0f2a6e02de6cde4c42a43ee9e (patch)
treeb88e2ea2f26121a939bb6f6e01307aab24f56a5e /src/Fl_Gl_Window.cxx
parent7851ae32521c3138d6c2749c1bd591311813eb6f (diff)
OpenGL overlays now work on NT. Tested on several different cards.
They work best on 8-bit overlays like the SGI 320 has. On cards with fewer bits you get only a few colors, really only FL_BLACK, FL_RED, and FL_WHITE are guaranteed to work. This could be improved but would mean copying the ugly X colormap allocation code. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1048 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Gl_Window.cxx')
-rw-r--r--src/Fl_Gl_Window.cxx69
1 files changed, 29 insertions, 40 deletions
diff --git a/src/Fl_Gl_Window.cxx b/src/Fl_Gl_Window.cxx
index 83242e957..601f73404 100644
--- a/src/Fl_Gl_Window.cxx
+++ b/src/Fl_Gl_Window.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Gl_Window.cxx,v 1.12.2.8 2000/03/18 10:04:18 bill Exp $"
+// "$Id: Fl_Gl_Window.cxx,v 1.12.2.9 2000/03/24 08:42:02 bill Exp $"
//
// OpenGL window code for the Fast Light Tool Kit (FLTK).
//
@@ -59,14 +59,6 @@
#define SWAP_TYPE SWAP
#endif
-//
-// Windows may need a different color palette...
-//
-
-#if defined(WIN32) && HAVE_GL
-extern HPALETTE fl_gl_palette;
-#endif
-
////////////////////////////////////////////////////////////////
int Fl_Gl_Window::can_do(int a, const int *b) {
@@ -159,41 +151,57 @@ void Fl_Gl_Window::swap_buffers() {
#endif
}
-#if HAVE_GL_OVERLAY
-#ifdef WIN32
+#if defined(_WIN32) && HAVE_GL_OVERLAY
uchar fl_overlay; // changes how fl_color() works
#endif
-#endif
void Fl_Gl_Window::flush() {
- make_current();
+ uchar save_valid = valid_;
#if defined(_WIN32) && HAVE_GL_OVERLAY
- uchar save_valid = valid_;
- if (overlay && overlay!= this && damage() == FL_DAMAGE_OVERLAY) goto DRAW_OVERLAY_ONLY;
+ if (overlay && overlay != this &&
+ ((damage()&(FL_DAMAGE_OVERLAY|FL_DAMAGE_ALL|FL_DAMAGE_EXPOSE))
+ || !save_valid)) {
+ // Draw into hardware overlay planes
+ if (!g->d) SetCursor(0); // SGI 320 messes up overlay over singlebuffer
+ fl_set_gl_context(this, (GLXContext)overlay);
+ glDisable(GL_SCISSOR_TEST);
+ glClear(GL_COLOR_BUFFER_BIT);
+ fl_overlay = 1;
+ draw_overlay();
+ fl_overlay = 0;
+ valid(save_valid);
+ if (damage() == FL_DAMAGE_OVERLAY) {
+ wglSwapLayerBuffers(Fl_X::i(this)->private_dc,WGL_SWAP_OVERLAY1);
+ if (!g->d) SetCursor(Fl_X::i(this)->cursor);
+ return;
+ }
+ if (!g->d) SetCursor(Fl_X::i(this)->cursor);
+ }
#endif
+ make_current();
+
if (g->d) {
#if SWAP_TYPE == NODAMAGE
// don't draw if only overlay damage or expose events:
- if ((damage()&~(FL_DAMAGE_OVERLAY|FL_DAMAGE_EXPOSE)) || !valid()) draw();
+ if ((damage()&~(FL_DAMAGE_OVERLAY|FL_DAMAGE_EXPOSE)) || !save_valid) draw();
swap_buffers();
#elif SWAP_TYPE == COPY
// don't draw if only the overlay is damaged:
- if (damage() != FL_DAMAGE_OVERLAY || !valid()) draw();
+ if (damage() != FL_DAMAGE_OVERLAY || !save_valid) draw();
swap_buffers();
#else // SWAP_TYPE == SWAP || SWAP_TYPE == UNDEFINED
if (overlay == this) { // Use CopyPixels to act like SWAP_TYPE == COPY
- uchar save_valid = valid_;
// don't draw if only the overlay is damaged:
- if (damage1_ || damage() != FL_DAMAGE_OVERLAY || !valid()) draw();
+ if (damage1_ || damage() != FL_DAMAGE_OVERLAY || !save_valid) draw();
// we use a seperate context for the copy because rasterpos must be 0
// and depth test needs to be off:
static GLXContext ortho_context = 0;
@@ -207,7 +215,6 @@ void Fl_Gl_Window::flush() {
#endif
fl_set_gl_context(this, ortho_context);
if (init || !save_valid || ortho_window != this) {
- ortho_window = this;
glDisable(GL_DEPTH_TEST);
glReadBuffer(GL_BACK);
glDrawBuffer(GL_FRONT);
@@ -215,6 +222,7 @@ void Fl_Gl_Window::flush() {
glViewport(0, 0, w(), h());
glOrtho(0, w(), 0, h(), -1, 1);
glRasterPos2i(0,0);
+ ortho_window = this;
}
glCopyPixels(0,0,w(),h(),GL_COLOR);
make_current(); // set current context back to draw overlay
@@ -251,25 +259,6 @@ void Fl_Gl_Window::flush() {
}
-#if HAVE_GL_OVERLAY
-#ifdef WIN32
- if (overlay && overlay != this) {
- DRAW_OVERLAY_ONLY:
- // Draw into hardware overlay planes
- if (!g->d) SetCursor(0); // SGI system messes up overlay over singlebuffer
- valid_ = save_valid;
- fl_set_gl_context(this, (GLXContext)overlay);
- glDisable(GL_SCISSOR_TEST);
- fl_overlay = 1;
- glClear(GL_COLOR_BUFFER_BIT);
- draw_overlay();
- wglSwapLayerBuffers(Fl_X::i(this)->private_dc,WGL_SWAP_OVERLAY1);
- fl_overlay = 0;
- if (!g->d) SetCursor(Fl_X::i(this)->cursor);
- }
-#endif
-#endif
-
valid(1);
}
@@ -318,5 +307,5 @@ void Fl_Gl_Window::draw_overlay() {}
#endif
//
-// End of "$Id: Fl_Gl_Window.cxx,v 1.12.2.8 2000/03/18 10:04:18 bill Exp $".
+// End of "$Id: Fl_Gl_Window.cxx,v 1.12.2.9 2000/03/24 08:42:02 bill Exp $".
//