and some more iphone code from http://github.com/zodttd/wolf3d/tree/master/wolf3d/newCode/iphone/ (thank you John Carmack!). will clean that up soon

This commit is contained in:
Albert Zeyer
2009-11-15 16:46:33 +01:00
parent 5d4ddf5a8f
commit 2b4fbe232a
15 changed files with 6018 additions and 0 deletions

58
src/sdl/iphone/EAGLView.h Executable file
View File

@@ -0,0 +1,58 @@
/*
Copyright (C) 2009 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#import <UIKit/UIKit.h>
#import <OpenGLES/EAGL.h>
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
/*
This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
The view content is basically an EAGL surface you render your OpenGL scene into.
Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
*/
@interface EAGLView : UIView <UITextFieldDelegate> {
@public
UITextField *textField;
@private
/* The pixel dimensions of the backbuffer */
GLint backingWidth;
GLint backingHeight;
EAGLContext *context;
/* OpenGL names for the renderbuffer and framebuffers used to render to this view */
GLuint viewRenderbuffer, viewFramebuffer;
/* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
GLuint depthRenderbuffer;
NSTimer *animationTimer;
NSTimeInterval animationInterval;
}
@property NSTimeInterval animationInterval;
- (void)drawView;
@end

293
src/sdl/iphone/EAGLView.m Executable file
View File

@@ -0,0 +1,293 @@
//
// EAGLView.m
// wolf3d
//
// Created by Cass Everitt on 2/20/09.
// Copyright Id Software 2009. All rights reserved.
//
#import <QuartzCore/QuartzCore.h>
#import <OpenGLES/EAGLDrawable.h>
#import "EAGLView.h"
#import "wolf3dAppDelegate.h"
#include "wolfiphone.h"
EAGLView *eaglview;
// A class extension to declare private methods
@interface EAGLView ()
@property (nonatomic, retain) EAGLContext *context;
@property (nonatomic, assign) NSTimer *animationTimer;
- (void) destroyFramebuffer;
- (void) swapBuffers;
@end
@implementation EAGLView
@synthesize context;
@synthesize animationTimer;
@synthesize animationInterval;
// You must implement this method
+ (Class)layerClass {
return [CAEAGLLayer class];
}
//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:
- (id)initWithCoder:(NSCoder*)coder {
self = [super initWithCoder:coder];
eaglview = self;
// Get the layer
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
eaglLayer.opaque = YES;
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO],
kEAGLDrawablePropertyRetainedBacking,
kEAGLColorFormatRGB565,
/* kEAGLColorFormatRGBA8, */
kEAGLDrawablePropertyColorFormat,
nil];
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
assert( context );
if ( ![EAGLContext setCurrentContext:context]) {
[self release];
return nil;
}
self.multipleTouchEnabled = true;
[EAGLContext setCurrentContext:context];
glGenFramebuffersOES(1, &viewFramebuffer);
glGenRenderbuffersOES(1, &viewRenderbuffer);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
glGenRenderbuffersOES(1, &depthRenderbuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);
if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
}
self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.032
target:self
selector:@selector(drawView)
userInfo:nil repeats:YES];
return self;
}
- (void)drawView {
int start, end;
[EAGLContext setCurrentContext:context];
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
[ (wolf3dAppDelegate *)[UIApplication sharedApplication].delegate restartAccelerometerIfNeeded];
start = Sys_Milliseconds();
extern void iphoneFrame();
iphoneFrame();
end = Sys_Milliseconds();
// Com_Printf( "msec: %i\n", end - start );
[self swapBuffers];
}
void GLimp_EndFrame() {
[eaglview swapBuffers];
}
- (void)swapBuffers {
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
}
- (void)layoutSubviews {
[self drawView];
}
- (void)destroyFramebuffer {
glDeleteFramebuffersOES(1, &viewFramebuffer);
viewFramebuffer = 0;
glDeleteRenderbuffersOES(1, &viewRenderbuffer);
viewRenderbuffer = 0;
glDeleteRenderbuffersOES(1, &depthRenderbuffer);
depthRenderbuffer = 0;
}
- (void)dealloc {
if ([EAGLContext currentContext] == context) {
[EAGLContext setCurrentContext:nil];
}
[context release];
[super dealloc];
}
void WolfensteinTouches( int numTouches, int touches[16] );
- (void) handleTouches:(NSSet*)touches withEvent:(UIEvent*)event {
int touchCount = 0;
int points[16];
static int previousTouchCount;
NSSet *t = [event allTouches];
for (UITouch *myTouch in t)
{
CGPoint touchLocation = [myTouch locationInView:nil];
points[ 2 * touchCount + 0 ] = touchLocation.x;
points[ 2 * touchCount + 1 ] = touchLocation.y; // ( h - 1 ) - touchLocation.y;
touchCount++;
if (myTouch.phase == UITouchPhaseBegan) {
// new touch handler
}
if (myTouch.phase == UITouchPhaseMoved) {
// touch moved handler
}
if (myTouch.phase == UITouchPhaseEnded) {
touchCount--;
}
}
// toggle the console with four touches
if ( touchCount == 4 && previousTouchCount != 4 ) {
if ( textField == nil ) {
void iphoneActivateConsole();
textField = [UITextField alloc];
[textField initWithFrame:CGRectMake( 0, 0, 20, 20 ) ];
[self addSubview:textField];
[textField release];
textField.hidden = true;
textField.delegate = self;
textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
[textField becomeFirstResponder];
iphoneActivateConsole();
} else {
void iphoneDeactivateConsole();
[textField resignFirstResponder];
[textField removeFromSuperview];
textField = nil;
iphoneDeactivateConsole();
}
}
previousTouchCount = touchCount;
WolfensteinTouches( touchCount, points );
}
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
[self handleTouches:touches withEvent:event];
}
- (void) touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
[self handleTouches:touches withEvent:event];
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
[self handleTouches:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[self handleTouches:touches withEvent:event];
}
@end
@implementation EAGLView (UITextFieldDelegate)
- (BOOL)textFieldShouldReturn:(UITextField *)_textField
{
void iphoneExecuteCommandLine();
iphoneExecuteCommandLine();
return YES;
}
@end
const char * GetCurrentCommandLine() {
assert( eaglview->textField != nil );
return [ eaglview->textField.text UTF8String ];
}
void SetCurrentCommandLine( const char * str) {
assert( eaglview->textField != nil );
eaglview->textField.text = [ NSString stringWithUTF8String: str ];
}
void OpenURL( const char *url ) {
Com_Printf( "OpenURL char *: %s\n", url );
NSString *nss = [NSString stringWithCString: url encoding: NSASCIIStringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: nss]];
}
void iPhoneLoadJPG( W8* jpegData, int jpegBytes, W8 **pic, W16 *width, W16 *height, W16 *bytes ) {
CFDataRef data;
int dataBytes = 0;
UIImage *img = [ UIImage imageWithData: [NSData dataWithBytes: (const char *)jpegData length: (NSUInteger)jpegBytes ] ];
int imgBytes;
*width = img.size.width;
*height = img.size.height;
imgBytes = (int)(*width) * (int)(*height) * 4;
data = CGDataProviderCopyData( CGImageGetDataProvider( img.CGImage ) );
dataBytes = CFDataGetLength( data );
*bytes = 4;
if ( dataBytes > imgBytes ) {
*pic = NULL;
return;
}
*pic = (W8 *)malloc( imgBytes );
CFDataGetBytes( data, CFRangeMake(0, dataBytes), *pic );
// convert BGRA to RGBA
for ( imgBytes = 0; imgBytes < dataBytes; imgBytes+= 4 ) {
W8 tmp = pic[0][ imgBytes + 0 ];
pic[0][ imgBytes + 0 ] = pic[0][ imgBytes + 2 ];
pic[0][ imgBytes + 2 ] = tmp;
}
}

36
src/sdl/iphone/Info.plist Executable file
View File

@@ -0,0 +1,36 @@
<?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></key>
<string></string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>${PRODUCT_NAME}_icon.png</string>
<key>CFBundleIdentifier</key>
<string>com.zodttd.${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>LSRequiresIPhoneOS</key>
<true/>
<key>NSMainNibFile</key>
<string>MainWindow</string>
<key>UIInterfaceOrientation</key>
<string>UIInterfaceOrientationPortrait</string>
<key>UIStatusBarHidden</key>
<true/>
</dict>
</plist>

223
src/sdl/iphone/MainWindow.xib Executable file
View File

@@ -0,0 +1,223 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.02">
<data>
<int key="IBDocument.SystemTarget">528</int>
<string key="IBDocument.SystemVersion">9E17</string>
<string key="IBDocument.InterfaceBuilderVersion">672</string>
<string key="IBDocument.AppKitVersion">949.33</string>
<string key="IBDocument.HIToolboxVersion">352.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="8"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBProxyObject" id="841351856">
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
</object>
<object class="IBProxyObject" id="191355593">
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
</object>
<object class="IBUICustomObject" id="664661524"/>
<object class="IBUIWindow" id="380026005">
<reference key="NSNextResponder"/>
<int key="NSvFlags">1316</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBUIView" id="773737154">
<reference key="NSNextResponder" ref="380026005"/>
<int key="NSvFlags">1298</int>
<string key="NSFrameSize">{320, 480}</string>
<reference key="NSSuperview" ref="380026005"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
<object class="NSColorSpace" key="NSCustomColorSpace">
<int key="NSID">2</int>
</object>
</object>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
</object>
</object>
<object class="NSPSMatrix" key="NSFrameMatrix"/>
<string key="NSFrameSize">{320, 480}</string>
<reference key="NSSuperview"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MSAxIDEAA</bytes>
</object>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<bool key="IBUIVisibleAtLaunch">YES</bool>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="664661524"/>
</object>
<int key="connectionID">4</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">window</string>
<reference key="source" ref="664661524"/>
<reference key="destination" ref="380026005"/>
</object>
<int key="connectionID">5</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">glView</string>
<reference key="source" ref="664661524"/>
<reference key="destination" ref="773737154"/>
</object>
<int key="connectionID">9</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<object class="NSArray" key="object" id="957960031">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">2</int>
<reference key="object" ref="380026005"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="773737154"/>
</object>
<reference key="parent" ref="957960031"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="841351856"/>
<reference key="parent" ref="957960031"/>
<string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">3</int>
<reference key="object" ref="664661524"/>
<reference key="parent" ref="957960031"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">8</int>
<reference key="object" ref="773737154"/>
<reference key="parent" ref="380026005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="191355593"/>
<reference key="parent" ref="957960031"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.CustomClassName</string>
<string>-2.CustomClassName</string>
<string>2.IBAttributePlaceholdersKey</string>
<string>2.IBEditorWindowLastContentRect</string>
<string>2.IBPluginDependency</string>
<string>3.CustomClassName</string>
<string>3.IBPluginDependency</string>
<string>8.CustomClassName</string>
<string>8.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>UIApplication</string>
<string>UIResponder</string>
<object class="NSMutableDictionary">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<string>{{500, 343}, {320, 480}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>wolf3dAppDelegate</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>EAGLView</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">9</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">EAGLView</string>
<string key="superclassName">UIView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Classes/EAGLView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">wolf3dAppDelegate</string>
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>glView</string>
<string>window</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>EAGLView</string>
<string>UIWindow</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Classes/wolf3dAppDelegate.h</string>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.LastKnownRelativeProjectPath">wolf3d.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>

134
src/sdl/iphone/gles_glue.c Executable file
View File

@@ -0,0 +1,134 @@
/*
Copyright (C) 2009 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "wolfiphone.h"
//int registration_sequence;
#include "iphone_qgl.h"
#ifdef QGL_LOG_GL_CALLS
unsigned int QGLLogGLCalls = 1;
FILE *QGLDebugFile(void) {
return stdout;
}
#endif
void QGLCheckError(const char *message) {
GLint err = qglGetError();
if ( err != GL_NO_ERROR ) {
printf( "GL ERROR %d from %s\n", err, message );
}
}
unsigned int QGLBeginStarted = 0;
struct Vertex {
float xyz[3];
float st[2];
GLubyte c[4];
};
#define MAX_VERTS 16384
typedef struct Vertex Vertex;
Vertex immediate[ MAX_VERTS ];
Vertex vab;
short quad_indexes[MAX_VERTS * 3 / 2 ];
int curr_vertex;
GLenum curr_prim;
void InitImmediateModeGL() {
for ( int i = 0; i < MAX_VERTS * 3 / 2; i+=6 ) {
int q = i / 6 * 4;
quad_indexes[ i + 0 ] = q + 0;
quad_indexes[ i + 1 ] = q + 1;
quad_indexes[ i + 2 ] = q + 2;
quad_indexes[ i + 3 ] = q + 0;
quad_indexes[ i + 4 ] = q + 2;
quad_indexes[ i + 5 ] = q + 3;
}
qglVertexPointer( 3, GL_FLOAT, sizeof( Vertex ), immediate[ 0 ].xyz );
qglTexCoordPointer( 2, GL_FLOAT, sizeof( Vertex ), immediate[ 0 ].st );
qglColorPointer( 4, GL_UNSIGNED_BYTE, sizeof( Vertex ), immediate[ 0 ].c );
qglEnableClientState( GL_VERTEX_ARRAY );
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglEnableClientState( GL_COLOR_ARRAY );
}
void pfglBegin( GLenum prim ) {
curr_vertex = 0;
curr_prim = prim;
}
void pfglVertex3f( float x, float y, float z ) {
assert( curr_vertex < MAX_VERTS );
vab.xyz[ 0 ] = x;
vab.xyz[ 1 ] = y;
vab.xyz[ 2 ] = z;
immediate[ curr_vertex ] = vab;
curr_vertex++;
}
void pfglVertex2i( GLint x, GLint y ) {
assert( curr_vertex < MAX_VERTS );
vab.xyz[ 0 ] = (float)x;
vab.xyz[ 1 ] = (float)y;
vab.xyz[ 2 ] = 0.0f;
immediate[ curr_vertex ] = vab;
curr_vertex++;
}
void pfglColor4ub( GLubyte r, GLubyte g, GLubyte b, GLubyte a ) {
vab.c[ 0 ] = r;
vab.c[ 1 ] = g;
vab.c[ 2 ] = b;
vab.c[ 3 ] = a;
}
void pfglColor4f( GLfloat r, GLfloat g, GLfloat b, GLfloat a ) {
vab.c[ 0 ] = (GLubyte) ( r * 255 );
vab.c[ 1 ] = (GLubyte) ( g * 255 );
vab.c[ 2 ] = (GLubyte) ( b * 255 );
vab.c[ 3 ] = (GLubyte) ( a * 255 );
}
void pfglTexCoord2i( GLint s, GLint t ) {
vab.st[ 0 ] = (float)s;
vab.st[ 1 ] = (float)t;
}
void pfglTexCoord2f( GLfloat s, GLfloat t ) {
vab.st[ 0 ] = s;
vab.st[ 1 ] = t;
}
void pfglEnd() {
if ( curr_prim == GL_QUADS ) {
qglDrawElements( GL_TRIANGLES, curr_vertex / 4 * 6, GL_UNSIGNED_SHORT, quad_indexes );
} else {
qglDrawArrays( curr_prim, 0, curr_vertex );
}
curr_vertex = 0;
curr_prim = 0;
}

77
src/sdl/iphone/gles_glue.h Executable file
View File

@@ -0,0 +1,77 @@
#ifndef __GLES_GLUE_H__
#define __GLES_GLUE_H__
#include "iphone_qgl.h"
typedef GLfloat GLdouble;
#define pfglEnable qglEnable
#define pfglDisable qglDisable
#define pfglActiveTextureARB qglActiveTexture
#define pfglGenTextures qglGenTextures
#define pfglDeleteTextures qglDeleteTextures
#define pfglDepthRange qglDepthRangef
#define pfglDepthFunc qglDepthFunc
#define pfglCullFace qglCullFace
#define pfglColor3f(r,g,b) pfglColor4f(r,g,b,1.0f)
#define pfglColor3ubv(c) pfglColor4ub( (c)[0], (c)[1], (c)[2], 255 )
#define pfglColor4ubv(c) pfglColor4ub( (c)[0], (c)[1], (c)[2], (c)[3] )
#define pfglBlendFunc qglBlendFunc
#define pfglClearColor qglClearColor
#define pfglClear qglClear
#define pfglDrawBuffer(buffer)
#define pfglLineWidth qglLineWidth
#define pfglBindTexture qglBindTexture
#define pfglTexParameteri qglTexParameteri
#define pfglTexParameterf qglTexParameterf
#define pfglTexImage2D qglTexImage2D
#define pfglFrustum qglFrustumf
#define pfglOrtho qglOrthof
#define pfglLoadIdentity qglLoadIdentity
#define pfglMatrixMode qglMatrixMode
#define pfglShadeModel qglShadeModel
#define pfglRotatef qglRotatef
#define pfglTranslatef qglTranslatef
#define pfglReadPixels qglReadPixels
#define pfglAlphaFunc qglAlphaFunc
#define pfglViewport qglViewport
#define pfglTexEnvi qglTexEnvi
#define pfglClientActiveTextureARB qglClientActiveTexture
#define pfglGetIntegerv qglGetIntegerv
#define pfglGetString qglGetString
#define pfglGetError qglGetError
#define GL_QUADS 888
/*
void GLimp_BeginFrame();
void GLimp_EndFrame( void );
_boolean GLimp_Init( void *hinstance, void *hWnd );
void GLimp_Shutdown( void );
int GLimp_SetMode( int *pwidth, int *pheight, int mode, _boolean fullscreen );
void GLimp_AppActivate( _boolean active );
*/
#ifdef __cplusplus
extern "C" {
#endif
void pfglBegin( GLenum prim );
void pfglVertex3f( float x, float y, float z );
void pfglVertex2i( GLint x, GLint y );
void pfglColor4ub( GLubyte r, GLubyte g, GLubyte b, GLubyte a );
void pfglColor4f( GLfloat r, GLfloat g, GLfloat b, GLfloat a );
void pfglTexCoord2i( GLint s, GLint t );
void pfglTexCoord2f( GLfloat s, GLfloat t );
void pfglEnd();
#ifdef __cplusplus
}
#endif
#endif

1025
src/sdl/iphone/iphone_loop.c Executable file

File diff suppressed because it is too large Load Diff

244
src/sdl/iphone/iphone_main.c Executable file
View File

@@ -0,0 +1,244 @@
/*
Copyright (C) 2004-2005 Michael Liebscher <johnnycanuck@users.sourceforge.net>
Copyright (C) 1997-2001 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
* unix_main.c: UNIX interface to application.
*
* Author: Michael Liebscher <johnnycanuck@users.sourceforge.net>
*
* Acknowledgement:
* This code was derived from Quake II, and was originally
* written by Id Software, Inc.
*
*/
#include "../wolfiphone.h"
cvar_t *controlScheme;
cvar_t *sensitivity;
cvar_t *stickSize;
cvar_t *stickTurnBase;
cvar_t *stickTurnScale;
cvar_t *stickMoveBase;
cvar_t *stickMoveScale;
cvar_t *stickDeadBand;
cvar_t *tiltTurn;
cvar_t *tiltMove;
cvar_t *tiltDeadBand;
cvar_t *tiltAverages;
cvar_t *tiltFire;
cvar_t *music;
cvar_t *showTilt;
cvar_t *cropSprites;
cvar_t *blends;
cvar_t *gunFrame;
cvar_t *slowAI;
W32 sys_frame_time;
void Sys_Error( const char *format, ... )
{
va_list argptr;
char string[ 1024 ];
va_start( argptr, format );
(void)vsnprintf( string, sizeof( string ), format, argptr );
va_end( argptr );
fprintf( stderr, "Error: %s\n", string );
_exit( 1 );
}
void Sys_Quit (void)
{
_exit( 0 );
}
void Sys_SendKeyEvents (void)
{
}
char *Sys_GetClipboardData( void )
{
return NULL;
}
void Reset_f() {
memset( &currentMap, 0, sizeof( currentMap ) );
currentMap.skill = 1;
cvar_vars = NULL; // don't write any cvars to the config file
iphoneShutdown();
}
/*
==================
iphoneStartup
==================
*/
void iphoneStartup() {
int i;
char *s;
int start = Sys_Milliseconds();
z_chain.next = z_chain.prev = &z_chain;
InitImmediateModeGL();
// Prepare enough of the subsystems to handle
// cvar and command buffer management.
COM_InitArgv( 0, NULL ); // FIXME: get args...
Cmd_Init();
Cvar_Init();
Con_Init();
FS_InitFilesystem();
// We need to add the early commands twice, because
// a basedir or cddir needs to be set before execing
// config files, but we want other parms to override
// the settings of the config files.
Cbuf_AddEarlyCommands( false );
Cbuf_Execute();
R_Init();
Cmd_AddCommand( "reset", Reset_f );
developer = Cvar_Get( "developer", "0", CVAR_INIT );
logfile_active = Cvar_Get( "logfile", "0", CVAR_INIT );
s = va( "%s %s %s %s %s %s", APP_VERSION, RELEASENAME, CPUSTRING, __DATE__, __TIME__, BUILDSTRING );
Cvar_Get( "version", s, CVAR_SERVERINFO | CVAR_NOSET );
Con_Init();
Sound_Init();
Game_Init(); // game and player init
Cbuf_AddText( "exec config.cfg\n" );
Cbuf_AddEarlyCommands( true );
Cbuf_Execute();
// add + commands from command line
Cbuf_AddLateCommands();
Cbuf_Execute();
for ( i = 0 ; i < 10 ; i++ ) {
char name[64];
sprintf( name, "iphone/font/%i.tga", i );
numberPics[i] = TM_FindTexture( name, TT_Pic );
}
Com_Printf( "\n====== Application Initialized ======\n\n" );
Sound_Activate( true );
consoleActive = 0;
controlScheme = Cvar_Get( "controlScheme", "0", CVAR_ARCHIVE );
sensitivity = Cvar_Get( "sensitivity", "0.3", CVAR_ARCHIVE );
stickSize = Cvar_Get( "stickSize", "120", CVAR_ARCHIVE );
stickTurnBase = Cvar_Get( "stickTurnBase", "300", CVAR_ARCHIVE );
stickTurnScale = Cvar_Get( "stickTurnScale", "500", CVAR_ARCHIVE );
stickMoveBase = Cvar_Get( "stickMoveBase", "3000", CVAR_ARCHIVE );
stickMoveScale = Cvar_Get( "stickMoveScale", "5000", CVAR_ARCHIVE );
stickDeadBand = Cvar_Get( "stickDeadBand", "0.2", CVAR_ARCHIVE );
tiltTurn = Cvar_Get( "tiltTurn", "0", CVAR_ARCHIVE );
tiltMove = Cvar_Get( "tiltMove", "0", CVAR_ARCHIVE );
tiltFire = Cvar_Get( "tiltFire", "0", CVAR_ARCHIVE );
music = Cvar_Get( "music", "1", CVAR_ARCHIVE );
tiltDeadBand = Cvar_Get( "tiltDeadBand", "0.08", CVAR_ARCHIVE );
tiltAverages = Cvar_Get( "tiltAverages", "3", CVAR_ARCHIVE );
cropSprites = Cvar_Get( "cropSprites", "1", 0 );
showTilt = Cvar_Get( "showTilt", "-1", 0 );
blends = Cvar_Get( "blends", "1", 0 );
gunFrame = Cvar_Get( "gunFrame", "0", 0 );
slowAI = Cvar_Get( "slowAI", "0", 0 );
// these should get overwritten by LoadTheGame
currentMap.skill = 1;
currentMap.episode = 0;
if ( !LoadTheGame() ) {
memset( currentMap.mapFlags, 0,sizeof( currentMap.mapFlags ) );
PL_NewGame( &Player );
iphoneStartMap( 0, 0, 1 );
}
// always start at main menu
menuState = IPM_MAIN;
Com_Printf( "startup time: %i msec\n", Sys_Milliseconds() - start );
}
/*
==================
iphoneWriteConfig
==================
*/
void iphoneWriteConfig( void ) {
FILE *fp;
char path[ MAX_OSPATH];
cvar_t *var;
char buffer[1024];
my_snprintf( path, sizeof( path ), "%s/config.cfg", iphoneDocDirectory );
fp = fopen( path, "w" );
if( ! fp ) {
Com_Printf( "Could not write config.cfg.\n" );
return;
}
// write out commands to set the archived cvars
for( var = cvar_vars ; var ; var = var->next ) {
if( var->flags & CVAR_ARCHIVE ) {
my_snprintf( buffer, sizeof( buffer ), "set %s \"%s\"\n", var->name, var->string );
fprintf( fp, "%s", buffer );
Com_Printf( "%s", buffer );
}
}
fclose( fp );
}
/*
==================
iphoneShutdown
Save the game at this position
==================
*/
void iphoneShutdown() {
Sound_StopAllSounds();
Sound_StopBGTrack();
iphoneWriteConfig();
SaveTheGame();
exit( 0 );
}

1061
src/sdl/iphone/iphone_menus.c Executable file

File diff suppressed because it is too large Load Diff

2392
src/sdl/iphone/iphone_qgl.h Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,40 @@
/*
Copyright (C) 2009 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef IPHONE_QGL_ENUMERANTS_H
#define IPHONE_QGL_ENUMERANTS_H
#ifdef QGL_LOG_GL_CALLS
#include <OpenGLES/ES1/gl.h>
#ifdef __cplusplus
extern "C" {
#endif
const char *StringFromGLEnumerant( GLenum enumerant );
#ifdef __cplusplus
}
#endif
#endif // QGL_LOG_GL_CALLS
#endif // IPHONE_QGL_ENUMERANTS_H

151
src/sdl/iphone/iphone_wolf.h Executable file
View File

@@ -0,0 +1,151 @@
/*
Copyright (C) 2009 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// define this to get only the first episode on selections, and the
// automatic sell screen at the end of episode 1
//#define EPISODE_ONE_ONLY
extern viddef_t viddef;
typedef enum menuState {
IPM_GAME,
IPM_MAIN,
IPM_SKILL,
IPM_EPISODE,
IPM_MAPS,
IPM_CONTROLS,
IPM_INTERMISSION,
IPM_VICTORY,
IPM_AUTOMAP
} menuState_t;
extern menuState_t menuState;
void iphoneDrawMenus();
#define SAVEGAME_VERSION 106
#define MAX_SKILLS 4
#define MAX_MAPS 60
#define MF_TRIED 1
#define MF_COMPLETED 2
#define MF_KILLS 4
#define MF_SECRETS 8
#define MF_TREASURE 16
#define MF_TIME 32
typedef struct {
int episode;
int map;
int skill;
int levelCompleted; // already at intermission when saved
int version;
int mapFlags[MAX_SKILLS][MAX_MAPS];
} currentMap_t;
extern currentMap_t currentMap;
void iphoneStartMap( int episodeNum, int mapNum, int skillLevel );
extern char iphoneDocDirectory[1024];
extern char iphoneAppDirectory[1024];
extern texture_t *numberPics[10];
extern vec3_t vnull;
void Client_PrepRefresh( const char *r_mapname );
extern int iphoneFrameNum;
extern int intermissionTriggerFrame;
extern int consoleActive;
extern cvar_t *controlScheme;
extern cvar_t *sensitivity;
extern cvar_t *stickSize;
extern cvar_t *stickTurnBase;
extern cvar_t *stickTurnScale;
extern cvar_t *stickMoveBase;
extern cvar_t *stickMoveScale;
extern cvar_t *stickDeadBand;
extern cvar_t *tiltTurn;
extern cvar_t *tiltMove;
extern cvar_t *tiltDeadBand;
extern cvar_t *tiltAverages;
extern cvar_t *tiltFire;
extern cvar_t *music;
extern cvar_t *showTilt;
extern cvar_t *cropSprites;
extern cvar_t *blends;
extern cvar_t *gunFrame;
extern cvar_t *slowAI;
// the native iPhone code should set the following each frame:
extern int numTouches;
extern int touches[5][2]; // [0] = x, [1] = y in landscape mode, raster order with y = 0 at top
extern float tilt; // -1.0 to 1.0
extern float tiltPitch;
// so we can detect button releases
extern int numPrevTouches;
extern int prevTouches[5][2];
// the layout drawing code sets these, which are then used
// by the touch processing
extern int menuButtonX, menuButtonY, menuButtonSize;
extern int fireButtonX, fireButtonY, fireButtonSize;
extern int moveAxisX, moveAxisY, moveAxisSize;
extern int turnAxisX, turnAxisY, turnAxisSize;
// incremented once each frame, regardless of framerate
extern int frameNum;
int TouchDown( int x, int y, int w, int h );
int TouchReleased( int x, int y, int w, int h );
int iphoneCenterText( int x, int y, const char *str );
void iphoneDrawNumber( int x, int y, int number, int charWidth, int charHeight );
void iphoneDrawPic( int x, int y, int w, int h, const char *pic );
void R_Draw_Blend( int x, int y, int w, int h, colour4_t c );
void SaveTheGame();
int LoadTheGame();
void StartGame( void );
void iphoneShutdown();
void iphoneOpenAutomap();
void InitImmediateModeGL();
extern colour4_t colorPressed;
extern int damageflash;
extern int bonusFrameNum;
extern int attackDirTime[2];
// interfaces from the game code
void iphoneStartBonusFlash();
void iphoneStartDamageFlash( int points );
void iphoneSetAttackDirection( int dir );
void iphoneStartIntermission( int framesFromNow );
void iphoneSetNotifyText( const char *str, ... );
// interfaces to hadware / system
void OpenURL( const char *url );

45
src/sdl/iphone/main.m Executable file
View File

@@ -0,0 +1,45 @@
/*
Copyright (C) 2009 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#import <UIKit/UIKit.h>
#include <unistd.h>
#include <string.h>
int main(int argc, char *argv[]) {
{
char cwd[256];
strcpy( cwd, argv[0] );
int len = strlen( cwd );
for( int i = len-1; i >= 0; i-- ) {
if ( cwd[i] == '/' ) {
cwd[i] = 0;
break;
}
cwd[i] = 0;
}
setenv( "CWD", cwd, 1 );
}
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}

View File

@@ -0,0 +1,62 @@
/*
Copyright (C) 2009 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#import <UIKit/UIKit.h>
#import <UIKit/UIAccelerometer.h>
#ifndef IPHONE_APPSTORE
#import "AltAds.h"
@interface SplashView : UIImageView
{
}
@end
#endif
#ifdef _cplusplus
extern "C" {
#endif
void vibrateDevice();
#ifdef _cplusplus
}
#endif
@class EAGLView;
@interface wolf3dAppDelegate : NSObject <UIApplicationDelegate, UIAccelerometerDelegate> {
UIWindow *window;
EAGLView *glView;
int lastAccelUpdateMsec;
#ifndef IPHONE_APPSTORE
SplashView* splashView;
AltAds* altAds;
#endif
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet EAGLView *glView;
- (void)restartAccelerometerIfNeeded;
#ifndef IPHONE_APPSTORE
- (void)startUp;
#endif
@end

View File

@@ -0,0 +1,177 @@
/*
Copyright (C) 2009 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#import "wolf3dAppDelegate.h"
#import "EAGLView.h"
#import <AudioToolbox/AudioServices.h>
extern int iphoneStartup();
extern int iphoneShutdown();
char iphoneDocDirectory[1024];
char iphoneAppDirectory[1024];
void vibrateDevice() {
printf( "vibrate\n" );
AudioServicesPlaySystemSound( kSystemSoundID_Vibrate );
}
#ifndef IPHONE_APPSTORE
@implementation SplashView
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.userInteractionEnabled = YES;
[self setImage:[UIImage imageNamed:@"splashscreen.png"]];
}
return self;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint temppoint = [touch locationInView:self];
if(temppoint.y > (self.frame.size.height - 100.0f) )
{
[[[UIApplication sharedApplication] delegate] startUp];
}
}
- (void)drawRect:(CGRect)rect {
}
- (void)dealloc {
[super dealloc];
}
@end
#endif
@implementation wolf3dAppDelegate
@synthesize window;
@synthesize glView;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
application.statusBarHidden = YES;
application.statusBarOrientation = UIInterfaceOrientationLandscapeLeft;
#ifdef IPHONE_APPSTORE
// get the documents directory, where we will write configs and save games
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
[documentsDirectory getCString: iphoneDocDirectory
maxLength: sizeof( iphoneDocDirectory ) - 1
encoding: NSASCIIStringEncoding ];
// get the app directory, where our data files live
paths = NSSearchPathForDirectoriesInDomains(NSApplicationDirectory, NSUserDomainMask, YES);
NSString *appDirectory = documentsDirectory = [paths objectAtIndex:0];
[appDirectory getCString: iphoneAppDirectory
maxLength: sizeof( iphoneAppDirectory ) - 1
encoding: NSASCIIStringEncoding ];
// start the flow of accelerometer events
UIAccelerometer *accelerometer = [UIAccelerometer sharedAccelerometer];
accelerometer.delegate = self;
accelerometer.updateInterval = 0.01;
// do all the game startup work
iphoneStartup();
#else
sprintf(iphoneAppDirectory, "/Applications/Wolf3D.app/");
sprintf(iphoneDocDirectory, "/Applications/Wolf3D.app/");
// do all the game startup work
iphoneStartup();
splashView = [[SplashView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 425.0f)];
[window addSubview: splashView];
altAds = [[AltAds alloc] initWithFrame:CGRectMake(0.0f, 425.0f, 320.0f, 55.0f) andWindow:window];
[window makeKeyAndVisible];
#endif
}
#ifndef IPHONE_APPSTORE
- (void)startUp
{
[splashView removeFromSuperview];
[altAds removeFromSuperview];
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft];
}
#endif
- (void)applicationWillResignActive:(UIApplication *)application {
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
}
- (void)applicationWillTerminate:(UIApplication *)application {
iphoneShutdown();
#ifndef IPHONE_APPSTORE
[altAds MobclixEndApplication];
#endif
}
- (void)dealloc {
[window release];
[glView release];
[super dealloc];
}
- (void)restartAccelerometerIfNeeded {
int Sys_Milliseconds();
// I have no idea why this seems to happen sometimes...
if ( Sys_Milliseconds() - lastAccelUpdateMsec > 1000 ) {
static int count;
if ( ++count < 100 ) {
printf( "Restarting accelerometer updates.\n" );
}
UIAccelerometer *accelerometer = [UIAccelerometer sharedAccelerometer];
accelerometer.delegate = self;
accelerometer.updateInterval = 0.01;
}
}
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
int Sys_Milliseconds();
void WolfensteinTilts( float *tilts );
float acc[4];
acc[0] = acceleration.x;
acc[1] = acceleration.y;
acc[2] = acceleration.z;
acc[3] = acceleration.timestamp;
WolfensteinTilts( acc );
lastAccelUpdateMsec = Sys_Milliseconds();
}
@end