summaryrefslogtreecommitdiff
path: root/src/Fl_Gl_Window.cxx
diff options
context:
space:
mode:
authorBill Spitzak <spitzak@gmail.com>1999-09-16 05:34:27 +0000
committerBill Spitzak <spitzak@gmail.com>1999-09-16 05:34:27 +0000
commitc8794e2f58b4bd0f6d7324546c7492849065ad66 (patch)
tree55658d20d55cb4dfb16852f38801568037d4e364 /src/Fl_Gl_Window.cxx
parent5e57d3cc1267c53692b070bfeea4bdf9951d5256 (diff)
Fixed some WIN32 bugs found in 1.0.5:
FL_MOUSELEAVE had an extra underscore call to toupper() removed const char* cast added to fl_draw_pixmap Change to Fl_Gl_Window that did not get in in time for 1.0.5, it caches the current gl context and does not call glXMakeCurrent (wglMakeCurrent on WIN32) if not needed. This distinctly speeds up Mesa, Irix, and Windows opengl, although I am stumped why such a test is not built into those libraries already. If you use other code that sets the current OpenGL context fltk will get confused because it does not know it changed. To fix such programs you must call fl_no_gl_context() to clear the cache. There is a report that this causes the fractals demo to crash on some Linux and Irix machines, although I can't reproduce it. I suspect the problem is the fractals demo and not fltk, but this change may be making it more likely to fail. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@726 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Gl_Window.cxx')
-rw-r--r--src/Fl_Gl_Window.cxx40
1 files changed, 14 insertions, 26 deletions
diff --git a/src/Fl_Gl_Window.cxx b/src/Fl_Gl_Window.cxx
index 7b1a21ebb..5b20d60d2 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.2 1999/08/09 06:19:32 bill Exp $"
+// "$Id: Fl_Gl_Window.cxx,v 1.12.2.3 1999/09/16 05:34:25 bill Exp $"
//
// OpenGL window code for the Fast Light Tool Kit (FLTK).
//
@@ -107,8 +107,6 @@ void Fl_Gl_Window::invalidate() {
#endif
}
-extern GLXContext fl_first_context; // in Fl_Gl_Choice.C
-
int Fl_Gl_Window::mode(int m, const int *a) {
if (m == mode_ && a == alist) return 0;
mode_ = m; alist = a;
@@ -129,33 +127,25 @@ int Fl_Gl_Window::mode(int m, const int *a) {
}
void Fl_Gl_Window::make_current() {
-#ifdef WIN32
- HDC hdc = fl_private_dc(this, mode_,&g);
-
if (!context) {
- context = wglCreateContext(hdc);
+#ifdef WIN32
+ context = wglCreateContext(fl_private_dc(this, mode_,&g));
if (fl_first_context) wglShareLists(fl_first_context, (GLXContext)context);
else fl_first_context = (GLXContext)context;
+#else
+ context = glXCreateContext(fl_display, g->vis, fl_first_context, 1);
+ if (!fl_first_context) fl_first_context = (GLXContext)context;
+#endif
valid(0);
}
- wglMakeCurrent(hdc, (GLXContext)context);
-
-# if USE_COLORMAP
+ fl_set_gl_context(this, (GLXContext)context);
+#if defined(WIN32) && USE_COLORMAP
if (fl_palette) {
fl_GetDC(fl_xid(this));
SelectPalette(fl_gc, fl_palette, FALSE);
RealizePalette(fl_gc);
}
-# endif // USE_COLORMAP
-#else
- if (!context) {
- context = glXCreateContext(fl_display, g->vis, fl_first_context, 1);
- if (!fl_first_context) fl_first_context = (GLXContext)context;
- valid(0);
- }
- glXMakeCurrent(fl_display, fl_xid(this), (GLXContext)context);
-#endif
-
+#endif // USE_COLORMAP
glDrawBuffer(GL_BACK);
}
@@ -215,12 +205,11 @@ void Fl_Gl_Window::flush() {
int init = !ortho_context;
#ifdef WIN32
if (init) ortho_context = wglCreateContext(Fl_X::i(this)->private_dc);
- wglMakeCurrent(Fl_X::i(this)->private_dc, ortho_context);
#else
if (init)
ortho_context = glXCreateContext(fl_display,g->vis,fl_first_context,1);
- glXMakeCurrent(fl_display, fl_xid(this), ortho_context);
#endif
+ fl_set_gl_context(this, ortho_context);
if (init) {
glDisable(GL_DEPTH_TEST);
glReadBuffer(GL_BACK);
@@ -266,7 +255,7 @@ void Fl_Gl_Window::flush() {
if (overlay && overlay != this) {
DRAW_OVERLAY_ONLY:
valid_ = save_valid;
- wglMakeCurrent(Fl_X::i(this)->private_dc, (GLXContext)overlay);
+ fl_set_gl_context(this, (GLXContext)overlay);
glDisable(GL_SCISSOR_TEST);
fl_overlay = 1;
glClear(GL_COLOR_BUFFER_BIT);
@@ -287,13 +276,12 @@ void Fl_Gl_Window::resize(int X,int Y,int W,int H) {
void Fl_Gl_Window::hide() {
if (context) {
+ fl_no_gl_context();
#ifdef WIN32
- wglMakeCurrent(0, 0);
if (context && context != fl_first_context)
wglDeleteContext((GLXContext)context);
g = 0;
#else
- glXMakeCurrent(fl_display, 0, 0);
if (context != fl_first_context)
glXDestroyContext(fl_display, (GLXContext)context);
#ifdef GLX_MESA_release_buffers
@@ -326,5 +314,5 @@ void Fl_Gl_Window::draw_overlay() {}
#endif
//
-// End of "$Id: Fl_Gl_Window.cxx,v 1.12.2.2 1999/08/09 06:19:32 bill Exp $".
+// End of "$Id: Fl_Gl_Window.cxx,v 1.12.2.3 1999/09/16 05:34:25 bill Exp $".
//