memmove() needs <string.h>...

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3062 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet
2003-07-23 14:38:00 +00:00
parent 89a7b606d1
commit b72950ea72
+44 -42
View File
@@ -1,5 +1,5 @@
// //
// "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.14 2003/07/17 05:52:47 matthiaswm Exp $" // "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.15 2003/07/23 14:38:00 easysw Exp $"
// //
// OpenGL visual selection code for the Fast Light Tool Kit (FLTK). // OpenGL visual selection code for the Fast Light Tool Kit (FLTK).
// //
@@ -26,14 +26,15 @@
#include <config.h> #include <config.h>
#if HAVE_GL #if HAVE_GL
#include <FL/Fl.H> # include <FL/Fl.H>
#include <FL/x.H> # include <FL/x.H>
#include <stdlib.h> # include <stdlib.h>
#include "Fl_Gl_Choice.H" # include "Fl_Gl_Choice.H"
# include "flstring.h"
#ifdef __APPLE__ # ifdef __APPLE__
# include <FL/Fl_Window.H> # include <FL/Fl_Window.H>
#endif # endif
static Fl_Gl_Choice *first; static Fl_Gl_Choice *first;
@@ -47,7 +48,7 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) {
if (g->mode == m && g->alist == alistp) if (g->mode == m && g->alist == alistp)
return g; return g;
#ifdef __APPLE__ # ifdef __APPLE__
const int *blist; const int *blist;
int list[32]; int list[32];
@@ -84,11 +85,11 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) {
if (m & FL_STENCIL) { if (m & FL_STENCIL) {
list[n++] = AGL_STENCIL_SIZE; list[n++] = 1; list[n++] = AGL_STENCIL_SIZE; list[n++] = 1;
} }
# ifdef AGL_STEREO /* is there such a thing as AGL_STEREO? */ # ifdef AGL_STEREO
if (m & FL_STEREO) { if (m & FL_STEREO) {
list[n++] = AGL_STEREO; list[n++] = AGL_STEREO;
} }
# endif # endif
list[n] = AGL_NONE; list[n] = AGL_NONE;
blist = list; blist = list;
} }
@@ -96,7 +97,7 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) {
AGLPixelFormat fmt = aglChoosePixelFormat(NULL, 0, (GLint*)blist); AGLPixelFormat fmt = aglChoosePixelFormat(NULL, 0, (GLint*)blist);
if (!fmt) return 0; if (!fmt) return 0;
#elif !defined(WIN32) # elif !defined(WIN32)
const int *blist; const int *blist;
int list[32]; int list[32];
@@ -137,12 +138,12 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) {
if (m & FL_STEREO) { if (m & FL_STEREO) {
list[n++] = GLX_STEREO; list[n++] = GLX_STEREO;
} }
# if defined(GLX_VERSION_1_1) && defined(GLX_SGIS_multisample) # if defined(GLX_VERSION_1_1) && defined(GLX_SGIS_multisample)
if (m & FL_MULTISAMPLE) { if (m & FL_MULTISAMPLE) {
list[n++] = GLX_SAMPLES_SGIS; list[n++] = GLX_SAMPLES_SGIS;
list[n++] = 4; // value Glut uses list[n++] = 4; // value Glut uses
} }
# endif # endif
list[n] = 0; list[n] = 0;
blist = list; blist = list;
} }
@@ -150,13 +151,13 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) {
fl_open_display(); fl_open_display();
XVisualInfo *visp = glXChooseVisual(fl_display, fl_screen, (int *)blist); XVisualInfo *visp = glXChooseVisual(fl_display, fl_screen, (int *)blist);
if (!visp) { if (!visp) {
# if defined(GLX_VERSION_1_1) && defined(GLX_SGIS_multisample) # if defined(GLX_VERSION_1_1) && defined(GLX_SGIS_multisample)
if (m&FL_MULTISAMPLE) return find(m&~FL_MULTISAMPLE,0); if (m&FL_MULTISAMPLE) return find(m&~FL_MULTISAMPLE,0);
# endif # endif
return 0; return 0;
} }
#else # else
// Replacement for ChoosePixelFormat() that finds one with an overlay // Replacement for ChoosePixelFormat() that finds one with an overlay
// if possible: // if possible:
@@ -189,7 +190,7 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) {
//printf("Chosen pixel format is %d\n", pixelformat); //printf("Chosen pixel format is %d\n", pixelformat);
if (!pixelformat) return 0; if (!pixelformat) return 0;
#endif # endif
g = new Fl_Gl_Choice; g = new Fl_Gl_Choice;
g->mode = m; g->mode = m;
@@ -197,12 +198,12 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) {
g->next = first; g->next = first;
first = g; first = g;
#ifdef WIN32 # ifdef WIN32
g->pixelformat = pixelformat; g->pixelformat = pixelformat;
g->pfd = chosen_pfd; g->pfd = chosen_pfd;
#elif defined(__APPLE__) # elif defined(__APPLE__)
g->pixelformat = fmt; g->pixelformat = fmt;
#else # else
g->vis = visp; g->vis = visp;
if (/*MaxCmapsOfScreen(ScreenOfDisplay(fl_display,fl_screen))==1 && */ if (/*MaxCmapsOfScreen(ScreenOfDisplay(fl_display,fl_screen))==1 && */
@@ -212,7 +213,7 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int m, const int *alistp) {
else else
g->colormap = XCreateColormap(fl_display, RootWindow(fl_display,fl_screen), g->colormap = XCreateColormap(fl_display, RootWindow(fl_display,fl_screen),
visp->visual, AllocNone); visp->visual, AllocNone);
#endif # endif
return g; return g;
} }
@@ -243,7 +244,7 @@ static void del_context(GLContext ctx) {
} }
} }
#ifdef WIN32 # ifdef WIN32
GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer) { GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer) {
Fl_X* i = Fl_X::i(window); Fl_X* i = Fl_X::i(window);
@@ -251,9 +252,9 @@ GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int lay
if (!hdc) { if (!hdc) {
hdc = i->private_dc = GetDCEx(i->xid, 0, DCX_CACHE); hdc = i->private_dc = GetDCEx(i->xid, 0, DCX_CACHE);
SetPixelFormat(hdc, g->pixelformat, (PIXELFORMATDESCRIPTOR*)(&g->pfd)); SetPixelFormat(hdc, g->pixelformat, (PIXELFORMATDESCRIPTOR*)(&g->pfd));
# if USE_COLORMAP # if USE_COLORMAP
if (fl_palette) SelectPalette(hdc, fl_palette, FALSE); if (fl_palette) SelectPalette(hdc, fl_palette, FALSE);
# endif # endif
} }
GLContext context = GLContext context =
layer ? wglCreateLayerContext(hdc, layer) : wglCreateContext(hdc); layer ? wglCreateLayerContext(hdc, layer) : wglCreateContext(hdc);
@@ -265,7 +266,7 @@ GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int lay
return context; return context;
} }
#elif defined(__APPLE__) # elif defined(__APPLE__)
GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer) { GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer) {
GLContext context, shared_ctx = context_list ? context_list[0] : 0; GLContext context, shared_ctx = context_list ? context_list[0] : 0;
context = aglCreateContext( g->pixelformat, shared_ctx); context = aglCreateContext( g->pixelformat, shared_ctx);
@@ -280,7 +281,7 @@ GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int lay
aglSetDrawable( context, GetWindowPort( fl_xid(window) ) ); aglSetDrawable( context, GetWindowPort( fl_xid(window) ) );
return (context); return (context);
} }
#else # else
GLContext fl_create_gl_context(XVisualInfo* vis) { GLContext fl_create_gl_context(XVisualInfo* vis) {
GLContext shared_ctx = context_list ? context_list[0] : 0; GLContext shared_ctx = context_list ? context_list[0] : 0;
@@ -290,7 +291,7 @@ GLContext fl_create_gl_context(XVisualInfo* vis) {
return context; return context;
} }
#endif # endif
static GLContext cached_context; static GLContext cached_context;
static Fl_Window* cached_window; static Fl_Window* cached_window;
@@ -299,9 +300,9 @@ void fl_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;
#ifdef WIN32 # ifdef WIN32
wglMakeCurrent(Fl_X::i(w)->private_dc, context); wglMakeCurrent(Fl_X::i(w)->private_dc, context);
#elif defined(__APPLE__) # elif defined(__APPLE__)
if ( w->parent() ) { //: resize our GL buffer rectangle if ( w->parent() ) { //: resize our GL buffer rectangle
Rect wrect; GetWindowPortBounds( fl_xid(w), &wrect ); Rect wrect; GetWindowPortBounds( fl_xid(w), &wrect );
GLint rect[] = { w->x(), wrect.bottom-w->h()-w->y(), w->w(), w->h() }; GLint rect[] = { w->x(), wrect.bottom-w->h()-w->y(), w->w(), w->h() };
@@ -310,40 +311,41 @@ void fl_set_gl_context(Fl_Window* w, GLContext context) {
} }
aglSetDrawable(context, GetWindowPort( fl_xid(w) ) ); aglSetDrawable(context, GetWindowPort( fl_xid(w) ) );
aglSetCurrentContext(context); aglSetCurrentContext(context);
#else # else
glXMakeCurrent(fl_display, fl_xid(w), context); glXMakeCurrent(fl_display, fl_xid(w), context);
#endif # endif
} }
} }
void fl_no_gl_context() { void fl_no_gl_context() {
cached_context = 0; cached_context = 0;
cached_window = 0; cached_window = 0;
#ifdef WIN32 # ifdef WIN32
wglMakeCurrent(0, 0); wglMakeCurrent(0, 0);
#elif defined(__APPLE__) # elif defined(__APPLE__)
aglSetCurrentContext(0); aglSetCurrentContext(0);
#else # else
glXMakeCurrent(fl_display, 0, 0); glXMakeCurrent(fl_display, 0, 0);
#endif # endif
} }
void fl_delete_gl_context(GLContext context) { void fl_delete_gl_context(GLContext context) {
if (cached_context == context) fl_no_gl_context(); if (cached_context == context) fl_no_gl_context();
#ifdef WIN32 # ifdef WIN32
wglDeleteContext(context); wglDeleteContext(context);
#elif defined(__APPLE__) # elif defined(__APPLE__)
aglSetCurrentContext( NULL ); aglSetCurrentContext( NULL );
aglSetDrawable( context, NULL ); aglSetDrawable( context, NULL );
aglDestroyContext( context ); aglDestroyContext( context );
#else # else
glXDestroyContext(fl_display, context); glXDestroyContext(fl_display, context);
#endif # endif
del_context(context); del_context(context);
} }
#endif #endif // HAVE_GL
// //
// End of "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.14 2003/07/17 05:52:47 matthiaswm Exp $". // End of "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.15 2003/07/23 14:38:00 easysw Exp $".
// //