Added Mac OSX XCode project with Cocoa userinterface (wrapping GLUT) for Bullet demos
Thanks to TomorrowPlus for the constribution!
This commit is contained in:
Binary file not shown.
1857
Extras/AllBulletDemosOSX/AllBulletDemos.xcodeproj/project.pbxproj
Normal file
1857
Extras/AllBulletDemosOSX/AllBulletDemos.xcodeproj/project.pbxproj
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,248 @@
|
|||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
||||||
|
activeArchitecture = i386;
|
||||||
|
activeBuildConfigurationName = Release;
|
||||||
|
activeExecutable = 36C69D030DC9E7BD0034504A /* AllBulletDemos */;
|
||||||
|
activeTarget = 8D1107260486CEB800E47090 /* AllBulletDemos */;
|
||||||
|
addToTargets = (
|
||||||
|
8D1107260486CEB800E47090 /* AllBulletDemos */,
|
||||||
|
);
|
||||||
|
codeSenseManager = 36C69D160DC9E7C30034504A /* Code sense */;
|
||||||
|
executables = (
|
||||||
|
36C69D030DC9E7BD0034504A /* AllBulletDemos */,
|
||||||
|
);
|
||||||
|
perUserDictionary = {
|
||||||
|
"PBXConfiguration.PBXBreakpointsDataSource.v1:1CA23EDF0692099D00951B8B" = {
|
||||||
|
PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
|
||||||
|
PBXFileTableDataSourceColumnSortingKey = PBXBreakpointsDataSource_BreakpointID;
|
||||||
|
PBXFileTableDataSourceColumnWidthsKey = (
|
||||||
|
20,
|
||||||
|
20,
|
||||||
|
327,
|
||||||
|
20,
|
||||||
|
227,
|
||||||
|
227,
|
||||||
|
156,
|
||||||
|
20,
|
||||||
|
);
|
||||||
|
PBXFileTableDataSourceColumnsKey = (
|
||||||
|
PBXBreakpointsDataSource_ActionID,
|
||||||
|
PBXBreakpointsDataSource_TypeID,
|
||||||
|
PBXBreakpointsDataSource_BreakpointID,
|
||||||
|
PBXBreakpointsDataSource_UseID,
|
||||||
|
PBXBreakpointsDataSource_LocationID,
|
||||||
|
PBXBreakpointsDataSource_ConditionID,
|
||||||
|
PBXBreakpointsDataSource_IgnoreCountID,
|
||||||
|
PBXBreakpointsDataSource_ContinueID,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = {
|
||||||
|
PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
|
||||||
|
PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID;
|
||||||
|
PBXFileTableDataSourceColumnWidthsKey = (
|
||||||
|
20,
|
||||||
|
827,
|
||||||
|
20,
|
||||||
|
48,
|
||||||
|
43,
|
||||||
|
43,
|
||||||
|
20,
|
||||||
|
);
|
||||||
|
PBXFileTableDataSourceColumnsKey = (
|
||||||
|
PBXFileDataSource_FiletypeID,
|
||||||
|
PBXFileDataSource_Filename_ColumnID,
|
||||||
|
PBXFileDataSource_Built_ColumnID,
|
||||||
|
PBXFileDataSource_ObjectSize_ColumnID,
|
||||||
|
PBXFileDataSource_Errors_ColumnID,
|
||||||
|
PBXFileDataSource_Warnings_ColumnID,
|
||||||
|
PBXFileDataSource_Target_ColumnID,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = {
|
||||||
|
PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
|
||||||
|
PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID;
|
||||||
|
PBXFileTableDataSourceColumnWidthsKey = (
|
||||||
|
20,
|
||||||
|
787,
|
||||||
|
60,
|
||||||
|
20,
|
||||||
|
48,
|
||||||
|
43,
|
||||||
|
43,
|
||||||
|
);
|
||||||
|
PBXFileTableDataSourceColumnsKey = (
|
||||||
|
PBXFileDataSource_FiletypeID,
|
||||||
|
PBXFileDataSource_Filename_ColumnID,
|
||||||
|
PBXTargetDataSource_PrimaryAttribute,
|
||||||
|
PBXFileDataSource_Built_ColumnID,
|
||||||
|
PBXFileDataSource_ObjectSize_ColumnID,
|
||||||
|
PBXFileDataSource_Errors_ColumnID,
|
||||||
|
PBXFileDataSource_Warnings_ColumnID,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
PBXPerProjectTemplateStateSaveDate = 231705029;
|
||||||
|
PBXWorkspaceStateSaveDate = 231705029;
|
||||||
|
};
|
||||||
|
sourceControlManager = 36C69D150DC9E7C30034504A /* Source Control */;
|
||||||
|
userBuildSettings = {
|
||||||
|
};
|
||||||
|
};
|
||||||
|
3620538A0DCE4FB70048F794 /* file.obj */ = {
|
||||||
|
uiCtxt = {
|
||||||
|
sepNavIntBoundsRect = "{{0, 0}, {1005, 23897}}";
|
||||||
|
sepNavSelRange = "{0, 0}";
|
||||||
|
sepNavVisRange = "{0, 1284}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
3699D19A0DCF64EE001D9494 /* SoftDemo.cpp */ = {
|
||||||
|
uiCtxt = {
|
||||||
|
sepNavIntBoundsRect = "{{0, 0}, {1713, 6007}}";
|
||||||
|
sepNavSelRange = "{0, 0}";
|
||||||
|
sepNavVisRange = "{0, 1773}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
36A05BBB0DCBA09000ADF289 /* English */ = {
|
||||||
|
uiCtxt = {
|
||||||
|
sepNavIntBoundsRect = "{{0, 0}, {1393, 270}}";
|
||||||
|
sepNavSelRange = "{126, 0}";
|
||||||
|
sepNavVisRect = "{{0, 0}, {1393, 270}}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
36A05DC70DCBBAC000ADF289 /* BTFullscreenWindow.h */ = {
|
||||||
|
uiCtxt = {
|
||||||
|
sepNavIntBoundsRect = "{{0, 0}, {1713, 523}}";
|
||||||
|
sepNavSelRange = "{973, 0}";
|
||||||
|
sepNavVisRange = "{0, 1071}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
36A05DC80DCBBAC000ADF289 /* BTFullscreenWindow.m */ = {
|
||||||
|
uiCtxt = {
|
||||||
|
sepNavIntBoundsRect = "{{0, 0}, {1713, 637}}";
|
||||||
|
sepNavSelRange = "{1017, 0}";
|
||||||
|
sepNavVisRange = "{464, 1072}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
36A05DC90DCBBAC000ADF289 /* BTGLUTKeyAdapter.h */ = {
|
||||||
|
uiCtxt = {
|
||||||
|
sepNavIntBoundsRect = "{{0, 0}, {1713, 611}}";
|
||||||
|
sepNavSelRange = "{949, 0}";
|
||||||
|
sepNavVisRange = "{0, 1547}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
36A05DCA0DCBBAC000ADF289 /* BTGLUTKeyAdapter.m */ = {
|
||||||
|
uiCtxt = {
|
||||||
|
sepNavIntBoundsRect = "{{0, 0}, {1713, 1410}}";
|
||||||
|
sepNavSelRange = "{949, 0}";
|
||||||
|
sepNavVisRange = "{0, 1483}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
36A05DCB0DCBBAC000ADF289 /* BTOpenGLDisplayDelegate.h */ = {
|
||||||
|
uiCtxt = {
|
||||||
|
sepNavIntBoundsRect = "{{0, 0}, {1713, 663}}";
|
||||||
|
sepNavSelRange = "{948, 0}";
|
||||||
|
sepNavVisRange = "{503, 1525}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
36A05DCC0DCBBAC000ADF289 /* BTOpenGLView.h */ = {
|
||||||
|
uiCtxt = {
|
||||||
|
sepNavIntBoundsRect = "{{0, 0}, {1713, 858}}";
|
||||||
|
sepNavSelRange = "{1773, 0}";
|
||||||
|
sepNavVisRange = "{1035, 919}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
36A05DCD0DCBBAC000ADF289 /* BTOpenGLView.m */ = {
|
||||||
|
uiCtxt = {
|
||||||
|
sepNavIntBoundsRect = "{{0, 0}, {1713, 4646}}";
|
||||||
|
sepNavSelRange = "{3853, 0}";
|
||||||
|
sepNavVisRange = "{3389, 750}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
36A05DCE0DCBBAC000ADF289 /* BTSimulationParameters.m */ = {
|
||||||
|
uiCtxt = {
|
||||||
|
sepNavIntBoundsRect = "{{0, 0}, {1713, 1118}}";
|
||||||
|
sepNavSelRange = "{1044, 0}";
|
||||||
|
sepNavVisRange = "{1466, 552}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
36A05DCF0DCBBAC000ADF289 /* BTDemosAppController.m */ = {
|
||||||
|
uiCtxt = {
|
||||||
|
sepNavIntBoundsRect = "{{0, 0}, {1713, 1578}}";
|
||||||
|
sepNavSelRange = "{1175, 0}";
|
||||||
|
sepNavVisRange = "{1623, 839}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
36A05DD00DCBBAC000ADF289 /* BTSimulationParameters.h */ = {
|
||||||
|
uiCtxt = {
|
||||||
|
sepNavIntBoundsRect = "{{0, 0}, {1713, 585}}";
|
||||||
|
sepNavSelRange = "{1140, 0}";
|
||||||
|
sepNavVisRange = "{137, 1474}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
36A05DD10DCBBAC000ADF289 /* BTDemosAppController.h */ = {
|
||||||
|
uiCtxt = {
|
||||||
|
sepNavIntBoundsRect = "{{0, 0}, {1713, 715}}";
|
||||||
|
sepNavSelRange = "{948, 0}";
|
||||||
|
sepNavVisRange = "{0, 1519}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
36A72EFD0DCC816F00BA8039 /* BTDemo.h */ = {
|
||||||
|
uiCtxt = {
|
||||||
|
sepNavIntBoundsRect = "{{0, 0}, {1713, 1352}}";
|
||||||
|
sepNavSelRange = "{1030, 0}";
|
||||||
|
sepNavVisRange = "{1827, 1143}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
36A72EFE0DCC816F00BA8039 /* BTDemo.mm */ = {
|
||||||
|
uiCtxt = {
|
||||||
|
sepNavIntBoundsRect = "{{0, 0}, {1713, 2372}}";
|
||||||
|
sepNavSelRange = "{948, 0}";
|
||||||
|
sepNavVisRange = "{0, 1551}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
36C69D030DC9E7BD0034504A /* AllBulletDemos */ = {
|
||||||
|
isa = PBXExecutable;
|
||||||
|
activeArgIndices = (
|
||||||
|
);
|
||||||
|
argumentStrings = (
|
||||||
|
);
|
||||||
|
autoAttachOnCrash = 1;
|
||||||
|
breakpointsEnabled = 0;
|
||||||
|
configStateDict = {
|
||||||
|
};
|
||||||
|
customDataFormattersEnabled = 1;
|
||||||
|
debuggerPlugin = GDBDebugging;
|
||||||
|
disassemblyDisplayState = 0;
|
||||||
|
dylibVariantSuffix = "";
|
||||||
|
enableDebugStr = 1;
|
||||||
|
environmentEntries = (
|
||||||
|
);
|
||||||
|
executableSystemSymbolLevel = 0;
|
||||||
|
executableUserSymbolLevel = 0;
|
||||||
|
libgmallocEnabled = 0;
|
||||||
|
name = AllBulletDemos;
|
||||||
|
savedGlobals = {
|
||||||
|
};
|
||||||
|
sourceDirectories = (
|
||||||
|
);
|
||||||
|
variableFormatDictionary = {
|
||||||
|
};
|
||||||
|
};
|
||||||
|
36C69D150DC9E7C30034504A /* Source Control */ = {
|
||||||
|
isa = PBXSourceControlManager;
|
||||||
|
fallbackIsa = XCSourceControlManager;
|
||||||
|
isSCMEnabled = 0;
|
||||||
|
scmConfiguration = {
|
||||||
|
};
|
||||||
|
};
|
||||||
|
36C69D160DC9E7C30034504A /* Code sense */ = {
|
||||||
|
isa = PBXCodeSenseManager;
|
||||||
|
indexTemplatePath = "";
|
||||||
|
};
|
||||||
|
8D1107260486CEB800E47090 /* AllBulletDemos */ = {
|
||||||
|
activeExec = 0;
|
||||||
|
executables = (
|
||||||
|
36C69D030DC9E7BD0034504A /* AllBulletDemos */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
7
Extras/AllBulletDemosOSX/AllBulletDemos_Prefix.pch
Normal file
7
Extras/AllBulletDemosOSX/AllBulletDemos_Prefix.pch
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
//
|
||||||
|
// Prefix header for all source files of the 'AllBulletDemos' target in the 'AllBulletDemos' project
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
||||||
BIN
Extras/AllBulletDemosOSX/BulletIcon.icns
Normal file
BIN
Extras/AllBulletDemosOSX/BulletIcon.icns
Normal file
Binary file not shown.
BIN
Extras/AllBulletDemosOSX/BulletIcon.psd
Normal file
BIN
Extras/AllBulletDemosOSX/BulletIcon.psd
Normal file
Binary file not shown.
11
Extras/AllBulletDemosOSX/English.lproj/Credits.rtf
Normal file
11
Extras/AllBulletDemosOSX/English.lproj/Credits.rtf
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf270
|
||||||
|
{\fonttbl\f0\fnil\fcharset0 LucidaGrande;}
|
||||||
|
{\colortbl;\red255\green255\blue255;}
|
||||||
|
\deftab560
|
||||||
|
\pard\tx560\pardeftab560\qc\pardirnatural
|
||||||
|
|
||||||
|
\f0\b\fs28 \cf0 \CocoaLigature0 Bullet Continuous Collision Detection and Physics Library
|
||||||
|
\b0\fs22 \
|
||||||
|
\
|
||||||
|
Copyright (c) 2003-2008 Erwin Coumans \
|
||||||
|
{\field{\*\fldinst{HYPERLINK "http://www.bulletphysics.com/"}}{\fldrslt http://www.bulletphysics.com}}}
|
||||||
BIN
Extras/AllBulletDemosOSX/English.lproj/InfoPlist.strings
Normal file
BIN
Extras/AllBulletDemosOSX/English.lproj/InfoPlist.strings
Normal file
Binary file not shown.
2095
Extras/AllBulletDemosOSX/English.lproj/MainMenu.xib
Normal file
2095
Extras/AllBulletDemosOSX/English.lproj/MainMenu.xib
Normal file
File diff suppressed because it is too large
Load Diff
28
Extras/AllBulletDemosOSX/Info.plist
Normal file
28
Extras/AllBulletDemosOSX/Info.plist
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//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>BulletIcon</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>org.bullet.${PRODUCT_NAME:identifier}</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>MainMenu</string>
|
||||||
|
<key>NSPrincipalClass</key>
|
||||||
|
<string>NSApplication</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
6
Extras/AllBulletDemosOSX/README.txt
Normal file
6
Extras/AllBulletDemosOSX/README.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
To build:
|
||||||
|
Place AllBulletDemosOSX in bullet-<version>/Extras and build with Xcode.
|
||||||
|
|
||||||
|
Questions:
|
||||||
|
contact Shamyl Zakariya
|
||||||
|
shamyl@zakariya.net
|
||||||
14
Extras/AllBulletDemosOSX/main.m
Normal file
14
Extras/AllBulletDemosOSX/main.m
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
//
|
||||||
|
// main.m
|
||||||
|
// AllBulletDemos
|
||||||
|
//
|
||||||
|
// Created by Shamyl Zakariya on 5/1/08.
|
||||||
|
// Copyright Shamyl Zakariya 2008. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
return NSApplicationMain(argc, (const char **) argv);
|
||||||
|
}
|
||||||
103
Extras/AllBulletDemosOSX/src/BTDemo.h
Normal file
103
Extras/AllBulletDemosOSX/src/BTDemo.h
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#import "BTOpenGLDisplayDelegate.h"
|
||||||
|
|
||||||
|
@class BTDemoEntry;
|
||||||
|
|
||||||
|
@interface BTDemo : NSObject <BTOpenGLDisplayDelegate> {
|
||||||
|
|
||||||
|
NSString *_demoName;
|
||||||
|
BTDemoEntry *_demo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Array of all available bullet demos
|
||||||
|
*/
|
||||||
|
+ (NSArray*) demoNames;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Verify a given string is a demo name
|
||||||
|
*/
|
||||||
|
+ (BOOL) isDemo: (NSString *) demoName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Create a demo with a given name
|
||||||
|
@note Returns nil if the name is not a valid demo name
|
||||||
|
*/
|
||||||
|
+ (BTDemo*) demoWithName: (NSString *) demoName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Initialize a demo with a given name
|
||||||
|
*/
|
||||||
|
- (id) initWithDemoName: (NSString *) demoName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Reset current demo
|
||||||
|
*/
|
||||||
|
- (void) reset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Name of current demo
|
||||||
|
*/
|
||||||
|
- (NSString*) demoName;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// BTOpenGLDisplayDelegate
|
||||||
|
|
||||||
|
- (void) contextCreated;
|
||||||
|
- (void) contextWillBeDestroyed;
|
||||||
|
- (void) contextWillResize;
|
||||||
|
- (void) contextResized: (NSSize) newSize;
|
||||||
|
- (void) contextDidResize;
|
||||||
|
- (void) contextStateInvalidated;
|
||||||
|
|
||||||
|
- (void) display: (float) deltaT;
|
||||||
|
|
||||||
|
- (void) keyPressed: (unsigned char) key;
|
||||||
|
- (void) keyReleased: (unsigned char) key;
|
||||||
|
|
||||||
|
- (void) specialKeyPressed: (unsigned) GLUTKey;
|
||||||
|
- (void) specialKeyReleased: (unsigned) GLUTKey;
|
||||||
|
|
||||||
|
- (void) mouseButtonPressed: (unsigned) mouseButton;
|
||||||
|
- (void) mouseButtonReleased: (unsigned) mouseButton;
|
||||||
|
- (void) mouseMoved: (NSPoint) delta;
|
||||||
|
- (void) newMousePosition: (NSPoint) newMousePosition;
|
||||||
|
- (void) scrollWheel: (NSPoint) delta;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// Global simulation properties -- applies to all demos
|
||||||
|
|
||||||
|
+ (void) setIterations: (unsigned) iterations;
|
||||||
|
+ (unsigned) iterations;
|
||||||
|
|
||||||
|
+ (unsigned) minIterations;
|
||||||
|
+ (unsigned) maxIterations;
|
||||||
|
|
||||||
|
+ (void) setDisableDeactivation: (BOOL) disableDeactivation;
|
||||||
|
+ (BOOL) disableDeactivation;
|
||||||
|
|
||||||
|
+ (void) setDrawAABBs: (BOOL) drawAABBs;
|
||||||
|
+ (BOOL) drawAABBs;
|
||||||
|
|
||||||
|
+ (void) setDebugDraw: (BOOL) debugDraw;
|
||||||
|
+ (BOOL) debugDraw;
|
||||||
|
|
||||||
|
+ (void) setDrawContacts: (BOOL) drawContacts;
|
||||||
|
+ (BOOL) drawContacts;
|
||||||
|
|
||||||
|
@end
|
||||||
390
Extras/AllBulletDemosOSX/src/BTDemo.mm
Normal file
390
Extras/AllBulletDemosOSX/src/BTDemo.mm
Normal file
@@ -0,0 +1,390 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "BTDemo.h"
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// Bullet includes
|
||||||
|
|
||||||
|
#include "LinearMath/btScalar.h"
|
||||||
|
#include "LinearMath/btMinMax.h"
|
||||||
|
|
||||||
|
#include "DemoApplication.h"
|
||||||
|
#include "DemoEntries.h"
|
||||||
|
#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
|
||||||
|
|
||||||
|
#include "GLDebugDrawer.h"
|
||||||
|
|
||||||
|
#include "LinearMath/btQuickprof.h"
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark Globals
|
||||||
|
|
||||||
|
static NSPoint MousePosition;
|
||||||
|
static NSSize ViewSize;
|
||||||
|
static int NumIterations = 10;
|
||||||
|
static BOOL DisableDeactivation = NO;
|
||||||
|
static BOOL DrawAABBs = NO;
|
||||||
|
static BOOL DebugDraw = NO;
|
||||||
|
static BOOL DrawContacts = NO;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark BTDemoEntry
|
||||||
|
|
||||||
|
@interface BTDemoEntry : NSObject {
|
||||||
|
btDemoEntry *ctor;
|
||||||
|
DemoApplication *demo;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithDemoEntry: (btDemoEntry*) constructor;
|
||||||
|
- (DemoApplication*) demo;
|
||||||
|
- (void) reset;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation BTDemoEntry
|
||||||
|
|
||||||
|
- (id) initWithDemoEntry: (btDemoEntry*) constructor
|
||||||
|
{
|
||||||
|
if ( self = [super init] )
|
||||||
|
{
|
||||||
|
ctor = constructor;
|
||||||
|
[self reset];
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
if ( demo ) delete demo;
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (DemoApplication*) demo
|
||||||
|
{
|
||||||
|
return demo;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) reset
|
||||||
|
{
|
||||||
|
if ( demo )
|
||||||
|
{
|
||||||
|
if (demo->getDynamicsWorld()->getDebugDrawer())
|
||||||
|
delete demo->getDynamicsWorld()->getDebugDrawer();
|
||||||
|
|
||||||
|
delete demo;
|
||||||
|
demo = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
demo = ctor->createFcn();
|
||||||
|
btAssert(demo);
|
||||||
|
|
||||||
|
if (demo->getDynamicsWorld())
|
||||||
|
{
|
||||||
|
demo->getDynamicsWorld()->setDebugDrawer(new GLDebugDrawer());
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef BT_NO_PROFILE
|
||||||
|
CProfileManager::Reset();
|
||||||
|
#endif //BT_NO_PROFILE
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark BTDemo
|
||||||
|
|
||||||
|
|
||||||
|
@implementation BTDemo
|
||||||
|
|
||||||
|
+ (NSArray*) demoNames
|
||||||
|
{
|
||||||
|
static NSMutableArray *DEMOS = nil;
|
||||||
|
if ( !DEMOS )
|
||||||
|
{
|
||||||
|
DEMOS = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
|
btDemoEntry* e = g_demoEntries;
|
||||||
|
while (e->createFcn)
|
||||||
|
{
|
||||||
|
[DEMOS addObject: [NSString stringWithUTF8String: e->name]];
|
||||||
|
++e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return DEMOS;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (BOOL) isDemo: (NSString *) demoName
|
||||||
|
{
|
||||||
|
return [[self demoNames] containsObject: demoName];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (BTDemo*) demoWithName: (NSString *) demoName
|
||||||
|
{
|
||||||
|
if ( [BTDemo isDemo: demoName] )
|
||||||
|
{
|
||||||
|
return [[[BTDemo alloc] initWithDemoName: demoName] autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithDemoName: (NSString *) demoName
|
||||||
|
{
|
||||||
|
if ( self = [super init] )
|
||||||
|
{
|
||||||
|
_demoName = [demoName copy];
|
||||||
|
|
||||||
|
// now walk the constructor list and find this demo
|
||||||
|
|
||||||
|
btDemoEntry* e = g_demoEntries;
|
||||||
|
while (e->createFcn)
|
||||||
|
{
|
||||||
|
NSString *name = [NSString stringWithCString: e->name];
|
||||||
|
if ( [name isEqualToString: demoName] )
|
||||||
|
{
|
||||||
|
_demo = [[BTDemoEntry alloc] initWithDemoEntry: e];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
e++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
[_demoName release];
|
||||||
|
[_demo release];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) reset
|
||||||
|
{
|
||||||
|
[_demo reset];
|
||||||
|
|
||||||
|
[self contextWillResize];
|
||||||
|
[self contextResized: ViewSize];
|
||||||
|
[self contextDidResize];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString*) demoName
|
||||||
|
{
|
||||||
|
return _demoName;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark BTOpenGLDisplayDelegate
|
||||||
|
|
||||||
|
- (void) contextCreated
|
||||||
|
{}
|
||||||
|
|
||||||
|
- (void) contextWillBeDestroyed
|
||||||
|
{}
|
||||||
|
|
||||||
|
- (void) contextWillResize
|
||||||
|
{}
|
||||||
|
|
||||||
|
- (void) contextResized: (NSSize) newSize
|
||||||
|
{
|
||||||
|
ViewSize = newSize;
|
||||||
|
glViewport( 0, 0, (int) newSize.width, (int) newSize.height );
|
||||||
|
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
[_demo demo]->reshape( (int) newSize.width, (int) newSize.height );
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) contextDidResize
|
||||||
|
{}
|
||||||
|
|
||||||
|
- (void) contextStateInvalidated
|
||||||
|
{}
|
||||||
|
|
||||||
|
- (void) display: (float) deltaT
|
||||||
|
{
|
||||||
|
DemoApplication *demo = [_demo demo];
|
||||||
|
|
||||||
|
if ( !demo )
|
||||||
|
{
|
||||||
|
glClearColor( 1, 0.5, 1, 1 );
|
||||||
|
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DrawAABBs)
|
||||||
|
{
|
||||||
|
demo->setDebugMode(demo->getDebugMode() |btIDebugDraw::DBG_DrawAabb);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_DrawAabb));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DebugDraw)
|
||||||
|
{
|
||||||
|
demo->setDebugMode(demo->getDebugMode() |btIDebugDraw::DBG_DrawWireframe);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_DrawWireframe));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DrawContacts)
|
||||||
|
{
|
||||||
|
demo->setDebugMode(demo->getDebugMode() |btIDebugDraw::DBG_DrawContactPoints);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_DrawContactPoints));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DisableDeactivation)
|
||||||
|
{
|
||||||
|
demo->setDebugMode(demo->getDebugMode() |btIDebugDraw::DBG_NoDeactivation);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_NoDeactivation));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (demo->getDynamicsWorld() && demo->getDynamicsWorld()->getWorldType() == BT_DISCRETE_DYNAMICS_WORLD)
|
||||||
|
{
|
||||||
|
btDiscreteDynamicsWorld* discreteWorld = (btDiscreteDynamicsWorld*) demo->getDynamicsWorld();
|
||||||
|
discreteWorld->getSolverInfo().m_numIterations = NumIterations;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!demo->isIdle())
|
||||||
|
{
|
||||||
|
demo->clientMoveAndDisplay();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
demo->displayCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) keyPressed: (unsigned char) key
|
||||||
|
{
|
||||||
|
[_demo demo]->keyboardCallback(key, (int)MousePosition.x, (int)MousePosition.y );
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) keyReleased: (unsigned char) key
|
||||||
|
{}
|
||||||
|
|
||||||
|
- (void) specialKeyPressed: (unsigned) key
|
||||||
|
{
|
||||||
|
[_demo demo]->specialKeyboard(key,(int)MousePosition.x, (int)MousePosition.y );
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) specialKeyReleased: (unsigned) key
|
||||||
|
{}
|
||||||
|
|
||||||
|
- (void) mouseButtonPressed: (unsigned) mouseButton
|
||||||
|
{
|
||||||
|
[_demo demo]->mouseFunc( mouseButton, GLUT_DOWN, (int)MousePosition.x, (int)MousePosition.y );
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) mouseButtonReleased: (unsigned) mouseButton
|
||||||
|
{
|
||||||
|
[_demo demo]->mouseFunc( mouseButton, GLUT_UP, (int)MousePosition.x, (int)MousePosition.y );
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) mouseMoved: (NSPoint) delta
|
||||||
|
{
|
||||||
|
[_demo demo]->mouseMotionFunc((int)MousePosition.x, (int)MousePosition.y );
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) newMousePosition: (NSPoint) newMousePosition
|
||||||
|
{
|
||||||
|
// Need to invert Y, since DemoApplication assumes origin at top-left
|
||||||
|
MousePosition = NSMakePoint( newMousePosition.x, ViewSize.height - newMousePosition.y );
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) scrollWheel: (NSPoint) delta
|
||||||
|
{}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark Global Simulation Properties
|
||||||
|
|
||||||
|
+ (void) setIterations: (unsigned) iterations
|
||||||
|
{
|
||||||
|
NumIterations = iterations;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (unsigned) iterations
|
||||||
|
{
|
||||||
|
return NumIterations;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (unsigned) minIterations { return 1; }
|
||||||
|
+ (unsigned) maxIterations { return 1000; }
|
||||||
|
|
||||||
|
|
||||||
|
+ (void) setDisableDeactivation: (BOOL) disableDeactivation
|
||||||
|
{
|
||||||
|
DisableDeactivation = disableDeactivation;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (BOOL) disableDeactivation
|
||||||
|
{
|
||||||
|
return DisableDeactivation;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void) setDrawAABBs: (BOOL) drawAABBs
|
||||||
|
{
|
||||||
|
DrawAABBs = drawAABBs;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (BOOL) drawAABBs
|
||||||
|
{
|
||||||
|
return DrawAABBs;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void) setDebugDraw: (BOOL) debugDraw
|
||||||
|
{
|
||||||
|
DebugDraw = debugDraw;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (BOOL) debugDraw
|
||||||
|
{
|
||||||
|
return DebugDraw;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void) setDrawContacts: (BOOL) drawContacts
|
||||||
|
{
|
||||||
|
DrawContacts = drawContacts;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (BOOL) drawContacts
|
||||||
|
{
|
||||||
|
return DrawContacts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
||||||
54
Extras/AllBulletDemosOSX/src/BTDemosAppController.h
Normal file
54
Extras/AllBulletDemosOSX/src/BTDemosAppController.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#import "BTOpenGLView.h"
|
||||||
|
#import "BTSimulationParameters.h"
|
||||||
|
#import "BTDemo.h"
|
||||||
|
|
||||||
|
@interface BTDemosAppController : NSObject {
|
||||||
|
|
||||||
|
IBOutlet BTOpenGLView* _glView;
|
||||||
|
IBOutlet BTSimulationParameters *_parameters;
|
||||||
|
|
||||||
|
BTDemo *_currentDemo;
|
||||||
|
BOOL _showParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// Public API
|
||||||
|
|
||||||
|
- (void) setFullscreen: (BOOL) fullscreen;
|
||||||
|
- (BOOL) fullscreen;
|
||||||
|
|
||||||
|
- (void) setShowParameters: (BOOL) showParameters;
|
||||||
|
- (BOOL) showParameters;
|
||||||
|
|
||||||
|
- (NSArray*) demos;
|
||||||
|
|
||||||
|
- (void) setDemo: (NSString*) demoName;
|
||||||
|
- (NSString*) demo;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// IBActions
|
||||||
|
|
||||||
|
- (IBAction) nextDemo: (id) sender;
|
||||||
|
- (IBAction) previousDemo: (id) sender;
|
||||||
|
- (IBAction) toggleFullscreen: (id) sender;
|
||||||
|
- (IBAction) toggleParameters: (id) sender;
|
||||||
|
- (IBAction) resetDemo: (id) sender;
|
||||||
|
- (IBAction) nullMenuTarget: (id) sender;
|
||||||
|
|
||||||
|
@end
|
||||||
151
Extras/AllBulletDemosOSX/src/BTDemosAppController.m
Normal file
151
Extras/AllBulletDemosOSX/src/BTDemosAppController.m
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "BTDemosAppController.h"
|
||||||
|
|
||||||
|
|
||||||
|
@implementation BTDemosAppController
|
||||||
|
|
||||||
|
- (id) init
|
||||||
|
{
|
||||||
|
if ( self = [super init] )
|
||||||
|
{
|
||||||
|
// change cwd to .app/Contents/Resources
|
||||||
|
NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
|
||||||
|
[[NSFileManager defaultManager] changeCurrentDirectoryPath:resourcePath];
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) awakeFromNib
|
||||||
|
{}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark Public API
|
||||||
|
|
||||||
|
- (void) setFullscreen: (BOOL) fullscreen
|
||||||
|
{
|
||||||
|
[_glView setFullscreen: fullscreen];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) fullscreen
|
||||||
|
{
|
||||||
|
return [_glView fullscreen];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setShowParameters: (BOOL) showParameters
|
||||||
|
{
|
||||||
|
_showParameters = showParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) showParameters
|
||||||
|
{
|
||||||
|
return _showParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray*) demos
|
||||||
|
{
|
||||||
|
return [BTDemo demoNames];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setDemo: (NSString*) demoName
|
||||||
|
{
|
||||||
|
[_currentDemo release];
|
||||||
|
[_glView setDelegate: nil];
|
||||||
|
|
||||||
|
_currentDemo = [[BTDemo demoWithName: demoName] retain];
|
||||||
|
|
||||||
|
if ( _currentDemo )
|
||||||
|
{
|
||||||
|
// the demo is the rendering & input delegate for the gl view
|
||||||
|
[_glView setDelegate: _currentDemo];
|
||||||
|
|
||||||
|
[_currentDemo contextWillResize];
|
||||||
|
[_currentDemo contextResized: [_glView bounds].size];
|
||||||
|
[_currentDemo contextDidResize];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString*) demo
|
||||||
|
{
|
||||||
|
return _currentDemo ? [_currentDemo demoName] : nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark IBActions
|
||||||
|
|
||||||
|
- (IBAction) nextDemo: (id) sender
|
||||||
|
{
|
||||||
|
NSArray *demos = [self demos];
|
||||||
|
unsigned index = [demos indexOfObject: [self demo]];
|
||||||
|
if ( index != NSNotFound )
|
||||||
|
{
|
||||||
|
index = ( index + 1 ) % [demos count];
|
||||||
|
[self setDemo: [demos objectAtIndex: index]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction) previousDemo: (id) sender
|
||||||
|
{
|
||||||
|
NSArray *demos = [self demos];
|
||||||
|
unsigned index = [demos indexOfObject: [self demo]];
|
||||||
|
if ( index != NSNotFound )
|
||||||
|
{
|
||||||
|
if ( index == 0 ) index = [demos count] - 1;
|
||||||
|
else index--;
|
||||||
|
|
||||||
|
[self setDemo: [demos objectAtIndex: index]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction) toggleFullscreen: (id) sender
|
||||||
|
{
|
||||||
|
[self setFullscreen: ![self fullscreen]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction) toggleParameters: (id) sender
|
||||||
|
{
|
||||||
|
[self setShowParameters: ![self showParameters]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction) resetDemo: (id) sender
|
||||||
|
{
|
||||||
|
[_currentDemo reset];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction) nullMenuTarget: (id) sender
|
||||||
|
{
|
||||||
|
// this handles a 10.4 bug. A menu bound to some property for toggling
|
||||||
|
// will not invoke unless it has a target and selector set.
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark NSApplicationDelegate
|
||||||
|
|
||||||
|
- (void) applicationDidFinishLaunching: (NSNotification *)aNotification
|
||||||
|
{
|
||||||
|
// note: We load the first demo here and not in -awakeFromNib as the
|
||||||
|
// OpenGL view is instantiated, but not running yet at that point
|
||||||
|
|
||||||
|
[self setDemo: [[self demos] objectAtIndex:0]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) applicationShouldTerminateAfterLastWindowClosed: (NSApplication *)theApplication
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
44
Extras/AllBulletDemosOSX/src/BTSimulationParameters.h
Normal file
44
Extras/AllBulletDemosOSX/src/BTSimulationParameters.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
BTSimulationParameters is an instanceable proxy for BTDemo's global
|
||||||
|
simulation properties. We're doing this so we can bind UI to something
|
||||||
|
in the nib file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@interface BTSimulationParameters : NSObject {}
|
||||||
|
|
||||||
|
- (void) setIterations: (unsigned) iterations;
|
||||||
|
- (unsigned) iterations;
|
||||||
|
|
||||||
|
- (unsigned) minIterations;
|
||||||
|
- (unsigned) maxIterations;
|
||||||
|
|
||||||
|
- (void) setDisableDeactivation: (BOOL) disableDeactivation;
|
||||||
|
- (BOOL) disableDeactivation;
|
||||||
|
|
||||||
|
- (void) setDrawAABBs: (BOOL) drawAABBs;
|
||||||
|
- (BOOL) drawAABBs;
|
||||||
|
|
||||||
|
- (void) setDebugDraw: (BOOL) debugDraw;
|
||||||
|
- (BOOL) debugDraw;
|
||||||
|
|
||||||
|
- (void) setDrawContacts: (BOOL) drawContacts;
|
||||||
|
- (BOOL) drawContacts;
|
||||||
|
|
||||||
|
@end
|
||||||
85
Extras/AllBulletDemosOSX/src/BTSimulationParameters.m
Normal file
85
Extras/AllBulletDemosOSX/src/BTSimulationParameters.m
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "BTSimulationParameters.h"
|
||||||
|
#import "BTDemo.h"
|
||||||
|
|
||||||
|
@implementation BTSimulationParameters
|
||||||
|
|
||||||
|
- (id) init
|
||||||
|
{
|
||||||
|
if ( self = [super init] )
|
||||||
|
{}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark Public API
|
||||||
|
|
||||||
|
- (void) setIterations: (unsigned) iterations
|
||||||
|
{
|
||||||
|
[BTDemo setIterations: iterations];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (unsigned) iterations
|
||||||
|
{
|
||||||
|
return [BTDemo iterations];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (unsigned) minIterations { return [BTDemo minIterations]; }
|
||||||
|
- (unsigned) maxIterations { return [BTDemo maxIterations]; }
|
||||||
|
|
||||||
|
|
||||||
|
- (void) setDisableDeactivation: (BOOL) disableDeactivation
|
||||||
|
{
|
||||||
|
[BTDemo setDisableDeactivation: disableDeactivation];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) disableDeactivation
|
||||||
|
{
|
||||||
|
return [BTDemo disableDeactivation];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setDrawAABBs: (BOOL) drawAABBs
|
||||||
|
{
|
||||||
|
[BTDemo setDrawAABBs: drawAABBs];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) drawAABBs
|
||||||
|
{
|
||||||
|
return [BTDemo drawAABBs];;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setDebugDraw: (BOOL) debugDraw
|
||||||
|
{
|
||||||
|
[BTDemo setDebugDraw: debugDraw];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) debugDraw
|
||||||
|
{
|
||||||
|
return [BTDemo debugDraw];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setDrawContacts: (BOOL) drawContacts
|
||||||
|
{
|
||||||
|
[BTDemo setDrawContacts: drawContacts];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) drawContacts
|
||||||
|
{
|
||||||
|
return [BTDemo drawContacts];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
25
Extras/AllBulletDemosOSX/src/toolkit/BTFullscreenWindow.h
Normal file
25
Extras/AllBulletDemosOSX/src/toolkit/BTFullscreenWindow.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
|
||||||
|
@interface BTFullScreenWindow : NSWindow {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initForScreen: (NSScreen *) screen;
|
||||||
|
|
||||||
|
@end
|
||||||
48
Extras/AllBulletDemosOSX/src/toolkit/BTFullscreenWindow.m
Normal file
48
Extras/AllBulletDemosOSX/src/toolkit/BTFullscreenWindow.m
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "BTFullScreenWindow.h"
|
||||||
|
|
||||||
|
|
||||||
|
@implementation BTFullScreenWindow
|
||||||
|
|
||||||
|
- (id) initForScreen: (NSScreen *) screen
|
||||||
|
{
|
||||||
|
NSRect frame = [screen frame];
|
||||||
|
frame.size.height -= [NSMenuView menuBarHeight];
|
||||||
|
|
||||||
|
self = [self initWithContentRect: frame
|
||||||
|
styleMask: NSBorderlessWindowMask
|
||||||
|
backing: NSBackingStoreBuffered
|
||||||
|
defer: YES
|
||||||
|
screen: screen ];
|
||||||
|
if ( self )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
For some reason, without this
|
||||||
|
we lose mouse moved events in fullscreen
|
||||||
|
*/
|
||||||
|
[self setAcceptsMouseMovedEvents: YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)canBecomeKeyWindow
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
46
Extras/AllBulletDemosOSX/src/toolkit/BTGLUTKeyAdapter.h
Normal file
46
Extras/AllBulletDemosOSX/src/toolkit/BTGLUTKeyAdapter.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __BT_KEY_CODE_H__
|
||||||
|
#define __BT_KEY_CODE_H__
|
||||||
|
|
||||||
|
#include <GLUT/glut.h>
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Determine if a key is a letter.
|
||||||
|
@return true if @a keycode is a letter, and not a control
|
||||||
|
or modifier key. E.g., the letter 'b' is, where the Esc key ( BTKey_Escape ) is not.
|
||||||
|
*/
|
||||||
|
extern BOOL BTKeyIsAlpha( int );
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Determine if a key is a GLUT special key. ( arrow, F-Keys, etc )
|
||||||
|
*/
|
||||||
|
extern BOOL BTKeyIsSpecial( int keycode );
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Convert an OS X keycode to GLUT Special key representation
|
||||||
|
*/
|
||||||
|
extern int BTKeyTranslateKeyCodeToSpecial( int );
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
128
Extras/AllBulletDemosOSX/src/toolkit/BTGLUTKeyAdapter.m
Normal file
128
Extras/AllBulletDemosOSX/src/toolkit/BTGLUTKeyAdapter.m
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "BTGLUTKeyAdapter.h"
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
BOOL BTKeyIsAlpha( int key )
|
||||||
|
{
|
||||||
|
return !BTKeyIsSpecial( key );
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL BTKeyIsSpecial( int keycode )
|
||||||
|
{
|
||||||
|
BOOL ret = NO;
|
||||||
|
switch( keycode )
|
||||||
|
{
|
||||||
|
case NSUpArrowFunctionKey:
|
||||||
|
case NSDownArrowFunctionKey:
|
||||||
|
case NSLeftArrowFunctionKey:
|
||||||
|
case NSRightArrowFunctionKey:
|
||||||
|
case NSF1FunctionKey:
|
||||||
|
case NSF2FunctionKey:
|
||||||
|
case NSF3FunctionKey:
|
||||||
|
case NSF4FunctionKey:
|
||||||
|
case NSF5FunctionKey:
|
||||||
|
case NSF6FunctionKey:
|
||||||
|
case NSF7FunctionKey:
|
||||||
|
case NSF8FunctionKey:
|
||||||
|
case NSF9FunctionKey:
|
||||||
|
case NSF10FunctionKey:
|
||||||
|
case NSF11FunctionKey:
|
||||||
|
case NSF12FunctionKey:
|
||||||
|
ret = YES;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int BTKeyTranslateKeyCodeToSpecial( int kc )
|
||||||
|
{
|
||||||
|
int ret = kc;
|
||||||
|
switch( kc )
|
||||||
|
{
|
||||||
|
case NSUpArrowFunctionKey:
|
||||||
|
ret = GLUT_KEY_UP;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSDownArrowFunctionKey:
|
||||||
|
ret = GLUT_KEY_DOWN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSLeftArrowFunctionKey:
|
||||||
|
ret = GLUT_KEY_LEFT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSRightArrowFunctionKey:
|
||||||
|
ret = GLUT_KEY_RIGHT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSF1FunctionKey:
|
||||||
|
ret = GLUT_KEY_F1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSF2FunctionKey:
|
||||||
|
ret = GLUT_KEY_F2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSF3FunctionKey:
|
||||||
|
ret = GLUT_KEY_F3;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSF4FunctionKey:
|
||||||
|
ret = GLUT_KEY_F4;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSF5FunctionKey:
|
||||||
|
ret = GLUT_KEY_F5;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSF6FunctionKey:
|
||||||
|
ret = GLUT_KEY_F6;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSF7FunctionKey:
|
||||||
|
ret = GLUT_KEY_F7;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSF8FunctionKey:
|
||||||
|
ret = GLUT_KEY_F8;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSF9FunctionKey:
|
||||||
|
ret = GLUT_KEY_F9;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSF10FunctionKey:
|
||||||
|
ret = GLUT_KEY_F10;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSF11FunctionKey:
|
||||||
|
ret = GLUT_KEY_F11;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NSF12FunctionKey:
|
||||||
|
ret = GLUT_KEY_F12;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
|
||||||
|
@protocol BTOpenGLDisplayDelegate
|
||||||
|
|
||||||
|
- (void) contextCreated;
|
||||||
|
- (void) contextWillBeDestroyed;
|
||||||
|
- (void) contextWillResize;
|
||||||
|
- (void) contextResized: (NSSize) newSize;
|
||||||
|
- (void) contextDidResize;
|
||||||
|
- (void) contextStateInvalidated;
|
||||||
|
|
||||||
|
- (void) display: (float) deltaT;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// ASCII keypresses
|
||||||
|
|
||||||
|
- (void) keyPressed: (unsigned char) key;
|
||||||
|
- (void) keyReleased: (unsigned char) key;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// GLUT Special Keys, such as GLUT_KEY_LEFT ( "left arrow key" )
|
||||||
|
|
||||||
|
- (void) specialKeyPressed: (unsigned) GLUTKey;
|
||||||
|
- (void) specialKeyReleased: (unsigned) GLUTKey;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// Mouse. button is GLUT_LEFT_MOUSE, GLUT_RIGHT_MOUSE, etc.
|
||||||
|
|
||||||
|
- (void) mouseButtonPressed: (unsigned) mouseButton;
|
||||||
|
- (void) mouseButtonReleased: (unsigned) mouseButton;
|
||||||
|
- (void) mouseMoved: (NSPoint) delta;
|
||||||
|
- (void) newMousePosition: (NSPoint) newMousePosition;
|
||||||
|
- (void) scrollWheel: (NSPoint) delta;
|
||||||
|
@end
|
||||||
65
Extras/AllBulletDemosOSX/src/toolkit/BTOpenGLView.h
Normal file
65
Extras/AllBulletDemosOSX/src/toolkit/BTOpenGLView.h
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#import <OpenGL/OpenGL.h>
|
||||||
|
#import "BTOpenGLDisplayDelegate.h"
|
||||||
|
|
||||||
|
@interface BTOpenGLView : NSView
|
||||||
|
{
|
||||||
|
IBOutlet id <BTOpenGLDisplayDelegate> _delegate;
|
||||||
|
|
||||||
|
BOOL _firstFrame,
|
||||||
|
_setupBoundsChangeNotification,
|
||||||
|
_isFullScreen,
|
||||||
|
_multisample,
|
||||||
|
_vblSync,
|
||||||
|
_suppressResize;
|
||||||
|
|
||||||
|
NSOpenGLContext *_windowedContext;
|
||||||
|
|
||||||
|
unsigned int _modifierFlags;
|
||||||
|
|
||||||
|
float _interval,
|
||||||
|
_currentFPS;
|
||||||
|
|
||||||
|
double _lastFrameTime;
|
||||||
|
|
||||||
|
NSWindow *_fullscreenWindow,
|
||||||
|
*_windowedWindow;
|
||||||
|
|
||||||
|
NSTimer *_timer;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setDelegate: (id <BTOpenGLDisplayDelegate>) delegate;
|
||||||
|
- (id <BTOpenGLDisplayDelegate>) delegate;
|
||||||
|
|
||||||
|
- (void) setTargetFPS: (float) fps;
|
||||||
|
- (float) targetFPS;
|
||||||
|
- (float) currentFPS;
|
||||||
|
|
||||||
|
- (void) setFullscreen: (BOOL) yesno;
|
||||||
|
- (BOOL) fullscreen;
|
||||||
|
|
||||||
|
- (void) setMultisampleRendering: (BOOL) multisample;
|
||||||
|
- (BOOL) multisampleRendering;
|
||||||
|
|
||||||
|
- (void) setVBLSync: (BOOL) sync;
|
||||||
|
- (BOOL) vblSync;
|
||||||
|
|
||||||
|
- (NSOpenGLContext*) openGLContext;
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
||||||
603
Extras/AllBulletDemosOSX/src/toolkit/BTOpenGLView.m
Normal file
603
Extras/AllBulletDemosOSX/src/toolkit/BTOpenGLView.m
Normal file
@@ -0,0 +1,603 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import "BTOpenGLView.h"
|
||||||
|
|
||||||
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
#import <OpenGL/OpenGL.h>
|
||||||
|
#import <Carbon/Carbon.h>
|
||||||
|
|
||||||
|
#import "BTFullScreenWindow.h"
|
||||||
|
#import "BTGLUTKeyAdapter.h"
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark Private Methods
|
||||||
|
|
||||||
|
@interface BTOpenGLView (Internal)
|
||||||
|
|
||||||
|
- (void) update;
|
||||||
|
- (void) boundsDidChange: (NSNotification *) notification;
|
||||||
|
- (void) setVBL: (BOOL*) vbl forContext: (NSOpenGLContext*) context;
|
||||||
|
- (void) setMultithreaded: (BOOL) mt;
|
||||||
|
- (NSOpenGLPixelFormat*) windowedPixelFormat: (BOOL*) antialias;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation BTOpenGLView
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark Bootstrap
|
||||||
|
|
||||||
|
- (id)initWithFrame:(NSRect)frameRect
|
||||||
|
{
|
||||||
|
self = [super initWithFrame:frameRect];
|
||||||
|
if (self == nil)
|
||||||
|
{
|
||||||
|
NSLog( @"BTOpenGLView::initWithFrame - Unable to init" );
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
_modifierFlags = 0;
|
||||||
|
_multisample = YES;
|
||||||
|
_vblSync = YES;
|
||||||
|
_firstFrame = YES;
|
||||||
|
_setupBoundsChangeNotification = NO;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Set up the windowed context -- it will be assigned to the
|
||||||
|
view later, not now.
|
||||||
|
*/
|
||||||
|
_windowedContext = [[NSOpenGLContext alloc] initWithFormat: [self windowedPixelFormat: &_multisample]
|
||||||
|
shareContext: nil];
|
||||||
|
|
||||||
|
[self setVBL: &_vblSync forContext: _windowedContext];
|
||||||
|
|
||||||
|
if (_windowedContext == nil)
|
||||||
|
{
|
||||||
|
NSLog(@"Got nil windowed context");
|
||||||
|
[self dealloc];
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Setup and start the update timer.
|
||||||
|
*/
|
||||||
|
_interval = 1.0 / 60.0;
|
||||||
|
_timer = [[NSTimer scheduledTimerWithTimeInterval: _interval
|
||||||
|
target: self
|
||||||
|
selector: @selector(update)
|
||||||
|
userInfo: nil
|
||||||
|
repeats: YES ] retain];
|
||||||
|
|
||||||
|
[[NSRunLoop currentRunLoop] addTimer: _timer forMode: NSEventTrackingRunLoopMode];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
[_timer invalidate];
|
||||||
|
[_timer release];
|
||||||
|
|
||||||
|
[_delegate contextWillBeDestroyed];
|
||||||
|
|
||||||
|
[_windowedContext release];
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||||
|
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) awakeFromNib
|
||||||
|
{
|
||||||
|
NSWindow *window = [self window];
|
||||||
|
[window setAcceptsMouseMovedEvents: YES];
|
||||||
|
[window makeFirstResponder: self];
|
||||||
|
[window setInitialFirstResponder: self];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)drawRect:(NSRect)rect
|
||||||
|
{
|
||||||
|
[self update];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark Public API
|
||||||
|
|
||||||
|
- (void) setDelegate: (id <BTOpenGLDisplayDelegate>) delegate
|
||||||
|
{
|
||||||
|
// we don't retain delegates
|
||||||
|
_delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id <BTOpenGLDisplayDelegate>) delegate
|
||||||
|
{
|
||||||
|
return _delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setTargetFPS: (float) fps
|
||||||
|
{
|
||||||
|
float newInterval = 1.0 / fps;
|
||||||
|
if ( ABS( newInterval - _interval ) > 1.0e-3 )
|
||||||
|
{
|
||||||
|
_interval = newInterval;
|
||||||
|
|
||||||
|
[_timer invalidate];
|
||||||
|
[_timer release];
|
||||||
|
|
||||||
|
_timer = [[NSTimer scheduledTimerWithTimeInterval: _interval
|
||||||
|
target: self
|
||||||
|
selector: @selector(update)
|
||||||
|
userInfo: nil
|
||||||
|
repeats: YES ] retain];
|
||||||
|
|
||||||
|
[[NSRunLoop currentRunLoop] addTimer: _timer forMode: NSEventTrackingRunLoopMode];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (float) targetFPS
|
||||||
|
{
|
||||||
|
return 1.0 / _interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (float) currentFPS
|
||||||
|
{
|
||||||
|
return _currentFPS;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setFullscreen: (BOOL) fullscreen
|
||||||
|
{
|
||||||
|
if ( fullscreen == _isFullScreen ) return;
|
||||||
|
|
||||||
|
_isFullScreen = fullscreen;
|
||||||
|
_suppressResize = YES;
|
||||||
|
|
||||||
|
if ( _isFullScreen )
|
||||||
|
{
|
||||||
|
_windowedWindow = [self window];
|
||||||
|
|
||||||
|
/*
|
||||||
|
Detach & retain the content view from the non-fullscreen window.
|
||||||
|
*/
|
||||||
|
|
||||||
|
NSView *contentView = [_windowedWindow contentView];
|
||||||
|
[contentView retain];
|
||||||
|
[contentView removeFromSuperviewWithoutNeedingDisplay];
|
||||||
|
|
||||||
|
/*
|
||||||
|
Create a fullscreen window, attach the content view,
|
||||||
|
and release the content view since the fullscreen window retained it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
_fullscreenWindow = [[BTFullScreenWindow alloc] initForScreen: [_windowedWindow screen]];
|
||||||
|
[_fullscreenWindow setContentView: contentView ];
|
||||||
|
[_fullscreenWindow makeKeyAndOrderFront:nil];
|
||||||
|
[contentView release];
|
||||||
|
|
||||||
|
/*
|
||||||
|
Hide the old window
|
||||||
|
*/
|
||||||
|
[_windowedWindow orderOut: nil];
|
||||||
|
|
||||||
|
/*
|
||||||
|
Now, use the SetSystemUIMode API to auto-hide the dock
|
||||||
|
*/
|
||||||
|
|
||||||
|
OSStatus error = SetSystemUIMode( kUIModeContentSuppressed, 0 );
|
||||||
|
if ( error != noErr)
|
||||||
|
{
|
||||||
|
NSLog(@"Error couldn't set SystemUIMode: %ld", (long)error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if ( _fullscreenWindow )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Detach and retain the content view from the fullscreen window
|
||||||
|
*/
|
||||||
|
NSView *contentView = [_fullscreenWindow contentView];
|
||||||
|
[contentView retain];
|
||||||
|
[contentView removeFromSuperviewWithoutNeedingDisplay];
|
||||||
|
|
||||||
|
/*
|
||||||
|
Reparent the content view to the non-fullscreen window,
|
||||||
|
and release it since it's now owned by the non-fullscreen window
|
||||||
|
*/
|
||||||
|
[_windowedWindow setContentView: contentView];
|
||||||
|
[contentView release];
|
||||||
|
|
||||||
|
[_windowedWindow makeKeyAndOrderFront: nil];
|
||||||
|
|
||||||
|
/*
|
||||||
|
Release the fullscreen window
|
||||||
|
*/
|
||||||
|
[_fullscreenWindow orderOut: nil];
|
||||||
|
[_fullscreenWindow release];
|
||||||
|
_fullscreenWindow = nil;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Restore dock's normal behaior
|
||||||
|
*/
|
||||||
|
|
||||||
|
OSStatus error = SetSystemUIMode( kUIModeNormal, 0 );
|
||||||
|
if ( error != noErr)
|
||||||
|
{
|
||||||
|
NSLog(@"Error couldn't set SystemUIMode: %ld", (long)error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_suppressResize = NO;
|
||||||
|
|
||||||
|
[self boundsDidChange: nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) fullscreen
|
||||||
|
{
|
||||||
|
return _isFullScreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setMultisampleRendering: (BOOL) multisample
|
||||||
|
{
|
||||||
|
if ( multisample == _multisample ) return;
|
||||||
|
|
||||||
|
_multisample = multisample;
|
||||||
|
_firstFrame = YES;
|
||||||
|
|
||||||
|
|
||||||
|
NSOpenGLContext *oldWindowedContext = _windowedContext;
|
||||||
|
_windowedContext = [[NSOpenGLContext alloc] initWithFormat: [self windowedPixelFormat: &_multisample]
|
||||||
|
shareContext: oldWindowedContext ];
|
||||||
|
|
||||||
|
[self setVBL: &_vblSync forContext: _windowedContext];
|
||||||
|
|
||||||
|
[oldWindowedContext release];
|
||||||
|
[_windowedContext setView: self];
|
||||||
|
[_windowedContext makeCurrentContext];
|
||||||
|
[_windowedContext update];
|
||||||
|
[self update];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) multisampleRendering
|
||||||
|
{
|
||||||
|
return _multisample;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setVBLSync: (BOOL) sync
|
||||||
|
{
|
||||||
|
if ( sync == _vblSync ) return;
|
||||||
|
|
||||||
|
_vblSync = sync;
|
||||||
|
[self setVBL: &_vblSync forContext: _windowedContext];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) vblSync
|
||||||
|
{
|
||||||
|
return _vblSync;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSOpenGLContext *) openGLContext
|
||||||
|
{
|
||||||
|
return _windowedContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark NSView Overrides
|
||||||
|
|
||||||
|
- (BOOL) isOpaque
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) acceptsFirstResponder
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) keyDown:(NSEvent *)theEvent
|
||||||
|
{
|
||||||
|
int key = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
|
||||||
|
|
||||||
|
if ( BTKeyIsAlpha( key ))
|
||||||
|
{
|
||||||
|
[ _delegate keyPressed: key ];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[_delegate specialKeyPressed: BTKeyTranslateKeyCodeToSpecial( key )];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) keyUp:(NSEvent *)theEvent
|
||||||
|
{
|
||||||
|
int key = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
|
||||||
|
|
||||||
|
if ( BTKeyIsAlpha( key ))
|
||||||
|
{
|
||||||
|
[ _delegate keyReleased: key ];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[_delegate specialKeyReleased: BTKeyTranslateKeyCodeToSpecial( key )];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) mouseDown: (NSEvent *) event
|
||||||
|
{
|
||||||
|
int button = GLUT_LEFT_BUTTON;
|
||||||
|
switch( [event buttonNumber] )
|
||||||
|
{
|
||||||
|
case 0: button = GLUT_LEFT_BUTTON; break;
|
||||||
|
case 1: button = GLUT_RIGHT_BUTTON; break;
|
||||||
|
case 2: button = GLUT_MIDDLE_BUTTON; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( _modifierFlags & NSControlKeyMask ) button = GLUT_RIGHT_BUTTON;
|
||||||
|
else if ( _modifierFlags & NSAlternateKeyMask ) button = GLUT_MIDDLE_BUTTON;
|
||||||
|
|
||||||
|
[_delegate mouseButtonPressed: button];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) mouseUp: (NSEvent *) event
|
||||||
|
{
|
||||||
|
int button = GLUT_LEFT_BUTTON;
|
||||||
|
switch( [event buttonNumber] )
|
||||||
|
{
|
||||||
|
case 0: button = GLUT_LEFT_BUTTON; break;
|
||||||
|
case 1: button = GLUT_RIGHT_BUTTON; break;
|
||||||
|
case 2: button = GLUT_MIDDLE_BUTTON; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( _modifierFlags & NSControlKeyMask ) button = GLUT_RIGHT_BUTTON;
|
||||||
|
else if ( _modifierFlags & NSAlternateKeyMask ) button = GLUT_MIDDLE_BUTTON;
|
||||||
|
|
||||||
|
[_delegate mouseButtonReleased: button];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) mouseMoved: (NSEvent *) event
|
||||||
|
{
|
||||||
|
float dx = [event deltaX],
|
||||||
|
dy = [event deltaY];
|
||||||
|
|
||||||
|
NSPoint locationInView = [self convertPoint: [event locationInWindow] fromView: nil ];
|
||||||
|
|
||||||
|
[_delegate mouseMoved: NSMakePoint( dx, dy )];
|
||||||
|
[_delegate newMousePosition: locationInView];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) mouseDragged: (NSEvent *) event
|
||||||
|
{
|
||||||
|
[self mouseMoved: event];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) scrollWheel: (NSEvent *) event
|
||||||
|
{
|
||||||
|
float dx = [event deltaX],
|
||||||
|
dy = [event deltaY];
|
||||||
|
|
||||||
|
[_delegate scrollWheel: NSMakePoint( dx, dy )];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)flagsChanged:(NSEvent *) event
|
||||||
|
{
|
||||||
|
_modifierFlags = [event modifierFlags];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark Private
|
||||||
|
|
||||||
|
- (void) update
|
||||||
|
{
|
||||||
|
if ( !_setupBoundsChangeNotification )
|
||||||
|
{
|
||||||
|
_setupBoundsChangeNotification = YES;
|
||||||
|
|
||||||
|
/*
|
||||||
|
This is hacky, but basically, we can't handle bounds-changing
|
||||||
|
ops correctly until everything's set up correctly.
|
||||||
|
*/
|
||||||
|
[self setPostsBoundsChangedNotifications:YES];
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver: self
|
||||||
|
selector: @selector( boundsDidChange: )
|
||||||
|
name: NSViewFrameDidChangeNotification
|
||||||
|
object: nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_firstFrame)
|
||||||
|
{
|
||||||
|
[_windowedContext setView:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
[_windowedContext makeCurrentContext];
|
||||||
|
|
||||||
|
if (_firstFrame)
|
||||||
|
{
|
||||||
|
_firstFrame = NO;
|
||||||
|
|
||||||
|
[_delegate contextCreated];
|
||||||
|
|
||||||
|
if ( _multisample )
|
||||||
|
{
|
||||||
|
glEnable (GL_MULTISAMPLE_ARB);
|
||||||
|
// this fucks up text rendering, on nVIDIA, at least
|
||||||
|
//glHint (GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glDisable( GL_MULTISAMPLE_ARB );
|
||||||
|
}
|
||||||
|
|
||||||
|
[self setMultithreaded: NO];
|
||||||
|
|
||||||
|
NSSize contextSize;
|
||||||
|
if ( _isFullScreen )
|
||||||
|
{
|
||||||
|
contextSize.width = CGDisplayPixelsWide(kCGDirectMainDisplay);
|
||||||
|
contextSize.height = CGDisplayPixelsHigh(kCGDirectMainDisplay);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
contextSize = [self bounds].size;
|
||||||
|
}
|
||||||
|
|
||||||
|
[_delegate contextWillResize];
|
||||||
|
[_delegate contextResized: contextSize];
|
||||||
|
[_delegate contextDidResize];
|
||||||
|
[_delegate contextStateInvalidated];
|
||||||
|
}
|
||||||
|
|
||||||
|
double now = CFAbsoluteTimeGetCurrent();
|
||||||
|
|
||||||
|
if ( _delegate) [_delegate display: now - _lastFrameTime];
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glClearColor( 0.5, 0.5, 0.5, 1 );
|
||||||
|
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastFrameTime = now;
|
||||||
|
|
||||||
|
|
||||||
|
[[NSOpenGLContext currentContext] flushBuffer];
|
||||||
|
|
||||||
|
/*
|
||||||
|
Now, update our FPS
|
||||||
|
*/
|
||||||
|
|
||||||
|
{
|
||||||
|
static unsigned int frameCounter = 1;
|
||||||
|
static double lastCheckTime = 0;
|
||||||
|
|
||||||
|
double elapsed = now - lastCheckTime;
|
||||||
|
if ( elapsed > 1.0 )
|
||||||
|
{
|
||||||
|
_currentFPS = (float) ( ((double) frameCounter ) / elapsed );
|
||||||
|
|
||||||
|
lastCheckTime = now;
|
||||||
|
frameCounter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
frameCounter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) boundsDidChange: (NSNotification *) notification
|
||||||
|
{
|
||||||
|
if ( _suppressResize ) return;
|
||||||
|
|
||||||
|
[_windowedContext setView:self];
|
||||||
|
[_windowedContext makeCurrentContext];
|
||||||
|
[_windowedContext update];
|
||||||
|
|
||||||
|
NSSize contextSize = [self bounds].size;
|
||||||
|
|
||||||
|
if ( _delegate )
|
||||||
|
{
|
||||||
|
[_delegate contextWillResize];
|
||||||
|
[_delegate contextResized: contextSize ];
|
||||||
|
[_delegate contextDidResize];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glViewport( 0, 0, (int) contextSize.width, (int) contextSize.height );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setVBL: (BOOL*) vbl forContext: (NSOpenGLContext*) context
|
||||||
|
{
|
||||||
|
GLint value = *vbl ? 1 : 0;
|
||||||
|
[context setValues: &value forParameter: NSOpenGLCPSwapInterval];
|
||||||
|
|
||||||
|
*vbl = value ? YES : NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setMultithreaded: (BOOL) mt
|
||||||
|
{
|
||||||
|
CGLError err = kCGLNoError;
|
||||||
|
CGLContextObj ctx = CGLGetCurrentContext();
|
||||||
|
|
||||||
|
// Enable Apple's multi-threaded GL engine -- it's generally useful for
|
||||||
|
// high vertex throughput. Not high fragment situations
|
||||||
|
|
||||||
|
if ( mt )
|
||||||
|
{
|
||||||
|
err = CGLEnable( ctx, kCGLCEMPEngine );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
err = CGLDisable( ctx, kCGLCEMPEngine );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err != kCGLNoError )
|
||||||
|
{
|
||||||
|
NSLog( @"BTOpenGLView -setMultithreaded: forContext: -- Unable to %s multithreaded GL",
|
||||||
|
mt ? "enable" : "disable" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSOpenGLPixelFormat*) windowedPixelFormat: (BOOL*) antialias
|
||||||
|
{
|
||||||
|
NSOpenGLPixelFormatAttribute aaAttrs[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAAccelerated,
|
||||||
|
NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)32,
|
||||||
|
NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)0,
|
||||||
|
NSOpenGLPFASingleRenderer,
|
||||||
|
NSOpenGLPFASampleBuffers, (NSOpenGLPixelFormatAttribute)( 1 ),
|
||||||
|
NSOpenGLPFASamples, (NSOpenGLPixelFormatAttribute)( 4 ),
|
||||||
|
NSOpenGLPFAScreenMask, (NSOpenGLPixelFormatAttribute) CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay),
|
||||||
|
NSOpenGLPFANoRecovery,
|
||||||
|
(NSOpenGLPixelFormatAttribute)0
|
||||||
|
};
|
||||||
|
|
||||||
|
NSOpenGLPixelFormatAttribute vanillaAttrs[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFADoubleBuffer,
|
||||||
|
NSOpenGLPFAAccelerated,
|
||||||
|
NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)32,
|
||||||
|
NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)0,
|
||||||
|
NSOpenGLPFASingleRenderer,
|
||||||
|
NSOpenGLPFASampleBuffers, (NSOpenGLPixelFormatAttribute)( 0 ),
|
||||||
|
NSOpenGLPFASamples, (NSOpenGLPixelFormatAttribute)( 0 ),
|
||||||
|
NSOpenGLPFAScreenMask, (NSOpenGLPixelFormatAttribute) CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay),
|
||||||
|
NSOpenGLPFANoRecovery,
|
||||||
|
(NSOpenGLPixelFormatAttribute)0
|
||||||
|
};
|
||||||
|
|
||||||
|
NSOpenGLPixelFormat* fmt = 0;
|
||||||
|
|
||||||
|
if ( *antialias )
|
||||||
|
{
|
||||||
|
fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: (NSOpenGLPixelFormatAttribute*) aaAttrs];
|
||||||
|
if ( nil == fmt )
|
||||||
|
{
|
||||||
|
*antialias = NO;
|
||||||
|
fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: (NSOpenGLPixelFormatAttribute*) vanillaAttrs];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: (NSOpenGLPixelFormatAttribute*) vanillaAttrs];
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
||||||
Reference in New Issue
Block a user