1998-10-20 00:46:58 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|
|
|
|
// OpenGL window code for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2006-01-15 05:26:54 +03:00
|
|
|
// Copyright 1998-2006 by Bill Spitzak and others.
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|
1998-10-06 23:14:55 +04:00
|
|
|
|
2002-05-25 17:38:25 +04:00
|
|
|
#include "flstring.h"
|
1998-10-06 23:14:55 +04:00
|
|
|
#if HAVE_GL
|
|
|
|
|
|
|
|
#include <FL/Fl.H>
|
|
|
|
#include <FL/x.H>
|
|
|
|
#include "Fl_Gl_Choice.H"
|
2001-03-14 20:20:02 +03:00
|
|
|
#include <FL/Fl_Gl_Window.H>
|
Buttons with box(FL_NO_BOX) did not draw. Apparently they did in
older versions of fltk, I restored this. (bug 108771)
Removed 8-bit colormap drawing code that was not doing anything in
fl_draw_image due to Mike's changes. I also made fl_color(r,g,b)
actually allocate the requested color rather than the nearest fltk
color-cube color (this is only done for the first color that maps to a
given entry in the fltk color cube), the result is that pixmaps with a
small number of colors are drawn much more accurately. The resulting
code seems to produce better images and is a good deal smaller!
Fixed makeinclude.in so CFLAGS are used for c source code instead of
CXXFLAGS. (bug 108694)
Better fix for gif files suggested by pauly (bug 108770)
Performance of Fl_Gl_Window may be improved on some types of OpenGL
implementations, in particular MESA or other software emulators, by
setting the GL_SWAP_TYPE environment variable. This variable
declares what is in the back buffer after you do a swapbuffers.
setenv GL_SWAP_TYPE COPY
This indicates that the back buffer is copied to the front buffer,
and still contains it's old data. This is true of many hardware
implementations. Setting this will speed up emulation of
overlays, and widgets that can do partial update can take
advantage of this as damage() will not be cleared to -1.
setenv GL_SWAP_TYPE NODAMAGE
This indicates that nothing changes the back buffer except drawing
into it. This is true of MESA and Win32 software emulation and
perhaps some hardware emulation on systems with lots of memory.
All other values for GL_SWAP_TYPE, and not setting the variable,
cause fltk to assumme that the back buffer must be completely
redrawn after a swap.
This is easily tested by running the gl_overlay demo program and
seeing if the display is correct when you drag another window over
it or if you drag the window off the screen and back on. You have to
exit and run the program again for it to see any changes to the
environment variable.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1246 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2000-07-07 12:38:58 +04:00
|
|
|
#include <stdlib.h>
|
1998-10-06 23:14:55 +04:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// The symbol SWAP_TYPE defines what is in the back buffer after doing
|
|
|
|
// a glXSwapBuffers().
|
|
|
|
|
|
|
|
// The OpenGl documentation says that the contents of the backbuffer
|
|
|
|
// are "undefined" after glXSwapBuffers(). However, if we know what
|
|
|
|
// is in the backbuffers then we can save a good deal of time. For
|
|
|
|
// this reason you can define some symbols to describe what is left in
|
|
|
|
// the back buffer.
|
|
|
|
|
Buttons with box(FL_NO_BOX) did not draw. Apparently they did in
older versions of fltk, I restored this. (bug 108771)
Removed 8-bit colormap drawing code that was not doing anything in
fl_draw_image due to Mike's changes. I also made fl_color(r,g,b)
actually allocate the requested color rather than the nearest fltk
color-cube color (this is only done for the first color that maps to a
given entry in the fltk color cube), the result is that pixmaps with a
small number of colors are drawn much more accurately. The resulting
code seems to produce better images and is a good deal smaller!
Fixed makeinclude.in so CFLAGS are used for c source code instead of
CXXFLAGS. (bug 108694)
Better fix for gif files suggested by pauly (bug 108770)
Performance of Fl_Gl_Window may be improved on some types of OpenGL
implementations, in particular MESA or other software emulators, by
setting the GL_SWAP_TYPE environment variable. This variable
declares what is in the back buffer after you do a swapbuffers.
setenv GL_SWAP_TYPE COPY
This indicates that the back buffer is copied to the front buffer,
and still contains it's old data. This is true of many hardware
implementations. Setting this will speed up emulation of
overlays, and widgets that can do partial update can take
advantage of this as damage() will not be cleared to -1.
setenv GL_SWAP_TYPE NODAMAGE
This indicates that nothing changes the back buffer except drawing
into it. This is true of MESA and Win32 software emulation and
perhaps some hardware emulation on systems with lots of memory.
All other values for GL_SWAP_TYPE, and not setting the variable,
cause fltk to assumme that the back buffer must be completely
redrawn after a swap.
This is easily tested by running the gl_overlay demo program and
seeing if the display is correct when you drag another window over
it or if you drag the window off the screen and back on. You have to
exit and run the program again for it to see any changes to the
environment variable.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1246 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2000-07-07 12:38:58 +04:00
|
|
|
// Having not found any way to determine this from glx (or wgl) I have
|
|
|
|
// resorted to letting the user specify it with an environment variable,
|
|
|
|
// GL_SWAP_TYPE, it should be equal to one of these symbols:
|
1998-10-06 23:14:55 +04:00
|
|
|
|
|
|
|
// contents of back buffer after glXSwapBuffers():
|
Buttons with box(FL_NO_BOX) did not draw. Apparently they did in
older versions of fltk, I restored this. (bug 108771)
Removed 8-bit colormap drawing code that was not doing anything in
fl_draw_image due to Mike's changes. I also made fl_color(r,g,b)
actually allocate the requested color rather than the nearest fltk
color-cube color (this is only done for the first color that maps to a
given entry in the fltk color cube), the result is that pixmaps with a
small number of colors are drawn much more accurately. The resulting
code seems to produce better images and is a good deal smaller!
Fixed makeinclude.in so CFLAGS are used for c source code instead of
CXXFLAGS. (bug 108694)
Better fix for gif files suggested by pauly (bug 108770)
Performance of Fl_Gl_Window may be improved on some types of OpenGL
implementations, in particular MESA or other software emulators, by
setting the GL_SWAP_TYPE environment variable. This variable
declares what is in the back buffer after you do a swapbuffers.
setenv GL_SWAP_TYPE COPY
This indicates that the back buffer is copied to the front buffer,
and still contains it's old data. This is true of many hardware
implementations. Setting this will speed up emulation of
overlays, and widgets that can do partial update can take
advantage of this as damage() will not be cleared to -1.
setenv GL_SWAP_TYPE NODAMAGE
This indicates that nothing changes the back buffer except drawing
into it. This is true of MESA and Win32 software emulation and
perhaps some hardware emulation on systems with lots of memory.
All other values for GL_SWAP_TYPE, and not setting the variable,
cause fltk to assumme that the back buffer must be completely
redrawn after a swap.
This is easily tested by running the gl_overlay demo program and
seeing if the display is correct when you drag another window over
it or if you drag the window off the screen and back on. You have to
exit and run the program again for it to see any changes to the
environment variable.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1246 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2000-07-07 12:38:58 +04:00
|
|
|
#define UNDEFINED 1 // anything
|
|
|
|
#define SWAP 2 // former front buffer (same as unknown)
|
|
|
|
#define COPY 3 // unchanged
|
|
|
|
#define NODAMAGE 4 // unchanged even by X expose() events
|
|
|
|
|
2001-12-19 12:10:00 +03:00
|
|
|
static char SWAP_TYPE = 0 ; // 0 = determine it from environment variable
|
1998-10-06 23:14:55 +04:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
int Fl_Gl_Window::can_do(int a, const int *b) {
|
|
|
|
return Fl_Gl_Choice::find(a,b) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Fl_Gl_Window::show() {
|
|
|
|
if (!shown()) {
|
|
|
|
if (!g) {
|
|
|
|
g = Fl_Gl_Choice::find(mode_,alist);
|
2002-10-16 00:45:58 +04:00
|
|
|
|
|
|
|
if (!g && (mode_ & FL_DOUBLE) == FL_SINGLE) {
|
|
|
|
g = Fl_Gl_Choice::find(mode_ | FL_DOUBLE,alist);
|
|
|
|
if (g) mode_ |= FL_FAKE_SINGLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!g) {
|
|
|
|
Fl::error("Insufficient GL support");
|
|
|
|
return;
|
|
|
|
}
|
1998-10-06 23:14:55 +04:00
|
|
|
}
|
2001-11-27 20:44:08 +03:00
|
|
|
#if !defined(WIN32) && !defined(__APPLE__)
|
1998-10-06 23:14:55 +04:00
|
|
|
Fl_X::make_xid(this, g->vis, g->colormap);
|
|
|
|
if (overlay && overlay != this) ((Fl_Gl_Window*)overlay)->show();
|
|
|
|
#endif
|
2001-03-14 20:20:02 +03:00
|
|
|
}
|
1998-10-06 23:14:55 +04:00
|
|
|
Fl_Window::show();
|
2007-12-15 20:29:32 +03:00
|
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
set_visible();
|
|
|
|
#endif /* __APPLE__ */
|
1998-10-06 23:14:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Fl_Gl_Window::invalidate() {
|
|
|
|
valid(0);
|
2006-08-17 13:49:43 +04:00
|
|
|
context_valid(0);
|
2001-03-14 20:20:02 +03:00
|
|
|
#ifndef WIN32
|
2006-08-17 13:49:43 +04:00
|
|
|
if (overlay) {
|
|
|
|
((Fl_Gl_Window*)overlay)->valid(0);
|
|
|
|
((Fl_Gl_Window*)overlay)->context_valid(0);
|
|
|
|
}
|
1998-10-06 23:14:55 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int Fl_Gl_Window::mode(int m, const int *a) {
|
|
|
|
if (m == mode_ && a == alist) return 0;
|
2001-12-18 14:00:09 +03:00
|
|
|
#ifndef __APPLE__
|
2001-03-14 20:20:02 +03:00
|
|
|
int oldmode = mode_;
|
2005-04-14 17:56:07 +04:00
|
|
|
#endif // !__APPLE__
|
|
|
|
#if !defined(WIN32) && !defined(__APPLE__)
|
2001-03-14 20:20:02 +03:00
|
|
|
Fl_Gl_Choice* oldg = g;
|
2005-04-14 17:56:07 +04:00
|
|
|
#endif // !WIN32 && !__APPLE__
|
2001-03-14 20:20:02 +03:00
|
|
|
context(0);
|
1998-10-06 23:14:55 +04:00
|
|
|
mode_ = m; alist = a;
|
|
|
|
if (shown()) {
|
2001-12-18 14:00:09 +03:00
|
|
|
g = Fl_Gl_Choice::find(m, a);
|
|
|
|
#if defined(WIN32)
|
|
|
|
if (!g || (oldmode^m)&FL_DOUBLE) {
|
|
|
|
hide();
|
|
|
|
show();
|
|
|
|
}
|
2004-08-25 04:20:27 +04:00
|
|
|
#elif defined(__APPLE_QD__)
|
|
|
|
redraw();
|
|
|
|
#elif defined(__APPLE_QUARTZ__)
|
2004-09-10 01:34:48 +04:00
|
|
|
// warning: the Quartz version should probably use Core GL (CGL) instead of AGL
|
2001-12-18 14:00:09 +03:00
|
|
|
redraw();
|
|
|
|
#else
|
2001-03-14 20:20:02 +03:00
|
|
|
// under X, if the visual changes we must make a new X window (yuck!):
|
|
|
|
if (!g || g->vis->visualid!=oldg->vis->visualid || (oldmode^m)&FL_DOUBLE) {
|
|
|
|
hide();
|
|
|
|
show();
|
1998-10-06 23:14:55 +04:00
|
|
|
}
|
|
|
|
#endif
|
2001-03-14 20:20:02 +03:00
|
|
|
} else {
|
|
|
|
g = 0;
|
|
|
|
}
|
1998-10-06 23:14:55 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2001-03-14 20:20:02 +03:00
|
|
|
#define NON_LOCAL_CONTEXT 0x80000000
|
|
|
|
|
1998-10-06 23:14:55 +04:00
|
|
|
void Fl_Gl_Window::make_current() {
|
2003-03-31 22:23:53 +04:00
|
|
|
// puts("Fl_Gl_Window::make_current()");
|
|
|
|
// printf("make_current: context_=%p\n", context_);
|
2001-03-14 20:20:02 +03:00
|
|
|
if (!context_) {
|
|
|
|
mode_ &= ~NON_LOCAL_CONTEXT;
|
|
|
|
context_ = fl_create_gl_context(this, g);
|
1998-10-06 23:14:55 +04:00
|
|
|
valid(0);
|
2006-08-17 13:49:43 +04:00
|
|
|
context_valid(0);
|
1998-10-06 23:14:55 +04:00
|
|
|
}
|
2001-03-14 20:20:02 +03:00
|
|
|
fl_set_gl_context(this, context_);
|
2005-05-12 23:16:27 +04:00
|
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
// Set the buffer rectangle here, since in resize() we won't have the
|
|
|
|
// correct parent window size to work with...
|
|
|
|
GLint xywh[4];
|
|
|
|
|
|
|
|
if (window()) {
|
|
|
|
xywh[0] = x();
|
|
|
|
xywh[1] = window()->h() - y() - h();
|
|
|
|
} else {
|
|
|
|
xywh[0] = 0;
|
|
|
|
xywh[1] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
xywh[2] = w();
|
|
|
|
xywh[3] = h();
|
|
|
|
|
|
|
|
aglEnable(context_, AGL_BUFFER_RECT);
|
|
|
|
aglSetInteger(context_, AGL_BUFFER_RECT, xywh);
|
|
|
|
// printf("make_current: xywh=[%d %d %d %d]\n", xywh[0], xywh[1], xywh[2], xywh[3]);
|
|
|
|
#endif // __APPLE__
|
|
|
|
|
2001-03-14 20:20:02 +03:00
|
|
|
#if defined(WIN32) && USE_COLORMAP
|
1998-11-08 20:02:40 +03:00
|
|
|
if (fl_palette) {
|
1998-11-08 19:37:21 +03:00
|
|
|
fl_GetDC(fl_xid(this));
|
1998-11-08 20:02:40 +03:00
|
|
|
SelectPalette(fl_gc, fl_palette, FALSE);
|
1998-11-08 18:55:23 +03:00
|
|
|
RealizePalette(fl_gc);
|
|
|
|
}
|
1999-09-16 09:34:27 +04:00
|
|
|
#endif // USE_COLORMAP
|
2002-10-16 00:45:58 +04:00
|
|
|
if (mode_ & FL_FAKE_SINGLE) {
|
|
|
|
glDrawBuffer(GL_FRONT);
|
|
|
|
glReadBuffer(GL_FRONT);
|
|
|
|
}
|
2000-06-03 12:37:09 +04:00
|
|
|
current_ = this;
|
1998-10-06 23:14:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Fl_Gl_Window::ortho() {
|
2000-03-18 13:04:18 +03:00
|
|
|
// Alpha NT seems to have a broken OpenGL that does not like negative coords:
|
|
|
|
#ifdef _M_ALPHA
|
|
|
|
glLoadIdentity();
|
|
|
|
glViewport(0, 0, w(), h());
|
|
|
|
glOrtho(0, w(), 0, h(), -1, 1);
|
|
|
|
#else
|
|
|
|
GLint v[2];
|
|
|
|
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, v);
|
1998-10-06 23:14:55 +04:00
|
|
|
glLoadIdentity();
|
2000-03-18 13:04:18 +03:00
|
|
|
glViewport(w()-v[0], h()-v[1], v[0], v[1]);
|
|
|
|
glOrtho(w()-v[0], w(), h()-v[1], h(), -1, 1);
|
|
|
|
#endif
|
1998-10-06 23:14:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Fl_Gl_Window::swap_buffers() {
|
2001-03-14 20:20:02 +03:00
|
|
|
#ifdef WIN32
|
2001-11-27 20:44:08 +03:00
|
|
|
# if HAVE_GL_OVERLAY
|
2000-06-10 22:24:31 +04:00
|
|
|
// Do not swap the overlay, to match GLX:
|
2001-12-21 17:35:34 +03:00
|
|
|
BOOL ret = wglSwapLayerBuffers(Fl_X::i(this)->private_dc, WGL_SWAP_MAIN_PLANE);
|
2001-12-04 07:12:58 +03:00
|
|
|
DWORD err = GetLastError();;
|
2001-11-27 20:44:08 +03:00
|
|
|
# else
|
1998-10-06 23:14:55 +04:00
|
|
|
SwapBuffers(Fl_X::i(this)->private_dc);
|
2001-11-27 20:44:08 +03:00
|
|
|
# endif
|
2004-08-25 04:20:27 +04:00
|
|
|
#elif defined(__APPLE_QD__)
|
|
|
|
aglSwapBuffers((AGLContext)context_);
|
|
|
|
#elif defined(__APPLE_QUARTZ__)
|
2004-09-10 01:34:48 +04:00
|
|
|
// warning: the Quartz version should probably use Core GL (CGL) instead of AGL
|
2001-11-27 20:44:08 +03:00
|
|
|
aglSwapBuffers((AGLContext)context_);
|
1998-10-06 23:14:55 +04:00
|
|
|
#else
|
|
|
|
glXSwapBuffers(fl_display, fl_xid(this));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2001-03-14 20:20:02 +03:00
|
|
|
#if HAVE_GL_OVERLAY && defined(WIN32)
|
1998-10-06 23:14:55 +04:00
|
|
|
uchar fl_overlay; // changes how fl_color() works
|
2000-04-07 20:55:46 +04:00
|
|
|
int fl_overlay_depth = 0;
|
1998-10-06 23:14:55 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void Fl_Gl_Window::flush() {
|
2006-08-17 13:49:43 +04:00
|
|
|
uchar save_valid = valid_f_ & 1;
|
|
|
|
#if HAVE_GL_OVERLAY && defined(WIN32)
|
|
|
|
uchar save_valid_f = valid_f_;
|
|
|
|
#endif
|
2001-03-14 20:20:02 +03:00
|
|
|
|
2004-08-25 04:20:27 +04:00
|
|
|
#ifdef __APPLE_QD__
|
|
|
|
//: clear previous clipping in this shared port
|
|
|
|
GrafPtr port = GetWindowPort( fl_xid(this) );
|
|
|
|
Rect rect; SetRect( &rect, 0, 0, 0x7fff, 0x7fff );
|
|
|
|
GrafPtr old; GetPort( &old );
|
|
|
|
SetPort( port );
|
|
|
|
ClipRect( &rect );
|
|
|
|
SetPort( old );
|
|
|
|
#elif defined(__APPLE_QUARTZ__)
|
2004-09-10 01:34:48 +04:00
|
|
|
// warning: the Quartz version should probably use Core GL (CGL) instead of AGL
|
2001-12-18 14:00:09 +03:00
|
|
|
//: clear previous clipping in this shared port
|
|
|
|
GrafPtr port = GetWindowPort( fl_xid(this) );
|
|
|
|
Rect rect; SetRect( &rect, 0, 0, 0x7fff, 0x7fff );
|
|
|
|
GrafPtr old; GetPort( &old );
|
|
|
|
SetPort( port );
|
|
|
|
ClipRect( &rect );
|
|
|
|
SetPort( old );
|
|
|
|
#endif
|
|
|
|
|
2001-03-14 20:20:02 +03:00
|
|
|
#if HAVE_GL_OVERLAY && defined(WIN32)
|
|
|
|
|
2001-07-18 12:11:02 +04:00
|
|
|
bool fixcursor = false; // for fixing the SGI 320 bug
|
1998-10-06 23:14:55 +04:00
|
|
|
|
2001-07-18 12:11:02 +04:00
|
|
|
// Draw into hardware overlay planes if they are damaged:
|
2000-06-10 22:24:31 +04:00
|
|
|
if (overlay && overlay != this
|
|
|
|
&& (damage()&(FL_DAMAGE_OVERLAY|FL_DAMAGE_EXPOSE) || !save_valid)) {
|
2001-07-18 12:11:02 +04:00
|
|
|
// SGI 320 messes up overlay with user-defined cursors:
|
|
|
|
if (Fl_X::i(this)->cursor && Fl_X::i(this)->cursor != fl_default_cursor) {
|
|
|
|
fixcursor = true; // make it restore cursor later
|
|
|
|
SetCursor(0);
|
|
|
|
}
|
2001-03-14 20:20:02 +03:00
|
|
|
fl_set_gl_context(this, (GLContext)overlay);
|
2000-04-07 20:55:46 +04:00
|
|
|
if (fl_overlay_depth)
|
|
|
|
wglRealizeLayerPalette(Fl_X::i(this)->private_dc, 1, TRUE);
|
2000-03-24 11:42:03 +03:00
|
|
|
glDisable(GL_SCISSOR_TEST);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
fl_overlay = 1;
|
|
|
|
draw_overlay();
|
|
|
|
fl_overlay = 0;
|
2006-08-17 13:49:43 +04:00
|
|
|
valid_f_ = save_valid_f;
|
2000-06-10 22:24:31 +04:00
|
|
|
wglSwapLayerBuffers(Fl_X::i(this)->private_dc, WGL_SWAP_OVERLAY1);
|
2001-07-18 12:11:02 +04:00
|
|
|
// if only the overlay was damaged we are done, leave main layer alone:
|
|
|
|
if (damage() == FL_DAMAGE_OVERLAY) {
|
2000-04-07 20:55:46 +04:00
|
|
|
if (fixcursor) SetCursor(Fl_X::i(this)->cursor);
|
2000-03-24 11:42:03 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
1998-10-06 23:14:55 +04:00
|
|
|
#endif
|
|
|
|
|
2000-03-24 11:42:03 +03:00
|
|
|
make_current();
|
|
|
|
|
2001-03-14 20:20:02 +03:00
|
|
|
if (mode_ & FL_DOUBLE) {
|
|
|
|
|
|
|
|
glDrawBuffer(GL_BACK);
|
1998-10-06 23:14:55 +04:00
|
|
|
|
Buttons with box(FL_NO_BOX) did not draw. Apparently they did in
older versions of fltk, I restored this. (bug 108771)
Removed 8-bit colormap drawing code that was not doing anything in
fl_draw_image due to Mike's changes. I also made fl_color(r,g,b)
actually allocate the requested color rather than the nearest fltk
color-cube color (this is only done for the first color that maps to a
given entry in the fltk color cube), the result is that pixmaps with a
small number of colors are drawn much more accurately. The resulting
code seems to produce better images and is a good deal smaller!
Fixed makeinclude.in so CFLAGS are used for c source code instead of
CXXFLAGS. (bug 108694)
Better fix for gif files suggested by pauly (bug 108770)
Performance of Fl_Gl_Window may be improved on some types of OpenGL
implementations, in particular MESA or other software emulators, by
setting the GL_SWAP_TYPE environment variable. This variable
declares what is in the back buffer after you do a swapbuffers.
setenv GL_SWAP_TYPE COPY
This indicates that the back buffer is copied to the front buffer,
and still contains it's old data. This is true of many hardware
implementations. Setting this will speed up emulation of
overlays, and widgets that can do partial update can take
advantage of this as damage() will not be cleared to -1.
setenv GL_SWAP_TYPE NODAMAGE
This indicates that nothing changes the back buffer except drawing
into it. This is true of MESA and Win32 software emulation and
perhaps some hardware emulation on systems with lots of memory.
All other values for GL_SWAP_TYPE, and not setting the variable,
cause fltk to assumme that the back buffer must be completely
redrawn after a swap.
This is easily tested by running the gl_overlay demo program and
seeing if the display is correct when you drag another window over
it or if you drag the window off the screen and back on. You have to
exit and run the program again for it to see any changes to the
environment variable.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1246 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2000-07-07 12:38:58 +04:00
|
|
|
if (!SWAP_TYPE) {
|
2004-08-25 04:20:27 +04:00
|
|
|
#ifdef __APPLE_QD__
|
|
|
|
SWAP_TYPE = COPY;
|
|
|
|
#elif defined __APPLE_QUARTZ__
|
2004-09-10 01:34:48 +04:00
|
|
|
// warning: the Quartz version should probably use Core GL (CGL) instead of AGL
|
2001-12-19 12:10:00 +03:00
|
|
|
SWAP_TYPE = COPY;
|
|
|
|
#else
|
Buttons with box(FL_NO_BOX) did not draw. Apparently they did in
older versions of fltk, I restored this. (bug 108771)
Removed 8-bit colormap drawing code that was not doing anything in
fl_draw_image due to Mike's changes. I also made fl_color(r,g,b)
actually allocate the requested color rather than the nearest fltk
color-cube color (this is only done for the first color that maps to a
given entry in the fltk color cube), the result is that pixmaps with a
small number of colors are drawn much more accurately. The resulting
code seems to produce better images and is a good deal smaller!
Fixed makeinclude.in so CFLAGS are used for c source code instead of
CXXFLAGS. (bug 108694)
Better fix for gif files suggested by pauly (bug 108770)
Performance of Fl_Gl_Window may be improved on some types of OpenGL
implementations, in particular MESA or other software emulators, by
setting the GL_SWAP_TYPE environment variable. This variable
declares what is in the back buffer after you do a swapbuffers.
setenv GL_SWAP_TYPE COPY
This indicates that the back buffer is copied to the front buffer,
and still contains it's old data. This is true of many hardware
implementations. Setting this will speed up emulation of
overlays, and widgets that can do partial update can take
advantage of this as damage() will not be cleared to -1.
setenv GL_SWAP_TYPE NODAMAGE
This indicates that nothing changes the back buffer except drawing
into it. This is true of MESA and Win32 software emulation and
perhaps some hardware emulation on systems with lots of memory.
All other values for GL_SWAP_TYPE, and not setting the variable,
cause fltk to assumme that the back buffer must be completely
redrawn after a swap.
This is easily tested by running the gl_overlay demo program and
seeing if the display is correct when you drag another window over
it or if you drag the window off the screen and back on. You have to
exit and run the program again for it to see any changes to the
environment variable.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1246 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2000-07-07 12:38:58 +04:00
|
|
|
SWAP_TYPE = UNDEFINED;
|
2001-12-19 12:10:00 +03:00
|
|
|
#endif
|
Buttons with box(FL_NO_BOX) did not draw. Apparently they did in
older versions of fltk, I restored this. (bug 108771)
Removed 8-bit colormap drawing code that was not doing anything in
fl_draw_image due to Mike's changes. I also made fl_color(r,g,b)
actually allocate the requested color rather than the nearest fltk
color-cube color (this is only done for the first color that maps to a
given entry in the fltk color cube), the result is that pixmaps with a
small number of colors are drawn much more accurately. The resulting
code seems to produce better images and is a good deal smaller!
Fixed makeinclude.in so CFLAGS are used for c source code instead of
CXXFLAGS. (bug 108694)
Better fix for gif files suggested by pauly (bug 108770)
Performance of Fl_Gl_Window may be improved on some types of OpenGL
implementations, in particular MESA or other software emulators, by
setting the GL_SWAP_TYPE environment variable. This variable
declares what is in the back buffer after you do a swapbuffers.
setenv GL_SWAP_TYPE COPY
This indicates that the back buffer is copied to the front buffer,
and still contains it's old data. This is true of many hardware
implementations. Setting this will speed up emulation of
overlays, and widgets that can do partial update can take
advantage of this as damage() will not be cleared to -1.
setenv GL_SWAP_TYPE NODAMAGE
This indicates that nothing changes the back buffer except drawing
into it. This is true of MESA and Win32 software emulation and
perhaps some hardware emulation on systems with lots of memory.
All other values for GL_SWAP_TYPE, and not setting the variable,
cause fltk to assumme that the back buffer must be completely
redrawn after a swap.
This is easily tested by running the gl_overlay demo program and
seeing if the display is correct when you drag another window over
it or if you drag the window off the screen and back on. You have to
exit and run the program again for it to see any changes to the
environment variable.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1246 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2000-07-07 12:38:58 +04:00
|
|
|
const char* c = getenv("GL_SWAP_TYPE");
|
|
|
|
if (c) {
|
|
|
|
if (!strcmp(c,"COPY")) SWAP_TYPE = COPY;
|
|
|
|
else if (!strcmp(c, "NODAMAGE")) SWAP_TYPE = NODAMAGE;
|
2001-12-19 12:10:00 +03:00
|
|
|
else if (!strcmp(c, "SWAP")) SWAP_TYPE = SWAP;
|
Buttons with box(FL_NO_BOX) did not draw. Apparently they did in
older versions of fltk, I restored this. (bug 108771)
Removed 8-bit colormap drawing code that was not doing anything in
fl_draw_image due to Mike's changes. I also made fl_color(r,g,b)
actually allocate the requested color rather than the nearest fltk
color-cube color (this is only done for the first color that maps to a
given entry in the fltk color cube), the result is that pixmaps with a
small number of colors are drawn much more accurately. The resulting
code seems to produce better images and is a good deal smaller!
Fixed makeinclude.in so CFLAGS are used for c source code instead of
CXXFLAGS. (bug 108694)
Better fix for gif files suggested by pauly (bug 108770)
Performance of Fl_Gl_Window may be improved on some types of OpenGL
implementations, in particular MESA or other software emulators, by
setting the GL_SWAP_TYPE environment variable. This variable
declares what is in the back buffer after you do a swapbuffers.
setenv GL_SWAP_TYPE COPY
This indicates that the back buffer is copied to the front buffer,
and still contains it's old data. This is true of many hardware
implementations. Setting this will speed up emulation of
overlays, and widgets that can do partial update can take
advantage of this as damage() will not be cleared to -1.
setenv GL_SWAP_TYPE NODAMAGE
This indicates that nothing changes the back buffer except drawing
into it. This is true of MESA and Win32 software emulation and
perhaps some hardware emulation on systems with lots of memory.
All other values for GL_SWAP_TYPE, and not setting the variable,
cause fltk to assumme that the back buffer must be completely
redrawn after a swap.
This is easily tested by running the gl_overlay demo program and
seeing if the display is correct when you drag another window over
it or if you drag the window off the screen and back on. You have to
exit and run the program again for it to see any changes to the
environment variable.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1246 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2000-07-07 12:38:58 +04:00
|
|
|
}
|
|
|
|
}
|
1998-10-06 23:14:55 +04:00
|
|
|
|
Buttons with box(FL_NO_BOX) did not draw. Apparently they did in
older versions of fltk, I restored this. (bug 108771)
Removed 8-bit colormap drawing code that was not doing anything in
fl_draw_image due to Mike's changes. I also made fl_color(r,g,b)
actually allocate the requested color rather than the nearest fltk
color-cube color (this is only done for the first color that maps to a
given entry in the fltk color cube), the result is that pixmaps with a
small number of colors are drawn much more accurately. The resulting
code seems to produce better images and is a good deal smaller!
Fixed makeinclude.in so CFLAGS are used for c source code instead of
CXXFLAGS. (bug 108694)
Better fix for gif files suggested by pauly (bug 108770)
Performance of Fl_Gl_Window may be improved on some types of OpenGL
implementations, in particular MESA or other software emulators, by
setting the GL_SWAP_TYPE environment variable. This variable
declares what is in the back buffer after you do a swapbuffers.
setenv GL_SWAP_TYPE COPY
This indicates that the back buffer is copied to the front buffer,
and still contains it's old data. This is true of many hardware
implementations. Setting this will speed up emulation of
overlays, and widgets that can do partial update can take
advantage of this as damage() will not be cleared to -1.
setenv GL_SWAP_TYPE NODAMAGE
This indicates that nothing changes the back buffer except drawing
into it. This is true of MESA and Win32 software emulation and
perhaps some hardware emulation on systems with lots of memory.
All other values for GL_SWAP_TYPE, and not setting the variable,
cause fltk to assumme that the back buffer must be completely
redrawn after a swap.
This is easily tested by running the gl_overlay demo program and
seeing if the display is correct when you drag another window over
it or if you drag the window off the screen and back on. You have to
exit and run the program again for it to see any changes to the
environment variable.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1246 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2000-07-07 12:38:58 +04:00
|
|
|
if (SWAP_TYPE == NODAMAGE) {
|
1998-10-06 23:14:55 +04:00
|
|
|
|
Buttons with box(FL_NO_BOX) did not draw. Apparently they did in
older versions of fltk, I restored this. (bug 108771)
Removed 8-bit colormap drawing code that was not doing anything in
fl_draw_image due to Mike's changes. I also made fl_color(r,g,b)
actually allocate the requested color rather than the nearest fltk
color-cube color (this is only done for the first color that maps to a
given entry in the fltk color cube), the result is that pixmaps with a
small number of colors are drawn much more accurately. The resulting
code seems to produce better images and is a good deal smaller!
Fixed makeinclude.in so CFLAGS are used for c source code instead of
CXXFLAGS. (bug 108694)
Better fix for gif files suggested by pauly (bug 108770)
Performance of Fl_Gl_Window may be improved on some types of OpenGL
implementations, in particular MESA or other software emulators, by
setting the GL_SWAP_TYPE environment variable. This variable
declares what is in the back buffer after you do a swapbuffers.
setenv GL_SWAP_TYPE COPY
This indicates that the back buffer is copied to the front buffer,
and still contains it's old data. This is true of many hardware
implementations. Setting this will speed up emulation of
overlays, and widgets that can do partial update can take
advantage of this as damage() will not be cleared to -1.
setenv GL_SWAP_TYPE NODAMAGE
This indicates that nothing changes the back buffer except drawing
into it. This is true of MESA and Win32 software emulation and
perhaps some hardware emulation on systems with lots of memory.
All other values for GL_SWAP_TYPE, and not setting the variable,
cause fltk to assumme that the back buffer must be completely
redrawn after a swap.
This is easily tested by running the gl_overlay demo program and
seeing if the display is correct when you drag another window over
it or if you drag the window off the screen and back on. You have to
exit and run the program again for it to see any changes to the
environment variable.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1246 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2000-07-07 12:38:58 +04:00
|
|
|
// don't draw if only overlay damage or expose events:
|
|
|
|
if ((damage()&~(FL_DAMAGE_OVERLAY|FL_DAMAGE_EXPOSE)) || !save_valid)
|
|
|
|
draw();
|
|
|
|
swap_buffers();
|
1998-10-06 23:14:55 +04:00
|
|
|
|
Buttons with box(FL_NO_BOX) did not draw. Apparently they did in
older versions of fltk, I restored this. (bug 108771)
Removed 8-bit colormap drawing code that was not doing anything in
fl_draw_image due to Mike's changes. I also made fl_color(r,g,b)
actually allocate the requested color rather than the nearest fltk
color-cube color (this is only done for the first color that maps to a
given entry in the fltk color cube), the result is that pixmaps with a
small number of colors are drawn much more accurately. The resulting
code seems to produce better images and is a good deal smaller!
Fixed makeinclude.in so CFLAGS are used for c source code instead of
CXXFLAGS. (bug 108694)
Better fix for gif files suggested by pauly (bug 108770)
Performance of Fl_Gl_Window may be improved on some types of OpenGL
implementations, in particular MESA or other software emulators, by
setting the GL_SWAP_TYPE environment variable. This variable
declares what is in the back buffer after you do a swapbuffers.
setenv GL_SWAP_TYPE COPY
This indicates that the back buffer is copied to the front buffer,
and still contains it's old data. This is true of many hardware
implementations. Setting this will speed up emulation of
overlays, and widgets that can do partial update can take
advantage of this as damage() will not be cleared to -1.
setenv GL_SWAP_TYPE NODAMAGE
This indicates that nothing changes the back buffer except drawing
into it. This is true of MESA and Win32 software emulation and
perhaps some hardware emulation on systems with lots of memory.
All other values for GL_SWAP_TYPE, and not setting the variable,
cause fltk to assumme that the back buffer must be completely
redrawn after a swap.
This is easily tested by running the gl_overlay demo program and
seeing if the display is correct when you drag another window over
it or if you drag the window off the screen and back on. You have to
exit and run the program again for it to see any changes to the
environment variable.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1246 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2000-07-07 12:38:58 +04:00
|
|
|
} else if (SWAP_TYPE == COPY) {
|
1998-10-06 23:14:55 +04:00
|
|
|
|
|
|
|
// don't draw if only the overlay is damaged:
|
Buttons with box(FL_NO_BOX) did not draw. Apparently they did in
older versions of fltk, I restored this. (bug 108771)
Removed 8-bit colormap drawing code that was not doing anything in
fl_draw_image due to Mike's changes. I also made fl_color(r,g,b)
actually allocate the requested color rather than the nearest fltk
color-cube color (this is only done for the first color that maps to a
given entry in the fltk color cube), the result is that pixmaps with a
small number of colors are drawn much more accurately. The resulting
code seems to produce better images and is a good deal smaller!
Fixed makeinclude.in so CFLAGS are used for c source code instead of
CXXFLAGS. (bug 108694)
Better fix for gif files suggested by pauly (bug 108770)
Performance of Fl_Gl_Window may be improved on some types of OpenGL
implementations, in particular MESA or other software emulators, by
setting the GL_SWAP_TYPE environment variable. This variable
declares what is in the back buffer after you do a swapbuffers.
setenv GL_SWAP_TYPE COPY
This indicates that the back buffer is copied to the front buffer,
and still contains it's old data. This is true of many hardware
implementations. Setting this will speed up emulation of
overlays, and widgets that can do partial update can take
advantage of this as damage() will not be cleared to -1.
setenv GL_SWAP_TYPE NODAMAGE
This indicates that nothing changes the back buffer except drawing
into it. This is true of MESA and Win32 software emulation and
perhaps some hardware emulation on systems with lots of memory.
All other values for GL_SWAP_TYPE, and not setting the variable,
cause fltk to assumme that the back buffer must be completely
redrawn after a swap.
This is easily tested by running the gl_overlay demo program and
seeing if the display is correct when you drag another window over
it or if you drag the window off the screen and back on. You have to
exit and run the program again for it to see any changes to the
environment variable.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1246 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2000-07-07 12:38:58 +04:00
|
|
|
if (damage() != FL_DAMAGE_OVERLAY || !save_valid) draw();
|
|
|
|
swap_buffers();
|
|
|
|
|
|
|
|
} else { // SWAP_TYPE == UNDEFINED
|
|
|
|
|
|
|
|
// If we are faking the overlay, use CopyPixels to act like
|
|
|
|
// SWAP_TYPE == COPY. Otherwise overlay redraw is way too slow.
|
|
|
|
if (overlay == this) {
|
|
|
|
// don't draw if only the overlay is damaged:
|
|
|
|
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:
|
2001-03-14 20:20:02 +03:00
|
|
|
static GLContext ortho_context = 0;
|
Buttons with box(FL_NO_BOX) did not draw. Apparently they did in
older versions of fltk, I restored this. (bug 108771)
Removed 8-bit colormap drawing code that was not doing anything in
fl_draw_image due to Mike's changes. I also made fl_color(r,g,b)
actually allocate the requested color rather than the nearest fltk
color-cube color (this is only done for the first color that maps to a
given entry in the fltk color cube), the result is that pixmaps with a
small number of colors are drawn much more accurately. The resulting
code seems to produce better images and is a good deal smaller!
Fixed makeinclude.in so CFLAGS are used for c source code instead of
CXXFLAGS. (bug 108694)
Better fix for gif files suggested by pauly (bug 108770)
Performance of Fl_Gl_Window may be improved on some types of OpenGL
implementations, in particular MESA or other software emulators, by
setting the GL_SWAP_TYPE environment variable. This variable
declares what is in the back buffer after you do a swapbuffers.
setenv GL_SWAP_TYPE COPY
This indicates that the back buffer is copied to the front buffer,
and still contains it's old data. This is true of many hardware
implementations. Setting this will speed up emulation of
overlays, and widgets that can do partial update can take
advantage of this as damage() will not be cleared to -1.
setenv GL_SWAP_TYPE NODAMAGE
This indicates that nothing changes the back buffer except drawing
into it. This is true of MESA and Win32 software emulation and
perhaps some hardware emulation on systems with lots of memory.
All other values for GL_SWAP_TYPE, and not setting the variable,
cause fltk to assumme that the back buffer must be completely
redrawn after a swap.
This is easily tested by running the gl_overlay demo program and
seeing if the display is correct when you drag another window over
it or if you drag the window off the screen and back on. You have to
exit and run the program again for it to see any changes to the
environment variable.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1246 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2000-07-07 12:38:58 +04:00
|
|
|
static Fl_Gl_Window* ortho_window = 0;
|
2002-08-09 07:17:30 +04:00
|
|
|
int orthoinit = !ortho_context;
|
|
|
|
if (orthoinit) ortho_context = fl_create_gl_context(this, g);
|
Buttons with box(FL_NO_BOX) did not draw. Apparently they did in
older versions of fltk, I restored this. (bug 108771)
Removed 8-bit colormap drawing code that was not doing anything in
fl_draw_image due to Mike's changes. I also made fl_color(r,g,b)
actually allocate the requested color rather than the nearest fltk
color-cube color (this is only done for the first color that maps to a
given entry in the fltk color cube), the result is that pixmaps with a
small number of colors are drawn much more accurately. The resulting
code seems to produce better images and is a good deal smaller!
Fixed makeinclude.in so CFLAGS are used for c source code instead of
CXXFLAGS. (bug 108694)
Better fix for gif files suggested by pauly (bug 108770)
Performance of Fl_Gl_Window may be improved on some types of OpenGL
implementations, in particular MESA or other software emulators, by
setting the GL_SWAP_TYPE environment variable. This variable
declares what is in the back buffer after you do a swapbuffers.
setenv GL_SWAP_TYPE COPY
This indicates that the back buffer is copied to the front buffer,
and still contains it's old data. This is true of many hardware
implementations. Setting this will speed up emulation of
overlays, and widgets that can do partial update can take
advantage of this as damage() will not be cleared to -1.
setenv GL_SWAP_TYPE NODAMAGE
This indicates that nothing changes the back buffer except drawing
into it. This is true of MESA and Win32 software emulation and
perhaps some hardware emulation on systems with lots of memory.
All other values for GL_SWAP_TYPE, and not setting the variable,
cause fltk to assumme that the back buffer must be completely
redrawn after a swap.
This is easily tested by running the gl_overlay demo program and
seeing if the display is correct when you drag another window over
it or if you drag the window off the screen and back on. You have to
exit and run the program again for it to see any changes to the
environment variable.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1246 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2000-07-07 12:38:58 +04:00
|
|
|
fl_set_gl_context(this, ortho_context);
|
2002-08-09 07:17:30 +04:00
|
|
|
if (orthoinit || !save_valid || ortho_window != this) {
|
Buttons with box(FL_NO_BOX) did not draw. Apparently they did in
older versions of fltk, I restored this. (bug 108771)
Removed 8-bit colormap drawing code that was not doing anything in
fl_draw_image due to Mike's changes. I also made fl_color(r,g,b)
actually allocate the requested color rather than the nearest fltk
color-cube color (this is only done for the first color that maps to a
given entry in the fltk color cube), the result is that pixmaps with a
small number of colors are drawn much more accurately. The resulting
code seems to produce better images and is a good deal smaller!
Fixed makeinclude.in so CFLAGS are used for c source code instead of
CXXFLAGS. (bug 108694)
Better fix for gif files suggested by pauly (bug 108770)
Performance of Fl_Gl_Window may be improved on some types of OpenGL
implementations, in particular MESA or other software emulators, by
setting the GL_SWAP_TYPE environment variable. This variable
declares what is in the back buffer after you do a swapbuffers.
setenv GL_SWAP_TYPE COPY
This indicates that the back buffer is copied to the front buffer,
and still contains it's old data. This is true of many hardware
implementations. Setting this will speed up emulation of
overlays, and widgets that can do partial update can take
advantage of this as damage() will not be cleared to -1.
setenv GL_SWAP_TYPE NODAMAGE
This indicates that nothing changes the back buffer except drawing
into it. This is true of MESA and Win32 software emulation and
perhaps some hardware emulation on systems with lots of memory.
All other values for GL_SWAP_TYPE, and not setting the variable,
cause fltk to assumme that the back buffer must be completely
redrawn after a swap.
This is easily tested by running the gl_overlay demo program and
seeing if the display is correct when you drag another window over
it or if you drag the window off the screen and back on. You have to
exit and run the program again for it to see any changes to the
environment variable.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1246 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2000-07-07 12:38:58 +04:00
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
glReadBuffer(GL_BACK);
|
|
|
|
glDrawBuffer(GL_FRONT);
|
|
|
|
glLoadIdentity();
|
|
|
|
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
|
|
|
|
damage1_ = 0;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
damage1_ = damage();
|
2005-04-28 21:48:04 +04:00
|
|
|
clear_damage(0xff); draw();
|
Buttons with box(FL_NO_BOX) did not draw. Apparently they did in
older versions of fltk, I restored this. (bug 108771)
Removed 8-bit colormap drawing code that was not doing anything in
fl_draw_image due to Mike's changes. I also made fl_color(r,g,b)
actually allocate the requested color rather than the nearest fltk
color-cube color (this is only done for the first color that maps to a
given entry in the fltk color cube), the result is that pixmaps with a
small number of colors are drawn much more accurately. The resulting
code seems to produce better images and is a good deal smaller!
Fixed makeinclude.in so CFLAGS are used for c source code instead of
CXXFLAGS. (bug 108694)
Better fix for gif files suggested by pauly (bug 108770)
Performance of Fl_Gl_Window may be improved on some types of OpenGL
implementations, in particular MESA or other software emulators, by
setting the GL_SWAP_TYPE environment variable. This variable
declares what is in the back buffer after you do a swapbuffers.
setenv GL_SWAP_TYPE COPY
This indicates that the back buffer is copied to the front buffer,
and still contains it's old data. This is true of many hardware
implementations. Setting this will speed up emulation of
overlays, and widgets that can do partial update can take
advantage of this as damage() will not be cleared to -1.
setenv GL_SWAP_TYPE NODAMAGE
This indicates that nothing changes the back buffer except drawing
into it. This is true of MESA and Win32 software emulation and
perhaps some hardware emulation on systems with lots of memory.
All other values for GL_SWAP_TYPE, and not setting the variable,
cause fltk to assumme that the back buffer must be completely
redrawn after a swap.
This is easily tested by running the gl_overlay demo program and
seeing if the display is correct when you drag another window over
it or if you drag the window off the screen and back on. You have to
exit and run the program again for it to see any changes to the
environment variable.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1246 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2000-07-07 12:38:58 +04:00
|
|
|
swap_buffers();
|
|
|
|
}
|
1998-10-06 23:14:55 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (overlay==this) { // fake overlay in front buffer
|
|
|
|
glDrawBuffer(GL_FRONT);
|
|
|
|
draw_overlay();
|
|
|
|
glDrawBuffer(GL_BACK);
|
|
|
|
glFlush();
|
|
|
|
}
|
|
|
|
|
|
|
|
} else { // single-buffered context is simpler:
|
|
|
|
|
1999-08-09 10:19:33 +04:00
|
|
|
draw();
|
1998-10-06 23:14:55 +04:00
|
|
|
if (overlay == this) draw_overlay();
|
|
|
|
glFlush();
|
Buttons with box(FL_NO_BOX) did not draw. Apparently they did in
older versions of fltk, I restored this. (bug 108771)
Removed 8-bit colormap drawing code that was not doing anything in
fl_draw_image due to Mike's changes. I also made fl_color(r,g,b)
actually allocate the requested color rather than the nearest fltk
color-cube color (this is only done for the first color that maps to a
given entry in the fltk color cube), the result is that pixmaps with a
small number of colors are drawn much more accurately. The resulting
code seems to produce better images and is a good deal smaller!
Fixed makeinclude.in so CFLAGS are used for c source code instead of
CXXFLAGS. (bug 108694)
Better fix for gif files suggested by pauly (bug 108770)
Performance of Fl_Gl_Window may be improved on some types of OpenGL
implementations, in particular MESA or other software emulators, by
setting the GL_SWAP_TYPE environment variable. This variable
declares what is in the back buffer after you do a swapbuffers.
setenv GL_SWAP_TYPE COPY
This indicates that the back buffer is copied to the front buffer,
and still contains it's old data. This is true of many hardware
implementations. Setting this will speed up emulation of
overlays, and widgets that can do partial update can take
advantage of this as damage() will not be cleared to -1.
setenv GL_SWAP_TYPE NODAMAGE
This indicates that nothing changes the back buffer except drawing
into it. This is true of MESA and Win32 software emulation and
perhaps some hardware emulation on systems with lots of memory.
All other values for GL_SWAP_TYPE, and not setting the variable,
cause fltk to assumme that the back buffer must be completely
redrawn after a swap.
This is easily tested by running the gl_overlay demo program and
seeing if the display is correct when you drag another window over
it or if you drag the window off the screen and back on. You have to
exit and run the program again for it to see any changes to the
environment variable.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1246 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2000-07-07 12:38:58 +04:00
|
|
|
|
1998-10-06 23:14:55 +04:00
|
|
|
}
|
|
|
|
|
2001-03-14 20:20:02 +03:00
|
|
|
#if HAVE_GL_OVERLAY && defined(WIN32)
|
2000-06-03 12:37:09 +04:00
|
|
|
if (fixcursor) SetCursor(Fl_X::i(this)->cursor);
|
|
|
|
#endif
|
1998-10-06 23:14:55 +04:00
|
|
|
valid(1);
|
2006-08-17 13:49:43 +04:00
|
|
|
context_valid(1);
|
1998-10-06 23:14:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Fl_Gl_Window::resize(int X,int Y,int W,int H) {
|
2003-03-31 22:23:53 +04:00
|
|
|
// printf("Fl_Gl_Window::resize(X=%d, Y=%d, W=%d, H=%d)\n", X, Y, W, H);
|
2005-05-12 23:16:27 +04:00
|
|
|
// printf("current: x()=%d, y()=%d, w()=%d, h()=%d\n", x(), y(), w(), h());
|
2003-03-31 22:23:53 +04:00
|
|
|
|
2005-05-12 23:16:27 +04:00
|
|
|
if (W != w() || H != h()) valid(0);
|
2003-03-31 22:23:53 +04:00
|
|
|
|
2005-05-12 23:16:27 +04:00
|
|
|
#ifdef __APPLE__
|
|
|
|
if (X != x() || Y != y() || W != w() || H != h()) aglUpdateContext(context_);
|
2001-11-27 20:44:08 +03:00
|
|
|
#elif !defined(WIN32)
|
2005-05-12 23:16:27 +04:00
|
|
|
if ((W != w() || H != h()) && !resizable() && overlay && overlay != this) {
|
|
|
|
((Fl_Gl_Window*)overlay)->resize(0,0,W,H);
|
2000-09-15 11:52:51 +04:00
|
|
|
}
|
2005-05-12 23:16:27 +04:00
|
|
|
#endif
|
|
|
|
|
1998-10-06 23:14:55 +04:00
|
|
|
Fl_Window::resize(X,Y,W,H);
|
|
|
|
}
|
|
|
|
|
2001-03-14 20:20:02 +03:00
|
|
|
void Fl_Gl_Window::context(void* v, int destroy_flag) {
|
|
|
|
if (context_ && !(mode_&NON_LOCAL_CONTEXT)) fl_delete_gl_context(context_);
|
|
|
|
context_ = (GLContext)v;
|
|
|
|
if (destroy_flag) mode_ &= ~NON_LOCAL_CONTEXT;
|
|
|
|
else mode_ |= NON_LOCAL_CONTEXT;
|
|
|
|
}
|
|
|
|
|
1998-10-06 23:14:55 +04:00
|
|
|
void Fl_Gl_Window::hide() {
|
2001-03-14 20:20:02 +03:00
|
|
|
context(0);
|
|
|
|
#if HAVE_GL_OVERLAY && defined(WIN32)
|
|
|
|
if (overlay && overlay != this) {
|
|
|
|
fl_delete_gl_context((GLContext)overlay);
|
2000-04-07 20:55:46 +04:00
|
|
|
overlay = 0;
|
|
|
|
}
|
|
|
|
#endif
|
1998-10-06 23:14:55 +04:00
|
|
|
Fl_Window::hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
Fl_Gl_Window::~Fl_Gl_Window() {
|
|
|
|
hide();
|
|
|
|
// delete overlay; this is done by ~Fl_Group
|
|
|
|
}
|
|
|
|
|
|
|
|
void Fl_Gl_Window::init() {
|
|
|
|
end(); // we probably don't want any children
|
|
|
|
box(FL_NO_BOX);
|
2001-12-11 19:03:13 +03:00
|
|
|
|
|
|
|
mode_ = FL_RGB | FL_DEPTH | FL_DOUBLE;
|
|
|
|
alist = 0;
|
2001-03-14 20:20:02 +03:00
|
|
|
context_ = 0;
|
2001-12-11 19:03:13 +03:00
|
|
|
g = 0;
|
|
|
|
overlay = 0;
|
2006-08-17 13:49:43 +04:00
|
|
|
valid_f_ = 0;
|
2001-12-11 19:03:13 +03:00
|
|
|
damage1_ = 0;
|
2002-12-04 07:44:54 +03:00
|
|
|
|
2006-01-15 02:12:27 +03:00
|
|
|
#if 0 // This breaks resizing on Linux/X11
|
2003-01-14 23:17:00 +03:00
|
|
|
int H = h();
|
|
|
|
h(1); // Make sure we actually do something in resize()...
|
|
|
|
resize(x(), y(), w(), H);
|
2006-01-15 02:12:27 +03:00
|
|
|
#endif // 0
|
1998-10-06 23:14:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Fl_Gl_Window::draw_overlay() {}
|
|
|
|
|
|
|
|
#endif
|
1998-10-20 00:46:58 +04:00
|
|
|
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
1998-10-20 00:46:58 +04:00
|
|
|
//
|