Skip to content

Commit

Permalink
- Mac: greatly improved OpenGL support, some window management,
Browse files Browse the repository at this point in the history
soem little bugs, better source comments


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1872 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Matthias Melcher committed Dec 18, 2001
1 parent 6642c67 commit b6b4e1e
Show file tree
Hide file tree
Showing 13 changed files with 162 additions and 96 deletions.
6 changes: 3 additions & 3 deletions FL/mac.H
@@ -1,5 +1,5 @@
//
// "$Id: mac.H,v 1.1.2.2 2001/12/06 00:17:47 matthiaswm Exp $"
// "$Id: mac.H,v 1.1.2.3 2001/12/18 11:00:09 matthiaswm Exp $"
//
// Mac header file for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -95,7 +95,7 @@ extern struct Fl_XMap {
ulong pen;
} *fl_current_xmap;

extern FL_EXPORT void *fl_display; //++ read yourself into multiple screen support!
extern FL_EXPORT void *fl_display;
extern FL_EXPORT Window fl_window;
extern FL_EXPORT Handle fl_system_menu;
extern FL_EXPORT class Fl_Sys_Menu_Bar *fl_sys_menu_bar;
Expand All @@ -120,6 +120,6 @@ extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b)
#endif // !FL_MAC_H

//
// End of "$Id: mac.H,v 1.1.2.2 2001/12/06 00:17:47 matthiaswm Exp $".
// End of "$Id: mac.H,v 1.1.2.3 2001/12/18 11:00:09 matthiaswm Exp $".
//

40 changes: 19 additions & 21 deletions README.mac
Expand Up @@ -15,9 +15,8 @@ CONTENTS
INTRODUCTION
------------

FLTK for Mac OS X is in pre-beta stage. Expect rapid changes to the
source code and build environment. Expect many crashes and funny
blinking patterns.
FLTK for Mac OS X is in beta stage. Expect rapid changes to the
source code and build environment.

FLTK currently supports the following development environment on the
Mac OS X platform:
Expand All @@ -39,15 +38,12 @@ gcc (Carbon) - how to build

Since the Max OS X command line build environment is based on BSD
Unix, the normal Unix build procedure as described in 'README'
applies. Compiled applications can only be started from within
the terminal though.
applies.

A 'resource fork' needs to be attached to applications to make
them visible to the Finder. A sample resource file is ./FL/mac.r .

To make 'hello' a full application, compile and link 'hello', then
change into the test directory and type:
A 'resource fork' will be attached to applications to make
them visible in the Finder. Thedefault resource file is ./FL/mac.r .

A possible way to add a resource fork is:
> Rez -t APPL -c Fltk ../FL/mac.r -o hello


Expand Down Expand Up @@ -82,14 +78,16 @@ echo "done."
known MacFLTK bugs
------------------

- OpenGL window resize
- font support not finished
- line styles missing
- file handles not supported
- timing not fully supported
- line styles not fully supported
- cut, copy, paste
- mousewheel (Carbon Events)
- sub-sub-subwindow
- sub-sub-subwindow not tested
- modal windows are not modal
- makefiles supporting Rez
- overlay not complete
- image transparency not implemented
- 'shiny' needs work (flush/aglFlush)
- threads not implemented


test suite status
Expand All @@ -99,14 +97,14 @@ OS X:

CubeView(++), adjuster(++), arc(++), ask(++), bitmap(++),
boxtype(++), browser(++), button(++), buttons(++), checkers(++),
clock(++), colbrowser(++), color_chooser(++), cube(++), cursor(+),
clock(++), colbrowser(++), color_chooser(++), cube(++), cursor(++),
curve(++), demo(++), doublebuffer(++), editor(++), fast_slow(++),
file_chooser(++), fonts(++), forms(++), fractals(+), fullscreen(+),
gl_overlay(o), glpuzzle(++), hello(++), help(++), iconize(+), image(+),
file_chooser(++), fonts(++), forms(++), fractals(++), fullscreen(++),
gl_overlay(-), glpuzzle(++), hello(++), help(++), iconize(++), image(+),
inactive(++), input(++), keyboard(+), label(++), line_style(+),
mandelbrot(++), menubar(++), message(++), minimum(++), navigation(++),
output(++), overlay(o), pack(++), pixmap(++), pixmap_browser(++),
radio(++), resizebox(++), scroll(++), shape(+), shiny(--), subwindow(++),
output(++), overlay(-), pack(++), pixmap(++), pixmap_browser(++),
radio(++), resizebox(++), scroll(++), shape(++), shiny(-), subwindow(++),
symbols(++), tabs(++), tile(++), tiled_image(++), valuators(++),
fluid(++)

Expand Down
13 changes: 10 additions & 3 deletions src/Fl.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl.cxx,v 1.24.2.41.2.13 2001/12/17 13:48:59 easysw Exp $"
// "$Id: Fl.cxx,v 1.24.2.41.2.14 2001/12/18 11:00:09 matthiaswm Exp $"
//
// Main event handling code for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -696,12 +696,19 @@ void Fl_Window::hide() {
fl_gc = 0;
}
#elif defined(__APPLE__)
//++ MacOS needs a simulation of focus events?! DONT!
//++ Matt: I have not checked yet what we need to do here
Fl::handle(FL_UNFOCUS, this);
#else
if (x->region) XDestroyRegion(x->region);
#endif

#ifdef __APPLE__
if ( !parent() ) // don't destroy shared windows!
XDestroyWindow(fl_display, x->xid);
#else
XDestroyWindow(fl_display, x->xid);
#endif

#ifdef WIN32
// Try to stop the annoying "raise another program" behavior
if (non_modal() && Fl::first_window() && Fl::first_window()->shown())
Expand Down Expand Up @@ -844,5 +851,5 @@ void Fl_Window::flush() {
}

//
// End of "$Id: Fl.cxx,v 1.24.2.41.2.13 2001/12/17 13:48:59 easysw Exp $".
// End of "$Id: Fl.cxx,v 1.24.2.41.2.14 2001/12/18 11:00:09 matthiaswm Exp $".
//
6 changes: 3 additions & 3 deletions src/Fl_Gl_Choice.H
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Gl_Choice.H,v 1.4.2.6.2.2 2001/12/06 00:17:47 matthiaswm Exp $"
// "$Id: Fl_Gl_Choice.H,v 1.4.2.6.2.3 2001/12/18 11:00:09 matthiaswm Exp $"
//
// OpenGL definitions for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -76,7 +76,7 @@ public:
int pixelformat; // the visual to use
PIXELFORMATDESCRIPTOR pfd; // some wgl calls need this thing
#elif defined(__APPLE__)
//++
AGLPixelFormat pixelformat;
#else
XVisualInfo *vis; // the visual to use
Colormap colormap; // a colormap for that visual
Expand Down Expand Up @@ -115,5 +115,5 @@ void fl_delete_gl_context(GLContext);
#endif

//
// End of "$Id: Fl_Gl_Choice.H,v 1.4.2.6.2.2 2001/12/06 00:17:47 matthiaswm Exp $".
// End of "$Id: Fl_Gl_Choice.H,v 1.4.2.6.2.3 2001/12/18 11:00:09 matthiaswm Exp $".
//
64 changes: 49 additions & 15 deletions src/Fl_Gl_Choice.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.4 2001/12/09 12:52:13 easysw Exp $"
// "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.5 2001/12/18 11:00:09 matthiaswm Exp $"
//
// OpenGL visual selection code for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -48,10 +48,51 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int mode, const int *alist) {
return g;

#ifdef __APPLE__

//++ later

const int *blist;
int list[32];

if (alist)
blist = alist;
else {
int n = 0;
if (mode & FL_INDEX) {
list[n++] = AGL_BUFFER_SIZE;
list[n++] = 8; // glut tries many sizes, but this should work...
} else {
list[n++] = AGL_RGBA;
list[n++] = AGL_GREEN_SIZE;
list[n++] = (mode & FL_RGB8) ? 8 : 1;
if (mode & FL_ALPHA) {
list[n++] = AGL_ALPHA_SIZE;
list[n++] = 1;
}
if (mode & FL_ACCUM) {
list[n++] = AGL_ACCUM_GREEN_SIZE;
list[n++] = 1;
if (mode & FL_ALPHA) {
list[n++] = AGL_ACCUM_ALPHA_SIZE;
list[n++] = 1;
}
}
}
if (mode & FL_DOUBLE) {
list[n++] = AGL_DOUBLEBUFFER;
}
if (mode & FL_DEPTH) {
list[n++] = AGL_DEPTH_SIZE; list[n++] = 16;
}
if (mode & FL_STENCIL) {
list[n++] = AGL_STENCIL_SIZE; list[n++] = 1;
}
list[n] = AGL_NONE;
blist = list;
}
fl_open_display();
AGLPixelFormat fmt = aglChoosePixelFormat(NULL, 0, (GLint*)blist);
if (!fmt) return 0;

#elif !defined(WIN32)

const int *blist;
int list[32];

Expand Down Expand Up @@ -151,7 +192,7 @@ Fl_Gl_Choice *Fl_Gl_Choice::find(int mode, const int *alist) {
g->pixelformat = pixelformat;
g->pfd = chosen_pfd;
#elif defined(__APPLE__)
//++ later
g->pixelformat = fmt;
#else
g->vis = vis;

Expand Down Expand Up @@ -193,15 +234,8 @@ GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int lay
#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, first_context);
context = aglCreateContext( g->pixelformat, first_context);
if ( !first_context ) first_context = (GLContext)context;
aglDestroyPixelFormat( fmt );
if ( window->parent() ) {
Rect wrect; GetWindowPortBounds( fl_xid(window), &wrect );
GLint rect[] = { window->x(), wrect.bottom-window->h()-window->y(), window->w(), window->h() };
Expand Down Expand Up @@ -237,7 +271,7 @@ void fl_set_gl_context(Fl_Window* w, GLContext context) {
aglSetInteger( context, AGL_BUFFER_RECT, rect );
aglEnable( context, AGL_BUFFER_RECT );
}
aglSetDrawable(context, GetWindowPort( fl_xid(w) ) ); //++ here or in Fl_Gl_Window::make_current creation part?
aglSetDrawable(context, GetWindowPort( fl_xid(w) ) ); //++ Matt: this probably belongs only in create_gl_context
aglSetCurrentContext(context);
#else
glXMakeCurrent(fl_display, fl_xid(w), context);
Expand Down Expand Up @@ -275,5 +309,5 @@ void fl_delete_gl_context(GLContext context) {
#endif

//
// End of "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.4 2001/12/09 12:52:13 easysw Exp $".
// End of "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.5 2001/12/18 11:00:09 matthiaswm Exp $".
//
51 changes: 30 additions & 21 deletions src/Fl_Gl_Window.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Gl_Window.cxx,v 1.12.2.22.2.4 2001/12/11 16:03:12 easysw Exp $"
// "$Id: Fl_Gl_Window.cxx,v 1.12.2.22.2.5 2001/12/18 11:00:09 matthiaswm Exp $"
//
// OpenGL window code for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -85,21 +85,22 @@ void Fl_Gl_Window::invalidate() {

int Fl_Gl_Window::mode(int m, const int *a) {
if (m == mode_ && a == alist) return 0;
#if !defined(__APPLE__)
#ifndef __APPLE__
int oldmode = mode_;
Fl_Gl_Choice* oldg = g;
#endif
context(0);
mode_ = m; alist = a;
if (shown()) {
g = Fl_Gl_Choice::find(m, a);
#ifdef WIN32
if (!g || (oldmode^m)&FL_DOUBLE) {
hide();
show();
}
#endif
#if !defined(WIN32) && !defined(__APPLE__)
g = Fl_Gl_Choice::find(m, a);
#if defined(WIN32)
if (!g || (oldmode^m)&FL_DOUBLE) {
hide();
show();
}
#elif defined(__APPLE__)
redraw();
#else
// under X, if the visual changes we must make a new X window (yuck!):
if (!g || g->vis->visualid!=oldg->vis->visualid || (oldmode^m)&FL_DOUBLE) {
hide();
Expand Down Expand Up @@ -170,6 +171,24 @@ int fl_overlay_depth = 0;
void Fl_Gl_Window::flush() {
uchar save_valid = valid_;

#ifdef __APPLE__
// matt: I have no idea hw expensive the following code is, but we need to reset the buffer rect after
// every window-reconfiguration, especially after window resizes.
if ( parent() ) { //: resize our GL buffer rectangle
Rect wrect; GetWindowPortBounds( fl_xid(this), &wrect );
GLint rect[] = { x(), wrect.bottom-h()-y(), w(), h() };
aglSetInteger( context_, AGL_BUFFER_RECT, rect );
aglEnable( context_, AGL_BUFFER_RECT );
}
//: clear previous clipping in this shared port
GrafPtr port = GetWindowPort( fl_xid(this) );
Rect rect; SetRect( &rect, 0, 0, 0x7fff, 0x7fff );
GrafPtr old; GetPort( &old );
SetPort( port );
ClipRect( &rect );
SetPort( old );
#endif

#if HAVE_GL_OVERLAY && defined(WIN32)

bool fixcursor = false; // for fixing the SGI 320 bug
Expand Down Expand Up @@ -200,16 +219,6 @@ void Fl_Gl_Window::flush() {
}
#endif

#ifdef __APPLE__
//: clear previous clipping in this shared port
GrafPtr port = GetWindowPort( fl_xid(this) );
Rect rect; SetRect( &rect, 0, 0, 0x7fff, 0x7fff );
GrafPtr old; GetPort( &old );
SetPort( port );
ClipRect( &rect );
SetPort( old );
#endif

make_current();

if (mode_ & FL_DOUBLE) {
Expand Down Expand Up @@ -354,5 +363,5 @@ void Fl_Gl_Window::draw_overlay() {}
#endif

//
// End of "$Id: Fl_Gl_Window.cxx,v 1.12.2.22.2.4 2001/12/11 16:03:12 easysw Exp $".
// End of "$Id: Fl_Gl_Window.cxx,v 1.12.2.22.2.5 2001/12/18 11:00:09 matthiaswm Exp $".
//
6 changes: 3 additions & 3 deletions src/Fl_Window_fullscreen.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Window_fullscreen.cxx,v 1.5.2.3.2.1 2001/11/27 17:44:06 easysw Exp $"
// "$Id: Fl_Window_fullscreen.cxx,v 1.5.2.3.2.2 2001/12/18 11:00:09 matthiaswm Exp $"
//
// Fullscreen window support for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -48,7 +48,7 @@ void Fl_Window::border(int b) {
// not yet implemented, but it's possible
// for full fullscreen we have to make the window topmost as well
#elif defined(__APPLE__)
//++
//++ Matt: I have not looked into this yet
#else
if (shown()) Fl_X::i(this)->sendxjunk();
#endif
Expand All @@ -73,5 +73,5 @@ void Fl_Window::fullscreen_off(int X,int Y,int W,int H) {
}

//
// End of "$Id: Fl_Window_fullscreen.cxx,v 1.5.2.3.2.1 2001/11/27 17:44:06 easysw Exp $".
// End of "$Id: Fl_Window_fullscreen.cxx,v 1.5.2.3.2.2 2001/12/18 11:00:09 matthiaswm Exp $".
//
8 changes: 3 additions & 5 deletions src/Fl_Window_iconize.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Window_iconize.cxx,v 1.5.2.3.2.2 2001/11/27 17:44:06 easysw Exp $"
// "$Id: Fl_Window_iconize.cxx,v 1.5.2.3.2.3 2001/12/18 11:00:09 matthiaswm Exp $"
//
// Window minification code for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -35,15 +35,13 @@ void Fl_Window::iconize() {
#ifdef WIN32
ShowWindow(i->xid, SW_SHOWMINNOACTIVE);
#elif defined(__APPLE__)
//: http://developer.apple.com/techpubs/mac/Toolbox/Toolbox-254.html#HEADING254-0
//++ see iconize, above is the WRONG CALL
//++ call "hide all" ZoomWindow(i->xid, inZoomIn, 0);
CollapseWindow( i->xid, true );
#else
XIconifyWindow(fl_display, i->xid, fl_screen);
#endif
}
}

//
// End of "$Id: Fl_Window_iconize.cxx,v 1.5.2.3.2.2 2001/11/27 17:44:06 easysw Exp $".
// End of "$Id: Fl_Window_iconize.cxx,v 1.5.2.3.2.3 2001/12/18 11:00:09 matthiaswm Exp $".
//

0 comments on commit b6b4e1e

Please sign in to comment.