Skip to content

Commit

Permalink
Replace gl_xxx() function names by new member functions of the Fl_X c…
Browse files Browse the repository at this point in the history
…lass to avoid

collisions with user-defined symbols.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10548 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Feb 2, 2015
1 parent f8ee30e commit 5017171
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
8 changes: 8 additions & 0 deletions FL/mac.H
Expand Up @@ -75,9 +75,11 @@ typedef CGContextRef Fl_Offscreen;
#ifdef __OBJC__
@class NSCursor;
@class NSOpenGLPixelFormat;
@class NSOpenGLContext;
#else
class NSCursor;
class NSOpenGLPixelFormat;
class NSOpenGLContext;
#endif // __OBJC__

typedef CGContextRef Fl_Offscreen;
Expand Down Expand Up @@ -168,6 +170,12 @@ public:
// Cocoa additions
static int resolution_scaling_factor(Fl_Window*);
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);
void destroy(void);
void map(void);
void unmap(void);
Expand Down
16 changes: 4 additions & 12 deletions src/Fl_Gl_Choice.cxx
Expand Up @@ -27,14 +27,6 @@
# include "flstring.h"
# include <FL/fl_utf8.h>

# ifdef __APPLE__
extern NSOpenGLContext* gl_create_context_for_window(NSOpenGLPixelFormat *pixelformat,
NSOpenGLContext *shared_ctx, Fl_Window *window);
extern void gl_context_release(NSOpenGLContext*);
extern void gl_context_makecurrent(NSOpenGLContext*);
extern void gl_cleardrawable(void);
# endif

# ifdef WIN32
void fl_save_dc(HWND, HDC);
# endif
Expand Down Expand Up @@ -247,7 +239,7 @@ GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int lay
GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer) {
GLContext context, shared_ctx = 0;
if (context_list && nContext) shared_ctx = context_list[0];
context = gl_create_context_for_window(g->pixelformat, shared_ctx, window);
context = Fl_X::create_GLcontext_for_window(g->pixelformat, shared_ctx, window);
if (!context) return 0;
add_context((GLContext)context);
return (context);
Expand All @@ -268,7 +260,7 @@ void fl_set_gl_context(Fl_Window* w, GLContext context) {
# elif defined(WIN32)
wglMakeCurrent(Fl_X::i(w)->private_dc, context);
# elif defined(__APPLE_QUARTZ__)
gl_context_makecurrent(context);
Fl_X::GLcontext_makecurrent(context);
# else
# error unsupported platform
# endif
Expand All @@ -283,7 +275,7 @@ void fl_no_gl_context() {
# elif defined(WIN32)
wglMakeCurrent(0, 0);
# elif defined(__APPLE_QUARTZ__)
gl_cleardrawable();
Fl_X::GL_cleardrawable();
# else
# error unsupported platform
# endif
Expand All @@ -296,7 +288,7 @@ void fl_delete_gl_context(GLContext context) {
# elif defined(WIN32)
wglDeleteContext(context);
# elif defined(__APPLE_QUARTZ__)
gl_context_release(context);
Fl_X::GLcontext_release(context);
# else
# error unsupported platform
# endif
Expand Down
8 changes: 3 additions & 5 deletions src/Fl_Gl_Window.cxx
Expand Up @@ -29,8 +29,6 @@ extern void gl_texture_reset();
#include "Fl_Gl_Choice.H"
#ifdef __APPLE__
#include <FL/gl.h>
extern void gl_context_update(NSOpenGLContext*);
extern void gl_context_flushbuffer(NSOpenGLContext*);
#endif
#include <FL/Fl_Gl_Window.H>
#include <stdlib.h>
Expand Down Expand Up @@ -191,7 +189,7 @@ void Fl_Gl_Window::make_current() {
if (Fl_X::i(this)->changed_resolution()){
Fl_X::i(this)->changed_resolution(false);
invalidate();
gl_context_update(context_);
Fl_X::GLcontext_update(context_);
}
#endif
if (!context_) {
Expand Down Expand Up @@ -406,7 +404,7 @@ void Fl_Gl_Window::flush() {

}
#ifdef __APPLE__
gl_context_flushbuffer(context_);
Fl_X::GLcontext_flushbuffer(context_);
#endif

if (overlay==this && SWAP_TYPE != SWAP) { // fake overlay in front buffer
Expand Down Expand Up @@ -436,7 +434,7 @@ void Fl_Gl_Window::resize(int X,int Y,int W,int H) {
if (is_a_resize) valid(0);

#ifdef __APPLE__
if (Fl_X::i(this)->in_windowDidResize()) gl_context_update(context_);
if (Fl_X::i(this)->in_windowDidResize()) Fl_X::GLcontext_update(context_);
#endif

#if ! ( defined(__APPLE__) || defined(WIN32) )
Expand Down
12 changes: 6 additions & 6 deletions src/Fl_cocoa.mm
Expand Up @@ -2724,35 +2724,35 @@ - (NSInteger)conversationIdentifier {
return pixform;
}

NSOpenGLContext* gl_create_context_for_window(NSOpenGLPixelFormat *pixelformat,
NSOpenGLContext* Fl_X::create_GLcontext_for_window(NSOpenGLPixelFormat *pixelformat,
NSOpenGLContext *shared_ctx, Fl_Window *window)
{
NSOpenGLContext *context = [[NSOpenGLContext alloc] initWithFormat:pixelformat shareContext:shared_ctx];
if (context) [context setView:[fl_xid(window) contentView]];
return context;
}

void gl_context_update(NSOpenGLContext* ctxt)
void Fl_X::GLcontext_update(NSOpenGLContext* ctxt)
{
[ctxt update];
}

void gl_context_flushbuffer(NSOpenGLContext* ctxt)
void Fl_X::GLcontext_flushbuffer(NSOpenGLContext* ctxt)
{
[ctxt flushBuffer];
}

void gl_context_release(NSOpenGLContext* ctxt)
void Fl_X::GLcontext_release(NSOpenGLContext* ctxt)
{
[ctxt release];
}

void gl_cleardrawable(void)
void Fl_X::GL_cleardrawable(void)
{
[[NSOpenGLContext currentContext] clearDrawable];
}

void gl_context_makecurrent(NSOpenGLContext* ctxt)
void Fl_X::GLcontext_makecurrent(NSOpenGLContext* ctxt)
{
[ctxt makeCurrentContext];
}
Expand Down
3 changes: 1 addition & 2 deletions src/gl_start.cxx
Expand Up @@ -48,7 +48,6 @@ static Fl_Gl_Choice* gl_choice;

#ifdef __APPLE__
static Fl_Gl_Choice* gl_choice;
extern void gl_context_update(NSOpenGLContext*);
#endif

Fl_Region XRectangleRegion(int x, int y, int w, int h); // in fl_rect.cxx
Expand All @@ -69,7 +68,7 @@ void gl_start() {
}
fl_set_gl_context(Fl_Window::current(), context);
#ifdef __APPLE__
gl_context_update(context); // supports window resizing
Fl_X::GLcontext_update(context); // supports window resizing
#elif !defined(WIN32)
glXWaitX();
#endif
Expand Down

0 comments on commit 5017171

Please sign in to comment.