summaryrefslogtreecommitdiff
path: root/src/Fl_Gl_Choice.cxx
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2001-11-27 17:44:08 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2001-11-27 17:44:08 +0000
commit2b85bf81680e2243ef5a5daf85d9eb04321c7278 (patch)
treedc7d3e1cdbd44ed10b358412098b73d24b64d143 /src/Fl_Gl_Choice.cxx
parent4dc5732a3e0f376786d1d6b788e5cf601439e890 (diff)
Preliminary commit of my MacOS X work.
**** THIS CODE COMPILES BUT DOES NOT WORK. **** TODO: fix event handling - getting blank windows, etc. TODO: re-port OpenGL code. TODO: add support for images with alpha. TODO: add support for more then just beeps in fl_beep(). TODO: other stuff I'm sure... git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1765 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Gl_Choice.cxx')
-rw-r--r--src/Fl_Gl_Choice.cxx48
1 files changed, 45 insertions, 3 deletions
diff --git a/src/Fl_Gl_Choice.cxx b/src/Fl_Gl_Choice.cxx
index ca485b2a5..fe5d702b0 100644
--- a/src/Fl_Gl_Choice.cxx
+++ b/src/Fl_Gl_Choice.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.1 2001/11/17 18:29:05 easysw Exp $"
+// "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.2 2001/11/27 17:44:06 easysw Exp $"
//
// OpenGL visual selection code for the Fast Light Tool Kit (FLTK).
//
@@ -43,7 +43,11 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int mode, const int *alist) {
if (g->mode == mode && g->alist == alist)
return g;
-#ifndef WIN32
+#ifdef __APPLE__
+
+ //++ later
+
+#elif !defined(WIN32)
const int *blist;
int list[32];
@@ -142,6 +146,8 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int mode, const int *alist) {
#ifdef WIN32
g->pixelformat = pixelformat;
g->pfd = chosen_pfd;
+#elif defined(__APPLE__)
+ //++ later
#else
g->vis = vis;
@@ -180,6 +186,27 @@ GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int lay
return context;
}
+#elif defined(__APPLE__)
+GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer) {
+ GLContext context;
+ GLint attrib[5] = {AGL_RGBA, //++ replace with requested data!
+ AGL_DOUBLEBUFFER,
+ AGL_DEPTH_SIZE, 16,
+ AGL_NONE };
+ AGLPixelFormat fmt;
+ fmt = aglChoosePixelFormat(NULL, 0, attrib);
+ context = aglCreateContext(fmt, fl_first_context);
+ if ( !fl_first_context ) fl_first_context = (GLXContext)context;
+ aglDestroyPixelFormat( fmt );
+ if ( parent() ) {
+ CGrafPort *port = (CGrafPort*)fl_xid(this);
+ GLint rect[] = { x(), port->portRect.bottom-h()-y(), w(), h() };
+ aglSetInteger( (GLXContext)context, AGL_BUFFER_RECT, rect );
+ aglEnable( (GLXContext)context, AGL_BUFFER_RECT );
+ }
+ aglSetDrawable((GLXContext)context, (CGrafPort*)fl_xid(window));
+ return (context);
+}
#else
GLContext fl_create_gl_context(XVisualInfo* vis) {
@@ -199,6 +226,15 @@ void fl_set_gl_context(Fl_Window* w, GLContext context) {
cached_window = w;
#ifdef WIN32
wglMakeCurrent(Fl_X::i(w)->private_dc, context);
+#elif defined(__APPLE__)
+ if ( w->parent() ) { //: resize our GL buffer rectangle
+ CGrafPort *port = (CGrafPort*)fl_xid(w);
+ GLint rect[] = { w->x(), port->portRect.bottom-w->h()-w->y(), w->w(), w->h() };
+ aglSetInteger( c, AGL_BUFFER_RECT, rect );
+ aglEnable( c, AGL_BUFFER_RECT );
+ }
+ aglSetDrawable(c, (CGrafPort*)fl_xid(w)); //++ here or in Fl_Gl_Window::make_current creation part?
+ aglSetCurrentContext(c);
#else
glXMakeCurrent(fl_display, fl_xid(w), context);
#endif
@@ -210,6 +246,8 @@ void fl_no_gl_context() {
cached_window = 0;
#ifdef WIN32
wglMakeCurrent(0, 0);
+#elif defined(__APPLE__)
+ aglSetCurrentContext(0);
#else
glXMakeCurrent(fl_display, 0, 0);
#endif
@@ -220,6 +258,10 @@ void fl_delete_gl_context(GLContext context) {
if (context != first_context) {
#ifdef WIN32
wglDeleteContext(context);
+#elif defined(__APPLE)
+ aglSetCurrentContext(NULL);
+ aglSetDrawable((AGLContext)context, NULL);
+ aglDestroyContext((AGLContext)context);
#else
glXDestroyContext(fl_display, context);
#endif
@@ -229,5 +271,5 @@ void fl_delete_gl_context(GLContext context) {
#endif
//
-// End of "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.1 2001/11/17 18:29:05 easysw Exp $".
+// End of "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.2 2001/11/27 17:44:06 easysw Exp $".
//