summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2018-10-31 12:45:51 +0000
committerManolo Gouy <Manolo>2018-10-31 12:45:51 +0000
commit6c8115ee9b30a89724df122c0af20c24ac6cfe52 (patch)
treee9142b3a91954f2ca61c3a49fb855af7f6198909
parent22bcc7b4cacee37be4e0559c84c848d1f6b1daf6 (diff)
Remove use of Fl_Gl_Window_Driver.H in file src/Fl_cocoa.mm
Thus, Fl_cocoa.mm is completely independent from code of libfltk_gl. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@13104 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--src/Fl_Gl_Choice.cxx12
-rw-r--r--src/Fl_Gl_Window.cxx6
-rw-r--r--src/Fl_Gl_Window_Driver.H7
-rw-r--r--src/Fl_cocoa.mm15
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H16
-rw-r--r--src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx7
-rw-r--r--src/gl_start.cxx3
7 files changed, 37 insertions, 29 deletions
diff --git a/src/Fl_Gl_Choice.cxx b/src/Fl_Gl_Choice.cxx
index c0e337674..7aa9171b0 100644
--- a/src/Fl_Gl_Choice.cxx
+++ b/src/Fl_Gl_Choice.cxx
@@ -85,13 +85,15 @@ static Fl_Window* cached_window;
#ifdef FL_CFG_GFX_QUARTZ
+# include "drivers/Cocoa/Fl_Cocoa_Window_Driver.H"
+
extern void gl_texture_reset();
Fl_Gl_Choice *Fl_Cocoa_Gl_Window_Driver::find(int m, const int *alistp)
{
Fl_Gl_Choice *g = Fl_Gl_Window_Driver::find_begin(m, alistp);
if (g) return g;
- NSOpenGLPixelFormat* fmt = mode_to_NSOpenGLPixelFormat(m, alistp);
+ NSOpenGLPixelFormat* fmt = Fl_Cocoa_Window_Driver::mode_to_NSOpenGLPixelFormat(m, alistp);
if (!fmt) return 0;
g = new Fl_Gl_Choice(m, alistp, first);
first = g;
@@ -105,7 +107,7 @@ GLContext Fl_Cocoa_Gl_Window_Driver::create_gl_context(Fl_Window* window, const
// resets the pile of string textures used to draw strings
// necessary before the first context is created
if (!shared_ctx) gl_texture_reset();
- context = create_GLcontext_for_window((NSOpenGLPixelFormat*)g->pixelformat, shared_ctx, window);
+ context = Fl_Cocoa_Window_Driver::create_GLcontext_for_window((NSOpenGLPixelFormat*)g->pixelformat, shared_ctx, window);
if (!context) return 0;
add_context(context);
return (context);
@@ -115,7 +117,7 @@ void Fl_Cocoa_Gl_Window_Driver::set_gl_context(Fl_Window* w, GLContext context)
if (context != cached_context || w != cached_window) {
cached_context = context;
cached_window = w;
- GLcontext_makecurrent(context);
+ Fl_Cocoa_Window_Driver::GLcontext_makecurrent(context);
}
}
@@ -123,9 +125,9 @@ void Fl_Cocoa_Gl_Window_Driver::delete_gl_context(GLContext context) {
if (cached_context == context) {
cached_context = 0;
cached_window = 0;
- GL_cleardrawable();
+ Fl_Cocoa_Window_Driver::GL_cleardrawable();
}
- GLcontext_release(context);
+ Fl_Cocoa_Window_Driver::GLcontext_release(context);
del_context(context);
}
diff --git a/src/Fl_Gl_Window.cxx b/src/Fl_Gl_Window.cxx
index 2248e1a84..3968fa7ca 100644
--- a/src/Fl_Gl_Window.cxx
+++ b/src/Fl_Gl_Window.cxx
@@ -558,7 +558,7 @@ void Fl_Cocoa_Gl_Window_Driver::make_current_before() {
if (d->changed_resolution()){
d->changed_resolution(false);
pWindow->invalidate();
- GLcontext_update(pWindow->context());
+ Fl_Cocoa_Window_Driver::GLcontext_update(pWindow->context());
}
}
@@ -594,13 +594,13 @@ void Fl_Cocoa_Gl_Window_Driver::swap_buffers() {
glRasterPos3f(pos[0], pos[1], pos[2]); // restore original glRasterPos
}
else
- flush_context(pWindow->context());//aglSwapBuffers((AGLContext)context_);
+ Fl_Cocoa_Window_Driver::flush_context(pWindow->context());//aglSwapBuffers((AGLContext)context_);
}
void Fl_Cocoa_Gl_Window_Driver::resize(int is_a_resize, int unused, int also) {
Fl_X *flx = Fl_X::i(pWindow);
Fl_Cocoa_Window_Driver *d = Fl_Cocoa_Window_Driver::driver(pWindow);
- if (flx && d->in_windowDidResize()) GLcontext_update(pWindow->context());
+ if (flx && d->in_windowDidResize()) Fl_Cocoa_Window_Driver::GLcontext_update(pWindow->context());
}
char Fl_Cocoa_Gl_Window_Driver::swap_type() {return COPY;}
diff --git a/src/Fl_Gl_Window_Driver.H b/src/Fl_Gl_Window_Driver.H
index 9ac15b3ae..c0e4e2c6c 100644
--- a/src/Fl_Gl_Window_Driver.H
+++ b/src/Fl_Gl_Window_Driver.H
@@ -119,13 +119,6 @@ class Fl_Cocoa_Gl_Window_Driver : public Fl_Gl_Window_Driver {
virtual void make_overlay_current();
virtual void redraw_overlay();
virtual void gl_start();
- static NSOpenGLContext* create_GLcontext_for_window(NSOpenGLPixelFormat *pixelformat, NSOpenGLContext *shared_ctx, Fl_Window *window);
- static NSOpenGLPixelFormat *mode_to_NSOpenGLPixelFormat(int mode, const int*); // uses Objective-c
- static void GLcontext_update(NSOpenGLContext*); // uses Objective-c
- static void GLcontext_release(NSOpenGLContext*); // uses Objective-c
- static void flush_context(NSOpenGLContext*); // uses Objective-c
- static void GLcontext_makecurrent(NSOpenGLContext*); // uses Objective-c
- static void GL_cleardrawable(void); // uses Objective-c
virtual char *alpha_mask_for_string(const char *str, int n, int w, int h);
};
#endif // FL_CFG_GFX_QUARTZ
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index e30b85943..dec3f3592 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -43,7 +43,6 @@ extern "C" {
#include <FL/Fl_Tooltip.H>
#include <FL/Fl_Printer.H>
#include <FL/fl_draw.H>
-#include "Fl_Gl_Window_Driver.H"
#include "drivers/Quartz/Fl_Quartz_Graphics_Driver.H"
#include "drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.H"
#include "drivers/Cocoa/Fl_Cocoa_Screen_Driver.H"
@@ -2811,7 +2810,7 @@ static CGContextRef prepare_bitmap_for_layer(int w, int h ) {
@end
-NSOpenGLPixelFormat* Fl_Cocoa_Gl_Window_Driver::mode_to_NSOpenGLPixelFormat(int m, const int *alistp)
+NSOpenGLPixelFormat* Fl_Cocoa_Window_Driver::mode_to_NSOpenGLPixelFormat(int m, const int *alistp)
{
NSOpenGLPixelFormatAttribute attribs[32];
int n = 0;
@@ -2899,7 +2898,7 @@ NSOpenGLPixelFormat* Fl_Cocoa_Gl_Window_Driver::mode_to_NSOpenGLPixelFormat(int
return pixform;
}
-NSOpenGLContext* Fl_Cocoa_Gl_Window_Driver::create_GLcontext_for_window(NSOpenGLPixelFormat *pixelformat,
+NSOpenGLContext* Fl_Cocoa_Window_Driver::create_GLcontext_for_window(NSOpenGLPixelFormat *pixelformat,
NSOpenGLContext *shared_ctx, Fl_Window *window)
{
NSOpenGLContext *context = [[NSOpenGLContext alloc] initWithFormat:pixelformat shareContext:shared_ctx];
@@ -2919,27 +2918,27 @@ NSOpenGLContext* Fl_Cocoa_Gl_Window_Driver::create_GLcontext_for_window(NSOpenGL
return context;
}
-void Fl_Cocoa_Gl_Window_Driver::GLcontext_update(NSOpenGLContext* ctxt)
+void Fl_Cocoa_Window_Driver::GLcontext_update(NSOpenGLContext* ctxt)
{
[ctxt update];
}
-void Fl_Cocoa_Gl_Window_Driver::flush_context(NSOpenGLContext* ctxt)
+void Fl_Cocoa_Window_Driver::flush_context(NSOpenGLContext* ctxt)
{
[ctxt flushBuffer];
}
-void Fl_Cocoa_Gl_Window_Driver::GLcontext_release(NSOpenGLContext* ctxt)
+void Fl_Cocoa_Window_Driver::GLcontext_release(NSOpenGLContext* ctxt)
{
[ctxt release];
}
-void Fl_Cocoa_Gl_Window_Driver::GL_cleardrawable(void)
+void Fl_Cocoa_Window_Driver::GL_cleardrawable(void)
{
[[NSOpenGLContext currentContext] clearDrawable];
}
-void Fl_Cocoa_Gl_Window_Driver::GLcontext_makecurrent(NSOpenGLContext* ctxt)
+void Fl_Cocoa_Window_Driver::GLcontext_makecurrent(NSOpenGLContext* ctxt)
{
[ctxt makeCurrentContext];
}
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
index 7ce5fe6aa..b46a66e9f 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
+++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
@@ -34,10 +34,14 @@ class Fl_Window;
@class CALayer;
@class NSCursor;
@class FLWindow;
+@class NSOpenGLContext;
+@class NSOpenGLPixelFormat;
#else
class CALayer;
class NSCursor;
class FLWindow;
+class NSOpenGLContext;
+class NSOpenGLPixelFormat;
#endif // __OBJC__
/**
@@ -136,10 +140,18 @@ public:
virtual void wait_for_expose();
static void draw_layer_to_context(CALayer *layer, CGContextRef gc, int w, int h);
virtual int scroll(int src_x, int src_y, int src_w, int src_h, int dest_x, int dest_y, void (*draw_area)(void*, int,int,int,int), void* data);
+
+ // these functions are OpenGL-related and use objective-c
+ // they are put here to avoid libfltk_gl dependency in Fl_cocoa.mm
+ static NSOpenGLContext* create_GLcontext_for_window(NSOpenGLPixelFormat *pixelformat, NSOpenGLContext *shared_ctx, Fl_Window *window);
+ static NSOpenGLPixelFormat *mode_to_NSOpenGLPixelFormat(int mode, const int*); // uses Objective-c
+ static void GLcontext_update(NSOpenGLContext*); // uses Objective-c
+ static void GLcontext_release(NSOpenGLContext*); // uses Objective-c
+ static void flush_context(NSOpenGLContext*); // uses Objective-c
+ static void GLcontext_makecurrent(NSOpenGLContext*); // uses Objective-c
+ static void GL_cleardrawable(void); // uses Objective-c
};
-
-
#endif // FL_COCOA_WINDOW_DRIVER_H
//
diff --git a/src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx b/src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx
index a51788018..3035ff94c 100644
--- a/src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx
+++ b/src/drivers/OpenGL/Fl_OpenGL_Display_Device.cxx
@@ -39,6 +39,7 @@ Fl_OpenGL_Display_Device::Fl_OpenGL_Display_Device(Fl_OpenGL_Graphics_Driver *gr
#ifdef FL_CFG_GFX_QUARTZ
#include "../../Fl_Gl_Window_Driver.H"
+#include "../Cocoa/Fl_Cocoa_Window_Driver.H"
// convert BGRA to RGB and also exchange top and bottom
static uchar *convert_BGRA_to_RGB(uchar *baseAddress, int w, int h, int mByteWidth)
@@ -68,8 +69,8 @@ Fl_RGB_Image* Fl_OpenGL_Display_Device::capture_gl_rectangle(Fl_Gl_Window* glw,
if (factor != 1) {
w *= factor; h *= factor; x *= factor; y *= factor;
}
- Fl_Cocoa_Gl_Window_Driver::GLcontext_makecurrent(glw->context());
- Fl_Cocoa_Gl_Window_Driver::flush_context(glw->context()); // to capture also the overlay and for directGL demo
+ Fl_Cocoa_Window_Driver::GLcontext_makecurrent(glw->context());
+ Fl_Cocoa_Window_Driver::flush_context(glw->context()); // to capture also the overlay and for directGL demo
// Read OpenGL context pixels directly.
// For extra safety, save & restore OpenGL states that are changed
glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
@@ -87,7 +88,7 @@ Fl_RGB_Image* Fl_OpenGL_Display_Device::capture_gl_rectangle(Fl_Gl_Window* glw,
baseAddress = convert_BGRA_to_RGB(baseAddress, w, h, mByteWidth);
Fl_RGB_Image *img = new Fl_RGB_Image(baseAddress, w, h, 3, 3 * w);
img->alloc_array = 1;
- Fl_Cocoa_Gl_Window_Driver::flush_context(glw->context());
+ Fl_Cocoa_Window_Driver::flush_context(glw->context());
return img;
}
diff --git a/src/gl_start.cxx b/src/gl_start.cxx
index 18ce99bc9..9a61b7d42 100644
--- a/src/gl_start.cxx
+++ b/src/gl_start.cxx
@@ -97,9 +97,10 @@ void Fl_Gl_Window_Driver::gl_visual(Fl_Gl_Choice *c) {
}
#ifdef FL_CFG_GFX_QUARTZ
+#include "drivers/Cocoa/Fl_Cocoa_Window_Driver.H"
void Fl_Cocoa_Gl_Window_Driver::gl_start() {
- GLcontext_update(context); // supports window resizing
+ Fl_Cocoa_Window_Driver::GLcontext_update(context); // supports window resizing
}
#endif