Add GLContext to the set of platform-dependent types defined in FL/platform_types.h

If a platform does not support OpenGL, it can just typedef GLContext as void*

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11733 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2016-05-13 06:45:40 +00:00
parent 01c5b06fa0
commit 207d8fe09b
10 changed files with 48 additions and 86 deletions

View File

@ -24,14 +24,6 @@
#include "Fl_Window.H"
#ifndef GLContext
/**
Opaque pointer type to hide system specific implementation.
*/
typedef void* GLContext; // actually a GLXContext or HGLDC
#endif
class Fl_Gl_Choice; // structure to hold result of glXChooseVisual
class Fl_Gl_Window_Driver;
/**
@ -201,9 +193,9 @@ public:
*/
int mode(const int *a) {return mode(0, a);}
/** Returns a pointer to the GLContext that this window is using.
\see void context(void* v, int destroy_flag) */
void* context() const {return context_;}
void context(void*, int destroy_flag = 0);
\see void context(GLContext c, int destroy_flag) */
GLContext context() const {return context_;}
void context(GLContext, int destroy_flag = 0);
void make_current();
void swap_buffers();
void ortho();

View File

@ -88,10 +88,8 @@ public:
#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 {

View File

@ -19,7 +19,7 @@
/* Platform-dependent types are defined here.
These types must be defined by any platform:
Fl_Offscreen, Fl_Bitmask, Fl_Region, FL_SOCKET, struct dirent, struct stat,
Fl_Offscreen, Fl_Bitmask, Fl_Region, FL_SOCKET, GLContext, struct dirent, struct stat,
fl_intptr_t, fl_uintptr_t
NOTE: *FIXME* AlbrechtS 13 Apr 2016 (concerning FL_SOCKET)
@ -57,6 +57,13 @@ typedef struct CGContext* Fl_Offscreen;
typedef struct CGImage* Fl_Bitmask;
typedef struct flCocoaRegion* Fl_Region;
typedef int FL_SOCKET;
#ifdef __OBJC__
@class NSOpenGLContext;
typedef NSOpenGLContext* GLContext;
#elif defined(__cplusplus)
typedef class NSOpenGLContext* GLContext;
#endif // __OBJC__
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
@ -73,6 +80,7 @@ typedef unsigned __int64 FL_SOCKET; /* *FIXME* - FL_SOCKET (see above) */
# else
typedef int FL_SOCKET;
# endif
typedef struct HGLRC__ *GLContext;
#include <sys/stat.h>
struct dirent {char d_name[1];};
@ -82,6 +90,7 @@ typedef void* Fl_Offscreen;
typedef void* Fl_Bitmask;
typedef void *Fl_Region;
typedef int FL_SOCKET;
typedef void *GLContext;
# pragma message "FL_PORTING: define struct dirent and implement scandir() for the platform"
struct dirent {char d_name[1];};
# pragma message "FL_PORTING: define struct stat and implement stat() for the platform"
@ -98,6 +107,7 @@ typedef unsigned long Fl_Offscreen;
typedef unsigned long Fl_Bitmask;
typedef struct _XRegion *Fl_Region;
typedef int FL_SOCKET;
typedef struct __GLXcontextRec *GLContext;
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>

View File

@ -42,58 +42,34 @@
#ifndef Fl_Gl_Choice_H
#define Fl_Gl_Choice_H
#ifdef FL_CFG_GFX_QUARTZ
# include <OpenGL/gl.h>
#ifdef __OBJC__
@class NSOpenGLPixelFormat;
@class NSOpenGLContext;
#else
class NSOpenGLPixelFormat;
class NSOpenGLContext;
#endif // __OBJC__
typedef NSOpenGLContext* FLOpenGLContextPtr;
# define GLContext FLOpenGLContextPtr
// Describes crap needed to create a GLContext under Mac OS X.
class Fl_Gl_Choice {
friend class Fl_Gl_Window_Driver;
int mode;
const int *alist;
Fl_Gl_Choice *next;
public:
Fl_Gl_Choice(int m, const int *alistp, Fl_Gl_Choice *n) : mode(m), alist(alistp), next(n) {}
NSOpenGLPixelFormat* pixelformat;
};
# define FL_GL_CHOICE_PLATFORM_SPECIFIC_MEMBERS void* pixelformat;
#endif // FL_CFG_GFX_QUARTZ
#ifdef FL_CFG_GFX_GDI
# include <FL/gl.h>
# define GLContext HGLRC
// Describes crap needed to create a GLContext under MSWindows.
class Fl_Gl_Choice {
friend class Fl_Gl_Window_Driver;
int mode;
const int *alist;
Fl_Gl_Choice *next;
public:
Fl_Gl_Choice(int m, const int *alistp, Fl_Gl_Choice *n) : mode(m), alist(alistp), next(n) {}
int pixelformat; // the visual to use
PIXELFORMATDESCRIPTOR pfd; // some wgl calls need this thing
};
#endif // FL_CFG_GFX_GDI
#ifdef FL_CFG_GFX_XLIB
# include <GL/glx.h>
# define GLContext GLXContext
# define FL_GL_CHOICE_PLATFORM_SPECIFIC_MEMBERS \
XVisualInfo *vis; /* the visual to use */ \
Colormap colormap; // a colormap for that visual
#endif // FL_CFG_GFX_XLIB*/
// Describes crap needed to create a GLContext under X11.
#ifdef FL_CFG_GFX_GDI
# include <FL/gl.h>
# define FL_GL_CHOICE_PLATFORM_SPECIFIC_MEMBERS \
int pixelformat; /* the visual to use */ \
PIXELFORMATDESCRIPTOR pfd; // some wgl calls need this thing
#endif // FL_CFG_GFX_GDI
#if defined(FL_PORTING) && !defined(FL_GL_CHOICE_PLATFORM_SPECIFIC_MEMBERS)
# pragma message "Define platform-specific members of the Fl_Gl_Choice class"
# define FL_GL_CHOICE_PLATFORM_SPECIFIC_MEMBERS
#endif
// Describes crap needed to create a GLContext.
class Fl_Gl_Choice {
friend class Fl_Gl_Window_Driver;
int mode;
@ -101,12 +77,10 @@ class Fl_Gl_Choice {
Fl_Gl_Choice *next;
public:
Fl_Gl_Choice(int m, const int *alistp, Fl_Gl_Choice *n) : mode(m), alist(alistp), next(n) {}
XVisualInfo *vis; // the visual to use
Colormap colormap; // a colormap for that visual
FL_GL_CHOICE_PLATFORM_SPECIFIC_MEMBERS
};
#endif // FL_CFG_GFX_XLIB
#undef FL_GL_CHOICE_PLATFORM_SPECIFIC_MEMBERS
#endif // Fl_Gl_Choice_H

View File

@ -20,7 +20,6 @@
#if HAVE_GL
# include <FL/Fl.H>
# include <FL/Fl_Graphics_Driver.H>
# include <stdlib.h>
# include "Fl_Gl_Choice.H"
# include <FL/Fl_Gl_Window.H>
@ -76,7 +75,6 @@ static Fl_Window* cached_window;
#ifdef FL_CFG_GFX_QUARTZ
#include "drivers/Cocoa/Fl_Cocoa_Screen_Driver.H"
extern void gl_texture_reset();
Fl_Gl_Choice *Fl_Cocoa_Gl_Window_Driver::find(int m, const int *alistp)
@ -97,9 +95,9 @@ 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(g->pixelformat, shared_ctx, window);
context = create_GLcontext_for_window((NSOpenGLPixelFormat*)g->pixelformat, shared_ctx, window);
if (!context) return 0;
add_context((GLContext)context);
add_context(context);
return (context);
}
@ -125,6 +123,7 @@ void Fl_Cocoa_Gl_Window_Driver::delete_gl_context(GLContext context) {
#ifdef FL_CFG_GFX_GDI
# include <FL/x.H>
# include <FL/Fl_Graphics_Driver.H>
#include "drivers/WinAPI/Fl_WinAPI_Window_Driver.H"
extern void fl_save_dc(HWND, HDC);

View File

@ -21,7 +21,6 @@
#include <FL/Fl.H>
#include <FL/gl.h>
#include "Fl_Gl_Choice.H"
#include <FL/Fl_Gl_Window.H>
#include <FL/Fl_Gl_Window_Driver.H>
#include <stdlib.h>

View File

@ -21,7 +21,7 @@
extern int fl_gl_load_plugin;
#include "Fl_Gl_Choice.H"
#include <FL/gl.h>
#include <FL/Fl_Gl_Window.H>
#include <FL/Fl_Gl_Window_Driver.H>
#include <stdlib.h>
@ -277,9 +277,9 @@ void Fl_Gl_Window::resize(int X,int Y,int W,int H) {
fltk when the window is destroyed, or when the mode() is changed,
or the next time context(x) is called.
*/
void Fl_Gl_Window::context(void* v, int destroy_flag) {
void Fl_Gl_Window::context(GLContext v, int destroy_flag) {
if (context_ && !(mode_&NON_LOCAL_CONTEXT)) pGlWindowDriver->delete_gl_context(context_);
context_ = (GLContext)v;
context_ = v;
if (destroy_flag) mode_ &= ~NON_LOCAL_CONTEXT;
else mode_ |= NON_LOCAL_CONTEXT;
}
@ -452,11 +452,9 @@ void* Fl_Gl_Window_Driver::GetProcAddress(const char *procName) {
#ifdef FL_CFG_GFX_QUARTZ
//#include <FL/gl.h>
#include <FL/x.H>
#include <OpenGL/OpenGL.h>
#include "drivers/Cocoa/Fl_Cocoa_Window_Driver.H"
#include "drivers/Cocoa/Fl_Cocoa_Screen_Driver.H"
Fl_Gl_Window_Driver *Fl_Gl_Window_Driver::newGlWindowDriver(Fl_Gl_Window *w)
{
@ -505,7 +503,7 @@ void Fl_Cocoa_Gl_Window_Driver::make_current_before() {
if (d->changed_resolution()){
d->changed_resolution(false);
invalidate();
GLcontext_update((GLContext)pWindow->context());
GLcontext_update(pWindow->context());
}
}
@ -549,7 +547,7 @@ void Fl_Cocoa_Gl_Window_Driver::swap_buffers() {
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((GLContext)pWindow->context());
if (flx && d->in_windowDidResize()) GLcontext_update(pWindow->context());
}
char Fl_Cocoa_Gl_Window_Driver::swap_type() {return COPY;}
@ -643,6 +641,7 @@ void* Fl_WinAPI_Gl_Window_Driver::GetProcAddress(const char *procName) {
#if defined(FL_CFG_GFX_XLIB)
#include <FL/x.H>
#include "Fl_Gl_Choice.H"
Fl_Gl_Window_Driver *Fl_Gl_Window_Driver::newGlWindowDriver(Fl_Gl_Window *w)
{

View File

@ -2839,7 +2839,7 @@ void Fl_Cocoa_Gl_Window_Driver::GLcontext_update(NSOpenGLContext* ctxt)
void Fl_Cocoa_Gl_Window_Driver::flush_context()
{
[(NSOpenGLContext*)pWindow->context() flushBuffer];
[pWindow->context() flushBuffer];
}
void Fl_Cocoa_Gl_Window_Driver::GLcontext_release(NSOpenGLContext* ctxt)

View File

@ -41,15 +41,6 @@
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:

View File

@ -35,7 +35,7 @@
#include <FL/Fl_Window.H>
#include <FL/fl_draw.H>
#include <FL/gl.h>
#include "Fl_Gl_Choice.H"
class Fl_Gl_Choice;
#include <FL/Fl_Gl_Window.H>
#include <FL/Fl_Gl_Window_Driver.H>
@ -86,7 +86,6 @@ void Fl_Gl_Window_Driver::gl_visual(Fl_Gl_Choice *c) {
}
#ifdef FL_CFG_GFX_QUARTZ
#include "drivers/Cocoa/Fl_Cocoa_Screen_Driver.H"
void Fl_Cocoa_Gl_Window_Driver::gl_start() {
GLcontext_update(context); // supports window resizing
@ -97,6 +96,7 @@ void Fl_Cocoa_Gl_Window_Driver::gl_start() {
#ifdef FL_CFG_GFX_XLIB
#include <FL/x.H>
#include "Fl_Gl_Choice.H"
void Fl_X11_Gl_Window_Driver::gl_visual(Fl_Gl_Choice *c) {
Fl_Gl_Window_Driver::gl_visual(c);