summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/mac.H16
-rw-r--r--src/Fl_Gl_Choice.cxx24
-rw-r--r--src/Fl_Gl_Window.cxx7
-rw-r--r--src/Fl_cocoa.mm22
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H18
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H4
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx3
-rw-r--r--src/gl_start.cxx6
8 files changed, 53 insertions, 47 deletions
diff --git a/FL/mac.H b/FL/mac.H
index 9c4ce11a8..ee212d1e4 100644
--- a/FL/mac.H
+++ b/FL/mac.H
@@ -76,14 +76,6 @@ typedef unsigned int NSUInteger;
#endif
#endif
-#ifdef __OBJC__
-@class NSOpenGLPixelFormat;
-@class NSOpenGLContext;
-#else
-class NSOpenGLPixelFormat;
-class NSOpenGLContext;
-#endif // __OBJC__
-
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4
typedef CGImageAlphaInfo CGBitmapInfo;
#endif
@@ -113,14 +105,6 @@ public:
Fl_X *next; // chain of mapped windows
static Fl_X* first;
static Fl_X* i(const Fl_Window* w) {return (Fl_X*)w->i;}
- // Cocoa additions
- static NSOpenGLPixelFormat *mode_to_NSOpenGLPixelFormat(int mode, const int*); // computes NSOpenGLPixelFormat from Gl window's mode
- static NSOpenGLContext* create_GLcontext_for_window(NSOpenGLPixelFormat *pixelformat, NSOpenGLContext *shared_ctx, Fl_Window *window);
- static void GLcontext_update(NSOpenGLContext*);
- static void GLcontext_flushbuffer(NSOpenGLContext*);
- static void GLcontext_release(NSOpenGLContext*);
- static void GLcontext_makecurrent(NSOpenGLContext*);
- static void GL_cleardrawable(void);
};
extern Window fl_window;
diff --git a/src/Fl_Gl_Choice.cxx b/src/Fl_Gl_Choice.cxx
index b3e615adb..1ea351e57 100644
--- a/src/Fl_Gl_Choice.cxx
+++ b/src/Fl_Gl_Choice.cxx
@@ -28,7 +28,9 @@
# include "flstring.h"
# include <FL/fl_utf8.h>
-#if defined(WIN32) || defined(__APPLE__) // PORTME: platform OpenGL management
+#if defined(WIN32)
+#elif defined(__APPLE__) // PORTME: platform OpenGL management
+#include "drivers/Cocoa/Fl_Cocoa_Screen_Driver.H"
#elif defined(FL_PORTING)
# pragma message "FL_PORTING: add code to list and select OpenGL drawing contexts"
#else
@@ -111,8 +113,8 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) {
return 0;
}
-#elif defined(__APPLE_QUARTZ__) // PORTME: platform OpenGL management
- NSOpenGLPixelFormat* fmt = Fl_X::mode_to_NSOpenGLPixelFormat(m, alistp);
+#elif defined(__APPLE__) // PORTME: platform OpenGL management
+ NSOpenGLPixelFormat* fmt = Fl_Cocoa_Screen_Driver::mode_to_NSOpenGLPixelFormat(m, alistp);
if (!fmt) return 0;
#elif defined(WIN32)
@@ -244,7 +246,7 @@ GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int lay
return context;
}
-# elif defined(__APPLE_QUARTZ__) // PORTME: platform OpenGL management
+# elif defined(__APPLE__) // PORTME: platform OpenGL management
GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer) {
GLContext context, shared_ctx = 0;
@@ -252,7 +254,7 @@ GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int lay
// resets the pile of string textures used to draw strings
// necessary before the first context is created
if (!shared_ctx) gl_texture_reset();
- context = Fl_X::create_GLcontext_for_window(g->pixelformat, shared_ctx, window);
+ context = Fl_Cocoa_Screen_Driver::create_GLcontext_for_window(g->pixelformat, shared_ctx, window);
if (!context) return 0;
add_context((GLContext)context);
return (context);
@@ -272,8 +274,8 @@ void fl_set_gl_context(Fl_Window* w, GLContext context) {
glXMakeCurrent(fl_display, fl_xid(w), context);
# elif defined(WIN32)
wglMakeCurrent(Fl_X::i(w)->private_dc, context);
-# elif defined(__APPLE_QUARTZ__) // PORTME: platform OpenGL management
- Fl_X::GLcontext_makecurrent(context);
+# elif defined(__APPLE__) // PORTME: platform OpenGL management
+ Fl_Cocoa_Screen_Driver::GLcontext_makecurrent(context);
# else
# error unsupported platform
# endif
@@ -287,8 +289,8 @@ void fl_no_gl_context() {
glXMakeCurrent(fl_display, 0, 0);
# elif defined(WIN32)
wglMakeCurrent(0, 0);
-# elif defined(__APPLE_QUARTZ__) // PORTME: platform OpenGL management
- Fl_X::GL_cleardrawable();
+# elif defined(__APPLE__) // PORTME: platform OpenGL management
+ Fl_Cocoa_Screen_Driver::GL_cleardrawable();
# else
# error unsupported platform
# endif
@@ -300,8 +302,8 @@ void fl_delete_gl_context(GLContext context) {
glXDestroyContext(fl_display, context);
# elif defined(WIN32)
wglDeleteContext(context);
-# elif defined(__APPLE_QUARTZ__) // PORTME: platform OpenGL management
- Fl_X::GLcontext_release(context);
+# elif defined(__APPLE__) // PORTME: platform OpenGL management
+ Fl_Cocoa_Screen_Driver::GLcontext_release(context);
# else
# error unsupported platform
# endif
diff --git a/src/Fl_Gl_Window.cxx b/src/Fl_Gl_Window.cxx
index 0078c089b..acd790e7b 100644
--- a/src/Fl_Gl_Window.cxx
+++ b/src/Fl_Gl_Window.cxx
@@ -31,6 +31,7 @@ extern int fl_gl_load_plugin;
#include <FL/gl.h>
#include <OpenGL/OpenGL.h>
#include "drivers/Cocoa/Fl_Cocoa_Window_Driver.H"
+#include "drivers/Cocoa/Fl_Cocoa_Screen_Driver.H"
#endif
#include <FL/Fl_Gl_Window.H>
#include <FL/Fl_Device.H>
@@ -201,7 +202,7 @@ void Fl_Gl_Window::make_current() {
if (d->changed_resolution()){
d->changed_resolution(false);
invalidate();
- Fl_X::GLcontext_update(context_);
+ Fl_Cocoa_Screen_Driver::GLcontext_update(context_);
}
#endif
if (!context_) {
@@ -411,7 +412,7 @@ void Fl_Gl_Window::flush() {
}
#ifdef __APPLE__ // PORTME: platform OpenGL management
- Fl_X::GLcontext_flushbuffer(context_);
+ Fl_Cocoa_Screen_Driver::GLcontext_flushbuffer(context_);
#endif
if (overlay==this && SWAP_TYPE != SWAP) { // fake overlay in front buffer
@@ -443,7 +444,7 @@ void Fl_Gl_Window::resize(int X,int Y,int W,int H) {
#ifdef __APPLE__ // PORTME: platform OpenGL management
Fl_X *flx = Fl_X::i(this);
Fl_Cocoa_Window_Driver *d = (Fl_Cocoa_Window_Driver*)driver();
- if (flx && d->in_windowDidResize()) Fl_X::GLcontext_update(context_);
+ if (flx && d->in_windowDidResize()) Fl_Cocoa_Screen_Driver::GLcontext_update(context_);
#endif
#if ! ( defined(__APPLE__) || defined(WIN32) ) // PORTME: platform OpenGL management
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 77f2d4d16..f924dd98f 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -2726,7 +2726,7 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
@end
-NSOpenGLPixelFormat* Fl_X::mode_to_NSOpenGLPixelFormat(int m, const int *alistp)
+NSOpenGLPixelFormat* Fl_Cocoa_Screen_Driver::mode_to_NSOpenGLPixelFormat(int m, const int *alistp)
{
NSOpenGLPixelFormatAttribute attribs[32];
int n = 0;
@@ -2814,7 +2814,7 @@ NSOpenGLPixelFormat* Fl_X::mode_to_NSOpenGLPixelFormat(int m, const int *alistp)
return pixform;
}
-NSOpenGLContext* Fl_X::create_GLcontext_for_window(NSOpenGLPixelFormat *pixelformat,
+NSOpenGLContext* Fl_Cocoa_Screen_Driver::create_GLcontext_for_window(NSOpenGLPixelFormat *pixelformat,
NSOpenGLContext *shared_ctx, Fl_Window *window)
{
NSOpenGLContext *context = [[NSOpenGLContext alloc] initWithFormat:pixelformat shareContext:shared_ctx];
@@ -2831,27 +2831,27 @@ NSOpenGLContext* Fl_X::create_GLcontext_for_window(NSOpenGLPixelFormat *pixelfor
return context;
}
-void Fl_X::GLcontext_update(NSOpenGLContext* ctxt)
+void Fl_Cocoa_Screen_Driver::GLcontext_update(NSOpenGLContext* ctxt)
{
[ctxt update];
}
-void Fl_X::GLcontext_flushbuffer(NSOpenGLContext* ctxt)
+void Fl_Cocoa_Screen_Driver::GLcontext_flushbuffer(NSOpenGLContext* ctxt)
{
[ctxt flushBuffer];
}
-void Fl_X::GLcontext_release(NSOpenGLContext* ctxt)
+void Fl_Cocoa_Screen_Driver::GLcontext_release(NSOpenGLContext* ctxt)
{
[ctxt release];
}
-void Fl_X::GL_cleardrawable(void)
+void Fl_Cocoa_Screen_Driver::GL_cleardrawable(void)
{
[[NSOpenGLContext currentContext] clearDrawable];
}
-void Fl_X::GLcontext_makecurrent(NSOpenGLContext* ctxt)
+void Fl_Cocoa_Screen_Driver::GLcontext_makecurrent(NSOpenGLContext* ctxt)
{
[ctxt makeCurrentContext];
}
@@ -3504,12 +3504,8 @@ int Fl_Darwin_System_Driver::clipboard_contains(const char *type) {
return found != nil;
}
-void Fl_Cocoa_Window_Driver::destroy() {
- FLWindow *xid = fl_xid(pWindow);
- if (xid) {
- [xid close];
- }
- delete subRect();
+void Fl_Cocoa_Window_Driver::destroy(FLWindow *xid) {
+ [xid close];
}
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H
index 4cde863d7..947d3d133 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H
+++ b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H
@@ -41,6 +41,15 @@
class Fl_Window;
class Fl_Input;
+#ifdef __OBJC__
+@class NSOpenGLPixelFormat;
+@class NSOpenGLContext;
+#else
+class NSOpenGLPixelFormat;
+class NSOpenGLContext;
+#endif // __OBJC__
+
+
class FL_EXPORT Fl_Cocoa_Screen_Driver : public Fl_Screen_Driver
{
protected:
@@ -55,6 +64,15 @@ protected:
public:
Fl_Cocoa_Screen_Driver();
static int next_marked_length; // next length of marked text after current marked text will have been replaced
+ // --- Cocoa-only members
+ // computes NSOpenGLPixelFormat from Gl window's mode
+ static NSOpenGLPixelFormat *mode_to_NSOpenGLPixelFormat(int mode, const int*); // uses Objective-c
+ static NSOpenGLContext* create_GLcontext_for_window(NSOpenGLPixelFormat *pixelformat, NSOpenGLContext *shared_ctx, Fl_Window *window);
+ static void GLcontext_update(NSOpenGLContext*);
+ static void GLcontext_flushbuffer(NSOpenGLContext*);
+ static void GLcontext_release(NSOpenGLContext*);
+ static void GLcontext_makecurrent(NSOpenGLContext*);
+ static void GL_cleardrawable(void);
// --- display management
// --- screen configuration
virtual void init();
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
index 3f7f0ab64..bd1071716 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
+++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
@@ -33,9 +33,11 @@ class Fl_Window;
#ifdef __OBJC__
@class CALayer;
@class NSCursor;
+@class FLWindow;
#else
class CALayer;
class NSCursor;
+class FLWindow;
#endif // __OBJC__
/*
@@ -85,7 +87,7 @@ public:
void in_windowDidResize(bool); // sets whether window is performing windowDidResize
CGRect* subRect() { return subRect_; } // getter
void subRect(CGRect *r) { subRect_ = r; } // setter
- void destroy();
+ static void destroy(FLWindow*);
unsigned char *bitmap_from_window_rect(int x, int y, int w, int h, int *bytesPerPixel);
CGImageRef CGImage_from_window_rect(int x, int y, int w, int h);
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx
index 8e1b59ee2..91e0c263f 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx
+++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx
@@ -240,7 +240,8 @@ void Fl_Cocoa_Window_Driver::hide() {
if ( ip->xid == fl_window )
fl_window = 0;
if (ip->region) Fl_Graphics_Driver::default_driver().XDestroyRegion(ip->region);
- destroy();
+ destroy(ip->xid);
+ delete subRect();
delete ip;
}
diff --git a/src/gl_start.cxx b/src/gl_start.cxx
index bfb50e3ce..a9da93f73 100644
--- a/src/gl_start.cxx
+++ b/src/gl_start.cxx
@@ -28,7 +28,9 @@
// be erased when the buffers are swapped (when double buffer hardware
// is being used)
-#if defined(WIN32) || defined(__APPLE__) // PORTME: platform opengl
+#if defined(WIN32) // PORTME: platform opengl
+#elif defined(__APPLE__)
+#include "drivers/Cocoa/Fl_Cocoa_Screen_Driver.H"
#elif defined(FL_PORTING)
# pragma message "FL_PORTING: if possible, add OpenGL rendering in non-OpenGL contexts"
#else
@@ -72,7 +74,7 @@ void gl_start() {
}
fl_set_gl_context(Fl_Window::current(), context);
#ifdef __APPLE__
- Fl_X::GLcontext_update(context); // supports window resizing
+ Fl_Cocoa_Screen_Driver::GLcontext_update(context); // supports window resizing
#elif !defined(WIN32)
glXWaitX();
#endif