Added missing templates
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403942
This commit is contained in:
parent
68b5d835c3
commit
9cf9fe1010
33 changed files with 8386 additions and 0 deletions
BIN
Xcode/TemplatesForXcodeTiger/SDL Application/English.lproj/InfoPlist.strings
Executable file
BIN
Xcode/TemplatesForXcodeTiger/SDL Application/English.lproj/InfoPlist.strings
Executable file
Binary file not shown.
28
Xcode/TemplatesForXcodeTiger/SDL Application/Info.plist
Normal file
28
Xcode/TemplatesForXcodeTiger/SDL Application/Info.plist
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>English</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>${EXECUTABLE_NAME}</string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string></string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>com.yourcompany.«PROJECTNAMEASXML»</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>${PRODUCT_NAME}</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>NSMainNibFile</key>
|
||||||
|
<string>SDLMain</string>
|
||||||
|
<key>NSPrincipalClass</key>
|
||||||
|
<string>NSApplication</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
FilesToRename = {
|
||||||
|
"SDLApp_Prefix.pch" = "ÇPROJECTNAMEÈ_Prefix.pch";
|
||||||
|
};
|
||||||
|
FilesToMacroExpand = (
|
||||||
|
"ÇPROJECTNAMEÈ_Prefix.pch",
|
||||||
|
"Info.plist",
|
||||||
|
"English.lproj/InfoPlist.strings",
|
||||||
|
"main.c",
|
||||||
|
);
|
||||||
|
Description = "This project builds an SDL-based application.";
|
||||||
|
}
|
|
@ -0,0 +1,297 @@
|
||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 42;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
002F39FA09D0881F00EBEB88 /* SDL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002F39F909D0881F00EBEB88 /* SDL.framework */; };
|
||||||
|
002F3A0009D0884600EBEB88 /* SDL.framework in Copy Frameworks into .app bundle */ = {isa = PBXBuildFile; fileRef = 002F39F909D0881F00EBEB88 /* SDL.framework */; };
|
||||||
|
002F3A3F09D088BA00EBEB88 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 002F3A3E09D088BA00EBEB88 /* main.c */; };
|
||||||
|
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
|
||||||
|
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
|
002F39FD09D0883400EBEB88 /* Copy Frameworks into .app bundle */ = {
|
||||||
|
isa = PBXCopyFilesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
dstPath = "";
|
||||||
|
dstSubfolderSpec = 10;
|
||||||
|
files = (
|
||||||
|
002F3A0009D0884600EBEB88 /* SDL.framework in Copy Frameworks into .app bundle */,
|
||||||
|
);
|
||||||
|
name = "Copy Frameworks into .app bundle";
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
002F39F909D0881F00EBEB88 /* SDL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL.framework; path = /Library/Frameworks/SDL.framework; sourceTree = "<absolute>"; };
|
||||||
|
002F3A3E09D088BA00EBEB88 /* main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = SOURCE_ROOT; };
|
||||||
|
089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||||
|
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
|
||||||
|
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
|
||||||
|
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
|
||||||
|
32CA4F630368D1EE00C91783 /* «PROJECTNAME»_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "«PROJECTNAME»_Prefix.pch"; sourceTree = "<group>"; };
|
||||||
|
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
8D1107320486CEB800E47090 /* «PROJECTNAME».app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "«PROJECTNAME».app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
8D11072E0486CEB800E47090 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
002F39FA09D0881F00EBEB88 /* SDL.framework in Frameworks */,
|
||||||
|
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
080E96DDFE201D6D7F000001 /* Classes */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
);
|
||||||
|
name = Classes;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
002F39F909D0881F00EBEB88 /* SDL.framework */,
|
||||||
|
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */,
|
||||||
|
);
|
||||||
|
name = "Linked Frameworks";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
29B97324FDCFA39411CA2CEA /* AppKit.framework */,
|
||||||
|
29B97325FDCFA39411CA2CEA /* Foundation.framework */,
|
||||||
|
);
|
||||||
|
name = "Other Frameworks";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
19C28FACFE9D520D11CA2CBB /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
8D1107320486CEB800E47090 /* «PROJECTNAME».app */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
29B97314FDCFA39411CA2CEA /* «PROJECTNAMEASXML» */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
080E96DDFE201D6D7F000001 /* Classes */,
|
||||||
|
29B97315FDCFA39411CA2CEA /* Other Sources */,
|
||||||
|
29B97317FDCFA39411CA2CEA /* Resources */,
|
||||||
|
29B97323FDCFA39411CA2CEA /* Frameworks */,
|
||||||
|
19C28FACFE9D520D11CA2CBB /* Products */,
|
||||||
|
);
|
||||||
|
name = "«PROJECTNAMEASXML»";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
32CA4F630368D1EE00C91783 /* «PROJECTNAME»_Prefix.pch */,
|
||||||
|
002F3A3E09D088BA00EBEB88 /* main.c */,
|
||||||
|
);
|
||||||
|
name = "Other Sources";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
29B97317FDCFA39411CA2CEA /* Resources */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
8D1107310486CEB800E47090 /* Info.plist */,
|
||||||
|
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
|
||||||
|
);
|
||||||
|
name = Resources;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */,
|
||||||
|
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */,
|
||||||
|
);
|
||||||
|
name = Frameworks;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
8D1107260486CEB800E47090 /* «PROJECTNAME» */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "«PROJECTNAME»" */;
|
||||||
|
buildPhases = (
|
||||||
|
8D1107290486CEB800E47090 /* Resources */,
|
||||||
|
8D11072C0486CEB800E47090 /* Sources */,
|
||||||
|
8D11072E0486CEB800E47090 /* Frameworks */,
|
||||||
|
002F39FD09D0883400EBEB88 /* Copy Frameworks into .app bundle */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
name = "«PROJECTNAME»";
|
||||||
|
productInstallPath = "$(HOME)/Applications";
|
||||||
|
productName = "«PROJECTNAME»";
|
||||||
|
productReference = 8D1107320486CEB800E47090 /* «PROJECTNAME».app */;
|
||||||
|
productType = "com.apple.product-type.application";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "SDLApp" */;
|
||||||
|
compatibilityVersion = "Xcode 2.4";
|
||||||
|
hasScannedForEncodings = 1;
|
||||||
|
mainGroup = 29B97314FDCFA39411CA2CEA /* «PROJECTNAMEASXML» */;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
8D1107260486CEB800E47090 /* «PROJECTNAME» */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXResourcesBuildPhase section */
|
||||||
|
8D1107290486CEB800E47090 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
8D11072C0486CEB800E47090 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
002F3A3F09D088BA00EBEB88 /* main.c in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXVariantGroup section */
|
||||||
|
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
089C165DFE840E0CC02AAC07 /* English */,
|
||||||
|
);
|
||||||
|
name = InfoPlist.strings;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXVariantGroup section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
C01FCF4B08A954540054247B /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_ENABLE_FIX_AND_CONTINUE = YES;
|
||||||
|
GCC_MODEL_TUNING = G5;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
INFOPLIST_FILE = Info.plist;
|
||||||
|
INSTALL_PATH = "$(HOME)/Applications";
|
||||||
|
PRODUCT_NAME = "«PROJECTNAME»";
|
||||||
|
WRAPPER_EXTENSION = app;
|
||||||
|
ZERO_LINK = YES;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
C01FCF4C08A954540054247B /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ARCHS = (
|
||||||
|
ppc,
|
||||||
|
i386,
|
||||||
|
);
|
||||||
|
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
|
||||||
|
GCC_MODEL_TUNING = G5;
|
||||||
|
INFOPLIST_FILE = Info.plist;
|
||||||
|
INSTALL_PATH = "$(HOME)/Applications";
|
||||||
|
PRODUCT_NAME = "«PROJECTNAME»";
|
||||||
|
WRAPPER_EXTENSION = app;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
C01FCF4F08A954540054247B /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
|
"$(HOME)/Library/Frameworks",
|
||||||
|
/Library/Frameworks,
|
||||||
|
"$(FRAMEWORK_SEARCH_PATHS)",
|
||||||
|
);
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
HEADER_SEARCH_PATHS = (
|
||||||
|
"$(HOME)/Library/Frameworks/SDL.framework/Headers",
|
||||||
|
/Library/Frameworks/SDL.framework/Headers,
|
||||||
|
"$(HEADER_SEARCH_PATHS)",
|
||||||
|
);
|
||||||
|
PREBINDING = NO;
|
||||||
|
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
C01FCF5008A954540054247B /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
|
"$(HOME)/Library/Frameworks",
|
||||||
|
/Library/Frameworks,
|
||||||
|
"$(FRAMEWORK_SEARCH_PATHS)",
|
||||||
|
);
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
HEADER_SEARCH_PATHS = (
|
||||||
|
"$(HOME)/Library/Frameworks/SDL.framework/Headers",
|
||||||
|
/Library/Frameworks/SDL.framework/Headers,
|
||||||
|
"$(HEADER_SEARCH_PATHS)",
|
||||||
|
);
|
||||||
|
PREBINDING = NO;
|
||||||
|
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "«PROJECTNAME»" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
C01FCF4B08A954540054247B /* Debug */,
|
||||||
|
C01FCF4C08A954540054247B /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
C01FCF4E08A954540054247B /* Build configuration list for PBXProject "SDLApp" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
C01FCF4F08A954540054247B /* Debug */,
|
||||||
|
C01FCF5008A954540054247B /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
};
|
||||||
|
rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
//
|
||||||
|
// Prefix header for all source files of the 'ÇPROJECTNAMEÈ' target in the 'ÇPROJECTNAMEÈ' project
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "SDL.h"
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
16
Xcode/TemplatesForXcodeTiger/SDL Application/SDLMain.h
Normal file
16
Xcode/TemplatesForXcodeTiger/SDL Application/SDLMain.h
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
|
||||||
|
Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
|
||||||
|
Non-NIB-Code & other changes: Max Horn <max@quendi.de>
|
||||||
|
|
||||||
|
Feel free to customize this file to suit your needs
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SDLMain_h_
|
||||||
|
#define _SDLMain_h_
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
@interface SDLMain : NSObject
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif /* _SDLMain_h_ */
|
383
Xcode/TemplatesForXcodeTiger/SDL Application/SDLMain.m
Normal file
383
Xcode/TemplatesForXcodeTiger/SDL Application/SDLMain.m
Normal file
|
@ -0,0 +1,383 @@
|
||||||
|
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
|
||||||
|
Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
|
||||||
|
Non-NIB-Code & other changes: Max Horn <max@quendi.de>
|
||||||
|
|
||||||
|
Feel free to customize this file to suit your needs
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "SDL.h"
|
||||||
|
#include "SDLMain.h"
|
||||||
|
#include <sys/param.h> /* for MAXPATHLEN */
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
|
||||||
|
but the method still is there and works. To avoid warnings, we declare
|
||||||
|
it ourselves here. */
|
||||||
|
@interface NSApplication(SDL_Missing_Methods)
|
||||||
|
- (void)setAppleMenu:(NSMenu *)menu;
|
||||||
|
@end
|
||||||
|
|
||||||
|
/* Use this flag to determine whether we use SDLMain.nib or not */
|
||||||
|
#define SDL_USE_NIB_FILE 0
|
||||||
|
|
||||||
|
/* Use this flag to determine whether we use CPS (docking) or not */
|
||||||
|
#define SDL_USE_CPS 1
|
||||||
|
#ifdef SDL_USE_CPS
|
||||||
|
/* Portions of CPS.h */
|
||||||
|
typedef struct CPSProcessSerNum
|
||||||
|
{
|
||||||
|
UInt32 lo;
|
||||||
|
UInt32 hi;
|
||||||
|
} CPSProcessSerNum;
|
||||||
|
|
||||||
|
extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn);
|
||||||
|
extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
|
||||||
|
extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn);
|
||||||
|
|
||||||
|
#endif /* SDL_USE_CPS */
|
||||||
|
|
||||||
|
static int gArgc;
|
||||||
|
static char **gArgv;
|
||||||
|
static BOOL gFinderLaunch;
|
||||||
|
static BOOL gCalledAppMainline = FALSE;
|
||||||
|
|
||||||
|
static NSString *getApplicationName(void)
|
||||||
|
{
|
||||||
|
const NSDictionary *dict;
|
||||||
|
NSString *appName = 0;
|
||||||
|
|
||||||
|
/* Determine the application name */
|
||||||
|
dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
|
||||||
|
if (dict)
|
||||||
|
appName = [dict objectForKey: @"CFBundleName"];
|
||||||
|
|
||||||
|
if (![appName length])
|
||||||
|
appName = [[NSProcessInfo processInfo] processName];
|
||||||
|
|
||||||
|
return appName;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SDL_USE_NIB_FILE
|
||||||
|
/* A helper category for NSString */
|
||||||
|
@interface NSString (ReplaceSubString)
|
||||||
|
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
|
||||||
|
@end
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@interface SDLApplication : NSApplication
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation SDLApplication
|
||||||
|
/* Invoked from the Quit menu item */
|
||||||
|
- (void)terminate:(id)sender
|
||||||
|
{
|
||||||
|
/* Post a SDL_QUIT event */
|
||||||
|
SDL_Event event;
|
||||||
|
event.type = SDL_QUIT;
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
/* The main class of the application, the application's delegate */
|
||||||
|
@implementation SDLMain
|
||||||
|
|
||||||
|
/* Set the working directory to the .app's parent directory */
|
||||||
|
- (void) setupWorkingDirectory:(BOOL)shouldChdir
|
||||||
|
{
|
||||||
|
if (shouldChdir)
|
||||||
|
{
|
||||||
|
char parentdir[MAXPATHLEN];
|
||||||
|
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||||
|
CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
|
||||||
|
if (CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, MAXPATHLEN)) {
|
||||||
|
chdir(parentdir); /* chdir to the binary app's parent */
|
||||||
|
}
|
||||||
|
CFRelease(url);
|
||||||
|
CFRelease(url2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SDL_USE_NIB_FILE
|
||||||
|
|
||||||
|
/* Fix menu to contain the real app name instead of "SDL App" */
|
||||||
|
- (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName
|
||||||
|
{
|
||||||
|
NSRange aRange;
|
||||||
|
NSEnumerator *enumerator;
|
||||||
|
NSMenuItem *menuItem;
|
||||||
|
|
||||||
|
aRange = [[aMenu title] rangeOfString:@"SDL App"];
|
||||||
|
if (aRange.length != 0)
|
||||||
|
[aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]];
|
||||||
|
|
||||||
|
enumerator = [[aMenu itemArray] objectEnumerator];
|
||||||
|
while ((menuItem = [enumerator nextObject]))
|
||||||
|
{
|
||||||
|
aRange = [[menuItem title] rangeOfString:@"SDL App"];
|
||||||
|
if (aRange.length != 0)
|
||||||
|
[menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]];
|
||||||
|
if ([menuItem hasSubmenu])
|
||||||
|
[self fixMenu:[menuItem submenu] withAppName:appName];
|
||||||
|
}
|
||||||
|
[ aMenu sizeToFit ];
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static void setApplicationMenu(void)
|
||||||
|
{
|
||||||
|
/* warning: this code is very odd */
|
||||||
|
NSMenu *appleMenu;
|
||||||
|
NSMenuItem *menuItem;
|
||||||
|
NSString *title;
|
||||||
|
NSString *appName;
|
||||||
|
|
||||||
|
appName = getApplicationName();
|
||||||
|
appleMenu = [[NSMenu alloc] initWithTitle:@""];
|
||||||
|
|
||||||
|
/* Add menu items */
|
||||||
|
title = [@"About " stringByAppendingString:appName];
|
||||||
|
[appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
|
||||||
|
|
||||||
|
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||||
|
|
||||||
|
title = [@"Hide " stringByAppendingString:appName];
|
||||||
|
[appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
|
||||||
|
|
||||||
|
menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
|
||||||
|
[menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
|
||||||
|
|
||||||
|
[appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
|
||||||
|
|
||||||
|
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||||
|
|
||||||
|
title = [@"Quit " stringByAppendingString:appName];
|
||||||
|
[appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
|
||||||
|
|
||||||
|
|
||||||
|
/* Put menu into the menubar */
|
||||||
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
|
||||||
|
[menuItem setSubmenu:appleMenu];
|
||||||
|
[[NSApp mainMenu] addItem:menuItem];
|
||||||
|
|
||||||
|
/* Tell the application object that this is now the application menu */
|
||||||
|
[NSApp setAppleMenu:appleMenu];
|
||||||
|
|
||||||
|
/* Finally give up our references to the objects */
|
||||||
|
[appleMenu release];
|
||||||
|
[menuItem release];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create a window menu */
|
||||||
|
static void setupWindowMenu(void)
|
||||||
|
{
|
||||||
|
NSMenu *windowMenu;
|
||||||
|
NSMenuItem *windowMenuItem;
|
||||||
|
NSMenuItem *menuItem;
|
||||||
|
|
||||||
|
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
|
||||||
|
|
||||||
|
/* "Minimize" item */
|
||||||
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
|
||||||
|
[windowMenu addItem:menuItem];
|
||||||
|
[menuItem release];
|
||||||
|
|
||||||
|
/* Put menu into the menubar */
|
||||||
|
windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
|
||||||
|
[windowMenuItem setSubmenu:windowMenu];
|
||||||
|
[[NSApp mainMenu] addItem:windowMenuItem];
|
||||||
|
|
||||||
|
/* Tell the application object that this is now the window menu */
|
||||||
|
[NSApp setWindowsMenu:windowMenu];
|
||||||
|
|
||||||
|
/* Finally give up our references to the objects */
|
||||||
|
[windowMenu release];
|
||||||
|
[windowMenuItem release];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Replacement for NSApplicationMain */
|
||||||
|
static void CustomApplicationMain (int argc, char **argv)
|
||||||
|
{
|
||||||
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
SDLMain *sdlMain;
|
||||||
|
|
||||||
|
/* Ensure the application object is initialised */
|
||||||
|
[SDLApplication sharedApplication];
|
||||||
|
|
||||||
|
#ifdef SDL_USE_CPS
|
||||||
|
{
|
||||||
|
CPSProcessSerNum PSN;
|
||||||
|
/* Tell the dock about us */
|
||||||
|
if (!CPSGetCurrentProcess(&PSN))
|
||||||
|
if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
|
||||||
|
if (!CPSSetFrontProcess(&PSN))
|
||||||
|
[SDLApplication sharedApplication];
|
||||||
|
}
|
||||||
|
#endif /* SDL_USE_CPS */
|
||||||
|
|
||||||
|
/* Set up the menubar */
|
||||||
|
[NSApp setMainMenu:[[NSMenu alloc] init]];
|
||||||
|
setApplicationMenu();
|
||||||
|
setupWindowMenu();
|
||||||
|
|
||||||
|
/* Create SDLMain and make it the app delegate */
|
||||||
|
sdlMain = [[SDLMain alloc] init];
|
||||||
|
[NSApp setDelegate:sdlMain];
|
||||||
|
|
||||||
|
/* Start the main event loop */
|
||||||
|
[NSApp run];
|
||||||
|
|
||||||
|
[sdlMain release];
|
||||||
|
[pool release];
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Catch document open requests...this lets us notice files when the app
|
||||||
|
* was launched by double-clicking a document, or when a document was
|
||||||
|
* dragged/dropped on the app's icon. You need to have a
|
||||||
|
* CFBundleDocumentsType section in your Info.plist to get this message,
|
||||||
|
* apparently.
|
||||||
|
*
|
||||||
|
* Files are added to gArgv, so to the app, they'll look like command line
|
||||||
|
* arguments. Previously, apps launched from the finder had nothing but
|
||||||
|
* an argv[0].
|
||||||
|
*
|
||||||
|
* This message may be received multiple times to open several docs on launch.
|
||||||
|
*
|
||||||
|
* This message is ignored once the app's mainline has been called.
|
||||||
|
*/
|
||||||
|
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||||
|
{
|
||||||
|
const char *temparg;
|
||||||
|
size_t arglen;
|
||||||
|
char *arg;
|
||||||
|
char **newargv;
|
||||||
|
|
||||||
|
if (!gFinderLaunch) /* MacOS is passing command line args. */
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (gCalledAppMainline) /* app has started, ignore this document. */
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
temparg = [filename UTF8String];
|
||||||
|
arglen = SDL_strlen(temparg) + 1;
|
||||||
|
arg = (char *) SDL_malloc(arglen);
|
||||||
|
if (arg == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2));
|
||||||
|
if (newargv == NULL)
|
||||||
|
{
|
||||||
|
SDL_free(arg);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
gArgv = newargv;
|
||||||
|
|
||||||
|
SDL_strlcpy(arg, temparg, arglen);
|
||||||
|
gArgv[gArgc++] = arg;
|
||||||
|
gArgv[gArgc] = NULL;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Called when the internal event loop has just started running */
|
||||||
|
- (void) applicationDidFinishLaunching: (NSNotification *) note
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
|
||||||
|
/* Set the working directory to the .app's parent directory */
|
||||||
|
[self setupWorkingDirectory:gFinderLaunch];
|
||||||
|
|
||||||
|
#if SDL_USE_NIB_FILE
|
||||||
|
/* Set the main menu to contain the real app name instead of "SDL App" */
|
||||||
|
[self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Hand off to main application code */
|
||||||
|
gCalledAppMainline = TRUE;
|
||||||
|
status = SDL_main (gArgc, gArgv);
|
||||||
|
|
||||||
|
/* We're done, thank you for playing */
|
||||||
|
exit(status);
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@implementation NSString (ReplaceSubString)
|
||||||
|
|
||||||
|
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString
|
||||||
|
{
|
||||||
|
unsigned int bufferSize;
|
||||||
|
unsigned int selfLen = [self length];
|
||||||
|
unsigned int aStringLen = [aString length];
|
||||||
|
unichar *buffer;
|
||||||
|
NSRange localRange;
|
||||||
|
NSString *result;
|
||||||
|
|
||||||
|
bufferSize = selfLen + aStringLen - aRange.length;
|
||||||
|
buffer = (unichar *)NSAllocateMemoryPages(bufferSize*sizeof(unichar));
|
||||||
|
|
||||||
|
/* Get first part into buffer */
|
||||||
|
localRange.location = 0;
|
||||||
|
localRange.length = aRange.location;
|
||||||
|
[self getCharacters:buffer range:localRange];
|
||||||
|
|
||||||
|
/* Get middle part into buffer */
|
||||||
|
localRange.location = 0;
|
||||||
|
localRange.length = aStringLen;
|
||||||
|
[aString getCharacters:(buffer+aRange.location) range:localRange];
|
||||||
|
|
||||||
|
/* Get last part into buffer */
|
||||||
|
localRange.location = aRange.location + aRange.length;
|
||||||
|
localRange.length = selfLen - localRange.location;
|
||||||
|
[self getCharacters:(buffer+aRange.location+aStringLen) range:localRange];
|
||||||
|
|
||||||
|
/* Build output string */
|
||||||
|
result = [NSString stringWithCharacters:buffer length:bufferSize];
|
||||||
|
|
||||||
|
NSDeallocateMemoryPages(buffer, bufferSize);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef main
|
||||||
|
# undef main
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Main entry point to executable - should *not* be SDL_main! */
|
||||||
|
int main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
/* Copy the arguments into a global variable */
|
||||||
|
/* This is passed if we are launched by double-clicking */
|
||||||
|
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
|
||||||
|
gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
|
||||||
|
gArgv[0] = argv[0];
|
||||||
|
gArgv[1] = NULL;
|
||||||
|
gArgc = 1;
|
||||||
|
gFinderLaunch = YES;
|
||||||
|
} else {
|
||||||
|
int i;
|
||||||
|
gArgc = argc;
|
||||||
|
gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
|
||||||
|
for (i = 0; i <= argc; i++)
|
||||||
|
gArgv[i] = argv[i];
|
||||||
|
gFinderLaunch = NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SDL_USE_NIB_FILE
|
||||||
|
[SDLApplication poseAsClass:[NSApplication class]];
|
||||||
|
NSApplicationMain (argc, argv);
|
||||||
|
#else
|
||||||
|
CustomApplicationMain (argc, argv);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
65
Xcode/TemplatesForXcodeTiger/SDL Application/main.c
Normal file
65
Xcode/TemplatesForXcodeTiger/SDL Application/main.c
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
|
||||||
|
/* Simple program: Create a blank window, wait for keypress, quit.
|
||||||
|
|
||||||
|
Please see the SDL documentation for details on using the SDL API:
|
||||||
|
/Developer/Documentation/SDL/docs.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "SDL.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */
|
||||||
|
SDL_Surface *screen;
|
||||||
|
Uint8 video_bpp = 0;
|
||||||
|
Uint32 videoflags = SDL_SWSURFACE;
|
||||||
|
int done;
|
||||||
|
SDL_Event event;
|
||||||
|
|
||||||
|
/* Initialize the SDL library */
|
||||||
|
if ( SDL_Init(initflags) < 0 ) {
|
||||||
|
fprintf(stderr, "Couldn't initialize SDL: %s\n",
|
||||||
|
SDL_GetError());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set 640x480 video mode */
|
||||||
|
screen=SDL_SetVideoMode(640,480, video_bpp, videoflags);
|
||||||
|
if (screen == NULL) {
|
||||||
|
fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
|
||||||
|
video_bpp, SDL_GetError());
|
||||||
|
SDL_Quit();
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
done = 0;
|
||||||
|
while ( !done ) {
|
||||||
|
|
||||||
|
/* Check for events */
|
||||||
|
while ( SDL_PollEvent(&event) ) {
|
||||||
|
switch (event.type) {
|
||||||
|
|
||||||
|
case SDL_MOUSEMOTION:
|
||||||
|
break;
|
||||||
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
break;
|
||||||
|
case SDL_KEYDOWN:
|
||||||
|
/* Any keypress quits the app... */
|
||||||
|
case SDL_QUIT:
|
||||||
|
done = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clean up the SDL library */
|
||||||
|
SDL_Quit();
|
||||||
|
return(0);
|
||||||
|
}
|
Binary file not shown.
19
Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/English.lproj/SDLMain.nib/classes.nib
generated
Normal file
19
Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/English.lproj/SDLMain.nib/classes.nib
generated
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
IBClasses = (
|
||||||
|
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
|
||||||
|
{
|
||||||
|
ACTIONS = {
|
||||||
|
help = id;
|
||||||
|
newGame = id;
|
||||||
|
openGame = id;
|
||||||
|
prefsMenu = id;
|
||||||
|
saveGame = id;
|
||||||
|
saveGameAs = id;
|
||||||
|
};
|
||||||
|
CLASS = SDLMain;
|
||||||
|
LANGUAGE = ObjC;
|
||||||
|
SUPERCLASS = NSObject;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
IBVersion = 1;
|
||||||
|
}
|
21
Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/English.lproj/SDLMain.nib/info.nib
generated
Normal file
21
Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/English.lproj/SDLMain.nib/info.nib
generated
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>IBDocumentLocation</key>
|
||||||
|
<string>62 117 356 240 0 0 1152 848 </string>
|
||||||
|
<key>IBEditorPositions</key>
|
||||||
|
<dict>
|
||||||
|
<key>29</key>
|
||||||
|
<string>62 362 195 44 0 0 1152 848 </string>
|
||||||
|
</dict>
|
||||||
|
<key>IBFramework Version</key>
|
||||||
|
<string>291.0</string>
|
||||||
|
<key>IBOpenObjects</key>
|
||||||
|
<array>
|
||||||
|
<integer>29</integer>
|
||||||
|
</array>
|
||||||
|
<key>IBSystem Version</key>
|
||||||
|
<string>6L60</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
BIN
Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/English.lproj/SDLMain.nib/objects.nib
generated
Normal file
BIN
Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/English.lproj/SDLMain.nib/objects.nib
generated
Normal file
Binary file not shown.
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>English</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>${EXECUTABLE_NAME}</string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string></string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>com.yourcompany.«PROJECTNAMEASXML»</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>${PRODUCT_NAME}</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>NSMainNibFile</key>
|
||||||
|
<string>SDLMain</string>
|
||||||
|
<key>NSPrincipalClass</key>
|
||||||
|
<string>NSApplication</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -0,0 +1,9 @@
|
||||||
|
//
|
||||||
|
// Prefix header for all source files of the 'ÇPROJECTNAMEÈ' target in the 'ÇPROJECTNAMEÈ' project
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "SDL.h"
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
FilesToRename = {
|
||||||
|
"SDLApp_Prefix.pch" = "ÇPROJECTNAMEÈ_Prefix.pch";
|
||||||
|
};
|
||||||
|
FilesToMacroExpand = (
|
||||||
|
"ÇPROJECTNAMEÈ_Prefix.pch",
|
||||||
|
"Info.plist",
|
||||||
|
"English.lproj/InfoPlist.strings",
|
||||||
|
"main.c",
|
||||||
|
);
|
||||||
|
Description = "This project builds an SDL-based application with Cocoa menus.";
|
||||||
|
}
|
|
@ -0,0 +1,309 @@
|
||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 42;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
002F39FA09D0881F00EBEB88 /* SDL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002F39F909D0881F00EBEB88 /* SDL.framework */; };
|
||||||
|
002F3A0009D0884600EBEB88 /* SDL.framework in Copy Frameworks into .app bundle */ = {isa = PBXBuildFile; fileRef = 002F39F909D0881F00EBEB88 /* SDL.framework */; };
|
||||||
|
002F3A3F09D088BA00EBEB88 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 002F3A3E09D088BA00EBEB88 /* main.c */; };
|
||||||
|
002F3AF109D08F1000EBEB88 /* SDLMain.nib in Resources */ = {isa = PBXBuildFile; fileRef = 002F3AEF09D08F1000EBEB88 /* SDLMain.nib */; };
|
||||||
|
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
|
||||||
|
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
|
002F39FD09D0883400EBEB88 /* Copy Frameworks into .app bundle */ = {
|
||||||
|
isa = PBXCopyFilesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
dstPath = "";
|
||||||
|
dstSubfolderSpec = 10;
|
||||||
|
files = (
|
||||||
|
002F3A0009D0884600EBEB88 /* SDL.framework in Copy Frameworks into .app bundle */,
|
||||||
|
);
|
||||||
|
name = "Copy Frameworks into .app bundle";
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
002F39F909D0881F00EBEB88 /* SDL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL.framework; path = /Library/Frameworks/SDL.framework; sourceTree = "<absolute>"; };
|
||||||
|
002F3A3E09D088BA00EBEB88 /* main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = SOURCE_ROOT; };
|
||||||
|
002F3AF009D08F1000EBEB88 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/SDLMain.nib; sourceTree = "<group>"; };
|
||||||
|
089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||||
|
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
|
||||||
|
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
|
||||||
|
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
|
||||||
|
32CA4F630368D1EE00C91783 /* «PROJECTNAME»_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "«PROJECTNAME»_Prefix.pch"; sourceTree = "<group>"; };
|
||||||
|
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
8D1107320486CEB800E47090 /* «PROJECTNAME».app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "«PROJECTNAME».app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
8D11072E0486CEB800E47090 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
002F39FA09D0881F00EBEB88 /* SDL.framework in Frameworks */,
|
||||||
|
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
080E96DDFE201D6D7F000001 /* Classes */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
);
|
||||||
|
name = Classes;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
002F39F909D0881F00EBEB88 /* SDL.framework */,
|
||||||
|
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */,
|
||||||
|
);
|
||||||
|
name = "Linked Frameworks";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
29B97324FDCFA39411CA2CEA /* AppKit.framework */,
|
||||||
|
29B97325FDCFA39411CA2CEA /* Foundation.framework */,
|
||||||
|
);
|
||||||
|
name = "Other Frameworks";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
19C28FACFE9D520D11CA2CBB /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
8D1107320486CEB800E47090 /* «PROJECTNAME».app */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
29B97314FDCFA39411CA2CEA /* «PROJECTNAMEASXML» */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
080E96DDFE201D6D7F000001 /* Classes */,
|
||||||
|
29B97315FDCFA39411CA2CEA /* Other Sources */,
|
||||||
|
29B97317FDCFA39411CA2CEA /* Resources */,
|
||||||
|
29B97323FDCFA39411CA2CEA /* Frameworks */,
|
||||||
|
19C28FACFE9D520D11CA2CBB /* Products */,
|
||||||
|
);
|
||||||
|
name = "«PROJECTNAMEASXML»";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
32CA4F630368D1EE00C91783 /* «PROJECTNAME»_Prefix.pch */,
|
||||||
|
002F3A3E09D088BA00EBEB88 /* main.c */,
|
||||||
|
);
|
||||||
|
name = "Other Sources";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
29B97317FDCFA39411CA2CEA /* Resources */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
8D1107310486CEB800E47090 /* Info.plist */,
|
||||||
|
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
|
||||||
|
002F3AEF09D08F1000EBEB88 /* SDLMain.nib */,
|
||||||
|
);
|
||||||
|
name = Resources;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */,
|
||||||
|
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */,
|
||||||
|
);
|
||||||
|
name = Frameworks;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
8D1107260486CEB800E47090 /* «PROJECTNAME» */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "«PROJECTNAME»" */;
|
||||||
|
buildPhases = (
|
||||||
|
8D1107290486CEB800E47090 /* Resources */,
|
||||||
|
8D11072C0486CEB800E47090 /* Sources */,
|
||||||
|
8D11072E0486CEB800E47090 /* Frameworks */,
|
||||||
|
002F39FD09D0883400EBEB88 /* Copy Frameworks into .app bundle */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
name = "«PROJECTNAME»";
|
||||||
|
productInstallPath = "$(HOME)/Applications";
|
||||||
|
productName = "«PROJECTNAME»";
|
||||||
|
productReference = 8D1107320486CEB800E47090 /* «PROJECTNAME».app */;
|
||||||
|
productType = "com.apple.product-type.application";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "SDLCocoaApp" */;
|
||||||
|
compatibilityVersion = "Xcode 2.4";
|
||||||
|
hasScannedForEncodings = 1;
|
||||||
|
mainGroup = 29B97314FDCFA39411CA2CEA /* «PROJECTNAMEASXML» */;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
8D1107260486CEB800E47090 /* «PROJECTNAME» */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXResourcesBuildPhase section */
|
||||||
|
8D1107290486CEB800E47090 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */,
|
||||||
|
002F3AF109D08F1000EBEB88 /* SDLMain.nib in Resources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
8D11072C0486CEB800E47090 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
002F3A3F09D088BA00EBEB88 /* main.c in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXVariantGroup section */
|
||||||
|
002F3AEF09D08F1000EBEB88 /* SDLMain.nib */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
002F3AF009D08F1000EBEB88 /* English */,
|
||||||
|
);
|
||||||
|
name = SDLMain.nib;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
089C165DFE840E0CC02AAC07 /* English */,
|
||||||
|
);
|
||||||
|
name = InfoPlist.strings;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXVariantGroup section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
C01FCF4B08A954540054247B /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_ENABLE_FIX_AND_CONTINUE = YES;
|
||||||
|
GCC_MODEL_TUNING = G5;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
INFOPLIST_FILE = Info.plist;
|
||||||
|
INSTALL_PATH = "$(HOME)/Applications";
|
||||||
|
PRODUCT_NAME = "«PROJECTNAME»";
|
||||||
|
WRAPPER_EXTENSION = app;
|
||||||
|
ZERO_LINK = YES;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
C01FCF4C08A954540054247B /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ARCHS = (
|
||||||
|
ppc,
|
||||||
|
i386,
|
||||||
|
);
|
||||||
|
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
|
||||||
|
GCC_MODEL_TUNING = G5;
|
||||||
|
INFOPLIST_FILE = Info.plist;
|
||||||
|
INSTALL_PATH = "$(HOME)/Applications";
|
||||||
|
PRODUCT_NAME = "«PROJECTNAME»";
|
||||||
|
WRAPPER_EXTENSION = app;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
C01FCF4F08A954540054247B /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
|
"$(HOME)/Library/Frameworks",
|
||||||
|
/Library/Frameworks,
|
||||||
|
"$(FRAMEWORK_SEARCH_PATHS)",
|
||||||
|
);
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
HEADER_SEARCH_PATHS = (
|
||||||
|
"$(HOME)/Library/Frameworks/SDL.framework/Headers",
|
||||||
|
/Library/Frameworks/SDL.framework/Headers,
|
||||||
|
"$(HEADER_SEARCH_PATHS)",
|
||||||
|
);
|
||||||
|
PREBINDING = NO;
|
||||||
|
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
C01FCF5008A954540054247B /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
|
"$(HOME)/Library/Frameworks",
|
||||||
|
/Library/Frameworks,
|
||||||
|
"$(FRAMEWORK_SEARCH_PATHS)",
|
||||||
|
);
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
HEADER_SEARCH_PATHS = (
|
||||||
|
"$(HOME)/Library/Frameworks/SDL.framework/Headers",
|
||||||
|
/Library/Frameworks/SDL.framework/Headers,
|
||||||
|
"$(HEADER_SEARCH_PATHS)",
|
||||||
|
);
|
||||||
|
PREBINDING = NO;
|
||||||
|
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "«PROJECTNAME»" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
C01FCF4B08A954540054247B /* Debug */,
|
||||||
|
C01FCF4C08A954540054247B /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
C01FCF4E08A954540054247B /* Build configuration list for PBXProject "SDLCocoaApp" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
C01FCF4F08A954540054247B /* Debug */,
|
||||||
|
C01FCF5008A954540054247B /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
};
|
||||||
|
rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
|
||||||
|
}
|
16
Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/SDLMain.h
Normal file
16
Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/SDLMain.h
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
|
||||||
|
Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
|
||||||
|
Non-NIB-Code & other changes: Max Horn <max@quendi.de>
|
||||||
|
|
||||||
|
Feel free to customize this file to suit your needs
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SDLMain_h_
|
||||||
|
#define _SDLMain_h_
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
@interface SDLMain : NSObject
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif /* _SDLMain_h_ */
|
383
Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/SDLMain.m
Normal file
383
Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/SDLMain.m
Normal file
|
@ -0,0 +1,383 @@
|
||||||
|
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
|
||||||
|
Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
|
||||||
|
Non-NIB-Code & other changes: Max Horn <max@quendi.de>
|
||||||
|
|
||||||
|
Feel free to customize this file to suit your needs
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "SDL.h"
|
||||||
|
#include "SDLMain.h"
|
||||||
|
#include <sys/param.h> /* for MAXPATHLEN */
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
|
||||||
|
but the method still is there and works. To avoid warnings, we declare
|
||||||
|
it ourselves here. */
|
||||||
|
@interface NSApplication(SDL_Missing_Methods)
|
||||||
|
- (void)setAppleMenu:(NSMenu *)menu;
|
||||||
|
@end
|
||||||
|
|
||||||
|
/* Use this flag to determine whether we use SDLMain.nib or not */
|
||||||
|
#define SDL_USE_NIB_FILE 0
|
||||||
|
|
||||||
|
/* Use this flag to determine whether we use CPS (docking) or not */
|
||||||
|
#define SDL_USE_CPS 1
|
||||||
|
#ifdef SDL_USE_CPS
|
||||||
|
/* Portions of CPS.h */
|
||||||
|
typedef struct CPSProcessSerNum
|
||||||
|
{
|
||||||
|
UInt32 lo;
|
||||||
|
UInt32 hi;
|
||||||
|
} CPSProcessSerNum;
|
||||||
|
|
||||||
|
extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn);
|
||||||
|
extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
|
||||||
|
extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn);
|
||||||
|
|
||||||
|
#endif /* SDL_USE_CPS */
|
||||||
|
|
||||||
|
static int gArgc;
|
||||||
|
static char **gArgv;
|
||||||
|
static BOOL gFinderLaunch;
|
||||||
|
static BOOL gCalledAppMainline = FALSE;
|
||||||
|
|
||||||
|
static NSString *getApplicationName(void)
|
||||||
|
{
|
||||||
|
const NSDictionary *dict;
|
||||||
|
NSString *appName = 0;
|
||||||
|
|
||||||
|
/* Determine the application name */
|
||||||
|
dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
|
||||||
|
if (dict)
|
||||||
|
appName = [dict objectForKey: @"CFBundleName"];
|
||||||
|
|
||||||
|
if (![appName length])
|
||||||
|
appName = [[NSProcessInfo processInfo] processName];
|
||||||
|
|
||||||
|
return appName;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SDL_USE_NIB_FILE
|
||||||
|
/* A helper category for NSString */
|
||||||
|
@interface NSString (ReplaceSubString)
|
||||||
|
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
|
||||||
|
@end
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@interface SDLApplication : NSApplication
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation SDLApplication
|
||||||
|
/* Invoked from the Quit menu item */
|
||||||
|
- (void)terminate:(id)sender
|
||||||
|
{
|
||||||
|
/* Post a SDL_QUIT event */
|
||||||
|
SDL_Event event;
|
||||||
|
event.type = SDL_QUIT;
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
/* The main class of the application, the application's delegate */
|
||||||
|
@implementation SDLMain
|
||||||
|
|
||||||
|
/* Set the working directory to the .app's parent directory */
|
||||||
|
- (void) setupWorkingDirectory:(BOOL)shouldChdir
|
||||||
|
{
|
||||||
|
if (shouldChdir)
|
||||||
|
{
|
||||||
|
char parentdir[MAXPATHLEN];
|
||||||
|
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||||
|
CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
|
||||||
|
if (CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, MAXPATHLEN)) {
|
||||||
|
chdir(parentdir); /* chdir to the binary app's parent */
|
||||||
|
}
|
||||||
|
CFRelease(url);
|
||||||
|
CFRelease(url2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SDL_USE_NIB_FILE
|
||||||
|
|
||||||
|
/* Fix menu to contain the real app name instead of "SDL App" */
|
||||||
|
- (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName
|
||||||
|
{
|
||||||
|
NSRange aRange;
|
||||||
|
NSEnumerator *enumerator;
|
||||||
|
NSMenuItem *menuItem;
|
||||||
|
|
||||||
|
aRange = [[aMenu title] rangeOfString:@"SDL App"];
|
||||||
|
if (aRange.length != 0)
|
||||||
|
[aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]];
|
||||||
|
|
||||||
|
enumerator = [[aMenu itemArray] objectEnumerator];
|
||||||
|
while ((menuItem = [enumerator nextObject]))
|
||||||
|
{
|
||||||
|
aRange = [[menuItem title] rangeOfString:@"SDL App"];
|
||||||
|
if (aRange.length != 0)
|
||||||
|
[menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]];
|
||||||
|
if ([menuItem hasSubmenu])
|
||||||
|
[self fixMenu:[menuItem submenu] withAppName:appName];
|
||||||
|
}
|
||||||
|
[ aMenu sizeToFit ];
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static void setApplicationMenu(void)
|
||||||
|
{
|
||||||
|
/* warning: this code is very odd */
|
||||||
|
NSMenu *appleMenu;
|
||||||
|
NSMenuItem *menuItem;
|
||||||
|
NSString *title;
|
||||||
|
NSString *appName;
|
||||||
|
|
||||||
|
appName = getApplicationName();
|
||||||
|
appleMenu = [[NSMenu alloc] initWithTitle:@""];
|
||||||
|
|
||||||
|
/* Add menu items */
|
||||||
|
title = [@"About " stringByAppendingString:appName];
|
||||||
|
[appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
|
||||||
|
|
||||||
|
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||||
|
|
||||||
|
title = [@"Hide " stringByAppendingString:appName];
|
||||||
|
[appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
|
||||||
|
|
||||||
|
menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
|
||||||
|
[menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
|
||||||
|
|
||||||
|
[appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
|
||||||
|
|
||||||
|
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||||
|
|
||||||
|
title = [@"Quit " stringByAppendingString:appName];
|
||||||
|
[appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
|
||||||
|
|
||||||
|
|
||||||
|
/* Put menu into the menubar */
|
||||||
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
|
||||||
|
[menuItem setSubmenu:appleMenu];
|
||||||
|
[[NSApp mainMenu] addItem:menuItem];
|
||||||
|
|
||||||
|
/* Tell the application object that this is now the application menu */
|
||||||
|
[NSApp setAppleMenu:appleMenu];
|
||||||
|
|
||||||
|
/* Finally give up our references to the objects */
|
||||||
|
[appleMenu release];
|
||||||
|
[menuItem release];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create a window menu */
|
||||||
|
static void setupWindowMenu(void)
|
||||||
|
{
|
||||||
|
NSMenu *windowMenu;
|
||||||
|
NSMenuItem *windowMenuItem;
|
||||||
|
NSMenuItem *menuItem;
|
||||||
|
|
||||||
|
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
|
||||||
|
|
||||||
|
/* "Minimize" item */
|
||||||
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
|
||||||
|
[windowMenu addItem:menuItem];
|
||||||
|
[menuItem release];
|
||||||
|
|
||||||
|
/* Put menu into the menubar */
|
||||||
|
windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
|
||||||
|
[windowMenuItem setSubmenu:windowMenu];
|
||||||
|
[[NSApp mainMenu] addItem:windowMenuItem];
|
||||||
|
|
||||||
|
/* Tell the application object that this is now the window menu */
|
||||||
|
[NSApp setWindowsMenu:windowMenu];
|
||||||
|
|
||||||
|
/* Finally give up our references to the objects */
|
||||||
|
[windowMenu release];
|
||||||
|
[windowMenuItem release];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Replacement for NSApplicationMain */
|
||||||
|
static void CustomApplicationMain (int argc, char **argv)
|
||||||
|
{
|
||||||
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
SDLMain *sdlMain;
|
||||||
|
|
||||||
|
/* Ensure the application object is initialised */
|
||||||
|
[SDLApplication sharedApplication];
|
||||||
|
|
||||||
|
#ifdef SDL_USE_CPS
|
||||||
|
{
|
||||||
|
CPSProcessSerNum PSN;
|
||||||
|
/* Tell the dock about us */
|
||||||
|
if (!CPSGetCurrentProcess(&PSN))
|
||||||
|
if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
|
||||||
|
if (!CPSSetFrontProcess(&PSN))
|
||||||
|
[SDLApplication sharedApplication];
|
||||||
|
}
|
||||||
|
#endif /* SDL_USE_CPS */
|
||||||
|
|
||||||
|
/* Set up the menubar */
|
||||||
|
[NSApp setMainMenu:[[NSMenu alloc] init]];
|
||||||
|
setApplicationMenu();
|
||||||
|
setupWindowMenu();
|
||||||
|
|
||||||
|
/* Create SDLMain and make it the app delegate */
|
||||||
|
sdlMain = [[SDLMain alloc] init];
|
||||||
|
[NSApp setDelegate:sdlMain];
|
||||||
|
|
||||||
|
/* Start the main event loop */
|
||||||
|
[NSApp run];
|
||||||
|
|
||||||
|
[sdlMain release];
|
||||||
|
[pool release];
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Catch document open requests...this lets us notice files when the app
|
||||||
|
* was launched by double-clicking a document, or when a document was
|
||||||
|
* dragged/dropped on the app's icon. You need to have a
|
||||||
|
* CFBundleDocumentsType section in your Info.plist to get this message,
|
||||||
|
* apparently.
|
||||||
|
*
|
||||||
|
* Files are added to gArgv, so to the app, they'll look like command line
|
||||||
|
* arguments. Previously, apps launched from the finder had nothing but
|
||||||
|
* an argv[0].
|
||||||
|
*
|
||||||
|
* This message may be received multiple times to open several docs on launch.
|
||||||
|
*
|
||||||
|
* This message is ignored once the app's mainline has been called.
|
||||||
|
*/
|
||||||
|
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||||
|
{
|
||||||
|
const char *temparg;
|
||||||
|
size_t arglen;
|
||||||
|
char *arg;
|
||||||
|
char **newargv;
|
||||||
|
|
||||||
|
if (!gFinderLaunch) /* MacOS is passing command line args. */
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (gCalledAppMainline) /* app has started, ignore this document. */
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
temparg = [filename UTF8String];
|
||||||
|
arglen = SDL_strlen(temparg) + 1;
|
||||||
|
arg = (char *) SDL_malloc(arglen);
|
||||||
|
if (arg == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2));
|
||||||
|
if (newargv == NULL)
|
||||||
|
{
|
||||||
|
SDL_free(arg);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
gArgv = newargv;
|
||||||
|
|
||||||
|
SDL_strlcpy(arg, temparg, arglen);
|
||||||
|
gArgv[gArgc++] = arg;
|
||||||
|
gArgv[gArgc] = NULL;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Called when the internal event loop has just started running */
|
||||||
|
- (void) applicationDidFinishLaunching: (NSNotification *) note
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
|
||||||
|
/* Set the working directory to the .app's parent directory */
|
||||||
|
[self setupWorkingDirectory:gFinderLaunch];
|
||||||
|
|
||||||
|
#if SDL_USE_NIB_FILE
|
||||||
|
/* Set the main menu to contain the real app name instead of "SDL App" */
|
||||||
|
[self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Hand off to main application code */
|
||||||
|
gCalledAppMainline = TRUE;
|
||||||
|
status = SDL_main (gArgc, gArgv);
|
||||||
|
|
||||||
|
/* We're done, thank you for playing */
|
||||||
|
exit(status);
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@implementation NSString (ReplaceSubString)
|
||||||
|
|
||||||
|
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString
|
||||||
|
{
|
||||||
|
unsigned int bufferSize;
|
||||||
|
unsigned int selfLen = [self length];
|
||||||
|
unsigned int aStringLen = [aString length];
|
||||||
|
unichar *buffer;
|
||||||
|
NSRange localRange;
|
||||||
|
NSString *result;
|
||||||
|
|
||||||
|
bufferSize = selfLen + aStringLen - aRange.length;
|
||||||
|
buffer = (unichar *)NSAllocateMemoryPages(bufferSize*sizeof(unichar));
|
||||||
|
|
||||||
|
/* Get first part into buffer */
|
||||||
|
localRange.location = 0;
|
||||||
|
localRange.length = aRange.location;
|
||||||
|
[self getCharacters:buffer range:localRange];
|
||||||
|
|
||||||
|
/* Get middle part into buffer */
|
||||||
|
localRange.location = 0;
|
||||||
|
localRange.length = aStringLen;
|
||||||
|
[aString getCharacters:(buffer+aRange.location) range:localRange];
|
||||||
|
|
||||||
|
/* Get last part into buffer */
|
||||||
|
localRange.location = aRange.location + aRange.length;
|
||||||
|
localRange.length = selfLen - localRange.location;
|
||||||
|
[self getCharacters:(buffer+aRange.location+aStringLen) range:localRange];
|
||||||
|
|
||||||
|
/* Build output string */
|
||||||
|
result = [NSString stringWithCharacters:buffer length:bufferSize];
|
||||||
|
|
||||||
|
NSDeallocateMemoryPages(buffer, bufferSize);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef main
|
||||||
|
# undef main
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Main entry point to executable - should *not* be SDL_main! */
|
||||||
|
int main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
/* Copy the arguments into a global variable */
|
||||||
|
/* This is passed if we are launched by double-clicking */
|
||||||
|
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
|
||||||
|
gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
|
||||||
|
gArgv[0] = argv[0];
|
||||||
|
gArgv[1] = NULL;
|
||||||
|
gArgc = 1;
|
||||||
|
gFinderLaunch = YES;
|
||||||
|
} else {
|
||||||
|
int i;
|
||||||
|
gArgc = argc;
|
||||||
|
gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
|
||||||
|
for (i = 0; i <= argc; i++)
|
||||||
|
gArgv[i] = argv[i];
|
||||||
|
gFinderLaunch = NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SDL_USE_NIB_FILE
|
||||||
|
[SDLApplication poseAsClass:[NSApplication class]];
|
||||||
|
NSApplicationMain (argc, argv);
|
||||||
|
#else
|
||||||
|
CustomApplicationMain (argc, argv);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
65
Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/main.c
Normal file
65
Xcode/TemplatesForXcodeTiger/SDL Cocoa Application/main.c
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
|
||||||
|
/* Simple program: Create a blank window, wait for keypress, quit.
|
||||||
|
|
||||||
|
Please see the SDL documentation for details on using the SDL API:
|
||||||
|
/Developer/Documentation/SDL/docs.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "SDL.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
Uint32 initflags = SDL_INIT_VIDEO; /* See documentation for details */
|
||||||
|
SDL_Surface *screen;
|
||||||
|
Uint8 video_bpp = 0;
|
||||||
|
Uint32 videoflags = SDL_SWSURFACE;
|
||||||
|
int done;
|
||||||
|
SDL_Event event;
|
||||||
|
|
||||||
|
/* Initialize the SDL library */
|
||||||
|
if ( SDL_Init(initflags) < 0 ) {
|
||||||
|
fprintf(stderr, "Couldn't initialize SDL: %s\n",
|
||||||
|
SDL_GetError());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set 640x480 video mode */
|
||||||
|
screen=SDL_SetVideoMode(640,480, video_bpp, videoflags);
|
||||||
|
if (screen == NULL) {
|
||||||
|
fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
|
||||||
|
video_bpp, SDL_GetError());
|
||||||
|
SDL_Quit();
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
done = 0;
|
||||||
|
while ( !done ) {
|
||||||
|
|
||||||
|
/* Check for events */
|
||||||
|
while ( SDL_PollEvent(&event) ) {
|
||||||
|
switch (event.type) {
|
||||||
|
|
||||||
|
case SDL_MOUSEMOTION:
|
||||||
|
break;
|
||||||
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
break;
|
||||||
|
case SDL_KEYDOWN:
|
||||||
|
/* Any keypress quits the app... */
|
||||||
|
case SDL_QUIT:
|
||||||
|
done = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clean up the SDL library */
|
||||||
|
SDL_Quit();
|
||||||
|
return(0);
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>English</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>${EXECUTABLE_NAME}</string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string></string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>com.yourcompany.«PROJECTNAMEASXML»</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>${PRODUCT_NAME}</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>NSMainNibFile</key>
|
||||||
|
<string>SDLMain</string>
|
||||||
|
<key>NSPrincipalClass</key>
|
||||||
|
<string>NSApplication</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -0,0 +1,9 @@
|
||||||
|
//
|
||||||
|
// Prefix header for all source files of the 'ÇPROJECTNAMEÈ' target in the 'ÇPROJECTNAMEÈ' project
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "SDL.h"
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
|
@ -0,0 +1,16 @@
|
||||||
|
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
|
||||||
|
Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
|
||||||
|
Non-NIB-Code & other changes: Max Horn <max@quendi.de>
|
||||||
|
|
||||||
|
Feel free to customize this file to suit your needs
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SDLMain_h_
|
||||||
|
#define _SDLMain_h_
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
@interface SDLMain : NSObject
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif /* _SDLMain_h_ */
|
383
Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/SDLMain.m
Normal file
383
Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/SDLMain.m
Normal file
|
@ -0,0 +1,383 @@
|
||||||
|
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
|
||||||
|
Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
|
||||||
|
Non-NIB-Code & other changes: Max Horn <max@quendi.de>
|
||||||
|
|
||||||
|
Feel free to customize this file to suit your needs
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "SDL.h"
|
||||||
|
#include "SDLMain.h"
|
||||||
|
#include <sys/param.h> /* for MAXPATHLEN */
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
|
||||||
|
but the method still is there and works. To avoid warnings, we declare
|
||||||
|
it ourselves here. */
|
||||||
|
@interface NSApplication(SDL_Missing_Methods)
|
||||||
|
- (void)setAppleMenu:(NSMenu *)menu;
|
||||||
|
@end
|
||||||
|
|
||||||
|
/* Use this flag to determine whether we use SDLMain.nib or not */
|
||||||
|
#define SDL_USE_NIB_FILE 0
|
||||||
|
|
||||||
|
/* Use this flag to determine whether we use CPS (docking) or not */
|
||||||
|
#define SDL_USE_CPS 1
|
||||||
|
#ifdef SDL_USE_CPS
|
||||||
|
/* Portions of CPS.h */
|
||||||
|
typedef struct CPSProcessSerNum
|
||||||
|
{
|
||||||
|
UInt32 lo;
|
||||||
|
UInt32 hi;
|
||||||
|
} CPSProcessSerNum;
|
||||||
|
|
||||||
|
extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn);
|
||||||
|
extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
|
||||||
|
extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn);
|
||||||
|
|
||||||
|
#endif /* SDL_USE_CPS */
|
||||||
|
|
||||||
|
static int gArgc;
|
||||||
|
static char **gArgv;
|
||||||
|
static BOOL gFinderLaunch;
|
||||||
|
static BOOL gCalledAppMainline = FALSE;
|
||||||
|
|
||||||
|
static NSString *getApplicationName(void)
|
||||||
|
{
|
||||||
|
const NSDictionary *dict;
|
||||||
|
NSString *appName = 0;
|
||||||
|
|
||||||
|
/* Determine the application name */
|
||||||
|
dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
|
||||||
|
if (dict)
|
||||||
|
appName = [dict objectForKey: @"CFBundleName"];
|
||||||
|
|
||||||
|
if (![appName length])
|
||||||
|
appName = [[NSProcessInfo processInfo] processName];
|
||||||
|
|
||||||
|
return appName;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SDL_USE_NIB_FILE
|
||||||
|
/* A helper category for NSString */
|
||||||
|
@interface NSString (ReplaceSubString)
|
||||||
|
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
|
||||||
|
@end
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@interface SDLApplication : NSApplication
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation SDLApplication
|
||||||
|
/* Invoked from the Quit menu item */
|
||||||
|
- (void)terminate:(id)sender
|
||||||
|
{
|
||||||
|
/* Post a SDL_QUIT event */
|
||||||
|
SDL_Event event;
|
||||||
|
event.type = SDL_QUIT;
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
/* The main class of the application, the application's delegate */
|
||||||
|
@implementation SDLMain
|
||||||
|
|
||||||
|
/* Set the working directory to the .app's parent directory */
|
||||||
|
- (void) setupWorkingDirectory:(BOOL)shouldChdir
|
||||||
|
{
|
||||||
|
if (shouldChdir)
|
||||||
|
{
|
||||||
|
char parentdir[MAXPATHLEN];
|
||||||
|
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||||
|
CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
|
||||||
|
if (CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, MAXPATHLEN)) {
|
||||||
|
chdir(parentdir); /* chdir to the binary app's parent */
|
||||||
|
}
|
||||||
|
CFRelease(url);
|
||||||
|
CFRelease(url2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SDL_USE_NIB_FILE
|
||||||
|
|
||||||
|
/* Fix menu to contain the real app name instead of "SDL App" */
|
||||||
|
- (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName
|
||||||
|
{
|
||||||
|
NSRange aRange;
|
||||||
|
NSEnumerator *enumerator;
|
||||||
|
NSMenuItem *menuItem;
|
||||||
|
|
||||||
|
aRange = [[aMenu title] rangeOfString:@"SDL App"];
|
||||||
|
if (aRange.length != 0)
|
||||||
|
[aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]];
|
||||||
|
|
||||||
|
enumerator = [[aMenu itemArray] objectEnumerator];
|
||||||
|
while ((menuItem = [enumerator nextObject]))
|
||||||
|
{
|
||||||
|
aRange = [[menuItem title] rangeOfString:@"SDL App"];
|
||||||
|
if (aRange.length != 0)
|
||||||
|
[menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]];
|
||||||
|
if ([menuItem hasSubmenu])
|
||||||
|
[self fixMenu:[menuItem submenu] withAppName:appName];
|
||||||
|
}
|
||||||
|
[ aMenu sizeToFit ];
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static void setApplicationMenu(void)
|
||||||
|
{
|
||||||
|
/* warning: this code is very odd */
|
||||||
|
NSMenu *appleMenu;
|
||||||
|
NSMenuItem *menuItem;
|
||||||
|
NSString *title;
|
||||||
|
NSString *appName;
|
||||||
|
|
||||||
|
appName = getApplicationName();
|
||||||
|
appleMenu = [[NSMenu alloc] initWithTitle:@""];
|
||||||
|
|
||||||
|
/* Add menu items */
|
||||||
|
title = [@"About " stringByAppendingString:appName];
|
||||||
|
[appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
|
||||||
|
|
||||||
|
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||||
|
|
||||||
|
title = [@"Hide " stringByAppendingString:appName];
|
||||||
|
[appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
|
||||||
|
|
||||||
|
menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
|
||||||
|
[menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
|
||||||
|
|
||||||
|
[appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
|
||||||
|
|
||||||
|
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||||
|
|
||||||
|
title = [@"Quit " stringByAppendingString:appName];
|
||||||
|
[appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
|
||||||
|
|
||||||
|
|
||||||
|
/* Put menu into the menubar */
|
||||||
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
|
||||||
|
[menuItem setSubmenu:appleMenu];
|
||||||
|
[[NSApp mainMenu] addItem:menuItem];
|
||||||
|
|
||||||
|
/* Tell the application object that this is now the application menu */
|
||||||
|
[NSApp setAppleMenu:appleMenu];
|
||||||
|
|
||||||
|
/* Finally give up our references to the objects */
|
||||||
|
[appleMenu release];
|
||||||
|
[menuItem release];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create a window menu */
|
||||||
|
static void setupWindowMenu(void)
|
||||||
|
{
|
||||||
|
NSMenu *windowMenu;
|
||||||
|
NSMenuItem *windowMenuItem;
|
||||||
|
NSMenuItem *menuItem;
|
||||||
|
|
||||||
|
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
|
||||||
|
|
||||||
|
/* "Minimize" item */
|
||||||
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
|
||||||
|
[windowMenu addItem:menuItem];
|
||||||
|
[menuItem release];
|
||||||
|
|
||||||
|
/* Put menu into the menubar */
|
||||||
|
windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
|
||||||
|
[windowMenuItem setSubmenu:windowMenu];
|
||||||
|
[[NSApp mainMenu] addItem:windowMenuItem];
|
||||||
|
|
||||||
|
/* Tell the application object that this is now the window menu */
|
||||||
|
[NSApp setWindowsMenu:windowMenu];
|
||||||
|
|
||||||
|
/* Finally give up our references to the objects */
|
||||||
|
[windowMenu release];
|
||||||
|
[windowMenuItem release];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Replacement for NSApplicationMain */
|
||||||
|
static void CustomApplicationMain (int argc, char **argv)
|
||||||
|
{
|
||||||
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
SDLMain *sdlMain;
|
||||||
|
|
||||||
|
/* Ensure the application object is initialised */
|
||||||
|
[SDLApplication sharedApplication];
|
||||||
|
|
||||||
|
#ifdef SDL_USE_CPS
|
||||||
|
{
|
||||||
|
CPSProcessSerNum PSN;
|
||||||
|
/* Tell the dock about us */
|
||||||
|
if (!CPSGetCurrentProcess(&PSN))
|
||||||
|
if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
|
||||||
|
if (!CPSSetFrontProcess(&PSN))
|
||||||
|
[SDLApplication sharedApplication];
|
||||||
|
}
|
||||||
|
#endif /* SDL_USE_CPS */
|
||||||
|
|
||||||
|
/* Set up the menubar */
|
||||||
|
[NSApp setMainMenu:[[NSMenu alloc] init]];
|
||||||
|
setApplicationMenu();
|
||||||
|
setupWindowMenu();
|
||||||
|
|
||||||
|
/* Create SDLMain and make it the app delegate */
|
||||||
|
sdlMain = [[SDLMain alloc] init];
|
||||||
|
[NSApp setDelegate:sdlMain];
|
||||||
|
|
||||||
|
/* Start the main event loop */
|
||||||
|
[NSApp run];
|
||||||
|
|
||||||
|
[sdlMain release];
|
||||||
|
[pool release];
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Catch document open requests...this lets us notice files when the app
|
||||||
|
* was launched by double-clicking a document, or when a document was
|
||||||
|
* dragged/dropped on the app's icon. You need to have a
|
||||||
|
* CFBundleDocumentsType section in your Info.plist to get this message,
|
||||||
|
* apparently.
|
||||||
|
*
|
||||||
|
* Files are added to gArgv, so to the app, they'll look like command line
|
||||||
|
* arguments. Previously, apps launched from the finder had nothing but
|
||||||
|
* an argv[0].
|
||||||
|
*
|
||||||
|
* This message may be received multiple times to open several docs on launch.
|
||||||
|
*
|
||||||
|
* This message is ignored once the app's mainline has been called.
|
||||||
|
*/
|
||||||
|
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||||
|
{
|
||||||
|
const char *temparg;
|
||||||
|
size_t arglen;
|
||||||
|
char *arg;
|
||||||
|
char **newargv;
|
||||||
|
|
||||||
|
if (!gFinderLaunch) /* MacOS is passing command line args. */
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (gCalledAppMainline) /* app has started, ignore this document. */
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
temparg = [filename UTF8String];
|
||||||
|
arglen = SDL_strlen(temparg) + 1;
|
||||||
|
arg = (char *) SDL_malloc(arglen);
|
||||||
|
if (arg == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2));
|
||||||
|
if (newargv == NULL)
|
||||||
|
{
|
||||||
|
SDL_free(arg);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
gArgv = newargv;
|
||||||
|
|
||||||
|
SDL_strlcpy(arg, temparg, arglen);
|
||||||
|
gArgv[gArgc++] = arg;
|
||||||
|
gArgv[gArgc] = NULL;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Called when the internal event loop has just started running */
|
||||||
|
- (void) applicationDidFinishLaunching: (NSNotification *) note
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
|
||||||
|
/* Set the working directory to the .app's parent directory */
|
||||||
|
[self setupWorkingDirectory:gFinderLaunch];
|
||||||
|
|
||||||
|
#if SDL_USE_NIB_FILE
|
||||||
|
/* Set the main menu to contain the real app name instead of "SDL App" */
|
||||||
|
[self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Hand off to main application code */
|
||||||
|
gCalledAppMainline = TRUE;
|
||||||
|
status = SDL_main (gArgc, gArgv);
|
||||||
|
|
||||||
|
/* We're done, thank you for playing */
|
||||||
|
exit(status);
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@implementation NSString (ReplaceSubString)
|
||||||
|
|
||||||
|
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString
|
||||||
|
{
|
||||||
|
unsigned int bufferSize;
|
||||||
|
unsigned int selfLen = [self length];
|
||||||
|
unsigned int aStringLen = [aString length];
|
||||||
|
unichar *buffer;
|
||||||
|
NSRange localRange;
|
||||||
|
NSString *result;
|
||||||
|
|
||||||
|
bufferSize = selfLen + aStringLen - aRange.length;
|
||||||
|
buffer = (unichar *)NSAllocateMemoryPages(bufferSize*sizeof(unichar));
|
||||||
|
|
||||||
|
/* Get first part into buffer */
|
||||||
|
localRange.location = 0;
|
||||||
|
localRange.length = aRange.location;
|
||||||
|
[self getCharacters:buffer range:localRange];
|
||||||
|
|
||||||
|
/* Get middle part into buffer */
|
||||||
|
localRange.location = 0;
|
||||||
|
localRange.length = aStringLen;
|
||||||
|
[aString getCharacters:(buffer+aRange.location) range:localRange];
|
||||||
|
|
||||||
|
/* Get last part into buffer */
|
||||||
|
localRange.location = aRange.location + aRange.length;
|
||||||
|
localRange.length = selfLen - localRange.location;
|
||||||
|
[self getCharacters:(buffer+aRange.location+aStringLen) range:localRange];
|
||||||
|
|
||||||
|
/* Build output string */
|
||||||
|
result = [NSString stringWithCharacters:buffer length:bufferSize];
|
||||||
|
|
||||||
|
NSDeallocateMemoryPages(buffer, bufferSize);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef main
|
||||||
|
# undef main
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Main entry point to executable - should *not* be SDL_main! */
|
||||||
|
int main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
/* Copy the arguments into a global variable */
|
||||||
|
/* This is passed if we are launched by double-clicking */
|
||||||
|
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
|
||||||
|
gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
|
||||||
|
gArgv[0] = argv[0];
|
||||||
|
gArgv[1] = NULL;
|
||||||
|
gArgc = 1;
|
||||||
|
gFinderLaunch = YES;
|
||||||
|
} else {
|
||||||
|
int i;
|
||||||
|
gArgc = argc;
|
||||||
|
gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
|
||||||
|
for (i = 0; i <= argc; i++)
|
||||||
|
gArgv[i] = argv[i];
|
||||||
|
gFinderLaunch = NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SDL_USE_NIB_FILE
|
||||||
|
[SDLApplication poseAsClass:[NSApplication class]];
|
||||||
|
NSApplicationMain (argc, argv);
|
||||||
|
#else
|
||||||
|
CustomApplicationMain (argc, argv);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
FilesToRename = {
|
||||||
|
"SDLApp_Prefix.pch" = "ÇPROJECTNAMEÈ_Prefix.pch";
|
||||||
|
};
|
||||||
|
FilesToMacroExpand = (
|
||||||
|
"ÇPROJECTNAMEÈ_Prefix.pch",
|
||||||
|
"Info.plist",
|
||||||
|
"English.lproj/InfoPlist.strings",
|
||||||
|
"main.c",
|
||||||
|
);
|
||||||
|
Description = "This project builds an SDL-based application that uses OpenGL.";
|
||||||
|
}
|
|
@ -0,0 +1,335 @@
|
||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 42;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
002F39FA09D0881F00EBEB88 /* SDL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002F39F909D0881F00EBEB88 /* SDL.framework */; };
|
||||||
|
002F3A0009D0884600EBEB88 /* SDL.framework in Copy Frameworks into .app bundle */ = {isa = PBXBuildFile; fileRef = 002F39F909D0881F00EBEB88 /* SDL.framework */; };
|
||||||
|
002F3A3F09D088BA00EBEB88 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 002F3A3E09D088BA00EBEB88 /* main.c */; };
|
||||||
|
002F3BFA09D0938900EBEB88 /* atlantis.c in Sources */ = {isa = PBXBuildFile; fileRef = 002F3BF409D0938900EBEB88 /* atlantis.c */; };
|
||||||
|
002F3BFC09D0938900EBEB88 /* dolphin.c in Sources */ = {isa = PBXBuildFile; fileRef = 002F3BF609D0938900EBEB88 /* dolphin.c */; };
|
||||||
|
002F3BFD09D0938900EBEB88 /* shark.c in Sources */ = {isa = PBXBuildFile; fileRef = 002F3BF709D0938900EBEB88 /* shark.c */; };
|
||||||
|
002F3BFE09D0938900EBEB88 /* swim.c in Sources */ = {isa = PBXBuildFile; fileRef = 002F3BF809D0938900EBEB88 /* swim.c */; };
|
||||||
|
002F3BFF09D0938900EBEB88 /* whale.c in Sources */ = {isa = PBXBuildFile; fileRef = 002F3BF909D0938900EBEB88 /* whale.c */; };
|
||||||
|
002F3C0109D093BD00EBEB88 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002F3C0009D093BD00EBEB88 /* OpenGL.framework */; };
|
||||||
|
002F3C6109D0951E00EBEB88 /* GLUT.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002F3C6009D0951E00EBEB88 /* GLUT.framework */; };
|
||||||
|
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
|
||||||
|
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
|
002F39FD09D0883400EBEB88 /* Copy Frameworks into .app bundle */ = {
|
||||||
|
isa = PBXCopyFilesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
dstPath = "";
|
||||||
|
dstSubfolderSpec = 10;
|
||||||
|
files = (
|
||||||
|
002F3A0009D0884600EBEB88 /* SDL.framework in Copy Frameworks into .app bundle */,
|
||||||
|
);
|
||||||
|
name = "Copy Frameworks into .app bundle";
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
002F39F909D0881F00EBEB88 /* SDL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL.framework; path = /Library/Frameworks/SDL.framework; sourceTree = "<absolute>"; };
|
||||||
|
002F3A3E09D088BA00EBEB88 /* main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = SOURCE_ROOT; };
|
||||||
|
002F3BF409D0938900EBEB88 /* atlantis.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = atlantis.c; path = atlantis/atlantis.c; sourceTree = SOURCE_ROOT; };
|
||||||
|
002F3BF509D0938900EBEB88 /* atlantis.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = atlantis.h; path = atlantis/atlantis.h; sourceTree = SOURCE_ROOT; };
|
||||||
|
002F3BF609D0938900EBEB88 /* dolphin.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = dolphin.c; path = atlantis/dolphin.c; sourceTree = SOURCE_ROOT; };
|
||||||
|
002F3BF709D0938900EBEB88 /* shark.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = shark.c; path = atlantis/shark.c; sourceTree = SOURCE_ROOT; };
|
||||||
|
002F3BF809D0938900EBEB88 /* swim.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = swim.c; path = atlantis/swim.c; sourceTree = SOURCE_ROOT; };
|
||||||
|
002F3BF909D0938900EBEB88 /* whale.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = whale.c; path = atlantis/whale.c; sourceTree = SOURCE_ROOT; };
|
||||||
|
002F3C0009D093BD00EBEB88 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; };
|
||||||
|
002F3C6009D0951E00EBEB88 /* GLUT.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLUT.framework; path = ../../../../../../../../../../System/Library/Frameworks/GLUT.framework; sourceTree = SOURCE_ROOT; };
|
||||||
|
089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||||
|
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
|
||||||
|
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
|
||||||
|
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
|
||||||
|
32CA4F630368D1EE00C91783 /* «PROJECTNAME»_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "«PROJECTNAME»_Prefix.pch"; sourceTree = "<group>"; };
|
||||||
|
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
8D1107320486CEB800E47090 /* «PROJECTNAME».app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "«PROJECTNAME».app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
8D11072E0486CEB800E47090 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
002F39FA09D0881F00EBEB88 /* SDL.framework in Frameworks */,
|
||||||
|
002F3C6109D0951E00EBEB88 /* GLUT.framework in Frameworks */,
|
||||||
|
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
|
||||||
|
002F3C0109D093BD00EBEB88 /* OpenGL.framework in Frameworks */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
002F3BF309D0937800EBEB88 /* atlantis */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
002F3BF409D0938900EBEB88 /* atlantis.c */,
|
||||||
|
002F3BF509D0938900EBEB88 /* atlantis.h */,
|
||||||
|
002F3BF609D0938900EBEB88 /* dolphin.c */,
|
||||||
|
002F3BF709D0938900EBEB88 /* shark.c */,
|
||||||
|
002F3BF809D0938900EBEB88 /* swim.c */,
|
||||||
|
002F3BF909D0938900EBEB88 /* whale.c */,
|
||||||
|
);
|
||||||
|
name = atlantis;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
080E96DDFE201D6D7F000001 /* Classes */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
);
|
||||||
|
name = Classes;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
002F39F909D0881F00EBEB88 /* SDL.framework */,
|
||||||
|
002F3C6009D0951E00EBEB88 /* GLUT.framework */,
|
||||||
|
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */,
|
||||||
|
002F3C0009D093BD00EBEB88 /* OpenGL.framework */,
|
||||||
|
);
|
||||||
|
name = "Linked Frameworks";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
29B97324FDCFA39411CA2CEA /* AppKit.framework */,
|
||||||
|
29B97325FDCFA39411CA2CEA /* Foundation.framework */,
|
||||||
|
);
|
||||||
|
name = "Other Frameworks";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
19C28FACFE9D520D11CA2CBB /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
8D1107320486CEB800E47090 /* «PROJECTNAME».app */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
29B97314FDCFA39411CA2CEA /* «PROJECTNAMEASXML» */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
080E96DDFE201D6D7F000001 /* Classes */,
|
||||||
|
29B97315FDCFA39411CA2CEA /* Other Sources */,
|
||||||
|
29B97317FDCFA39411CA2CEA /* Resources */,
|
||||||
|
29B97323FDCFA39411CA2CEA /* Frameworks */,
|
||||||
|
19C28FACFE9D520D11CA2CBB /* Products */,
|
||||||
|
);
|
||||||
|
name = "«PROJECTNAMEASXML»";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
002F3BF309D0937800EBEB88 /* atlantis */,
|
||||||
|
32CA4F630368D1EE00C91783 /* «PROJECTNAME»_Prefix.pch */,
|
||||||
|
002F3A3E09D088BA00EBEB88 /* main.c */,
|
||||||
|
);
|
||||||
|
name = "Other Sources";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
29B97317FDCFA39411CA2CEA /* Resources */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
8D1107310486CEB800E47090 /* Info.plist */,
|
||||||
|
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
|
||||||
|
);
|
||||||
|
name = Resources;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */,
|
||||||
|
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */,
|
||||||
|
);
|
||||||
|
name = Frameworks;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
8D1107260486CEB800E47090 /* «PROJECTNAME» */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "«PROJECTNAME»" */;
|
||||||
|
buildPhases = (
|
||||||
|
8D1107290486CEB800E47090 /* Resources */,
|
||||||
|
8D11072C0486CEB800E47090 /* Sources */,
|
||||||
|
8D11072E0486CEB800E47090 /* Frameworks */,
|
||||||
|
002F39FD09D0883400EBEB88 /* Copy Frameworks into .app bundle */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
name = "«PROJECTNAME»";
|
||||||
|
productInstallPath = "$(HOME)/Applications";
|
||||||
|
productName = "«PROJECTNAME»";
|
||||||
|
productReference = 8D1107320486CEB800E47090 /* «PROJECTNAME».app */;
|
||||||
|
productType = "com.apple.product-type.application";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "SDLOpenGLApp" */;
|
||||||
|
compatibilityVersion = "Xcode 2.4";
|
||||||
|
hasScannedForEncodings = 1;
|
||||||
|
mainGroup = 29B97314FDCFA39411CA2CEA /* «PROJECTNAMEASXML» */;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
8D1107260486CEB800E47090 /* «PROJECTNAME» */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXResourcesBuildPhase section */
|
||||||
|
8D1107290486CEB800E47090 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
8D11072C0486CEB800E47090 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
002F3A3F09D088BA00EBEB88 /* main.c in Sources */,
|
||||||
|
002F3BFA09D0938900EBEB88 /* atlantis.c in Sources */,
|
||||||
|
002F3BFC09D0938900EBEB88 /* dolphin.c in Sources */,
|
||||||
|
002F3BFD09D0938900EBEB88 /* shark.c in Sources */,
|
||||||
|
002F3BFE09D0938900EBEB88 /* swim.c in Sources */,
|
||||||
|
002F3BFF09D0938900EBEB88 /* whale.c in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXVariantGroup section */
|
||||||
|
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
089C165DFE840E0CC02AAC07 /* English */,
|
||||||
|
);
|
||||||
|
name = InfoPlist.strings;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXVariantGroup section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
C01FCF4B08A954540054247B /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_ENABLE_FIX_AND_CONTINUE = YES;
|
||||||
|
GCC_MODEL_TUNING = G5;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
INFOPLIST_FILE = Info.plist;
|
||||||
|
INSTALL_PATH = "$(HOME)/Applications";
|
||||||
|
PRODUCT_NAME = "«PROJECTNAME»";
|
||||||
|
WRAPPER_EXTENSION = app;
|
||||||
|
ZERO_LINK = YES;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
C01FCF4C08A954540054247B /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ARCHS = (
|
||||||
|
ppc,
|
||||||
|
i386,
|
||||||
|
);
|
||||||
|
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
|
||||||
|
GCC_MODEL_TUNING = G5;
|
||||||
|
INFOPLIST_FILE = Info.plist;
|
||||||
|
INSTALL_PATH = "$(HOME)/Applications";
|
||||||
|
PRODUCT_NAME = "«PROJECTNAME»";
|
||||||
|
WRAPPER_EXTENSION = app;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
C01FCF4F08A954540054247B /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
|
"$(HOME)/Library/Frameworks",
|
||||||
|
/Library/Frameworks,
|
||||||
|
"$(FRAMEWORK_SEARCH_PATHS)",
|
||||||
|
);
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
HEADER_SEARCH_PATHS = (
|
||||||
|
"$(HOME)/Library/Frameworks/SDL.framework/Headers",
|
||||||
|
/Library/Frameworks/SDL.framework/Headers,
|
||||||
|
"$(HEADER_SEARCH_PATHS)",
|
||||||
|
);
|
||||||
|
PREBINDING = NO;
|
||||||
|
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
C01FCF5008A954540054247B /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
|
"$(HOME)/Library/Frameworks",
|
||||||
|
/Library/Frameworks,
|
||||||
|
"$(FRAMEWORK_SEARCH_PATHS)",
|
||||||
|
);
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
HEADER_SEARCH_PATHS = (
|
||||||
|
"$(HOME)/Library/Frameworks/SDL.framework/Headers",
|
||||||
|
/Library/Frameworks/SDL.framework/Headers,
|
||||||
|
"$(HEADER_SEARCH_PATHS)",
|
||||||
|
);
|
||||||
|
PREBINDING = NO;
|
||||||
|
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "«PROJECTNAME»" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
C01FCF4B08A954540054247B /* Debug */,
|
||||||
|
C01FCF4C08A954540054247B /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
C01FCF4E08A954540054247B /* Build configuration list for PBXProject "SDLOpenGLApp" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
C01FCF4F08A954540054247B /* Debug */,
|
||||||
|
C01FCF5008A954540054247B /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
};
|
||||||
|
rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
|
||||||
|
}
|
|
@ -0,0 +1,459 @@
|
||||||
|
|
||||||
|
/* Copyright (c) Mark J. Kilgard, 1994. */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (c) Copyright 1993, 1994, Silicon Graphics, Inc.
|
||||||
|
* ALL RIGHTS RESERVED
|
||||||
|
* Permission to use, copy, modify, and distribute this software for
|
||||||
|
* any purpose and without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice appear in all copies and that both the copyright notice
|
||||||
|
* and this permission notice appear in supporting documentation, and that
|
||||||
|
* the name of Silicon Graphics, Inc. not be used in advertising
|
||||||
|
* or publicity pertaining to distribution of the software without specific,
|
||||||
|
* written prior permission.
|
||||||
|
*
|
||||||
|
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
||||||
|
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
||||||
|
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
||||||
|
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
|
||||||
|
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
|
||||||
|
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
|
||||||
|
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
|
||||||
|
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
||||||
|
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*
|
||||||
|
* US Government Users Restricted Rights
|
||||||
|
* Use, duplication, or disclosure by the Government is subject to
|
||||||
|
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
||||||
|
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
||||||
|
* clause at DFARS 252.227-7013 and/or in similar or successor
|
||||||
|
* clauses in the FAR or the DOD or NASA FAR Supplement.
|
||||||
|
* Unpublished-- rights reserved under the copyright laws of the
|
||||||
|
* United States. Contractor/manufacturer is Silicon Graphics,
|
||||||
|
* Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
|
||||||
|
*
|
||||||
|
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <GLUT/glut.h>
|
||||||
|
#include "atlantis.h"
|
||||||
|
|
||||||
|
fishRec sharks[NUM_SHARKS];
|
||||||
|
fishRec momWhale;
|
||||||
|
fishRec babyWhale;
|
||||||
|
fishRec dolph;
|
||||||
|
|
||||||
|
GLboolean Timing = GL_TRUE;
|
||||||
|
|
||||||
|
int w_win = 640;
|
||||||
|
int h_win = 480;
|
||||||
|
GLint count = 0;
|
||||||
|
GLenum StrMode = GL_VENDOR;
|
||||||
|
|
||||||
|
GLboolean moving;
|
||||||
|
|
||||||
|
static double mtime(void)
|
||||||
|
{
|
||||||
|
struct timeval tk_time;
|
||||||
|
struct timezone tz;
|
||||||
|
|
||||||
|
gettimeofday(&tk_time, &tz);
|
||||||
|
|
||||||
|
return 4294.967296 * tk_time.tv_sec + 0.000001 * tk_time.tv_usec;
|
||||||
|
}
|
||||||
|
|
||||||
|
static double filter(double in, double *save)
|
||||||
|
{
|
||||||
|
static double k1 = 0.9;
|
||||||
|
static double k2 = 0.05;
|
||||||
|
|
||||||
|
save[3] = in;
|
||||||
|
save[1] = save[0]*k1 + k2*(save[3] + save[2]);
|
||||||
|
|
||||||
|
save[0]=save[1];
|
||||||
|
save[2]=save[3];
|
||||||
|
|
||||||
|
return(save[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawStr(const char *str)
|
||||||
|
{
|
||||||
|
GLint i = 0;
|
||||||
|
|
||||||
|
if(!str) return;
|
||||||
|
|
||||||
|
while(str[i])
|
||||||
|
{
|
||||||
|
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
InitFishs(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_SHARKS; i++) {
|
||||||
|
sharks[i].x = 70000.0 + rand() % 6000;
|
||||||
|
sharks[i].y = rand() % 6000;
|
||||||
|
sharks[i].z = rand() % 6000;
|
||||||
|
sharks[i].psi = rand() % 360 - 180.0;
|
||||||
|
sharks[i].v = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
dolph.x = 30000.0;
|
||||||
|
dolph.y = 0.0;
|
||||||
|
dolph.z = 6000.0;
|
||||||
|
dolph.psi = 90.0;
|
||||||
|
dolph.theta = 0.0;
|
||||||
|
dolph.v = 3.0;
|
||||||
|
|
||||||
|
momWhale.x = 70000.0;
|
||||||
|
momWhale.y = 0.0;
|
||||||
|
momWhale.z = 0.0;
|
||||||
|
momWhale.psi = 90.0;
|
||||||
|
momWhale.theta = 0.0;
|
||||||
|
momWhale.v = 3.0;
|
||||||
|
|
||||||
|
babyWhale.x = 60000.0;
|
||||||
|
babyWhale.y = -2000.0;
|
||||||
|
babyWhale.z = -2000.0;
|
||||||
|
babyWhale.psi = 90.0;
|
||||||
|
babyWhale.theta = 0.0;
|
||||||
|
babyWhale.v = 3.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Atlantis_Init(void)
|
||||||
|
{
|
||||||
|
static float ambient[] = {0.2, 0.2, 0.2, 1.0};
|
||||||
|
static float diffuse[] = {1.0, 1.0, 1.0, 1.0};
|
||||||
|
static float position[] = {0.0, 1.0, 0.0, 0.0};
|
||||||
|
static float mat_shininess[] = {90.0};
|
||||||
|
static float mat_specular[] = {0.8, 0.8, 0.8, 1.0};
|
||||||
|
static float mat_diffuse[] = {0.46, 0.66, 0.795, 1.0};
|
||||||
|
static float mat_ambient[] = {0.3, 0.4, 0.5, 1.0};
|
||||||
|
static float lmodel_ambient[] = {0.4, 0.4, 0.4, 1.0};
|
||||||
|
static float lmodel_localviewer[] = {0.0};
|
||||||
|
//GLfloat map1[4] = {0.0, 0.0, 0.0, 0.0};
|
||||||
|
//GLfloat map2[4] = {0.0, 0.0, 0.0, 0.0};
|
||||||
|
static float fog_color[] = {0.0, 0.5, 0.9, 1.0};
|
||||||
|
|
||||||
|
glFrontFace(GL_CCW);
|
||||||
|
|
||||||
|
glDepthFunc(GL_LESS);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
|
||||||
|
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
|
||||||
|
glLightfv(GL_LIGHT0, GL_POSITION, position);
|
||||||
|
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
|
||||||
|
glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_localviewer);
|
||||||
|
glEnable(GL_LIGHTING);
|
||||||
|
glEnable(GL_LIGHT0);
|
||||||
|
|
||||||
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
|
||||||
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
|
||||||
|
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse);
|
||||||
|
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);
|
||||||
|
|
||||||
|
InitFishs();
|
||||||
|
|
||||||
|
glEnable(GL_FOG);
|
||||||
|
glFogi(GL_FOG_MODE, GL_EXP);
|
||||||
|
glFogf(GL_FOG_DENSITY, 0.0000025);
|
||||||
|
glFogfv(GL_FOG_COLOR, fog_color);
|
||||||
|
|
||||||
|
glClearColor(0.0, 0.5, 0.9, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Atlantis_Reshape(int width, int height)
|
||||||
|
{
|
||||||
|
w_win = width;
|
||||||
|
h_win = height;
|
||||||
|
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
gluPerspective(60.0, (GLfloat) width / (GLfloat) height, 20000.0, 300000.0);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Atlantis_Animate(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_SHARKS; i++) {
|
||||||
|
SharkPilot(&sharks[i]);
|
||||||
|
SharkMiss(i);
|
||||||
|
}
|
||||||
|
WhalePilot(&dolph);
|
||||||
|
dolph.phi++;
|
||||||
|
//glutPostRedisplay();
|
||||||
|
WhalePilot(&momWhale);
|
||||||
|
momWhale.phi++;
|
||||||
|
WhalePilot(&babyWhale);
|
||||||
|
babyWhale.phi++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Atlantis_Key(unsigned char key, int x, int y)
|
||||||
|
{
|
||||||
|
switch (key) {
|
||||||
|
case 't':
|
||||||
|
Timing = !Timing;
|
||||||
|
break;
|
||||||
|
case ' ':
|
||||||
|
switch(StrMode)
|
||||||
|
{
|
||||||
|
case GL_EXTENSIONS:
|
||||||
|
StrMode = GL_VENDOR;
|
||||||
|
break;
|
||||||
|
case GL_VENDOR:
|
||||||
|
StrMode = GL_RENDERER;
|
||||||
|
break;
|
||||||
|
case GL_RENDERER:
|
||||||
|
StrMode = GL_VERSION;
|
||||||
|
break;
|
||||||
|
case GL_VERSION:
|
||||||
|
StrMode = GL_EXTENSIONS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 27: /* Esc will quit */
|
||||||
|
exit(1);
|
||||||
|
break;
|
||||||
|
case 's': /* "s" start animation */
|
||||||
|
moving = GL_TRUE;
|
||||||
|
//glutIdleFunc(Animate);
|
||||||
|
break;
|
||||||
|
case 'a': /* "a" stop animation */
|
||||||
|
moving = GL_FALSE;
|
||||||
|
//glutIdleFunc(NULL);
|
||||||
|
break;
|
||||||
|
case '.': /* "." will advance frame */
|
||||||
|
if (!moving) {
|
||||||
|
Atlantis_Animate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
void Display(void)
|
||||||
|
{
|
||||||
|
static float P123[3] = {-448.94, -203.14, 9499.60};
|
||||||
|
static float P124[3] = {-442.64, -185.20, 9528.07};
|
||||||
|
static float P125[3] = {-441.07, -148.05, 9528.07};
|
||||||
|
static float P126[3] = {-443.43, -128.84, 9499.60};
|
||||||
|
static float P127[3] = {-456.87, -146.78, 9466.67};
|
||||||
|
static float P128[3] = {-453.68, -183.93, 9466.67};
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
FishTransform(&dolph);
|
||||||
|
DrawDolphin(&dolph);
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
glutSwapBuffers();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
Atlantis_Display(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
static double th[4] = {0.0, 0.0, 0.0, 0.0};
|
||||||
|
static double t1 = 0.0, t2 = 0.0, t;
|
||||||
|
char num_str[128];
|
||||||
|
|
||||||
|
t1 = t2;
|
||||||
|
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_SHARKS; i++) {
|
||||||
|
glPushMatrix();
|
||||||
|
FishTransform(&sharks[i]);
|
||||||
|
DrawShark(&sharks[i]);
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
FishTransform(&dolph);
|
||||||
|
DrawDolphin(&dolph);
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
FishTransform(&momWhale);
|
||||||
|
DrawWhale(&momWhale);
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
FishTransform(&babyWhale);
|
||||||
|
glScalef(0.45, 0.45, 0.3);
|
||||||
|
DrawWhale(&babyWhale);
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
if(Timing)
|
||||||
|
{
|
||||||
|
t2 = mtime();
|
||||||
|
t = t2 - t1;
|
||||||
|
if(t > 0.0001) t = 1.0 / t;
|
||||||
|
|
||||||
|
glDisable(GL_LIGHTING);
|
||||||
|
//glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
glColor3f(1.0, 0.0, 0.0);
|
||||||
|
|
||||||
|
glMatrixMode (GL_PROJECTION);
|
||||||
|
glPushMatrix();
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(0, w_win, 0, h_win, -10.0, 10.0);
|
||||||
|
|
||||||
|
glRasterPos2f(5.0, 5.0);
|
||||||
|
|
||||||
|
switch(StrMode)
|
||||||
|
{
|
||||||
|
case GL_VENDOR:
|
||||||
|
sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th), w_win, h_win);
|
||||||
|
DrawStr(num_str);
|
||||||
|
DrawStr(glGetString(GL_VENDOR));
|
||||||
|
break;
|
||||||
|
case GL_RENDERER:
|
||||||
|
sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th), w_win, h_win);
|
||||||
|
DrawStr(num_str);
|
||||||
|
DrawStr(glGetString(GL_RENDERER));
|
||||||
|
break;
|
||||||
|
case GL_VERSION:
|
||||||
|
sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th), w_win, h_win);
|
||||||
|
DrawStr(num_str);
|
||||||
|
DrawStr(glGetString(GL_VERSION));
|
||||||
|
break;
|
||||||
|
case GL_EXTENSIONS:
|
||||||
|
sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th), w_win, h_win);
|
||||||
|
DrawStr(num_str);
|
||||||
|
DrawStr(glGetString(GL_EXTENSIONS));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
|
glEnable(GL_LIGHTING);
|
||||||
|
//glEnable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
count++;
|
||||||
|
|
||||||
|
glutSwapBuffers();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void
|
||||||
|
Visible(int state)
|
||||||
|
{
|
||||||
|
if (state == GLUT_VISIBLE) {
|
||||||
|
if (moving)
|
||||||
|
glutIdleFunc(Animate);
|
||||||
|
} else {
|
||||||
|
if (moving)
|
||||||
|
glutIdleFunc(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
timingSelect(int value)
|
||||||
|
{
|
||||||
|
switch(value)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
StrMode = GL_VENDOR;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
StrMode = GL_RENDERER;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
StrMode = GL_VERSION;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
StrMode = GL_EXTENSIONS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
menuSelect(int value)
|
||||||
|
{
|
||||||
|
switch (value) {
|
||||||
|
case 1:
|
||||||
|
moving = GL_TRUE;
|
||||||
|
glutIdleFunc(Animate);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
moving = GL_FALSE;
|
||||||
|
glutIdleFunc(NULL);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
exit(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
GLboolean fullscreen = GL_FALSE;
|
||||||
|
GLint time_menu;
|
||||||
|
|
||||||
|
srand(0);
|
||||||
|
|
||||||
|
glutInit(&argc, argv);
|
||||||
|
if (argc > 1 && !strcmp(argv[1], "-w"))
|
||||||
|
fullscreen = GL_FALSE;
|
||||||
|
|
||||||
|
//glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
|
glutInitDisplayString("rgba double depth=24");
|
||||||
|
if (fullscreen) {
|
||||||
|
glutGameModeString("1024x768:32");
|
||||||
|
glutEnterGameMode();
|
||||||
|
} else {
|
||||||
|
glutInitWindowSize(320, 240);
|
||||||
|
glutCreateWindow("Atlantis Timing");
|
||||||
|
}
|
||||||
|
Init();
|
||||||
|
glutDisplayFunc(Display);
|
||||||
|
glutReshapeFunc(Reshape);
|
||||||
|
glutKeyboardFunc(Key);
|
||||||
|
moving = GL_TRUE;
|
||||||
|
glutIdleFunc(Animate);
|
||||||
|
glutVisibilityFunc(Visible);
|
||||||
|
|
||||||
|
time_menu = glutCreateMenu(timingSelect);
|
||||||
|
glutAddMenuEntry("GL_VENDOR", 1);
|
||||||
|
glutAddMenuEntry("GL_RENDERER", 2);
|
||||||
|
glutAddMenuEntry("GL_VERSION", 3);
|
||||||
|
glutAddMenuEntry("GL_EXTENSIONS", 4);
|
||||||
|
|
||||||
|
glutCreateMenu(menuSelect);
|
||||||
|
glutAddMenuEntry("Start motion", 1);
|
||||||
|
glutAddMenuEntry("Stop motion", 2);
|
||||||
|
glutAddSubMenu("Timing Mode", time_menu);
|
||||||
|
glutAddMenuEntry("Quit", 4);
|
||||||
|
|
||||||
|
//glutAttachMenu(GLUT_RIGHT_BUTTON);
|
||||||
|
glutAttachMenu(GLUT_RIGHT_BUTTON);
|
||||||
|
glutMainLoop();
|
||||||
|
return 0; // ANSI C requires main to return int.
|
||||||
|
}
|
||||||
|
*/
|
|
@ -0,0 +1,65 @@
|
||||||
|
/**
|
||||||
|
* (c) Copyright 1993, 1994, Silicon Graphics, Inc.
|
||||||
|
* ALL RIGHTS RESERVED
|
||||||
|
* Permission to use, copy, modify, and distribute this software for
|
||||||
|
* any purpose and without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice appear in all copies and that both the copyright notice
|
||||||
|
* and this permission notice appear in supporting documentation, and that
|
||||||
|
* the name of Silicon Graphics, Inc. not be used in advertising
|
||||||
|
* or publicity pertaining to distribution of the software without specific,
|
||||||
|
* written prior permission.
|
||||||
|
*
|
||||||
|
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
||||||
|
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
||||||
|
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
||||||
|
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
|
||||||
|
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
|
||||||
|
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
|
||||||
|
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
|
||||||
|
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
||||||
|
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*
|
||||||
|
* US Government Users Restricted Rights
|
||||||
|
* Use, duplication, or disclosure by the Government is subject to
|
||||||
|
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
||||||
|
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
||||||
|
* clause at DFARS 252.227-7013 and/or in similar or successor
|
||||||
|
* clauses in the FAR or the DOD or NASA FAR Supplement.
|
||||||
|
* Unpublished-- rights reserved under the copyright laws of the
|
||||||
|
* United States. Contractor/manufacturer is Silicon Graphics,
|
||||||
|
* Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
|
||||||
|
*
|
||||||
|
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
||||||
|
*/
|
||||||
|
#define RAD 57.295
|
||||||
|
#define RRAD 0.01745
|
||||||
|
|
||||||
|
#define NUM_SHARKS 4
|
||||||
|
#define SHARKSIZE 6000
|
||||||
|
#define SHARKSPEED 100.0
|
||||||
|
|
||||||
|
#define WHALESPEED 250.0
|
||||||
|
|
||||||
|
typedef struct _fishRec {
|
||||||
|
float x, y, z, phi, theta, psi, v;
|
||||||
|
float xt, yt, zt;
|
||||||
|
float htail, vtail;
|
||||||
|
float dtheta;
|
||||||
|
int spurt, attack;
|
||||||
|
} fishRec;
|
||||||
|
|
||||||
|
extern fishRec sharks[NUM_SHARKS];
|
||||||
|
extern fishRec momWhale;
|
||||||
|
extern fishRec babyWhale;
|
||||||
|
extern fishRec dolph;
|
||||||
|
|
||||||
|
extern void FishTransform(fishRec *);
|
||||||
|
extern void WhalePilot(fishRec *);
|
||||||
|
extern void SharkPilot(fishRec *);
|
||||||
|
extern void SharkMiss(int);
|
||||||
|
extern void DrawWhale(fishRec *);
|
||||||
|
extern void DrawShark(fishRec *);
|
||||||
|
extern void DrawDolphin(fishRec *);
|
File diff suppressed because it is too large
Load diff
1308
Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/atlantis/shark.c
Normal file
1308
Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/atlantis/shark.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,188 @@
|
||||||
|
/**
|
||||||
|
* (c) Copyright 1993, 1994, Silicon Graphics, Inc.
|
||||||
|
* ALL RIGHTS RESERVED
|
||||||
|
* Permission to use, copy, modify, and distribute this software for
|
||||||
|
* any purpose and without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice appear in all copies and that both the copyright notice
|
||||||
|
* and this permission notice appear in supporting documentation, and that
|
||||||
|
* the name of Silicon Graphics, Inc. not be used in advertising
|
||||||
|
* or publicity pertaining to distribution of the software without specific,
|
||||||
|
* written prior permission.
|
||||||
|
*
|
||||||
|
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
||||||
|
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
||||||
|
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
||||||
|
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
|
||||||
|
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
|
||||||
|
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
|
||||||
|
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
|
||||||
|
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
||||||
|
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*
|
||||||
|
* US Government Users Restricted Rights
|
||||||
|
* Use, duplication, or disclosure by the Government is subject to
|
||||||
|
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
||||||
|
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
||||||
|
* clause at DFARS 252.227-7013 and/or in similar or successor
|
||||||
|
* clauses in the FAR or the DOD or NASA FAR Supplement.
|
||||||
|
* Unpublished-- rights reserved under the copyright laws of the
|
||||||
|
* United States. Contractor/manufacturer is Silicon Graphics,
|
||||||
|
* Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
|
||||||
|
*
|
||||||
|
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
||||||
|
*/
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdlib.h> /* For rand(). */
|
||||||
|
#include <GLUT/glut.h>
|
||||||
|
#include "atlantis.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
FishTransform(fishRec * fish)
|
||||||
|
{
|
||||||
|
|
||||||
|
glTranslatef(fish->y, fish->z, -fish->x);
|
||||||
|
glRotatef(-fish->psi, 0.0, 1.0, 0.0);
|
||||||
|
glRotatef(fish->theta, 1.0, 0.0, 0.0);
|
||||||
|
glRotatef(-fish->phi, 0.0, 0.0, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
WhalePilot(fishRec * fish)
|
||||||
|
{
|
||||||
|
|
||||||
|
fish->phi = -20.0;
|
||||||
|
fish->theta = 0.0;
|
||||||
|
fish->psi -= 0.5;
|
||||||
|
|
||||||
|
fish->x += WHALESPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
|
||||||
|
fish->y += WHALESPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
|
||||||
|
fish->z += WHALESPEED * fish->v * sin(fish->theta / RAD);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SharkPilot(fishRec * fish)
|
||||||
|
{
|
||||||
|
static int sign = 1;
|
||||||
|
float X, Y, Z, tpsi, ttheta, thetal;
|
||||||
|
|
||||||
|
fish->xt = 60000.0;
|
||||||
|
fish->yt = 0.0;
|
||||||
|
fish->zt = 0.0;
|
||||||
|
|
||||||
|
X = fish->xt - fish->x;
|
||||||
|
Y = fish->yt - fish->y;
|
||||||
|
Z = fish->zt - fish->z;
|
||||||
|
|
||||||
|
thetal = fish->theta;
|
||||||
|
|
||||||
|
ttheta = RAD * atan(Z / (sqrt(X * X + Y * Y)));
|
||||||
|
|
||||||
|
if (ttheta > fish->theta + 0.25) {
|
||||||
|
fish->theta += 0.5;
|
||||||
|
} else if (ttheta < fish->theta - 0.25) {
|
||||||
|
fish->theta -= 0.5;
|
||||||
|
}
|
||||||
|
if (fish->theta > 90.0) {
|
||||||
|
fish->theta = 90.0;
|
||||||
|
}
|
||||||
|
if (fish->theta < -90.0) {
|
||||||
|
fish->theta = -90.0;
|
||||||
|
}
|
||||||
|
fish->dtheta = fish->theta - thetal;
|
||||||
|
|
||||||
|
tpsi = RAD * atan2(Y, X);
|
||||||
|
|
||||||
|
fish->attack = 0;
|
||||||
|
|
||||||
|
if (fabs(tpsi - fish->psi) < 10.0) {
|
||||||
|
fish->attack = 1;
|
||||||
|
} else if (fabs(tpsi - fish->psi) < 45.0) {
|
||||||
|
if (fish->psi > tpsi) {
|
||||||
|
fish->psi -= 0.5;
|
||||||
|
if (fish->psi < -180.0) {
|
||||||
|
fish->psi += 360.0;
|
||||||
|
}
|
||||||
|
} else if (fish->psi < tpsi) {
|
||||||
|
fish->psi += 0.5;
|
||||||
|
if (fish->psi > 180.0) {
|
||||||
|
fish->psi -= 360.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (rand() % 100 > 98) {
|
||||||
|
sign = 1 - sign;
|
||||||
|
}
|
||||||
|
fish->psi += sign;
|
||||||
|
if (fish->psi > 180.0) {
|
||||||
|
fish->psi -= 360.0;
|
||||||
|
}
|
||||||
|
if (fish->psi < -180.0) {
|
||||||
|
fish->psi += 360.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fish->attack) {
|
||||||
|
if (fish->v < 1.1) {
|
||||||
|
fish->spurt = 1;
|
||||||
|
}
|
||||||
|
if (fish->spurt) {
|
||||||
|
fish->v += 0.2;
|
||||||
|
}
|
||||||
|
if (fish->v > 5.0) {
|
||||||
|
fish->spurt = 0;
|
||||||
|
}
|
||||||
|
if ((fish->v > 1.0) && (!fish->spurt)) {
|
||||||
|
fish->v -= 0.2;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!(rand() % 400) && (!fish->spurt)) {
|
||||||
|
fish->spurt = 1;
|
||||||
|
}
|
||||||
|
if (fish->spurt) {
|
||||||
|
fish->v += 0.05;
|
||||||
|
}
|
||||||
|
if (fish->v > 3.0) {
|
||||||
|
fish->spurt = 0;
|
||||||
|
}
|
||||||
|
if ((fish->v > 1.0) && (!fish->spurt)) {
|
||||||
|
fish->v -= 0.05;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fish->x += SHARKSPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
|
||||||
|
fish->y += SHARKSPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
|
||||||
|
fish->z += SHARKSPEED * fish->v * sin(fish->theta / RAD);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SharkMiss(int i)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
float avoid, thetal;
|
||||||
|
float X, Y, Z, R;
|
||||||
|
|
||||||
|
for (j = 0; j < NUM_SHARKS; j++) {
|
||||||
|
if (j != i) {
|
||||||
|
X = sharks[j].x - sharks[i].x;
|
||||||
|
Y = sharks[j].y - sharks[i].y;
|
||||||
|
Z = sharks[j].z - sharks[i].z;
|
||||||
|
|
||||||
|
R = sqrt(X * X + Y * Y + Z * Z);
|
||||||
|
|
||||||
|
avoid = 1.0;
|
||||||
|
thetal = sharks[i].theta;
|
||||||
|
|
||||||
|
if (R < SHARKSIZE) {
|
||||||
|
if (Z > 0.0) {
|
||||||
|
sharks[i].theta -= avoid;
|
||||||
|
} else {
|
||||||
|
sharks[i].theta += avoid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sharks[i].dtheta += (sharks[i].theta - thetal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1798
Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/atlantis/whale.c
Normal file
1798
Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/atlantis/whale.c
Normal file
File diff suppressed because it is too large
Load diff
179
Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/main.c
Normal file
179
Xcode/TemplatesForXcodeTiger/SDL OpenGL Application/main.c
Normal file
|
@ -0,0 +1,179 @@
|
||||||
|
|
||||||
|
/* Simple program: Create a blank window, wait for keypress, quit.
|
||||||
|
|
||||||
|
Please see the SDL documentation for details on using the SDL API:
|
||||||
|
/Developer/Documentation/SDL/docs.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "SDL.h"
|
||||||
|
|
||||||
|
extern void Atlantis_Init ();
|
||||||
|
extern void Atlantis_Reshape (int w, int h);
|
||||||
|
extern void Atlantis_Animate ();
|
||||||
|
extern void Atlantis_Display ();
|
||||||
|
|
||||||
|
static SDL_Surface *gScreen;
|
||||||
|
|
||||||
|
static void initAttributes ()
|
||||||
|
{
|
||||||
|
// Setup attributes we want for the OpenGL context
|
||||||
|
|
||||||
|
int value;
|
||||||
|
|
||||||
|
// Don't set color bit sizes (SDL_GL_RED_SIZE, etc)
|
||||||
|
// Mac OS X will always use 8-8-8-8 ARGB for 32-bit screens and
|
||||||
|
// 5-5-5 RGB for 16-bit screens
|
||||||
|
|
||||||
|
// Request a 16-bit depth buffer (without this, there is no depth buffer)
|
||||||
|
value = 16;
|
||||||
|
SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, value);
|
||||||
|
|
||||||
|
|
||||||
|
// Request double-buffered OpenGL
|
||||||
|
// The fact that windows are double-buffered on Mac OS X has no effect
|
||||||
|
// on OpenGL double buffering.
|
||||||
|
value = 1;
|
||||||
|
SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void printAttributes ()
|
||||||
|
{
|
||||||
|
// Print out attributes of the context we created
|
||||||
|
int nAttr;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
int attr[] = { SDL_GL_RED_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_GREEN_SIZE,
|
||||||
|
SDL_GL_ALPHA_SIZE, SDL_GL_BUFFER_SIZE, SDL_GL_DEPTH_SIZE };
|
||||||
|
|
||||||
|
char *desc[] = { "Red size: %d bits\n", "Blue size: %d bits\n", "Green size: %d bits\n",
|
||||||
|
"Alpha size: %d bits\n", "Color buffer size: %d bits\n",
|
||||||
|
"Depth bufer size: %d bits\n" };
|
||||||
|
|
||||||
|
nAttr = sizeof(attr) / sizeof(int);
|
||||||
|
|
||||||
|
for (i = 0; i < nAttr; i++) {
|
||||||
|
|
||||||
|
int value;
|
||||||
|
SDL_GL_GetAttribute (attr[i], &value);
|
||||||
|
printf (desc[i], value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void createSurface (int fullscreen)
|
||||||
|
{
|
||||||
|
Uint32 flags = 0;
|
||||||
|
|
||||||
|
flags = SDL_OPENGL;
|
||||||
|
if (fullscreen)
|
||||||
|
flags |= SDL_FULLSCREEN;
|
||||||
|
|
||||||
|
// Create window
|
||||||
|
gScreen = SDL_SetVideoMode (640, 480, 0, flags);
|
||||||
|
if (gScreen == NULL) {
|
||||||
|
|
||||||
|
fprintf (stderr, "Couldn't set 640x480 OpenGL video mode: %s\n",
|
||||||
|
SDL_GetError());
|
||||||
|
SDL_Quit();
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void initGL ()
|
||||||
|
{
|
||||||
|
Atlantis_Init ();
|
||||||
|
Atlantis_Reshape (gScreen->w, gScreen->h);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void drawGL ()
|
||||||
|
{
|
||||||
|
Atlantis_Animate ();
|
||||||
|
Atlantis_Display ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mainLoop ()
|
||||||
|
{
|
||||||
|
SDL_Event event;
|
||||||
|
int done = 0;
|
||||||
|
int fps = 24;
|
||||||
|
int delay = 1000/fps;
|
||||||
|
int thenTicks = -1;
|
||||||
|
int nowTicks;
|
||||||
|
|
||||||
|
while ( !done ) {
|
||||||
|
|
||||||
|
/* Check for events */
|
||||||
|
while ( SDL_PollEvent (&event) ) {
|
||||||
|
switch (event.type) {
|
||||||
|
|
||||||
|
case SDL_MOUSEMOTION:
|
||||||
|
break;
|
||||||
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
break;
|
||||||
|
case SDL_KEYDOWN:
|
||||||
|
/* Any keypress quits the app... */
|
||||||
|
case SDL_QUIT:
|
||||||
|
done = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw at 24 hz
|
||||||
|
// This approach is not normally recommended - it is better to
|
||||||
|
// use time-based animation and run as fast as possible
|
||||||
|
drawGL ();
|
||||||
|
SDL_GL_SwapBuffers ();
|
||||||
|
|
||||||
|
// Time how long each draw-swap-delay cycle takes
|
||||||
|
// and adjust delay to get closer to target framerate
|
||||||
|
if (thenTicks > 0) {
|
||||||
|
nowTicks = SDL_GetTicks ();
|
||||||
|
delay += (1000/fps - (nowTicks-thenTicks));
|
||||||
|
thenTicks = nowTicks;
|
||||||
|
if (delay < 0)
|
||||||
|
delay = 1000/fps;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
thenTicks = SDL_GetTicks ();
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Delay (delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
// Init SDL video subsystem
|
||||||
|
if ( SDL_Init (SDL_INIT_VIDEO) < 0 ) {
|
||||||
|
|
||||||
|
fprintf(stderr, "Couldn't initialize SDL: %s\n",
|
||||||
|
SDL_GetError());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set GL context attributes
|
||||||
|
initAttributes ();
|
||||||
|
|
||||||
|
// Create GL context
|
||||||
|
createSurface (0);
|
||||||
|
|
||||||
|
// Get GL context attributes
|
||||||
|
printAttributes ();
|
||||||
|
|
||||||
|
// Init GL state
|
||||||
|
initGL ();
|
||||||
|
|
||||||
|
// Draw, get events...
|
||||||
|
mainLoop ();
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
SDL_Quit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue