summaryrefslogtreecommitdiff
path: root/src/Fl_Gl_Window.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2009-12-06 22:21:55 +0000
committerMatthias Melcher <fltk@matthiasm.com>2009-12-06 22:21:55 +0000
commitb2cffc688ea7abbddabc9ed23deea1921f59ac9d (patch)
tree74a50bdb133fd6b5af7c785541bcc46e2e8e9c15 /src/Fl_Gl_Window.cxx
parent1ea4b4573538f2d53960dd8a4ef4f35480d2f5f7 (diff)
Moved OS X code base to the more moder Cocoa toolkit thanks to the awesome work of Manolo Gouy (STR #2221). This is a big one! I tested all test applications under 32-bit autoconf and Xcode, and a few apps under 64bit intel. No PPC testing was done. Please verify this patch if you have the machine!
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6951 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Gl_Window.cxx')
-rw-r--r--src/Fl_Gl_Window.cxx29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/Fl_Gl_Window.cxx b/src/Fl_Gl_Window.cxx
index ae84f38de..b5b052075 100644
--- a/src/Fl_Gl_Window.cxx
+++ b/src/Fl_Gl_Window.cxx
@@ -66,6 +66,9 @@ int Fl_Gl_Window::can_do(int a, const int *b) {
}
void Fl_Gl_Window::show() {
+#if defined(__APPLE__) && defined(__APPLE_COCOA__)
+ int need_redraw = 0;
+#endif
if (!shown()) {
if (!g) {
g = Fl_Gl_Choice::find(mode_,alist);
@@ -83,12 +86,19 @@ void Fl_Gl_Window::show() {
#if !defined(WIN32) && !defined(__APPLE__)
Fl_X::make_xid(this, g->vis, g->colormap);
if (overlay && overlay != this) ((Fl_Gl_Window*)overlay)->show();
+#elif defined(__APPLE__) && defined(__APPLE_COCOA__)
+ extern void MACsetContainsGLsubwindow(Fl_Window *);
+ if( ! parent() ) need_redraw=1;
+ else MACsetContainsGLsubwindow( window() );
#endif
}
Fl_Window::show();
#ifdef __APPLE__
set_visible();
+#ifdef __APPLE_COCOA__
+ if(need_redraw) redraw();//necessary only after creation of a top-level GL window
+#endif
#endif /* __APPLE__ */
}
@@ -154,6 +164,7 @@ int Fl_Gl_Window::mode(int m, const int *a) {
being called and can also be used to implement feedback and/or
selection within the handle() method.
*/
+
void Fl_Gl_Window::make_current() {
// puts("Fl_Gl_Window::make_current()");
// printf("make_current: context_=%p\n", context_);
@@ -237,6 +248,15 @@ void Fl_Gl_Window::swap_buffers() {
# endif
#elif defined(__APPLE_QUARTZ__)
// warning: the Quartz version should probably use Core GL (CGL) instead of AGL
+#ifdef __APPLE_COCOA__
+ if(overlay != NULL) {
+ //aglSwapBuffers does not work well with overlays under cocoa
+ glReadBuffer(GL_BACK);
+ glDrawBuffer(GL_FRONT);
+ glCopyPixels(0,0,w(),h(),GL_COLOR);
+ }
+ else
+#endif
aglSwapBuffers((AGLContext)context_);
#else
# error unsupported platform
@@ -248,6 +268,7 @@ uchar fl_overlay; // changes how fl_color() works
int fl_overlay_depth = 0;
#endif
+
void Fl_Gl_Window::flush() {
uchar save_valid = valid_f_ & 1;
#if HAVE_GL_OVERLAY && defined(WIN32)
@@ -257,13 +278,19 @@ void Fl_Gl_Window::flush() {
#if defined(__APPLE_QUARTZ__)
// warning: the Quartz version should probably use Core GL (CGL) instead of AGL
//: clear previous clipping in this shared port
+#if ! __LP64__
+#ifdef __APPLE_COCOA__
+ GrafPtr port = GetWindowPort( MACwindowRef(this) );
+#else
GrafPtr port = GetWindowPort( fl_xid(this) );
+#endif
Rect rect; SetRect( &rect, 0, 0, 0x7fff, 0x7fff );
GrafPtr old; GetPort( &old );
SetPort( port );
ClipRect( &rect );
SetPort( old );
#endif
+#endif
#if HAVE_GL_OVERLAY && defined(WIN32)
@@ -327,7 +354,7 @@ void Fl_Gl_Window::flush() {
// don't draw if only the overlay is damaged:
if (damage() != FL_DAMAGE_OVERLAY || !save_valid) draw();
- swap_buffers();
+ swap_buffers();
} else { // SWAP_TYPE == UNDEFINED