Skip to content

Commit

Permalink
Added initial support for Quartz video (thanks Darrell!)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Lantinga committed Jun 7, 2001
1 parent 0795576 commit 924ec82
Show file tree
Hide file tree
Showing 23 changed files with 2,131 additions and 33 deletions.
43 changes: 28 additions & 15 deletions BUGS
Expand Up @@ -70,22 +70,35 @@ MacOS:
Not all of the keys are properly recognized on the keyboard.

MacOS X:
Fullscreen mode doesn't work - it requires the QuickTime framework
and that the new SDL window gets raised to the top of the Z order.

Joystick and CD-ROM functions are not implemented yet.

Closing window from window's close widget not implemented yet.

Minimizing the window erases the framebuffer to the pinstripe pattern.

Window may not close when unsetting video mode and resetting.

Depth switching for windowed mode isn't implemented yet.

Palette handling isn't implemented in windowed mode yet.

Native sound and video routines are not finished, though Carbon
seems to work fairly well.

Joysticks and CD-ROM functions are not implemented yet.

SDL_WM_GrabInput() is not implemented.
Does anyone know how to do this? SDL_WM_GrabInput() is designed
to prevent the user from switching input and mouse focus away from
the SDL application.

Continuous relative mouse motion is not implemented.

Command-line arguments Dialog is not implemented yet.

Fullscreen drawing has some artifacts.

Fullscreen window covers *all* other windows - even force quit.

Fullscreen OpenGL for the software renderer is broken.

Some OpenGL parameters are not accounted for, for example color bits customization.

Getting OpenGL context parameters is not implemented.

Continuous mouse motion perhaps is not as smooth as it should be.

SDL_WM_GrabInput() is implemented, but it "freezes" the hardware
cursor in the center of the window/screen. Also, mouse moved events
are not generated, and the keyboard cannot be grabbed.

Not all of the keys are properly recognized on the keyboard.

Expand Down
79 changes: 74 additions & 5 deletions README.MacOSX
Expand Up @@ -34,11 +34,80 @@ and linking, respectively:
sdl-config knows about the linking path and -framework, so it's
recommended to use it to fill in your Makefile variables.

[Add instructions for how to build using PB]
==============================================================================
Using the Simple DirectMedia Layer with Project Builder
==============================================================================

These instructions are for using Apple's Project Builder IDE to build SDL applications.

- Building the Framework

The SDL Library is packaged as a framework bundle, an organized
relocatable folder heirarchy of executible code, interface headers,
and additional resources. For practical purposes, you can think of a
framework as a more user and system-friendly shared library, whose library
file behaves more or less like a standard UNIX shared library.

To build the framework, simply open the framework project and build it.
By default, the framework bundle "SDL.framework" is installed in
~/Library/Frameworks. Therefore, the testers and project stationary expect
it to be located there. However, it will function the same in any of the
following locations:

~/Library/Frameworks
/Local/Library/Frameworks
/System/Library/Frameworks

- Build Options
There are two "Build Styles" (See the "Targets" tab) for SDL.
"Deployment" should be used if you aren't tweaking the SDL library.
"Development" should be used to debug SDL apps or the library itself.

- Building the Testers
Open the SDLTest project and build away!

- Using the Project Stationary
Copy the stationary to the indicated folders to access it from
the "New Project" and "Add target" menus. What could be easier?

As of this writing (Sep 2000), OS X is in public beta. This means
that while most of the APIs are frozen, things are still subject to
change, and many of the known problems will be resolved before the
final release comes out.
- Setting up a new project by hand
Some of you won't want to use the Stationary so I'll give some tips:
* Create a new "Cocoa Application"
* Add src/main/macosx/SDLMain.m , .h and .nib to your project
* Remove "main.c" from your project
* Remove "MainMenu.nib" from your project
* Add "$(HOME)/Library/Frameworks/SDL.framework/Headers" to include path
* Add "$(HOME)/Library/Frameworks" to the frameworks search path
* Add "-framework SDL" to the "OTHER_LDFLAGS" variable
* Set the "Main Nib File" under "Application Settings" to "SDLMain.nib"
* Add your files
* Clean and build

- Building from command line
Use pbxbuild in the same directory as your .pbproj file

- Running your app
You can send command line args to your app by either invoking it from
the command line (in *.app/Contents/MacOS) or by entering them in the
"Executibles" panel of the target settings.

- Implementation Notes
Some things that may be of interest about how it all works...
* Working directory
As defined in the SDLMain.m file, the working directory of your SDL app
is by default set to its parent. You may wish to change this to better
suit your needs.
* You have a Cocoa App!
Your SDL app is essentially a Cocoa application. When your app
starts up and the libraries finish loading, a Cocoa procedure is called,
which sets up the working directory and calls your main() method.
You are free to modify your Cocoa app with generally no consequence
to SDL. You cannot, however, easily change the SDL window itself.
Functionality may be added in the future to help this.
* My development setup:
I am using version 1.0.1 (v63.0) of Project Builder on MacOS X 10.0.3,
from the Developer Tools CD for May 2001.
As of May 31 2001, Apple hasn't released this version of the tools to the public,
but I expect that things will still work on older versions.

Known bugs are listed in the file "BUGS"
5 changes: 5 additions & 0 deletions configure.in
Expand Up @@ -63,6 +63,10 @@ case "$target" in
*-*-linux*)
AC_PROG_CXX
;;
*-*-darwin*)
OBJC="???"
AC_SUBST(OBJC)
;;
esac
AC_PROG_INSTALL
AC_FUNC_ALLOCA
Expand Down Expand Up @@ -1979,6 +1983,7 @@ src/video/ggi/Makefile
src/video/maccommon/Makefile
src/video/macdsp/Makefile
src/video/macrom/Makefile
src/video/quartz/Makefile
src/video/svga/Makefile
src/video/aalib/Makefile
src/video/wincommon/Makefile
Expand Down
1 change: 1 addition & 0 deletions docs.html
Expand Up @@ -16,6 +16,7 @@ <H2>
Major changes since SDL 1.0.0:
</H2>
<UL>
<LI> 1.2.1: Added initial support for Quartz video (thanks Darrell!)
<LI> 1.2.1: Added native OpenBSD audio driver (thanks vedge!)
<LI> 1.2.1: Added detection of Open Sound System on Solaris x86
<LI> 1.2.1: Added initial support for Nano-X (thanks Hsieh-Fu!)
Expand Down
2 changes: 1 addition & 1 deletion include/SDL_main.h
Expand Up @@ -31,7 +31,7 @@ static char rcsid =
/* Redefine main() on Win32 and MacOS so that it is called by winmain.c */

#if defined(WIN32) || (defined(__MWERKS__) && !defined(__BEOS__)) || \
defined(macintosh)
defined(macintosh) || defined(__APPLE__)

#ifdef __cplusplus
#define C_LINKAGE "C"
Expand Down
4 changes: 4 additions & 0 deletions include/SDL_video.h
Expand Up @@ -878,6 +878,10 @@ typedef enum {
*/
extern DECLSPEC SDL_GrabMode SDL_WM_GrabInput(SDL_GrabMode mode);

/* Not in public API at the moment - do not use! */
extern DECLSPEC int SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect);

/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
Expand Down
28 changes: 20 additions & 8 deletions src/audio/macrom/SDL_romaudio.c
Expand Up @@ -105,9 +105,8 @@ static void callBackProc (SndChannel *chan, SndCommand *cmd_passed ) {
UInt32 fill_me, play_me;
SndCommand cmd;
SDL_AudioDevice *audio = (SDL_AudioDevice *)chan->userInfo;

fill_me = cmd_passed->param2; /* buffer that has just finished playing,
so fill it */

fill_me = cmd_passed->param2; /* buffer that has just finished playing, so fill it */
play_me = ! fill_me; /* filled buffer to play _now_ */

if ( ! audio->enabled ) {
Expand All @@ -119,15 +118,21 @@ so fill it */
cmd.cmd = bufferCmd;
cmd.param1 = 0;
cmd.param2 = (long)&header;
SndDoCommand (chan, &cmd, 0);

SndDoCommand (chan, &cmd, 0);

memset (buffer[fill_me], 0, audio->spec.size);

if ( ! audio->paused ) {
if ( audio->convert.needed ) {
audio->spec.callback(audio->spec.userdata,
(Uint8 *)audio->convert.buf,audio->convert.len);
#if MACOSX
SDL_mutexP(audio->mixer_lock);
#endif
audio->spec.callback(audio->spec.userdata,
(Uint8 *)audio->convert.buf,audio->convert.len);
#if MACOSX
SDL_mutexV(audio->mixer_lock);
#endif
SDL_ConvertAudio(&audio->convert);
#if 0
if ( audio->convert.len_cvt != audio->spec.size ) {
Expand All @@ -137,11 +142,17 @@ so fill it */
memcpy(buffer[fill_me], audio->convert.buf,
audio->convert.len_cvt);
} else {
#if MACOSX
SDL_mutexP(audio->mixer_lock);
#endif
audio->spec.callback(audio->spec.userdata,
(Uint8 *)buffer[fill_me], audio->spec.size);
#if MACOSX
SDL_mutexV(audio->mixer_lock);
#endif
}
}

if ( running ) {

cmd.cmd = callBackCmd;
Expand All @@ -150,6 +161,7 @@ so fill it */

SndDoCommand (chan, &cmd, 0);
}

}

static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec) {
Expand Down
8 changes: 8 additions & 0 deletions src/main/macosx/SDLMain.h
@@ -0,0 +1,8 @@
#import <Cocoa/Cocoa.h>

@interface SDLMain : NSObject
{
}
- (IBAction)quit:(id)sender;
- (IBAction)makeFullscreen:(id)sender;
@end
88 changes: 88 additions & 0 deletions src/main/macosx/SDLMain.m
@@ -0,0 +1,88 @@
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
Darrell Walisser - dwaliss1@purdue.edu
Feel free to customize this file to suit your needs
*/

#import "SDL.h"
#import "SDLMain.h"
#import <sys/param.h> /* for MAXPATHLEN */
#import <unistd.h>

static int gArgc;
static char **gArgv;

/* The main class of the application, the application's delegate */
@implementation SDLMain

/* Invoked from the Quit menu item */
- (void) quit:(id)sender
{
SDL_Event event;
event.type = SDL_QUIT;
SDL_PushEvent(&event);
}

/* Invoked from the "Make fulllscreen" menu item */
- (void) makeFullscreen:(id)sender
{

}

/* Set the working directory to the .app's parent directory */
- (void) setupWorkingDirectory
{
char parentdir[MAXPATHLEN];
char *c;

strncpy ( parentdir, gArgv[0], MAXPATHLEN );
c = (char*) parentdir;

while (*c != '\0') /* go to end */
c++;

while (*c != '/') /* back up to parent */
c--;

*c = '\0'; /* cut off last part (binary name) */

assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */
assert ( chdir ("../../../") == 0 ); /* chdir to the .app's parent */
}

/* Called when the internal event loop has just started running */
- (void) applicationDidFinishLaunching: (NSNotification *) note
{
/* Set the working directory to the .app's parent directory */
[ self setupWorkingDirectory ];

/* This is passed if we are launched by double-clicking */
if ( gArgc >= 2 && strncmp (gArgv[1], "-psn", 4) == 0 )
gArgc = 1;

/* Hand off to main application code */
SDL_main (gArgc, gArgv);
exit(0);
}
@end

#ifdef main
# undef main
#endif

/* Main entry point to executible - should *not* be SDL_main! */
int main (int argc, char **argv) {

/* Copy the arguments into a global variable */
int i;

gArgc = argc;
gArgv = (char**) malloc (sizeof(*gArgv) * gArgc);
assert (gArgv != NULL);
for (i = 0; i < gArgc; i++) {
gArgv[i] = strdup (argv[i]);
}

NSApplicationMain (argc, argv);
return 0;
}
35 changes: 35 additions & 0 deletions src/main/macosx/exports/Makefile
@@ -0,0 +1,35 @@

EXPORTS = SDL.x
HEADERS = \
../../../../include/SDL.h \
../../../../include/SDL_active.h \
../../../../include/SDL_audio.h \
../../../../include/SDL_byteorder.h \
../../../../include/SDL_cdrom.h \
../../../../include/SDL_copying.h \
../../../../include/SDL_endian.h \
../../../../include/SDL_error.h \
../../../../include/SDL_events.h \
../../../../include/SDL_getenv.h \
../../../../include/SDL_joystick.h \
../../../../include/SDL_keyboard.h \
../../../../include/SDL_keysym.h \
../../../../include/SDL_mouse.h \
../../../../include/SDL_mutex.h \
../../../../include/SDL_quit.h \
../../../../include/SDL_rwops.h \
../../../../include/SDL_syswm.h \
../../../../include/SDL_thread.h \
../../../../include/SDL_timer.h \
../../../../include/SDL_types.h \
../../../../include/SDL_version.h \
../../../../include/SDL_video.h


all: $(EXPORTS)

$(EXPORTS): $(HEADERS)
perl gendef.pl $(HEADERS) >$@ || rm $@

clean:
rm -f $(EXPORTS)

0 comments on commit 924ec82

Please sign in to comment.