Eric Wing to Sam

Lots of fixes.
Fixed missing power management building.
Added template icons to the project templates.
DocSet stuff
Documentation fixes..

Fixed all the SDLtests. (Lots of tedious work.) It now depends on the static library target for convenience so I am not going to remove it from the SDL xcode project.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403952
This commit is contained in:
Sam Lantinga 2009-10-01 15:30:26 +00:00
parent 64da4d2ac8
commit 7210963bc0
156 changed files with 37042 additions and 0 deletions

View 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>

View file

@ -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

View file

@ -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.";
}

View file

@ -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 */;
}

View file

@ -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.
}
*/

View file

@ -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

File diff suppressed because it is too large Load diff

View file

@ -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);
}
}
}

File diff suppressed because it is too large Load diff

View 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;
}