mirror of
https://github.com/fltk/fltk.git
synced 2026-06-01 23:06:54 +08:00
Move GL-related member functions from class Fl_Cocoa_Screen_Driver to class Fl_Cocoa_Gl_Window_Driver
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11728 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -86,6 +86,14 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifdef FL_CFG_GFX_QUARTZ
|
#ifdef FL_CFG_GFX_QUARTZ
|
||||||
|
#ifdef __OBJC__
|
||||||
|
@class NSOpenGLPixelFormat;
|
||||||
|
@class NSOpenGLContext;
|
||||||
|
#else
|
||||||
|
class NSOpenGLPixelFormat;
|
||||||
|
class NSOpenGLContext;
|
||||||
|
#endif // __OBJC__
|
||||||
|
|
||||||
class Fl_Cocoa_Gl_Window_Driver : public Fl_Gl_Window_Driver {
|
class Fl_Cocoa_Gl_Window_Driver : public Fl_Gl_Window_Driver {
|
||||||
friend class Fl_Gl_Window_Driver;
|
friend class Fl_Gl_Window_Driver;
|
||||||
Fl_Cocoa_Gl_Window_Driver(Fl_Gl_Window *win) : Fl_Gl_Window_Driver(win) {}
|
Fl_Cocoa_Gl_Window_Driver(Fl_Gl_Window *win) : Fl_Gl_Window_Driver(win) {}
|
||||||
@@ -106,6 +114,12 @@ class Fl_Cocoa_Gl_Window_Driver : public Fl_Gl_Window_Driver {
|
|||||||
virtual void redraw_overlay();
|
virtual void redraw_overlay();
|
||||||
virtual void gl_start();
|
virtual void gl_start();
|
||||||
virtual void draw_string(const char* str, int n);
|
virtual void draw_string(const char* str, int n);
|
||||||
|
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 GLcontext_makecurrent(NSOpenGLContext*); // uses Objective-c
|
||||||
|
static void GL_cleardrawable(void); // uses Objective-c
|
||||||
};
|
};
|
||||||
#endif // FL_CFG_GFX_QUARTZ
|
#endif // FL_CFG_GFX_QUARTZ
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ 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);
|
Fl_Gl_Choice *g = Fl_Gl_Window_Driver::find_begin(m, alistp);
|
||||||
if (g) return g;
|
if (g) return g;
|
||||||
NSOpenGLPixelFormat* fmt = Fl_Cocoa_Screen_Driver::mode_to_NSOpenGLPixelFormat(m, alistp);
|
NSOpenGLPixelFormat* fmt = mode_to_NSOpenGLPixelFormat(m, alistp);
|
||||||
if (!fmt) return 0;
|
if (!fmt) return 0;
|
||||||
g = new Fl_Gl_Choice(m, alistp, first);
|
g = new Fl_Gl_Choice(m, alistp, first);
|
||||||
first = g;
|
first = g;
|
||||||
@@ -97,7 +97,7 @@ GLContext Fl_Cocoa_Gl_Window_Driver::create_gl_context(Fl_Window* window, const
|
|||||||
// resets the pile of string textures used to draw strings
|
// resets the pile of string textures used to draw strings
|
||||||
// necessary before the first context is created
|
// necessary before the first context is created
|
||||||
if (!shared_ctx) gl_texture_reset();
|
if (!shared_ctx) gl_texture_reset();
|
||||||
context = Fl_Cocoa_Screen_Driver::create_GLcontext_for_window(g->pixelformat, shared_ctx, window);
|
context = create_GLcontext_for_window(g->pixelformat, shared_ctx, window);
|
||||||
if (!context) return 0;
|
if (!context) return 0;
|
||||||
add_context((GLContext)context);
|
add_context((GLContext)context);
|
||||||
return (context);
|
return (context);
|
||||||
@@ -107,7 +107,7 @@ void Fl_Cocoa_Gl_Window_Driver::set_gl_context(Fl_Window* w, GLContext context)
|
|||||||
if (context != cached_context || w != cached_window) {
|
if (context != cached_context || w != cached_window) {
|
||||||
cached_context = context;
|
cached_context = context;
|
||||||
cached_window = w;
|
cached_window = w;
|
||||||
Fl_Cocoa_Screen_Driver::GLcontext_makecurrent(context);
|
GLcontext_makecurrent(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,9 +115,9 @@ void Fl_Cocoa_Gl_Window_Driver::delete_gl_context(GLContext context) {
|
|||||||
if (cached_context == context) {
|
if (cached_context == context) {
|
||||||
cached_context = 0;
|
cached_context = 0;
|
||||||
cached_window = 0;
|
cached_window = 0;
|
||||||
Fl_Cocoa_Screen_Driver::GL_cleardrawable();
|
GL_cleardrawable();
|
||||||
}
|
}
|
||||||
Fl_Cocoa_Screen_Driver::GLcontext_release(context);
|
GLcontext_release(context);
|
||||||
del_context(context);
|
del_context(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -505,7 +505,7 @@ void Fl_Cocoa_Gl_Window_Driver::make_current_before() {
|
|||||||
if (d->changed_resolution()){
|
if (d->changed_resolution()){
|
||||||
d->changed_resolution(false);
|
d->changed_resolution(false);
|
||||||
invalidate();
|
invalidate();
|
||||||
Fl_Cocoa_Screen_Driver::GLcontext_update((GLContext)pWindow->context());
|
GLcontext_update((GLContext)pWindow->context());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,15 +549,11 @@ void Fl_Cocoa_Gl_Window_Driver::swap_buffers() {
|
|||||||
void Fl_Cocoa_Gl_Window_Driver::resize(int is_a_resize, int unused, int also) {
|
void Fl_Cocoa_Gl_Window_Driver::resize(int is_a_resize, int unused, int also) {
|
||||||
Fl_X *flx = Fl_X::i(pWindow);
|
Fl_X *flx = Fl_X::i(pWindow);
|
||||||
Fl_Cocoa_Window_Driver *d = Fl_Cocoa_Window_Driver::driver(pWindow);
|
Fl_Cocoa_Window_Driver *d = Fl_Cocoa_Window_Driver::driver(pWindow);
|
||||||
if (flx && d->in_windowDidResize()) Fl_Cocoa_Screen_Driver::GLcontext_update((GLContext)pWindow->context());
|
if (flx && d->in_windowDidResize()) GLcontext_update((GLContext)pWindow->context());
|
||||||
}
|
}
|
||||||
|
|
||||||
char Fl_Cocoa_Gl_Window_Driver::swap_type() {return COPY;}
|
char Fl_Cocoa_Gl_Window_Driver::swap_type() {return COPY;}
|
||||||
|
|
||||||
void Fl_Cocoa_Gl_Window_Driver::flush_context() {
|
|
||||||
Fl_Cocoa_Screen_Driver::GLcontext_flushbuffer((GLContext)pWindow->context());
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FL_CFG_GFX_QUARTZ
|
#endif // FL_CFG_GFX_QUARTZ
|
||||||
|
|
||||||
#if defined(FL_CFG_GFX_GDI)
|
#if defined(FL_CFG_GFX_GDI)
|
||||||
|
|||||||
+10
-9
@@ -34,7 +34,7 @@ extern "C" {
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "config_lib.h"
|
||||||
#include <FL/Fl.H>
|
#include <FL/Fl.H>
|
||||||
#include <FL/x.H>
|
#include <FL/x.H>
|
||||||
#include <FL/Fl_Window_Driver.H>
|
#include <FL/Fl_Window_Driver.H>
|
||||||
@@ -44,6 +44,7 @@ extern "C" {
|
|||||||
#include <FL/Fl_Printer.H>
|
#include <FL/Fl_Printer.H>
|
||||||
#include <FL/Fl_Shared_Image.H>
|
#include <FL/Fl_Shared_Image.H>
|
||||||
#include <FL/fl_draw.H>
|
#include <FL/fl_draw.H>
|
||||||
|
#include <FL/Fl_Gl_Window_Driver.H>
|
||||||
#include "drivers/Quartz/Fl_Quartz_Graphics_Driver.H"
|
#include "drivers/Quartz/Fl_Quartz_Graphics_Driver.H"
|
||||||
#include "drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.H"
|
#include "drivers/Quartz/Fl_Quartz_Copy_Surface_Driver.H"
|
||||||
#include "drivers/Cocoa/Fl_Cocoa_Screen_Driver.H"
|
#include "drivers/Cocoa/Fl_Cocoa_Screen_Driver.H"
|
||||||
@@ -2726,7 +2727,7 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
NSOpenGLPixelFormat* Fl_Cocoa_Screen_Driver::mode_to_NSOpenGLPixelFormat(int m, const int *alistp)
|
NSOpenGLPixelFormat* Fl_Cocoa_Gl_Window_Driver::mode_to_NSOpenGLPixelFormat(int m, const int *alistp)
|
||||||
{
|
{
|
||||||
NSOpenGLPixelFormatAttribute attribs[32];
|
NSOpenGLPixelFormatAttribute attribs[32];
|
||||||
int n = 0;
|
int n = 0;
|
||||||
@@ -2814,7 +2815,7 @@ NSOpenGLPixelFormat* Fl_Cocoa_Screen_Driver::mode_to_NSOpenGLPixelFormat(int m,
|
|||||||
return pixform;
|
return pixform;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSOpenGLContext* Fl_Cocoa_Screen_Driver::create_GLcontext_for_window(NSOpenGLPixelFormat *pixelformat,
|
NSOpenGLContext* Fl_Cocoa_Gl_Window_Driver::create_GLcontext_for_window(NSOpenGLPixelFormat *pixelformat,
|
||||||
NSOpenGLContext *shared_ctx, Fl_Window *window)
|
NSOpenGLContext *shared_ctx, Fl_Window *window)
|
||||||
{
|
{
|
||||||
NSOpenGLContext *context = [[NSOpenGLContext alloc] initWithFormat:pixelformat shareContext:shared_ctx];
|
NSOpenGLContext *context = [[NSOpenGLContext alloc] initWithFormat:pixelformat shareContext:shared_ctx];
|
||||||
@@ -2831,27 +2832,27 @@ NSOpenGLContext* Fl_Cocoa_Screen_Driver::create_GLcontext_for_window(NSOpenGLPix
|
|||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Cocoa_Screen_Driver::GLcontext_update(NSOpenGLContext* ctxt)
|
void Fl_Cocoa_Gl_Window_Driver::GLcontext_update(NSOpenGLContext* ctxt)
|
||||||
{
|
{
|
||||||
[ctxt update];
|
[ctxt update];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Cocoa_Screen_Driver::GLcontext_flushbuffer(NSOpenGLContext* ctxt)
|
void Fl_Cocoa_Gl_Window_Driver::flush_context()
|
||||||
{
|
{
|
||||||
[ctxt flushBuffer];
|
[(NSOpenGLContext*)pWindow->context() flushBuffer];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Cocoa_Screen_Driver::GLcontext_release(NSOpenGLContext* ctxt)
|
void Fl_Cocoa_Gl_Window_Driver::GLcontext_release(NSOpenGLContext* ctxt)
|
||||||
{
|
{
|
||||||
[ctxt release];
|
[ctxt release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Cocoa_Screen_Driver::GL_cleardrawable(void)
|
void Fl_Cocoa_Gl_Window_Driver::GL_cleardrawable(void)
|
||||||
{
|
{
|
||||||
[[NSOpenGLContext currentContext] clearDrawable];
|
[[NSOpenGLContext currentContext] clearDrawable];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Cocoa_Screen_Driver::GLcontext_makecurrent(NSOpenGLContext* ctxt)
|
void Fl_Cocoa_Gl_Window_Driver::GLcontext_makecurrent(NSOpenGLContext* ctxt)
|
||||||
{
|
{
|
||||||
[ctxt makeCurrentContext];
|
[ctxt makeCurrentContext];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,15 +64,6 @@ protected:
|
|||||||
public:
|
public:
|
||||||
Fl_Cocoa_Screen_Driver();
|
Fl_Cocoa_Screen_Driver();
|
||||||
static int next_marked_length; // next length of marked text after current marked text will have been replaced
|
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
|
// --- display management
|
||||||
// --- screen configuration
|
// --- screen configuration
|
||||||
virtual void init();
|
virtual void init();
|
||||||
|
|||||||
+1
-1
@@ -89,7 +89,7 @@ void Fl_Gl_Window_Driver::gl_visual(Fl_Gl_Choice *c) {
|
|||||||
#include "drivers/Cocoa/Fl_Cocoa_Screen_Driver.H"
|
#include "drivers/Cocoa/Fl_Cocoa_Screen_Driver.H"
|
||||||
|
|
||||||
void Fl_Cocoa_Gl_Window_Driver::gl_start() {
|
void Fl_Cocoa_Gl_Window_Driver::gl_start() {
|
||||||
Fl_Cocoa_Screen_Driver::GLcontext_update(context); // supports window resizing
|
GLcontext_update(context); // supports window resizing
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user