diff --git a/src/sdl/iphone/EAGLView.h b/src/sdl/iphone/EAGLView.h new file mode 100755 index 000000000..80e888168 --- /dev/null +++ b/src/sdl/iphone/EAGLView.h @@ -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 +#import +#import +#import + +/* +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 { +@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 diff --git a/src/sdl/iphone/EAGLView.m b/src/sdl/iphone/EAGLView.m new file mode 100755 index 000000000..34a41f4d1 --- /dev/null +++ b/src/sdl/iphone/EAGLView.m @@ -0,0 +1,293 @@ +// +// EAGLView.m +// wolf3d +// +// Created by Cass Everitt on 2/20/09. +// Copyright Id Software 2009. All rights reserved. +// + + + +#import +#import + +#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; + } +} + diff --git a/src/sdl/iphone/Info.plist b/src/sdl/iphone/Info.plist new file mode 100755 index 000000000..d09bca096 --- /dev/null +++ b/src/sdl/iphone/Info.plist @@ -0,0 +1,36 @@ + + + + + + + CFBundleDevelopmentRegion + English + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + ${PRODUCT_NAME}_icon.png + CFBundleIdentifier + com.zodttd.${PRODUCT_NAME:identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + NSMainNibFile + MainWindow + UIInterfaceOrientation + UIInterfaceOrientationPortrait + UIStatusBarHidden + + + diff --git a/src/sdl/iphone/MainWindow.xib b/src/sdl/iphone/MainWindow.xib new file mode 100755 index 000000000..fc76dc53e --- /dev/null +++ b/src/sdl/iphone/MainWindow.xib @@ -0,0 +1,223 @@ + + + + 528 + 9E17 + 672 + 949.33 + 352.00 + + YES + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + IBFilesOwner + + + IBFirstResponder + + + + + 1316 + + YES + + + 1298 + {320, 480} + + + 3 + MQA + + 2 + + + NO + + + + {320, 480} + + + 1 + MSAxIDEAA + + NO + YES + + + + + YES + + + delegate + + + + 4 + + + + window + + + + 5 + + + + glView + + + + 9 + + + + + YES + + 0 + + YES + + + + + + 2 + + + YES + + + + + + -1 + + + RmlsZSdzIE93bmVyA + + + 3 + + + + + 8 + + + + + -2 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 2.IBAttributePlaceholdersKey + 2.IBEditorWindowLastContentRect + 2.IBPluginDependency + 3.CustomClassName + 3.IBPluginDependency + 8.CustomClassName + 8.IBPluginDependency + + + YES + UIApplication + UIResponder + + YES + + YES + + + YES + + + {{500, 343}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + wolf3dAppDelegate + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + EAGLView + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + YES + + + YES + + + + + YES + + YES + + + YES + + + + 9 + + + + YES + + EAGLView + UIView + + IBProjectSource + Classes/EAGLView.h + + + + wolf3dAppDelegate + NSObject + + YES + + YES + glView + window + + + YES + EAGLView + UIWindow + + + + IBProjectSource + Classes/wolf3dAppDelegate.h + + + + + 0 + wolf3d.xcodeproj + 3 + + diff --git a/src/sdl/iphone/gles_glue.c b/src/sdl/iphone/gles_glue.c new file mode 100755 index 000000000..08ac8f747 --- /dev/null +++ b/src/sdl/iphone/gles_glue.c @@ -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; +} + diff --git a/src/sdl/iphone/gles_glue.h b/src/sdl/iphone/gles_glue.h new file mode 100755 index 000000000..6eca2a806 --- /dev/null +++ b/src/sdl/iphone/gles_glue.h @@ -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 \ No newline at end of file diff --git a/src/sdl/iphone/iphone_loop.c b/src/sdl/iphone/iphone_loop.c new file mode 100755 index 000000000..a64902a4e --- /dev/null +++ b/src/sdl/iphone/iphone_loop.c @@ -0,0 +1,1025 @@ +/* + remove wolf_render.c + for the iphone build, we only need the following lsfx files: + + 001 + 003 + 008 + 009 + 012 + 023 + 028 + 030 + 031 + 033 + 034 + 035 + 036 + 037 + 038 + 040 + 044 + 045 + 061 + 062 + 064 + 069 + 076 + 078 + 080 + 085 + 086 + + */ + +#include "../wolfiphone.h" + +currentMap_t currentMap; + +vec3_t vnull = { 0, 0, 0 }; + +int iphoneFrameNum; +int intermissionTriggerFrame; +int slowAIFrame; + +// console mode +int consoleActive; + +// the native iPhone code should set the following each frame: +int numTouches; +int touches[5][2]; // [0] = x, [1] = y in landscape mode, raster order with y = 0 at top +float tilt; // -1.0 to 1.0 +float tiltPitch; + +#define MAX_TILT_HISTORY 64 +float tiltHistory[MAX_TILT_HISTORY][4]; +int tiltHistoryNum; + +// so we can detect button releases +int numPrevTouches; +int prevTouches[5][2]; + + +// the layout drawing code sets these, which are then used +// by the touch processing +int fireButtonX, fireButtonY, fireButtonSize; +int moveAxisX, moveAxisY, moveAxisSize; +int turnAxisX, turnAxisY, turnAxisSize; + +texture_t *numberPics[10]; + +int damageflash; +int bonusFrameNum; +int attackDirTime[2]; + +/* + ================== + iphoneActivateConsole + + ================== + */ +void iphoneActivateConsole() { + extern float scr_conlines; + scr_conlines = 0.5f; + consoleActive = 1; +} + +/* + ================== + iphoneDeactivateConsole + + ================== + */ +void iphoneDeactivateConsole() { + extern float scr_conlines; + scr_conlines = 0.0f; + consoleActive = 0; +} + +/* + ================== + iphoneExecuteCommandLine + + ================== + */ +void iphoneExecuteCommandLine() { + const char * GetCurrentCommandLine(); + void SetCurrentCommandLine(const char *); + char buf[256]; + strcpy( buf, GetCurrentCommandLine() ); + + Cmd_ExecuteString( buf ); + SetCurrentCommandLine( "" ); +} + + + +/* + ================== + iphoneSavePrevTouches + + ================== + */ +void iphoneSavePrevTouches() { + numPrevTouches = numTouches; + memcpy( prevTouches, touches, sizeof( prevTouches ) ); +#if 0 + // display the touch locations + for ( int i = 0 ; i < numTouches ; i++ ) { + int w = 32; + iphoneDrawPic( touches[i][0] - w/2, touches[i][1] - w/2, w, w, "iphone/diractional_02.tga" ); + } +#endif +} + +/* + ================== + iphoneCenterText + + Returns the width in pixels + ================== + */ +extern font_t *myfonts[ 1 ]; +int iphoneCenterText( int x, int y, const char *str ) { + int l = strlen( str ); + int i; + font_t *myfont = myfonts[0]; + int scale; + int step = 10; + + scale = 16; + + x -= l * step / 2; + + R_Bind( myfont->texfont->texnum ); + pfglBegin( GL_QUADS ); + + for ( i = 0 ; i < l ; i++, x += step ) { + int row, col; + float frow, fcol; + int num = str[i]; + + if ( num == ' ' ) { + continue; + } + + row = (num >> 4) - 2; + col = num & 15; + + frow = row * myfont->hFrac; + fcol = col * myfont->wFrac; + + pfglTexCoord2f( fcol, frow ); + pfglVertex2i( x, y ); + + pfglTexCoord2f( fcol+myfont->wFrac, frow ); + pfglVertex2i( x+scale, y ); + + pfglTexCoord2f( fcol+myfont->wFrac, frow+myfont->hFrac ); + pfglVertex2i( x+scale, y+scale ); + + pfglTexCoord2f( fcol, frow+myfont->hFrac ); + pfglVertex2i( x, y+scale ); + } + + pfglEnd(); + + return l * step; +} + + +/* + ================== + TouchDown + + Checks all touches against a square + ================== + */ +int TouchDown( int x, int y, int w, int h ) { + int i; + for ( i = 0 ; i < numTouches ; i++ ) { + if ( touches[i][0] >= x && touches[i][1] >= y + && touches[i][0] < x + w && touches[i][1] < y + h ) { + return 1; + } + } + return 0; +} + +/* + ================== + TouchReleased + + Perform an action when released in the box. + If not down this frame, but down the previous frame, it is released + ================== + */ +int TouchReleased( int x, int y, int w, int h ) { + int i; + int downPrev = 0; + int downNow = 0; + + for ( i = 0 ; i < numPrevTouches ; i++ ) { + if ( prevTouches[i][0] >= x && prevTouches[i][1] >= y + && prevTouches[i][0] < x + w && prevTouches[i][1] < y + h ) { + downPrev = 1; + break; + } + } + + // see if not down this frame + for ( i = 0 ; i < numTouches ; i++ ) { + if ( touches[i][0] >= x && touches[i][1] >= y + && touches[i][0] < x + w && touches[i][1] < y + h ) { + downNow = 1; + break; + } + } + + if ( !downPrev ) { + if ( downNow ) { + Sound_StartLocalSound( "iphone/bdown_01.wav" ); + } + // wasn't down the previous frame + return 0; + } + + if ( downNow ) { + // still down + return 0; + } + + if ( numTouches != 0 ) { + // finger dragged off + Sound_StartLocalSound( "iphone/baborted_01.wav" ); + return 0; + } + + // released + Sound_StartLocalSound( "iphone/baction_01.wav" ); + return 1; +} + +/* + ================== + iphoneSet2D + + ================== + */ +void iphoneSet2D( void ) { + pfglViewport( 0,0, 480, 320 ); + pfglMatrixMode( GL_MODELVIEW ); + pfglLoadIdentity(); + pfglDisable( GL_DEPTH_TEST ); + pfglDisable( GL_CULL_FACE ); + pfglEnable( GL_BLEND ); + pfglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + pfglDisable( GL_ALPHA_TEST ); + pfglColor4f( 1,1,1,1 ); + + pfglMatrixMode( GL_PROJECTION ); + pfglLoadIdentity(); + pfglRotatef( 90, 0, 0, 1 ); + pfglOrtho( 0, 480, 320, 0, -99999, 99999 ); +} + + +/* + ================== + DeadBandAdjust + + Compresses the 0.0 - 1.0 range into deadband - 1.0 + ================== + */ +float DeadBandAdjust( float f, float deadBand ) { + if ( f < 0 ) { + return -DeadBandAdjust( -f, deadBand ); + } + if ( f > 1.0 ) { + return 1.0; + } + if ( f < deadBand ) { + return 0; + } + return (f-deadBand) / (1.0 - deadBand); +} + +/* +================== +AxisHit + +Returns a -1 to 1 range + +If activeFraction is less than 1.0, the range will clamp +to the limits before the edge of the box is hit. +================== +*/ +float AxisHit( int x, int y, int size, int isXaxis, float activeFraction ) { + int i; + + // allow the touches to go outside the indicated bounds with clamping + x -= size/2; + y -= size/2; + size *= 2; + activeFraction *= 0.5f; + + for ( i = 0 ; i < numTouches ; i++ ) { + if ( touches[i][0] >= x && touches[i][1] >= y + && touches[i][0] < x + size && touches[i][1] < y + size ) { + float f; + if ( isXaxis ) { + f = (float)( touches[i][0] - x ) / size * 2.0f - 1.0f; + } else { + f = (float)( touches[i][1] - y ) / size * 2.0f - 1.0f; + } + f /= activeFraction; + if ( f > 1.0f ) { + f = 1.0f; + } else if ( f < -1.0f ) { + f = -1.0f; + } + if ( f > -stickDeadBand->value && f < stickDeadBand->value ) { + f = 0; + } + return f; + } + } + return 0; +} + +void WolfensteinTouches( int _numTouches, int _touches[16] ) { + numTouches = _numTouches; + for ( int i = 0 ; i < numTouches ; i++ ) { + touches[i][0] = 480 - _touches[i*2+1]; + touches[i][1] = _touches[i*2+0]; + } +} + +void WolfensteinTilts( float *tilts ) { + int i; + int j; + int c; + float sum[3]; + static float prevTime; + + c = tiltAverages->value; + if ( c < 1 ) { + c = 1; + } else if ( c > MAX_TILT_HISTORY ) { + c = MAX_TILT_HISTORY; + } + + // acc[0] - [2] are accelerometer values, ax[3] is the timestamp + for ( i = 0 ; i < 3 ; i++ ) { + tiltHistory[tiltHistoryNum&(MAX_TILT_HISTORY-1)][i] = tilts[i]; + sum[i] = 0; + for ( j = 0 ; j < c ; j++ ) { + sum[i] += tiltHistory[(tiltHistoryNum-j)&(MAX_TILT_HISTORY-1)][i]; + } + sum[i] /= c; + } + // save the timestamp for analysis + tiltHistory[tiltHistoryNum&(MAX_TILT_HISTORY-1)][3] = tilts[3] - prevTime; + prevTime = tilts[3]; + tiltHistoryNum++; + + tilt = sum[1]; + tiltPitch = sum[0]; +// Com_Printf( "%4.2f %4.2f %4.2f\n", tilts[0], tilts[1], tilts[2] ); +} + +void ShowTilt() { + int i; + int axis = (int)showTilt->value; + colour4_t fillColor = { 255, 0, 0, 255 }; + colour4_t whiteColor = { 255, 255, 255, 255 }; + colour4_t nowColor = { 0, 255, 0, 255 }; + float x; + + if ( axis < 0 || axis > 2 ) { + return; + } + for ( i = 0 ; i < MAX_TILT_HISTORY ; i++ ) { + x = tiltHistory[(tiltHistoryNum-1-i)&(MAX_TILT_HISTORY-1)][axis] * ( 10 / 0.018168604 ); + if ( x < 0 ) { + R_Draw_Fill( 240 + x, i*4, -x, 4, fillColor ); + } else if ( x > 0 ) { + R_Draw_Fill( 240, i*4, x, 4, fillColor ); + } + } + x = tilt * ( 10 / 0.018168604 ); + if ( x < 0 ) { + R_Draw_Fill( 240 + x, i*4, -x, 4, nowColor ); + } else if ( x > 0 ) { + R_Draw_Fill( 240, i*4, x, 4, nowColor ); + } + R_Draw_Fill( 240, 0, 1, MAX_TILT_HISTORY*4, whiteColor ); +} + + +/* +================== +CreateIphoneUserCmd + +Build the movement, angles, and buttons for a frame of action: + +Player.position.angle +Player.cmd.buttons +Player.cmd.forwardMove +Player.cmd.sideMove +================== +*/ +PRIVATE void CreateIphoneUserCmd() +{ + float stickTurnValue; + float stickMoveValue; + + stickTurnValue = stickTurnBase->value + stickTurnScale->value * sensitivity->value; + stickMoveValue = stickMoveBase->value + stickMoveScale->value * sensitivity->value; + + usercmd_t *cmd = &Player.cmd; + memset( cmd, 0, sizeof( *cmd ) ); + + if ( TouchDown( fireButtonX, fireButtonY, fireButtonSize, fireButtonSize ) ) { + cmd->buttons |= BUTTON_ATTACK; + } + if ( tiltFire->value > 0 && tiltPitch < tiltFire->value ) { + cmd->buttons |= BUTTON_ATTACK; + } + + cmd->forwardmove = -stickMoveValue * AxisHit( moveAxisX, moveAxisY, moveAxisSize, 0, 0.8f ); + + if( controlScheme->value == 0 || controlScheme->value == 1 ) { + Player.position.angle += -stickTurnValue * AxisHit( moveAxisX, moveAxisY, moveAxisSize, 1, 0.8f ); + } else { + Player.position.angle += -stickTurnValue * AxisHit( turnAxisX, turnAxisY, turnAxisSize, 1, 0.8f ); + cmd->sidemove = stickMoveValue * AxisHit( moveAxisX, moveAxisY, moveAxisSize, 1, 0.8f ); + } + + // accelerometer tilting + cmd->sidemove += tiltMove->value * DeadBandAdjust( tilt, tiltDeadBand->value ); + Player.position.angle -= tiltTurn->value * DeadBandAdjust( tilt, tiltDeadBand->value ); + + // always use + if ( iphoneFrameNum & 1 ) { + cmd->buttons |= BUTTON_USE; + } +} + + +/* +================== +iphoneHighlightPicWhenTouched + +Draw transparent except when touched +================= +*/ +void iphoneHighlightPicWhenTouched( int x, int y, int w, int h, const char *pic ) { + if ( TouchDown( x, y, w, h ) ) { + pfglColor4f(1,1,1,1); + } else { + pfglColor4f(1,1,1,0.5); + } + R_Draw_StretchPic( x, y, w, h, pic ); + pfglColor4f(1,1,1,1); +} +int iphoneActivatePicWhenTouched( int x, int y, int w, int h, const char *pic ) { + iphoneHighlightPicWhenTouched( x, y, w, h, pic ); + return TouchReleased( x, y, w, h ); +} + + +/* +================== +iphoneDrawControls + + scheme 0: turnstick on left + scheme 1: turnstick on right + scheme 2: dualstick, move on left + scheme 3: dualstick, move on right +================= +*/ +static const int BUTTON_SIZE = 100; +void iphoneDrawControls( void ) { + int ss = (int)stickSize->value; + + switch ( (int)controlScheme->value ) { + case 0: + moveAxisX = 0; + moveAxisY = 320 - ss; + moveAxisSize = ss; + iphoneHighlightPicWhenTouched( moveAxisX, moveAxisY, moveAxisSize, moveAxisSize, "iphone/diractional_02.tga" ); + + fireButtonX = 480 - BUTTON_SIZE; + fireButtonY = 320 - BUTTON_SIZE; + fireButtonSize = BUTTON_SIZE; + break; + + case 1: + moveAxisX = 480 - ss; + moveAxisY = 320 - ss; + moveAxisSize = ss; + iphoneHighlightPicWhenTouched( moveAxisX, moveAxisY, moveAxisSize, moveAxisSize, "iphone/diractional_02.tga" ); + + fireButtonX = 0; + fireButtonY = 320 - BUTTON_SIZE; + fireButtonSize = BUTTON_SIZE; + break; + + case 2: + moveAxisX = 0; + moveAxisY = 320 - ss; + moveAxisSize = ss; + iphoneHighlightPicWhenTouched( moveAxisX, moveAxisY, moveAxisSize, moveAxisSize, "iphone/diractional_01.tga" ); + + turnAxisX = 480 - ss; + turnAxisY = 320 - ss; + turnAxisSize = ss; + iphoneHighlightPicWhenTouched( turnAxisX, turnAxisY, turnAxisSize, turnAxisSize, "iphone/diractional_03.tga" ); + + fireButtonX = 480-BUTTON_SIZE; + fireButtonY = 0; + fireButtonSize = BUTTON_SIZE; + break; + case 3: + moveAxisX = 480 - ss; + moveAxisY = 320 - ss; + moveAxisSize = ss; + iphoneHighlightPicWhenTouched( moveAxisX, moveAxisY, moveAxisSize, moveAxisSize, "iphone/diractional_01.tga" ); + + turnAxisX = 0; + turnAxisY = 320 - ss; + turnAxisSize = ss; + iphoneHighlightPicWhenTouched( turnAxisX, turnAxisY, turnAxisSize, turnAxisSize, "iphone/diractional_03.tga" ); + + fireButtonX = 480-BUTTON_SIZE; + fireButtonY = 0; + fireButtonSize = BUTTON_SIZE; + break; + } + + iphoneHighlightPicWhenTouched( fireButtonX, fireButtonY, fireButtonSize, fireButtonSize, "iphone/shoot.tga" ); +} + +/* + ================== + iphoneDrawWeapon + + ================== + */ +void iphoneDrawWeapon( void ) { + char name[ 32 ]; + texture_t *tex; + static int w = 200; + static int h = 200; + int x = (viddef.width - w ) >> 1; + int y = viddef.height - 80 - h; + int frame; + + if ( gunFrame->value ) { + // screenshots look better with the muzzle flash + frame = Player.weapon * 5 + gunFrame->value + SPR_KNIFEREADY; + } else { + frame = Player.weapon * 5 + Player.weaponframe + SPR_KNIFEREADY; + } + + my_snprintf( name, sizeof( name ), "%s/%d.tga", spritelocation, frame); + tex = TM_FindTexture( name, TT_Pic ); + + R_Bind( tex->texnum ); + + pfglBegin( GL_QUADS ); + + pfglTexCoord2f( 0.01f, 0.01f ); pfglVertex2i( x, y ); + pfglTexCoord2f( 0.99f, 0.01f ); pfglVertex2i( x + w, y ); + pfglTexCoord2f( 0.99f, 0.99f ); pfglVertex2i( x + w, y + h ); + pfglTexCoord2f( 0.01f, 0.99f ); pfglVertex2i( x, y + h ); + + pfglEnd(); +} + +/* + ================== + iphoneDrawNumber + + ================== + */ +void iphoneDrawNumber( int x, int y, int number, int charWidth, int charHeight ) { + texture_t *tex; + int i; + char string[ 20 ]; + W32 length; + float charStep = charWidth * 0.8; // trim off extra width + + if ( number < 0 ) { + number = 0; + } + my_snprintf( string, sizeof( string ), "%d", number ); + length = strlen( string ); + + x -= length * charStep / 2; + + for( i = 0 ; i < length ; i++ ) { + int digit = string[i] - '0'; + tex = numberPics[digit]; + R_Bind( tex->texnum ); + pfglBegin( GL_QUADS ); + + pfglTexCoord2f( 0, 0 ); pfglVertex2i( x, y ); + pfglTexCoord2f( 1, 0 ); pfglVertex2i( x+charWidth, y ); + pfglTexCoord2f( 1, 1 ); pfglVertex2i( x+charWidth, y+charHeight ); + pfglTexCoord2f( 0, 1 ); pfglVertex2i( x, y+charHeight ); + + pfglEnd(); + x += charStep; + } +} + +/* + ================== + iphoneDrawHUD + + ================== + */ +void iphoneDrawHUD( void ) { + int y; + + if( Player.items & ITEM_KEY_1 ) { + R_Draw_Pic( 0, 100, "iphone/GOLDKEYPIC.tga" ); + } + + if( Player.items & ITEM_KEY_2 ) { + R_Draw_Pic( 0, 130, "iphone/SILVERKEYPIC.tga" ); + } + + iphoneDrawNumber( 240, 304, Player.health, 16, 16 ); + if ( fireButtonY < 160 ) { + y = fireButtonY + fireButtonSize + 8; + } else { + y = fireButtonY - 8 - 48; + } + iphoneDrawNumber( fireButtonX + fireButtonSize/2, y, Player.ammo[AMMO_BULLETS], 48, 48 ); +} + +/* + ================== + iphoneDrawFace + + ================== + */ +void iphoneDrawFace( void ) { + int i; + int w = 64; + int h = 80; + int x = (viddef.width - w ) >> 1; + int y = viddef.height - h; + const char *pic; + static const char *mugshotnames[ 24 ] = + { + "iphone/newhead/FACE1APIC.tga", + "iphone/newhead/FACE1BPIC.tga", + "iphone/newhead/FACE1CPIC.tga", + + "iphone/newhead/FACE2APIC.tga", + "iphone/newhead/FACE2BPIC.tga", + "iphone/newhead/FACE2CPIC.tga", + + "iphone/newhead/FACE3APIC.tga", + "iphone/newhead/FACE3BPIC.tga", + "iphone/newhead/FACE3CPIC.tga", + + "iphone/newhead/FACE4APIC.tga", + "iphone/newhead/FACE4BPIC.tga", + "iphone/newhead/FACE4CPIC.tga", + + "iphone/newhead/FACE5APIC.tga", + "iphone/newhead/FACE5BPIC.tga", + "iphone/newhead/FACE5CPIC.tga", + + "iphone/newhead/FACE6APIC.tga", + "iphone/newhead/FACE6BPIC.tga", + "iphone/newhead/FACE6CPIC.tga", + + "iphone/newhead/FACE7APIC.tga", + "iphone/newhead/FACE7BPIC.tga", + "iphone/newhead/FACE7CPIC.tga", + + "iphone/newhead/FACE8APIC.tga" + }; + + static const char *godmugshotnames[] = + { + "iphone/newhead/GODMODEFACE0PIC.tga", + "iphone/newhead/GODMODEFACE1PIC.tga", + "iphone/newhead/GODMODEFACE2PIC.tga" + }; + + iphoneDrawPic( 240 - 64, 320 - 80, 128, 80, "iphone/status_hud.tga" ); + + Player.facecount += tics; + if ( Player.face_gotgun && Player.facecount > 0 ) { + // gotgun will set facecount to a negative number initially, go back + // to normal face with random look after expired. + Player.face_gotgun = false; + } + if( Player.facecount > US_RndT() ) + { + Player.face_gotgun = Player.face_ouch = false; + Player.faceframe = US_RndT() >> 6; + if( Player.faceframe == 3 ) + { + Player.faceframe = 0; + } + + Player.facecount = 0; + } + + if( Player.health ) + { + if( g_version->value == SPEAROFDESTINY && Player.flags & FL_GODMODE ) + { + pic = godmugshotnames[ Player.faceframe ]; + } + else if( Player.face_gotgun ) + { + pic = "iphone/newhead/GOTGATLINGPIC.tga"; + } + else + { + int h = Player.health; + if ( h > 100 ) { + h = 100; + } + if ( h < 0 ) { + h = 0; + } + pic = mugshotnames[ 3*((100-h)/16)+Player.faceframe ]; + } + } + else + { +#if 0 // forgot to convert the mutant face pic... + if( Player.LastAttacker && Player.LastAttacker->type == en_needle ) + { + pic = "iphone/MUTANTBJPIC.tga"; + } + else +#endif + { + pic = "iphone/newhead/FACE8APIC.tga"; + } + } + + R_Draw_StretchPic( x, y, w, h, pic ); + + // blend the right / left damage indicators on the side + for ( i = 0 ; i < 2 ; i++ ) { + float f; + if ( attackDirTime[i] == 0 ) { + continue; + } + f = iphoneFrameNum - attackDirTime[i]; + if ( f > 30 ) { + attackDirTime[i] = 0; + continue; + } + if ( f < 20 ) { + f = 1.0; + } else { + f = ( 30 - f ) * 0.1; + } + pfglColor4f( 1, 1, 1, f ); + if ( i == 0 ) { + iphoneDrawPic( 240 - 64, 320 - 80, 40, 80, "iphone/L_damage.tga" ); + } else { + iphoneDrawPic( 240 + 64 - 40, 320 - 80, 40, 80, "iphone/R_damage.tga" ); + } + pfglColor4f( 1, 1, 1, 1 ); + } +} + +/* + ================== + iphoneSetNotifyText + + Notify text is a single centered line for "got a key", "found a secret", etc + ================== + */ +char notifyText[128]; +int notifyFrameNum; +void iphoneSetNotifyText( const char *str, ... ) { + va_list argptr; + + va_start( argptr, str ); + (void)vsnprintf( notifyText, sizeof( notifyText )-1, str, argptr ); + va_end( argptr ); + + notifyFrameNum = iphoneFrameNum; +} + +void iphoneDrawNotifyText() { + if ( notifyFrameNum == 0 ) { + return; + } + // display for three seconds, then fade over 0.3 + float f = iphoneFrameNum - notifyFrameNum - 80; + if ( f < 0 ) { + f = 1.0; + } else { + f = 1.0 - f * 0.1f; + if ( f < 0 ) { + notifyFrameNum = 0; + return; + } + } + + pfglColor4f( 1, 1, 1, f ); + iphoneCenterText( 240, 20, notifyText ); + pfglColor4f( 1, 1, 1, 1 ); +} + +void iphoneStartBonusFlash() { + bonusFrameNum = iphoneFrameNum; +} + +void iphoneStartDamageFlash( int damage ) { + damageflash += damage; + if ( damageflash > 64 ) { + damageflash = 64; + } + if ( damageflash < 10 ) { + damageflash = 10; + } +} + +/* + ================== + iphoneSetAttackDirection + + +1 = attacked from the left + -1 = attacked from the right + ================== + */ +void iphoneSetAttackDirection( int dir ) { + if ( dir > 0 ) { + attackDirTime[0] = iphoneFrameNum; + } + if ( dir < 0 ) { + attackDirTime[1] = iphoneFrameNum; + } +} + + +/* +================== +iphoneFrame + +================== +*/ +void iphoneFrame() { + unsigned char blendColor[4]; + + int msec = 14; // fixed time + + iphoneFrameNum++; + + // check for delayed intermission trigger after boss kill + if ( intermissionTriggerFrame > 0 && iphoneFrameNum >= intermissionTriggerFrame ) { + iphoneStartIntermission( 0 ); + } + + // toggle / scroll down the console + Client_Screen_RunConsole(); + + + // fixed frame timing, assume we go 30hz + tics = 2; // wolf's global rate counter + + Sound_Update( vnull, vnull, vnull, vnull ); + + if ( consoleActive ) { + iphoneSet2D(); + + Client_Screen_DrawConsole(); + + iphoneSavePrevTouches(); + GLimp_EndFrame(); + return; + } + if ( menuState != IPM_GAME ) { + iphoneSet2D(); + + iphoneDrawMenus(); + + iphoneSavePrevTouches(); + GLimp_EndFrame(); + return; + } + + //------------------ + // normal gameplay + //------------------ + + if( Player.playstate != ex_dead ) + { + CreateIphoneUserCmd(); + Player.position.angle = NormalizeAngle( Player.position.angle ); + + PL_Process( &Player, r_world ); // Player processing + if ( !slowAI->value || --slowAIFrame < 0 ) { + // slowAIframe is for slow-motion screenshot capture + slowAIFrame += slowAI->value; + ProcessGuards(); + } + PushWall_Process(); + Door_ProcessDoors_e( &r_world->Doors, tics, msec ); + + levelstate.time += tics; + } + + // fill the floor and ceiling + R_Draw_Fill( 0, 0, viddef.width, viddef.height >> 1, r_world->ceilingColour ); + R_Draw_Fill( 0, viddef.height >> 1, viddef.width, viddef.height, r_world->floorColour ); + + // draw 3D world + R_SetGL3D( Player.position ); + R_RayCast( Player.position, r_world ); + R_DrawSprites(); + + // draw 2D overlays + iphoneSet2D(); + + // do a full screen blend for damage, death, and bonus pickup + if( Player.playstate == ex_dead ) { + static int deathFadeIntensity; + blendColor[0] = 255; + blendColor[1] = 0; + blendColor[2] = 0; + blendColor[3] = deathFadeIntensity; + deathFadeIntensity += 2; + if( deathFadeIntensity >= 240 ) { + deathFadeIntensity = 0; + PL_NewGame( &Player ); + iphoneStartMap( currentMap.episode, currentMap.map, currentMap.skill ); + } + } else { + iphoneDrawWeapon(); + if( damageflash ) { + blendColor[0] = 255; + blendColor[1] = 0; + blendColor[2] = 0; + blendColor[3] = damageflash >= 64 ? 255 : damageflash * 4; + + if( (damageflash -= 1) < 0 ) { + damageflash = 0; + } + } else if ( bonusFrameNum ) { + float f = ( iphoneFrameNum - bonusFrameNum ) * 0.1; + if ( f > 1.0 ) { + bonusFrameNum = 0; + } else { + blendColor[0] = 255; + blendColor[1] = 255; + blendColor[2] = 128; + blendColor[3] = ( 1.0 - f ) * 64; + } + } + } + if ( blendColor[3] != 0 && blends->value != 0 ) { + R_DrawBox( 0, 0, viddef.width, viddef.height, *(int *)blendColor ); + } + + iphoneDrawNotifyText(); + + iphoneDrawFace(); + + iphoneDrawControls(); + + iphoneDrawHUD(); + + // draw menu and map buttons + if ( controlScheme->value < 2 ) { + if ( iphoneActivatePicWhenTouched( 480-50, 0, 50, 50, "iphone/menu.tga" ) ) { + menuState = IPM_MAIN; + } + if ( iphoneActivatePicWhenTouched( 0, 0, 50, 50, "iphone/map.tga" ) ) { + iphoneOpenAutomap(); + } + } else { + if ( iphoneActivatePicWhenTouched( 0, 50, 50, 50, "iphone/menu.tga" ) ) { + menuState = IPM_MAIN; + } + if ( iphoneActivatePicWhenTouched( 0, 0, 50, 50, "iphone/map.tga" ) ) { + iphoneOpenAutomap(); + } + } + + Client_Screen_DrawConsole(); + + ShowTilt(); + + iphoneSavePrevTouches(); + + // do the swapbuffers + GLimp_EndFrame(); +} diff --git a/src/sdl/iphone/iphone_main.c b/src/sdl/iphone/iphone_main.c new file mode 100755 index 000000000..bbcd626bc --- /dev/null +++ b/src/sdl/iphone/iphone_main.c @@ -0,0 +1,244 @@ +/* + + Copyright (C) 2004-2005 Michael Liebscher + 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 + * + * 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( ¤tMap, 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 ); +} + diff --git a/src/sdl/iphone/iphone_menus.c b/src/sdl/iphone/iphone_menus.c new file mode 100755 index 000000000..91ba1d6cf --- /dev/null +++ b/src/sdl/iphone/iphone_menus.c @@ -0,0 +1,1061 @@ +/* + + 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 intermissionStartFrameNum; +int hasReleased; + +menuState_t menuState; +colour4_t highlightColor = { 128, 128, 128, 255 }; +colour4_t colorPressed = { 128, 128, 0, 255 }; + +/* + ================== + iphoneDrawPic + + ================== + */ +void iphoneDrawPic( int x, int y, int w, int h, const char *pic ) { + R_Draw_StretchPic( x, y, w, h, pic ); +} + +/* + ================== + iphoneDrawPicWithTouch + + ================== + */ +int iphoneDrawPicWithTouch( int x, int y, int w, int h, const char *pic ) { + int r = TouchReleased( x, y, w, h ); + + if ( r ) { + // make sure it is full intensity if it is touch-released, even if + // it wasn't active previously + pfglColor3f( 1, 1, 1 ); + } + R_Draw_StretchPic( x, y, w, h, pic ); + if ( TouchDown( x, y, w, h ) ) { + colour4_t color = { 255, 255, 255, 64 }; + R_Draw_Blend( x, y, w, h, color ); + } + return r; +} + + + +/* + ================== + iphoneSlider + + ================== + */ +void iphoneSlider( int x, int y, int w, int h, const char *title, cvar_t *cvar, + float min, float max ) { + float value = cvar->value; + char str[80]; + float f = ( value - min ) / ( max - min ); + colour4_t backColor = { 32, 32, 80, 255 }; + colour4_t highlightColor = { 64, 64, 160, 255 }; + + if ( f < 0 ) { + f = 0; + } + if ( f > 1 ) { + f = 1; + } + + // draw the background + R_Draw_Fill( x, y, w, h, backColor ); + + // draw the current range + R_Draw_Fill( x+2, y+2, f*(w-4), h-4, highlightColor ); + + // draw the title and fraction + sprintf( str, "%s : %i%%", title, (int)(f*100) ); + iphoneCenterText( x+ w/2, y+h/2-8, str ); + + // check for touches + if ( numTouches > 0 && touches[0][0] >= x && touches[0][0] < x + w + && touches[0][1] >= y && touches[0][1] < y+ h ) { + float newValue; + float delta; + + f = (float)( touches[0][0] - x ) / w; + // round to tenths + f = (int)( ( f + 0.05 ) * 10 ) * 0.1f; + if ( f < 0 ) { + f = 0; + } + if ( f > 1.0 ) { + f = 1.0; + } + + newValue = min + f * ( max - min ); + delta = fabs( newValue - cvar->value ); + if ( f == 0 && cvar->value == 0 ) { + // special case of disable-at-0 + } else if ( delta > 0.01 ) { + Cvar_SetValue( cvar->name, newValue ); + Sound_StartLocalSound( "iphone/slide_01.wav" ); + } + } + +} + +/* + ================== + BackButton + + ================== + */ +int BackButton() { + if ( iphoneDrawPicWithTouch( 0, 0, 64, 32, "iphone/button_back.tga" ) ) { + return 1; + } + return 0; +} + +void GetMoreLevels( int x, int y ) { + if ( iphoneDrawPicWithTouch( x, y, 128, 64, "iphone/button_levels.tga" ) ) { + // directly to the app store for more levels + OpenURL( "http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=304694876" ); + } +} + + +/* + ================== + SaveTheGame + + ================== + */ +extern W8 areaconnect[ NUMAREAS ][ NUMAREAS ]; +extern _boolean areabyplayer[ NUMAREAS ]; + +void SaveTheGame() { + FILE *f; + char path[1024]; + int version = SAVEGAME_VERSION; + int i; + + my_snprintf( path, sizeof( path ), "%s/savegame.bin", iphoneDocDirectory ); + f = fopen( path, "wb" ); + if( ! f ) { + Com_Printf( "Could not open savegame.bin.\n" ); + return; + } + + // turn the r_world->Doors.doors from pointers to indexes + // ok to be destructive, because we are quiting + for ( i = 0 ; i < r_world->Doors.doornum ; i++ ) { + int index = r_world->Doors.Doors[i] - &r_world->Doors.DoorMap[0][0]; + assert( index >= 0 && index < 4096 ); + r_world->Doors.Doors[i] = (void *)index; + } + + // this is only used for the mutant death face, so just + // clear it instead of fixing it up + Player.LastAttacker = NULL; + + currentMap.version = SAVEGAME_VERSION; + fwrite( ¤tMap, 1,sizeof(currentMap), f ); + fwrite( r_world, 1,sizeof(*r_world), f ); + fwrite( &LevelRatios, 1,sizeof(LevelRatios), f ); + fwrite( &levelstate, 1,sizeof(levelstate), f ); + fwrite( Guards, 1,sizeof(Guards), f ); + fwrite( areaconnect, 1,sizeof(areaconnect), f ); + fwrite( areabyplayer, 1,sizeof(areabyplayer), f ); + fwrite( &PWall, 1,sizeof(PWall), f ); + fwrite( &Player, 1,sizeof(Player), f ); + fwrite( &version, 1,sizeof(version), f ); + + fclose( f ); +} + +/* + ================== + LoadTheGame + + ================== + */ +int LoadTheGame() { + FILE *f; + char path[1024]; + int version; + int i; + int oldCompleted; + + my_snprintf( path, sizeof( path ), "%s/savegame.bin", iphoneDocDirectory ); + f = fopen( path, "rb" ); + if( ! f ) { + Com_Printf( "Could not open savegame.bin.\n" ); + return 0; + } + + fread( ¤tMap, 1,sizeof(currentMap) , f); + + if ( currentMap.version != SAVEGAME_VERSION ) { + Com_Printf( "Savegame header version mismatch: %i != %i\n", currentMap.version, SAVEGAME_VERSION ); + fclose( f ); + return 0; + } + + // do a normal map start + Cvar_SetValue( skill->name, currentMap.skill ); + PL_NewGame( &Player ); + + oldCompleted = currentMap.levelCompleted; + iphoneStartMap( currentMap.episode, currentMap.map, currentMap.skill ); + currentMap.levelCompleted = oldCompleted; + + // load modifiactions on top + r_world = Z_Malloc( sizeof( *r_world ) ); + fread( r_world, 1,sizeof(*r_world), f); + fread( &LevelRatios, 1,sizeof(LRstruct), f ); + fread( &levelstate, 1,sizeof(levelstate), f ); + fread( Guards, 1,sizeof(Guards), f ); + fread( areaconnect, 1,sizeof(areaconnect), f ); + fread( areabyplayer, 1,sizeof(areabyplayer), f ); + fread( &PWall, 1,sizeof(PWall), f ); + fread( &Player, 1,sizeof(Player), f ); + fread( &version, 1,sizeof(version), f ); + + fclose( f ); + + if ( version != SAVEGAME_VERSION ) { + Com_Printf( "Savegame trailer version mismatch: %i != %i\n", version, SAVEGAME_VERSION ); + return 0; + } + + // turn the r_world->Doors.doors back to pointers + for ( i = 0 ; i < r_world->Doors.doornum ; i++ ) { + int index = (int)r_world->Doors.Doors[i]; + assert( index >= 0 && index < 4096 ); + r_world->Doors.Doors[i] = &r_world->Doors.DoorMap[0][0] + index; + } + return 1; +} + + +/* + ================== + iphoneStartMap + + This does not reset the player, so call PL_NewGame( &Player ) if it is a new start. + ================== + */ +void iphoneStartMap( int episodeNum, int mapNum, int skillLevel ) { + char command[128]; + int levelNum = episodeNum*10+mapNum; + + Com_Printf( "iphoneStartMap( %i, %i, %i )\n", episodeNum, mapNum, skillLevel ); + + // get the sound playing + Sound_Update( vnull, vnull, vnull, vnull ); + + // clean up game feedback + damageflash = 0; + bonusFrameNum = 0; + attackDirTime[0] = 0; + attackDirTime[1] = 0; + + // note that this has been tried now + currentMap.mapFlags[currentMap.skill][levelNum] |= MF_TRIED; + + // start the game + currentMap.episode = episodeNum; + currentMap.map = mapNum; + currentMap.skill = skillLevel; + currentMap.levelCompleted = 0; + + Cvar_SetValue( skill->name, skillLevel ); + Cvar_SetValue( episode->name, episodeNum ); + sprintf( command, "w%i%i", currentMap.episode, currentMap.map ); + Client_PrepRefresh( command ); + + menuState = IPM_GAME; +} + +/* + ================== + iphoneMainMenu + + ================== + */ +void iphoneMainMenu() { + char str[80]; + float scale = 40 / 32.0; + + iphoneDrawPic( 480-256, 0, 256, 128, "iphone/wolf_logo.tga" ); +#ifdef EPISODE1 + iphoneDrawPic( -20, 0, 256, 64, "iphone/ep_1.tga" ); + GetMoreLevels( 0, 96 ); +#else + iphoneDrawPic( -20, 0, 256, 64, "iphone/ep_1_6.tga" ); +#endif + iphoneDrawPic( 0, 320 - 128, 128, 128, "iphone/id_logo.tga" ); + + if ( iphoneDrawPicWithTouch( 300 - 64*scale, 80, 128*scale, 64*scale, "iphone/button_resume.tga" ) ) { + // if the game was saved at the intermission screen, immediately + // bring it back up when it is loaded + if ( currentMap.levelCompleted ) { + iphoneStartIntermission( 0 ); + } else { + menuState = IPM_GAME; + } + } + sprintf( str, "E%iM%i", currentMap.episode+1, currentMap.map+1 ); + iphoneCenterText( 300, 80+34*scale, str ); + + if ( iphoneDrawPicWithTouch( 300 - 64*scale, 170, 128*scale, 32*scale, "iphone/button_control.tga" ) ) { + menuState = IPM_CONTROLS; + } + if ( iphoneDrawPicWithTouch( 300 - 64*scale, 220, 128*scale, 32*scale, "iphone/button_new.tga" ) ) { + menuState = IPM_SKILL; + } + if ( iphoneDrawPicWithTouch( 300 - 64*scale, 270, 128*scale, 32*scale, "iphone/button_web.tga" ) ) { + OpenURL( "http://www.idsoftware.com/wolfenstein3dclassic/" ); + } + +} + + +/* + ================== + iphoneControlMenu + + ================== + */ +void iphoneControlMenu() { + int i; + + if ( BackButton() ) { + menuState = IPM_MAIN; + } + + for ( i = 0 ; i < 4 ; i++ ) { + char str[128]; + int remap[4] = { 3,4,1,2}; // artist named them differently than intended... + sprintf( str, "iphone/layout_%i.tga", remap[i] ); + if ( i != controlScheme->value ) { + pfglColor3f( 0.5, 0.5, 0.5 ); + } + if ( iphoneDrawPicWithTouch( 120 * i, 40, 120, 120, str ) ) { + Cvar_SetValue( controlScheme->name, i ); + } + pfglColor3f( 1, 1, 1 ); + } + + iphoneSlider( 20, 170, 440, 40, "sensitivity", sensitivity, 0, 1 ); + + iphoneSlider( 20, 220, 440, 40, "tilt move speed", tiltMove, 5000, 30000 ); + if ( tiltMove->value == 5000 ) { + Cvar_SetValue( tiltMove->name, 0 ); + } + if ( tiltMove->value ) { + Cvar_SetValue( tiltTurn->name, 0 ); + } + iphoneSlider( 20, 270, 440, 40, "tilt turn speed", tiltTurn, 500, 3000 ); + if ( tiltTurn->value == 500 ) { + Cvar_SetValue( tiltTurn->name, 0 ); + } + if ( tiltTurn->value ) { + Cvar_SetValue( tiltMove->name, 0 ); + } + + //iphoneSlider( 20, 280, 440, 40, "tilt fire", tiltFire, 0, 1 ); + +} + +/* + ================== + iphoneSkillMenu + + ================== + */ +void iphoneSkillMenu() { + int s; + char str[64]; + + if ( BackButton() ) { + menuState = IPM_MAIN; + } + + // highlight the current skill selection + s = (int)skill->value; +// R_Draw_Fill( 80, 40+64*s, 320, 64, highlightColor ); + + for ( s = 0 ; s < 4 ; s++ ) { + my_snprintf( str, sizeof( str ), "iphone/button_skill%i.tga", s+1 ); + + if ( s != (int)skill->value ) { + pfglColor3f( 0.5, 0.5, 0.5 ); + } + if ( iphoneDrawPicWithTouch( 112, 40+64*s, 256, 64, str ) ) { + Cvar_SetValue( skill->name, s ); + menuState = IPM_EPISODE; + } + pfglColor3f( 1, 1, 1 ); + } +} + +/* + ================== + iphoneEpisodeMenu + + ================== + */ +void iphoneEpisodeMenu() { + int e; + char str[64]; +#ifdef EPISODE1 + int numE = 1; +#else + int numE = 6; +#endif + + if ( BackButton() ) { + menuState = IPM_SKILL; + } + + // 96 x 48 images + for ( e = 0 ; e < numE ; e++ ) { + my_snprintf( str, sizeof( str ), "iphone/button_ep%i.tga", e+1 ); + + if ( e != (int)episode->value ) { + pfglColor3f( 0.5, 0.5, 0.5 ); + } + if ( iphoneDrawPicWithTouch( 48, 32+48*e, 384, 48, str ) ) { + Cvar_SetValue( episode->name, e ); + menuState = IPM_MAPS; + } + pfglColor3f( 1, 1, 1 ); + } + +#ifdef EPISODE1 + // buy more episodes button + GetMoreLevels( 240 - 64, 200 ); +#endif +} + +/* + ================== + iphoneMapMenu + + ================== + */ +void iphoneMapMenu() { + int e, m, s; + char str[64]; + + if ( BackButton() ) { + menuState = IPM_EPISODE; + } + + // draw the level selection + e = episode->value; + if ( e < 0 ) { + e = 0; + } + if ( e > 5 ) { + e = 5; + } + s = skill->value; + if ( s < 0 ) { + s = 0; + } + if ( s > 3 ) { + s = 3; + } + + // draw the episode selection + my_snprintf( str, sizeof( str ), "iphone/button_ep%i.tga", e+1 ); + iphoneDrawPicWithTouch( 96, 0, 384, 48, str ); + + // draw the individual maps + for ( m = 0 ; m < 10 ; m++ ) { + int x; + int y; + colour4_t colorSecret = { 32, 32, 32, 255 }; + colour4_t colorNoTry = { 0, 0, 0, 255 }; + colour4_t colorTried = { 80, 80, 0, 255 }; + colour4_t colorCompleted = { 0, 80, 0, 255 }; + + if ( m == 9 ) { + sprintf( str, "SECRET" ); + x = 120; + y = 90 + 160; + } else if ( m == 8 ) { + sprintf( str, "BOSS" ); + x = 360; + y = 90 + 160; + } else { + sprintf( str, "LEVEL %i", m+1 ); + x = 60 + 120 * ( m % 4 ); + y = 90 + 80 * ( m / 4 ); + } + + unsigned char *color = colorNoTry; + // decide on the background color + int levelNum = e*10+m; + int ch = currentMap.mapFlags[s][levelNum]; + // bit1 = attempted + // bit2 = completed + // bit3 = 100% kills + // bit4 = 100% secrets + // bit5 = 100% treasure + if ( m == 9 && !( ch & MF_TRIED ) ) { + color = colorSecret; + } if ( ch & MF_COMPLETED ) { + color = colorCompleted; + } else if ( ch & MF_TRIED ) { + color = colorTried; + } else { + color = colorNoTry; + } + + // blink the level you are currently on + if ( ( iphoneFrameNum & 8 ) && levelNum == currentMap.map && e == currentMap.episode ) { + color = colorNoTry; + } + + // draw the level text and check for button hit + if ( TouchDown( x-46, y-9, 88, 32 ) ) { + color = colorPressed; + } + R_Draw_Fill( x-46, y-9, 88, 32, color ); + iphoneCenterText( x, y, str ); + + // draw awards + if ( ch & MF_KILLS ) { + iphoneDrawPic( x-46,y+23, 22, 22, "iphone/kills.tga" ); + } + if ( ch & MF_SECRETS ) { + iphoneDrawPic( x-24,y+23, 22, 22, "iphone/secrets.tga" ); + } + if ( ch & MF_TREASURE ) { + iphoneDrawPic( x-2,y+23, 22, 22, "iphone/treasure.tga" ); + } + if ( ch & MF_TIME ) { + iphoneDrawPic( x+20,y+23, 22, 22, "iphone/partime.tga" ); + } + + // don't let them go to the secret level unless they earned it + if ( m == 9 && !( ch & MF_TRIED ) ) { + continue; + } + + if ( TouchReleased( x - 46, y - 9, 88, 32 ) ) { + PL_NewGame( &Player ); + iphoneStartMap( e, m, s ); + } + } +} + +/* + ================== + iphoneStartIntermission + + The framesFromNow value allow boss death animations to be triggered + ================== + */ +void iphoneStartIntermission( int framesFromNow ) { + // this goes in the savegame if they save at the intermission point, + // which will cause it to come back up there on return + currentMap.levelCompleted = 1; + + // mark this level as having been completed for the level selection menu + int mapNum = currentMap.episode * 10 + currentMap.map; + + // note that this has been tried now + currentMap.mapFlags[currentMap.skill][mapNum] |= MF_COMPLETED; + + // mark the awards + if ( levelstate.time / 70.0f < levelstate.fpartime * 60 ) { // fpartime is in minutes, time is in tics + currentMap.mapFlags[currentMap.skill][mapNum] |= MF_TIME; + } + if( levelstate.killed_monsters == levelstate.total_monsters ) { + currentMap.mapFlags[currentMap.skill][mapNum] |= MF_KILLS; + } + if( levelstate.found_secrets == levelstate.total_secrets ) { + currentMap.mapFlags[currentMap.skill][mapNum] |= MF_SECRETS; + } + if( levelstate.found_treasure == levelstate.total_treasure ) { + currentMap.mapFlags[currentMap.skill][mapNum] |= MF_TREASURE; + } + + intermissionStartFrameNum = iphoneFrameNum; + + if ( framesFromNow ) { + intermissionTriggerFrame = iphoneFrameNum + framesFromNow; + return; + } + + intermissionTriggerFrame = 0; + menuState = IPM_INTERMISSION; + hasReleased = 0; // ensure touch up before skipping intermission +} + +/* + ================== + DrawDigit + + ================== + */ +void DrawDigit( int x, int y, int digit ) { + R_Bind( numberPics[digit]->texnum ); + pfglBegin( GL_QUADS ); + + pfglTexCoord2f( 0, 0 ); pfglVertex2i( x, y ); + pfglTexCoord2f( 1, 0 ); pfglVertex2i( x+32, y ); + pfglTexCoord2f( 1, 1 ); pfglVertex2i( x+32, y+32 ); + pfglTexCoord2f( 0, 1 ); pfglVertex2i( x, y+32 ); + + pfglEnd(); +} + +void DrawDoubleDigit( int x, int y, int number ) { + int step = 32; + if ( number >= 100 ) { + // cram three digits into the same space + DrawDigit( x-8, y, number / 100 ); + number %= 100; + x += 16; + step = 24; + } + if ( number >= 10 ) { + DrawDigit( x, y, number / 10 ); + number %= 10; + } + DrawDigit( x+step, y, number ); +} + +void DrawTime( int x, int y, int seconds ) { + int min = seconds / 60; + int sec = seconds % 60; + + DrawDoubleDigit( x, y, min ); +// DrawDoubleDigit( x+76, y, sec ); + // always print both digits of seconds, so 2:00 prints correctly + DrawDigit( x+76, y, sec / 10 ); + DrawDigit( x+76+32, y, sec % 10 ); +} + +void DrawRatio( int y, int got, int total, const char *bonusPic ) { + DrawDoubleDigit( 285, y, got ); + DrawDoubleDigit( 361, y, total ); + + // draw the award icon + if ( got == total ) { + iphoneDrawPic( 480 - 40, y, 32, 32, bonusPic ); + } +} + +/* + ================== + iphoneIntermission + + ================== + */ +void iphoneIntermission() { + int nextLevel = 0; + char str[128]; + + iphoneDrawPic( 0, 0, 480, 320, "iphone/intermission.tga" ); + + // episode + my_snprintf( str, sizeof( str ), "iphone/button_ep%i.tga", currentMap.episode+1 ); + iphoneDrawPic( 0, 0, 384, 48, str ); + + // level + iphoneDrawNumber( 430, 0, currentMap.map + 1, 48, 48 ); + + // par / time + DrawTime( 51, 63, levelstate.fpartime * 60 ); // fpartime is in minutes + DrawTime( 285, 63, levelstate.time / 70 ); // levelstate.time is in tics + if ( levelstate.time/70 <= levelstate.fpartime * 60 ) { + iphoneDrawPic( 480 - 40, 63, 32, 32, "iphone/partime.tga" ); + } + + // ratios + DrawRatio( 124, levelstate.killed_monsters, levelstate.total_monsters, "iphone/kills.tga" ); + DrawRatio( 189, levelstate.found_secrets, levelstate.total_secrets, "iphone/secrets.tga" ); + DrawRatio( 255, levelstate.found_treasure, levelstate.total_treasure, "iphone/treasure.tga" ); + + // require all touches off before the intermission can exit + if ( numTouches == 0 && hasReleased == 0 ) { + hasReleased = 1; + return; // don't let the TouchReleased immediately fire + } + if ( !hasReleased ) { + return; + } + + //---------------------- + // tap for next level + //---------------------- + if ( !TouchReleased( 0, 0, 480, 320 ) ) { + return; + } + + menuState = IPM_GAME; + + PL_NextLevel( &Player ); + + if( g_version->value == SPEAROFDESTINY ) { + } + else + { + int currentLevel = currentMap.episode * 10 + currentMap.map; + + if( Player.playstate == ex_secretlevel ) { + switch( currentLevel ) { + case 0: nextLevel = 9; break; + case 10: nextLevel = 19; break; + case 26: nextLevel = 29; break; + case 32: nextLevel = 39; break; + case 44: nextLevel = 49; break; + case 52: nextLevel = 59; break; + } + } else { + switch ( currentLevel ) { + case 8: + case 18: + case 28: + case 38: + case 48: + case 58: + // go back to the episode select screen + menuState = IPM_VICTORY; + Sound_StartBGTrack( "music/URAHERO.ogg", "music/URAHERO.ogg" ); + return; + case 9: nextLevel = 1; break; + case 19: nextLevel = 11; break; + case 29: nextLevel = 27; break; + case 39: nextLevel = 33; break; + case 49: nextLevel = 44; break; + case 59: nextLevel = 53; break; + default: nextLevel = currentLevel + 1; break; + } + } + } + + iphoneStartMap( (nextLevel/10), (nextLevel%10), skill->value ); +} + +/* + ================== + iphoneVictory + + ================== + */ +void iphoneVictory() { + iphoneDrawPic( 0, 0, 480, 320, "iphone/victory.tga" ); + if ( !TouchReleased( 0, 0, 480, 320 ) ) { + return; + } + menuState = IPM_EPISODE; +} + +/* + ================== + iphoneAutomap + + ================== + */ +float mapOrigin[2]; +float mapCenterY; +float mapScale; + +typedef struct { + W8 x, y; + short texnum; +} mapTile_t; +#define MAPTILE_SPRITE_FLAG 1024 +#define MAX_MAP_TILES 5000 // 4096 tiles + sprites +mapTile_t mapTiles[MAX_MAP_TILES]; +int numMapTiles; + +int MapTileSort( const void *a, const void *b ) { + return ((mapTile_t *)a)->texnum - ((mapTile_t *)b)->texnum; +} + +void iphoneOpenAutomap() { + mapTile_t *mt = mapTiles; + numMapTiles = 0; + int x, y; + int xx, yy; + W32 tx, ty, n; + sprite_t* sprt; + + mapOrigin[0] = Player.position.origin[0] / (float)TILEGLOBAL; + mapOrigin[1] = Player.position.origin[1] / (float)TILEGLOBAL; + mapScale = 10; + menuState = IPM_AUTOMAP; + + // identify all the tiles to fill in + for( x = 0 ; x < 64; ++x ) { + for( y = 0 ; y < 64; ++y ) { + if ( r_world->tilemap[ x ][ y ] & ( WALL_TILE | PUSHWALL_TILE ) ) { + int visible = 0; + // check all 8 surrounding tiles for visibility + for ( xx = -1 ; xx <= 1 ; xx++ ) { + if ( x + xx < 0 ) { + continue; + } + if ( x + xx > 63 ) { + continue; + } + for ( yy = -1 ; yy <= 1 ; yy++ ) { + if ( y + yy < 0 ) { + continue; + } + if ( y + yy > 63 ) { + continue; + } + if ( r_world->tileEverVisible[x+xx][y+yy] ) { + visible = 1; + break; + } + } + } + if ( !visible ) { + continue; + } + int tex = r_world->wall_tex_y[ x ][ y ]; + // special hack for the elevator switch tile, which is always + // facing east west for the switch, and north south for the railing + if ( tex == 40 && ( ( x>0 && r_world->tileEverVisible[x+1][y] ) + || ( x < 63 && r_world->tileEverVisible[x-1][y] ) ) ) { + tex = r_world->wall_tex_x[ x ][ y ]; + } + if ( tex < 0x6a ) { // skip pushwall destinations + assert( tex >= 0 && tex < 1000 ); + mt->x = x; + mt->y = y; + mt->texnum = tex; + if ( !wallTextures[mt->texnum] ) { + char name[1024]; + my_snprintf( name, sizeof( name ), "walls/%.3d.tga", mt->texnum ); + wallTextures[mt->texnum] = TM_FindTexture( name, TT_Wall ); + assert( wallTextures[mt->texnum] ); + } + mt++; + continue; + } + } + if ( !r_world->tileEverVisible[x][y] ) { + continue; + } + if( r_world->tilemap[ x ][ y ] & DOOR_TILE ) { + mt->x = x; + mt->y = y; + mt->texnum = r_world->Doors.DoorMap[ x ][ y ].texture; + if ( !wallTextures[ mt->texnum] ) { + char name[1024]; + my_snprintf( name, sizeof( name ), "walls/%.3d.tga", mt->texnum ); + wallTextures[mt->texnum] = TM_FindTexture( name, TT_Wall ); + assert( wallTextures[mt->texnum] ); + } + mt++; + continue; + } + // solid floor + mt->x = x; + mt->y = y; + mt->texnum = -1; + mt++; + } + } + + // add solid sprite objects + for( n = 0, sprt = Spr_Sprites; n < n_of_sprt; ++n, ++sprt ) { + if( sprt->flags & SPRT_REMOVE ) { + continue; + } + if ( sprt->tex[0] >= SPR_GRD_S_1 ) { + // don't draw enemies, only static sprites + continue; + } + + tx = sprt->tilex; + ty = sprt->tiley; + + if( tx > 63 ) { + continue; + } + if( ty > 63 ) { + continue; + } + if ( !r_world->tileEverVisible[tx][ty] ) { + continue; + } + mt->x = tx; + mt->y = ty; + mt->texnum = MAPTILE_SPRITE_FLAG | sprt->tex[0]; + mt++; + + if ( !spriteTextures[ sprt->tex[0] ] ) { + char name[1024]; + my_snprintf( name, sizeof( name ), "sprites/%.3d.tga", sprt->tex[0] ); + spriteTextures[sprt->tex[0]] = TM_FindTexture( name, TT_Sprite ); + } + + if ( mt == &mapTiles[MAX_MAP_TILES] ) { + break; // list is full, some items won't show (shouldn't happen) + } + } + + // sort the tiles to be drawn by texture + numMapTiles = mt - mapTiles; + + qsort( mapTiles, numMapTiles, sizeof( mapTiles[0] ), MapTileSort ); +} + +void iphoneAutomap() { + mapTile_t *mt; + float px, py; + float angle, c, s; + int texnum; + + // do touch ops before drawing for minimum latency + + // drag for scrolling + if ( numTouches == 1 ) { + if ( numPrevTouches == 1 ) { + mapOrigin[0] -= ( touches[0][0] - prevTouches[0][0] ) / mapScale; + mapOrigin[1] += ( touches[0][1] - prevTouches[0][1] ) / mapScale; + } + } + + // pinch for scaling + if ( numTouches == 2 ) { + if ( numPrevTouches == 2 ) { + float curDist = sqrt( + ( touches[0][0] - touches[1][0] ) * ( touches[0][0] - touches[1][0] ) + + ( touches[0][1] - touches[1][1] ) * ( touches[0][1] - touches[1][1] ) ); + float prevDist = sqrt( + ( prevTouches[0][0] - prevTouches[1][0] ) * ( prevTouches[0][0] - prevTouches[1][0] ) + + ( prevTouches[0][1] - prevTouches[1][1] ) * ( prevTouches[0][1] - prevTouches[1][1] ) ); + if ( prevDist == 0 ) { + prevDist = curDist; + } + mapScale *= curDist / prevDist; + if ( mapScale < 4 ) { + mapScale = 4; + } + if ( mapScale > 64 ) { + mapScale = 64; + } + } + + } + + // todo -- double tap for center on player + + + // set up matrix for drawing in tile units + pfglMatrixMode( GL_PROJECTION ); + pfglLoadIdentity(); + pfglRotatef( 90, 0, 0, 1 ); + pfglOrtho( mapOrigin[0]-240.0 / mapScale, mapOrigin[0]+240.0 / mapScale, + mapOrigin[1]-160.0 / mapScale, mapOrigin[1]+160.0 / mapScale, -99999, 99999 ); + + mt = mapTiles; + texnum = 99999; + for ( int i = 0 ; i < numMapTiles ; i++, mt++ ) { + if ( texnum != mt->texnum ) { + texnum = mt->texnum; + if ( i != 0 ) { + pfglEnd(); + } + if ( mt->texnum == -1 ) { + qglDisable( GL_TEXTURE_2D ); + pfglColor3f( r_world->floorColour[0]/255.0, r_world->floorColour[1]/255.0, r_world->floorColour[2]/255.0 ); + } else if ( mt->texnum & MAPTILE_SPRITE_FLAG ) { + qglEnable( GL_TEXTURE_2D ); + pfglColor3f( 1, 1, 1 ); + R_Bind( spriteTextures[mt->texnum&~MAPTILE_SPRITE_FLAG]->texnum ); + } else { + qglEnable( GL_TEXTURE_2D ); + pfglColor3f( 1, 1, 1 ); + R_Bind( wallTextures[mt->texnum]->texnum ); + } + pfglBegin( GL_QUADS ); + } + pfglTexCoord2f( 0, 1 ); + pfglVertex2i( mt->x, mt->y ); + pfglTexCoord2f( 1, 1 ); + pfglVertex2i( mt->x+1, mt->y ); + pfglTexCoord2f( 1, 0 ); + pfglVertex2i( mt->x+1, mt->y+1 ); + pfglTexCoord2f( 0, 0 ); + pfglVertex2i( mt->x, mt->y+1 ); + } + pfglEnd(); + + // draw the yellow player triangle + qglDisable( GL_TEXTURE_2D ); + if ( iphoneFrameNum & 8 ) { // blink it + pfglColor3f( 1, 1, 0 ); + } else { + pfglColor3f( 0.5, 0.5, 0 ); + } + angle = M_PI * Player.position.angle / (float)ANG_180; + c = cos( angle ); + s = sin( angle ); + px = Player.position.origin[0] / (float)TILEGLOBAL; + py = Player.position.origin[1] / (float)TILEGLOBAL; + pfglBegin( GL_TRIANGLES ); + pfglVertex3f( px + c * 0.5, py + s * 0.5, 0 ); + pfglVertex3f( px - c * 0.5 - s * 0.3, py - s * 0.5 + c * 0.3, 0 ); + pfglVertex3f( px - c * 0.5 + s * 0.3, py - s * 0.5 - c * 0.3, 0 ); + pfglEnd(); + + qglEnable( GL_TEXTURE_2D ); + pfglColor3f( 1, 1, 1 ); + + // back button for returning to game + pfglMatrixMode( GL_PROJECTION ); + pfglLoadIdentity(); + pfglRotatef( 90, 0, 0, 1 ); + pfglOrtho( 0, 480, 320, 0, -99999, 99999 ); + if ( BackButton() ) { + menuState = IPM_GAME; + } +} + +void iphoneDrawMenus() { + iphoneDrawPic( 0, 0, 480, 320, "iphone/background_1.tga" ); + + switch ( menuState ) { + case IPM_MAIN: iphoneMainMenu(); break; + case IPM_SKILL: iphoneSkillMenu(); break; + case IPM_EPISODE: iphoneEpisodeMenu(); break; + case IPM_MAPS: iphoneMapMenu(); break; + case IPM_CONTROLS: iphoneControlMenu(); break; + case IPM_INTERMISSION: iphoneIntermission(); break; + case IPM_VICTORY: iphoneVictory(); break; + case IPM_AUTOMAP: iphoneAutomap(); break; + } +} + + diff --git a/src/sdl/iphone/iphone_qgl.h b/src/sdl/iphone/iphone_qgl.h new file mode 100755 index 000000000..793ec74db --- /dev/null +++ b/src/sdl/iphone/iphone_qgl.h @@ -0,0 +1,2392 @@ +/**** This file is autogenerated. Run GenerateQGL.pl to update it ****/ + +#ifndef _IPHONE_QGL_H_ +#define _IPHONE_QGL_H_ + +#ifdef QGL_LOG_GL_CALLS +extern unsigned int QGLLogGLCalls; +#ifdef __cplusplus +extern "C" { +#endif + FILE *QGLDebugFile(void); +#ifdef __cplusplus +} +#endif +#endif + +#include "iphone_qgl_enumerants.h" + + +#ifdef __cplusplus +extern "C" { +#endif + void QGLCheckError(const char *message); +#ifdef __cplusplus +} +#endif +extern unsigned int QGLBeginStarted; + +// This has to be done to avoid infinite recursion between our glGetError wrapper and QGLCheckError() +static inline GLenum _glGetError(void) { + return glGetError(); +} + +// void glAlphaFunc (GLenum func, GLclampf ref); +static inline void qglAlphaFunc(GLenum func, GLclampf ref) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glAlphaFunc(func=%s, ref=%f)\n", StringFromGLEnumerant( func ), ref); +#endif + glAlphaFunc(func, ref); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glAlphaFunc"); +#endif +} + +// void glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +static inline void qglClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glClearColor(red=%f, green=%f, blue=%f, alpha=%f)\n", red, green, blue, alpha); +#endif + glClearColor(red, green, blue, alpha); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glClearColor"); +#endif +} + +// void glClearDepthf (GLclampf depth); +static inline void qglClearDepthf(GLclampf depth) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glClearDepthf(depth=%f)\n", depth); +#endif + glClearDepthf(depth); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glClearDepthf"); +#endif +} + +// void glClipPlanef (GLenum plane, const GLfloat *equation); +static inline void qglClipPlanef(GLenum plane, const GLfloat *equation) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glClipPlanef(plane=%s, equation=%p)\n", StringFromGLEnumerant( plane ), equation); +#endif + glClipPlanef(plane, equation); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glClipPlanef"); +#endif +} + +// void glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +// void glDepthRangef (GLclampf zNear, GLclampf zFar); +static inline void qglDepthRangef(GLclampf zNear, GLclampf zFar) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDepthRangef(zNear=%f, zFar=%f)\n", zNear, zFar); +#endif + glDepthRangef(zNear, zFar); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDepthRangef"); +#endif +} + +// void glFogf (GLenum pname, GLfloat param); +static inline void qglFogf(GLenum pname, GLfloat param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glFogf(pname=%s, param=%f)\n", StringFromGLEnumerant( pname ), param); +#endif + glFogf(pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glFogf"); +#endif +} + +// void glFogfv (GLenum pname, const GLfloat *params); +static inline void qglFogfv(GLenum pname, const GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glFogfv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glFogfv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glFogfv"); +#endif +} + +// void glFrustumf (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); +static inline void qglFrustumf(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glFrustumf(left=%f, right=%f, bottom=%f, top=%f, zNear=%f, zFar=%f)\n", left, right, bottom, top, zNear, zFar); +#endif + glFrustumf(left, right, bottom, top, zNear, zFar); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glFrustumf"); +#endif +} + +// void glGetClipPlanef (GLenum pname, GLfloat *equation); +static inline void qglGetClipPlanef(GLenum pname, GLfloat *equation) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetClipPlanef(pname=%s, equation=%p)\n", StringFromGLEnumerant( pname ), equation); +#endif + glGetClipPlanef(pname, equation); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetClipPlanef"); +#endif +} + +// void glGetFloatv (GLenum pname, GLfloat *params); +static inline void qglGetFloatv(GLenum pname, GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetFloatv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glGetFloatv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetFloatv"); +#endif +} + +// void glGetLightfv (GLenum light, GLenum pname, GLfloat *params); +static inline void qglGetLightfv(GLenum light, GLenum pname, GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetLightfv(light=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( light ), StringFromGLEnumerant( pname ), params); +#endif + glGetLightfv(light, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetLightfv"); +#endif +} + +// void glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params); +static inline void qglGetMaterialfv(GLenum face, GLenum pname, GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetMaterialfv(face=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( face ), StringFromGLEnumerant( pname ), params); +#endif + glGetMaterialfv(face, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetMaterialfv"); +#endif +} + +// void glGetTexEnvfv (GLenum env, GLenum pname, GLfloat *params); +static inline void qglGetTexEnvfv(GLenum env, GLenum pname, GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetTexEnvfv(env=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( env ), StringFromGLEnumerant( pname ), params); +#endif + glGetTexEnvfv(env, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetTexEnvfv"); +#endif +} + +// void glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); +static inline void qglGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetTexParameterfv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glGetTexParameterfv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetTexParameterfv"); +#endif +} + +// void glLightModelf (GLenum pname, GLfloat param); +static inline void qglLightModelf(GLenum pname, GLfloat param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLightModelf(pname=%s, param=%f)\n", StringFromGLEnumerant( pname ), param); +#endif + glLightModelf(pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLightModelf"); +#endif +} + +// void glLightModelfv (GLenum pname, const GLfloat *params); +static inline void qglLightModelfv(GLenum pname, const GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLightModelfv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glLightModelfv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLightModelfv"); +#endif +} + +// void glLightf (GLenum light, GLenum pname, GLfloat param); +static inline void qglLightf(GLenum light, GLenum pname, GLfloat param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLightf(light=%s, pname=%s, param=%f)\n", StringFromGLEnumerant( light ), StringFromGLEnumerant( pname ), param); +#endif + glLightf(light, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLightf"); +#endif +} + +// void glLightfv (GLenum light, GLenum pname, const GLfloat *params); +static inline void qglLightfv(GLenum light, GLenum pname, const GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLightfv(light=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( light ), StringFromGLEnumerant( pname ), params); +#endif + glLightfv(light, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLightfv"); +#endif +} + +// void glLineWidth (GLfloat width); +static inline void qglLineWidth(GLfloat width) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLineWidth(width=%f)\n", width); +#endif + glLineWidth(width); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLineWidth"); +#endif +} + +// void glLoadMatrixf (const GLfloat *m); +static inline void qglLoadMatrixf(const GLfloat *m) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLoadMatrixf(m=%p)\n", m); +#endif + glLoadMatrixf(m); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLoadMatrixf"); +#endif +} + +// void glMaterialf (GLenum face, GLenum pname, GLfloat param); +static inline void qglMaterialf(GLenum face, GLenum pname, GLfloat param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMaterialf(face=%s, pname=%s, param=%f)\n", StringFromGLEnumerant( face ), StringFromGLEnumerant( pname ), param); +#endif + glMaterialf(face, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMaterialf"); +#endif +} + +// void glMaterialfv (GLenum face, GLenum pname, const GLfloat *params); +static inline void qglMaterialfv(GLenum face, GLenum pname, const GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMaterialfv(face=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( face ), StringFromGLEnumerant( pname ), params); +#endif + glMaterialfv(face, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMaterialfv"); +#endif +} + +// void glMultMatrixf (const GLfloat *m); +static inline void qglMultMatrixf(const GLfloat *m) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMultMatrixf(m=%p)\n", m); +#endif + glMultMatrixf(m); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMultMatrixf"); +#endif +} + +// void glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +static inline void qglMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMultiTexCoord4f(target=%s, s=%f, t=%f, r=%f, q=%f)\n", StringFromGLEnumerant( target ), s, t, r, q); +#endif + glMultiTexCoord4f(target, s, t, r, q); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMultiTexCoord4f"); +#endif +} + +// void glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz); +static inline void qglNormal3f(GLfloat nx, GLfloat ny, GLfloat nz) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glNormal3f(nx=%f, ny=%f, nz=%f)\n", nx, ny, nz); +#endif + glNormal3f(nx, ny, nz); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glNormal3f"); +#endif +} + +// void glOrthof (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); +static inline void qglOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glOrthof(left=%f, right=%f, bottom=%f, top=%f, zNear=%f, zFar=%f)\n", left, right, bottom, top, zNear, zFar); +#endif + glOrthof(left, right, bottom, top, zNear, zFar); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glOrthof"); +#endif +} + +// void glPointParameterf (GLenum pname, GLfloat param); +static inline void qglPointParameterf(GLenum pname, GLfloat param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPointParameterf(pname=%s, param=%f)\n", StringFromGLEnumerant( pname ), param); +#endif + glPointParameterf(pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPointParameterf"); +#endif +} + +// void glPointParameterfv (GLenum pname, const GLfloat *params); +static inline void qglPointParameterfv(GLenum pname, const GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPointParameterfv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glPointParameterfv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPointParameterfv"); +#endif +} + +// void glPointSize (GLfloat size); +static inline void qglPointSize(GLfloat size) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPointSize(size=%f)\n", size); +#endif + glPointSize(size); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPointSize"); +#endif +} + +// void glPolygonOffset (GLfloat factor, GLfloat units); +static inline void qglPolygonOffset(GLfloat factor, GLfloat units) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPolygonOffset(factor=%f, units=%f)\n", factor, units); +#endif + glPolygonOffset(factor, units); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPolygonOffset"); +#endif +} + +// void glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +static inline void qglRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glRotatef(angle=%f, x=%f, y=%f, z=%f)\n", angle, x, y, z); +#endif + glRotatef(angle, x, y, z); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glRotatef"); +#endif +} + +// void glScalef (GLfloat x, GLfloat y, GLfloat z); +static inline void qglScalef(GLfloat x, GLfloat y, GLfloat z) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glScalef(x=%f, y=%f, z=%f)\n", x, y, z); +#endif + glScalef(x, y, z); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glScalef"); +#endif +} + +// void glTexEnvf (GLenum target, GLenum pname, GLfloat param); +static inline void qglTexEnvf(GLenum target, GLenum pname, GLfloat param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexEnvf(target=%s, pname=%s, param=%f)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), param); +#endif + glTexEnvf(target, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexEnvf"); +#endif +} + +// void glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params); +static inline void qglTexEnvfv(GLenum target, GLenum pname, const GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexEnvfv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glTexEnvfv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexEnvfv"); +#endif +} + +// void glTexParameterf (GLenum target, GLenum pname, GLfloat param); +static inline void qglTexParameterf(GLenum target, GLenum pname, GLfloat param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexParameterf(target=%s, pname=%s, param=%f)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), param); +#endif + glTexParameterf(target, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexParameterf"); +#endif +} + +// void glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); +static inline void qglTexParameterfv(GLenum target, GLenum pname, const GLfloat *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexParameterfv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glTexParameterfv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexParameterfv"); +#endif +} + +// void glTranslatef (GLfloat x, GLfloat y, GLfloat z); +static inline void qglTranslatef(GLfloat x, GLfloat y, GLfloat z) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTranslatef(x=%f, y=%f, z=%f)\n", x, y, z); +#endif + glTranslatef(x, y, z); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTranslatef"); +#endif +} + +// void glActiveTexture (GLenum texture); +static inline void qglActiveTexture(GLenum texture) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glActiveTexture(texture=%s)\n", StringFromGLEnumerant( texture )); +#endif + glActiveTexture(texture); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glActiveTexture"); +#endif +} + +// void glAlphaFuncx (GLenum func, GLclampx ref); +static inline void qglAlphaFuncx(GLenum func, GLclampx ref) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glAlphaFuncx(func=%s, ref=%ld)\n", StringFromGLEnumerant( func ), ref); +#endif + glAlphaFuncx(func, ref); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glAlphaFuncx"); +#endif +} + +// void glBindBuffer (GLenum target, GLuint buffer); +static inline void qglBindBuffer(GLenum target, GLuint buffer) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glBindBuffer(target=%s, buffer=%lu)\n", StringFromGLEnumerant( target ), buffer); +#endif + glBindBuffer(target, buffer); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glBindBuffer"); +#endif +} + +// void glBindTexture (GLenum target, GLuint texture); +static inline void qglBindTexture(GLenum target, GLuint texture) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glBindTexture(target=%s, texture=%lu)\n", StringFromGLEnumerant( target ), texture); +#endif + glBindTexture(target, texture); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glBindTexture"); +#endif +} + +// void glBlendFunc (GLenum sfactor, GLenum dfactor); +static inline void qglBlendFunc(GLenum sfactor, GLenum dfactor) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glBlendFunc(sfactor=%s, dfactor=%s)\n", StringFromGLEnumerant( sfactor ), StringFromGLEnumerant( dfactor )); +#endif + glBlendFunc(sfactor, dfactor); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glBlendFunc"); +#endif +} + +// void glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +static inline void qglBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glBufferData(target=%s, size=%ld, data=%p, usage=%s)\n", StringFromGLEnumerant( target ), size, data, StringFromGLEnumerant( usage )); +#endif + glBufferData(target, size, data, usage); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glBufferData"); +#endif +} + +// void glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +static inline void qglBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glBufferSubData(target=%s, offset=%ld, size=%ld, data=%p)\n", StringFromGLEnumerant( target ), offset, size, data); +#endif + glBufferSubData(target, offset, size, data); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glBufferSubData"); +#endif +} + +// void glClear (GLbitfield mask); +static inline void qglClear(GLbitfield mask) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glClear(mask=%lu)\n", mask); +#endif + glClear(mask); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glClear"); +#endif +} + +// void glClearColorx (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha); +static inline void qglClearColorx(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glClearColorx(red=%ld, green=%ld, blue=%ld, alpha=%ld)\n", red, green, blue, alpha); +#endif + glClearColorx(red, green, blue, alpha); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glClearColorx"); +#endif +} + +// void glClearDepthx (GLclampx depth); +static inline void qglClearDepthx(GLclampx depth) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glClearDepthx(depth=%ld)\n", depth); +#endif + glClearDepthx(depth); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glClearDepthx"); +#endif +} + +// void glClearStencil (GLint s); +static inline void qglClearStencil(GLint s) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glClearStencil(s=%ld)\n", s); +#endif + glClearStencil(s); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glClearStencil"); +#endif +} + +// void glClientActiveTexture (GLenum texture); +static inline void qglClientActiveTexture(GLenum texture) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glClientActiveTexture(texture=%s)\n", StringFromGLEnumerant( texture )); +#endif + glClientActiveTexture(texture); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glClientActiveTexture"); +#endif +} + +// void glClipPlanex (GLenum plane, const GLfixed *equation); +static inline void qglClipPlanex(GLenum plane, const GLfixed *equation) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glClipPlanex(plane=%s, equation=%p)\n", StringFromGLEnumerant( plane ), equation); +#endif + glClipPlanex(plane, equation); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glClipPlanex"); +#endif +} + +// void glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +static inline void qglColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glColor4ub(red=%u, green=%u, blue=%u, alpha=%u)\n", red, green, blue, alpha); +#endif + glColor4ub(red, green, blue, alpha); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glColor4ub"); +#endif +} + +// void glColor4x (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +static inline void qglColor4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glColor4x(red=%ld, green=%ld, blue=%ld, alpha=%ld)\n", red, green, blue, alpha); +#endif + glColor4x(red, green, blue, alpha); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glColor4x"); +#endif +} + +// void glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +static inline void qglColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glColorMask(red=%u, green=%u, blue=%u, alpha=%u)\n", red, green, blue, alpha); +#endif + glColorMask(red, green, blue, alpha); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glColorMask"); +#endif +} + +// void glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +static inline void qglColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glColorPointer(size=%ld, type=%s, stride=%ld, pointer=%p)\n", size, StringFromGLEnumerant( type ), stride, pointer); +#endif + glColorPointer(size, type, stride, pointer); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glColorPointer"); +#endif +} + +// void glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +static inline void qglCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glCompressedTexImage2D(target=%s, level=%ld, internalformat=%s, width=%ld, height=%ld, border=%ld, imageSize=%ld, data=%p)\n", StringFromGLEnumerant( target ), level, StringFromGLEnumerant( internalformat ), width, height, border, imageSize, data); +#endif + glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glCompressedTexImage2D"); +#endif +} + +// void glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +static inline void qglCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glCompressedTexSubImage2D(target=%s, level=%ld, xoffset=%ld, yoffset=%ld, width=%ld, height=%ld, format=%s, imageSize=%ld, data=%p)\n", StringFromGLEnumerant( target ), level, xoffset, yoffset, width, height, StringFromGLEnumerant( format ), imageSize, data); +#endif + glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glCompressedTexSubImage2D"); +#endif +} + +// void glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +static inline void qglCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glCopyTexImage2D(target=%s, level=%ld, internalformat=%s, x=%ld, y=%ld, width=%ld, height=%ld, border=%ld)\n", StringFromGLEnumerant( target ), level, StringFromGLEnumerant( internalformat ), x, y, width, height, border); +#endif + glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glCopyTexImage2D"); +#endif +} + +// void glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +static inline void qglCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glCopyTexSubImage2D(target=%s, level=%ld, xoffset=%ld, yoffset=%ld, x=%ld, y=%ld, width=%ld, height=%ld)\n", StringFromGLEnumerant( target ), level, xoffset, yoffset, x, y, width, height); +#endif + glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glCopyTexSubImage2D"); +#endif +} + +// void glCullFace (GLenum mode); +static inline void qglCullFace(GLenum mode) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glCullFace(mode=%s)\n", StringFromGLEnumerant( mode )); +#endif + glCullFace(mode); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glCullFace"); +#endif +} + +// void glDeleteBuffers (GLsizei n, const GLuint *buffers); +static inline void qglDeleteBuffers(GLsizei n, const GLuint *buffers) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDeleteBuffers(n=%ld, buffers=%p)\n", n, buffers); +#endif + glDeleteBuffers(n, buffers); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDeleteBuffers"); +#endif +} + +// void glDeleteTextures (GLsizei n, const GLuint *textures); +static inline void qglDeleteTextures(GLsizei n, const GLuint *textures) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDeleteTextures(n=%ld, textures=%p)\n", n, textures); +#endif + glDeleteTextures(n, textures); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDeleteTextures"); +#endif +} + +// void glDepthFunc (GLenum func); +static inline void qglDepthFunc(GLenum func) +{ + func = GL_ALWAYS; +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDepthFunc(func=%s)\n", StringFromGLEnumerant( func )); +#endif + glDepthFunc(func); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDepthFunc"); +#endif +} + +// void glDepthMask (GLboolean flag); +static inline void qglDepthMask(GLboolean flag) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDepthMask(flag=%u)\n", flag); +#endif + glDepthMask(flag); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDepthMask"); +#endif +} + +// void glDepthRangex (GLclampx zNear, GLclampx zFar); +static inline void qglDepthRangex(GLclampx zNear, GLclampx zFar) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDepthRangex(zNear=%ld, zFar=%ld)\n", zNear, zFar); +#endif + glDepthRangex(zNear, zFar); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDepthRangex"); +#endif +} + +// void glDisable (GLenum cap); +static inline void qglDisable(GLenum cap) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDisable(cap=%s)\n", StringFromGLEnumerant( cap )); +#endif + glDisable(cap); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDisable"); +#endif +} + +// void glDisableClientState (GLenum array); +static inline void qglDisableClientState(GLenum array) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDisableClientState(array=%s)\n", StringFromGLEnumerant( array )); +#endif + glDisableClientState(array); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDisableClientState"); +#endif +} + +// void glDrawArrays (GLenum mode, GLint first, GLsizei count); +static inline void qglDrawArrays(GLenum mode, GLint first, GLsizei count) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawArrays(mode=%s, first=%ld, count=%ld)\n", StringFromGLEnumerant( mode ), first, count); +#endif + glDrawArrays(mode, first, count); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawArrays"); +#endif +} + +// void glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); +static inline void qglDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawElements(mode=%s, count=%ld, type=%s, indices=%p)\n", StringFromGLEnumerant( mode ), count, StringFromGLEnumerant( type ), indices); +#endif + glDrawElements(mode, count, type, indices); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawElements"); +#endif +} + +// void glEnable (GLenum cap); +static inline void qglEnable(GLenum cap) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glEnable(cap=%s)\n", StringFromGLEnumerant( cap )); +#endif + glEnable(cap); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glEnable"); +#endif +} + +// void glEnableClientState (GLenum array); +static inline void qglEnableClientState(GLenum array) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glEnableClientState(array=%s)\n", StringFromGLEnumerant( array )); +#endif + glEnableClientState(array); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glEnableClientState"); +#endif +} + +// void glFinish (void); +static inline void qglFinish(void) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glFinish(void)\n"); +#endif + glFinish(); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glFinish"); +#endif +} + +// void glFlush (void); +static inline void qglFlush(void) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glFlush(void)\n"); +#endif + glFlush(); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glFlush"); +#endif +} + +// void glFogx (GLenum pname, GLfixed param); +static inline void qglFogx(GLenum pname, GLfixed param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glFogx(pname=%s, param=%ld)\n", StringFromGLEnumerant( pname ), param); +#endif + glFogx(pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glFogx"); +#endif +} + +// void glFogxv (GLenum pname, const GLfixed *params); +static inline void qglFogxv(GLenum pname, const GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glFogxv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glFogxv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glFogxv"); +#endif +} + +// void glFrontFace (GLenum mode); +static inline void qglFrontFace(GLenum mode) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glFrontFace(mode=%s)\n", StringFromGLEnumerant( mode )); +#endif + glFrontFace(mode); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glFrontFace"); +#endif +} + +// void glFrustumx (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); +static inline void qglFrustumx(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glFrustumx(left=%ld, right=%ld, bottom=%ld, top=%ld, zNear=%ld, zFar=%ld)\n", left, right, bottom, top, zNear, zFar); +#endif + glFrustumx(left, right, bottom, top, zNear, zFar); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glFrustumx"); +#endif +} + +// void glGetBooleanv (GLenum pname, GLboolean *params); +static inline void qglGetBooleanv(GLenum pname, GLboolean *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetBooleanv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glGetBooleanv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetBooleanv"); +#endif +} + +// void glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +static inline void qglGetBufferParameteriv(GLenum target, GLenum pname, GLint *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetBufferParameteriv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glGetBufferParameteriv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetBufferParameteriv"); +#endif +} + +// void glGetClipPlanex (GLenum pname, GLfixed eqn[4]); +static inline void qglGetClipPlanex(GLenum pname, GLfixed eqn[4]) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetClipPlanex(pname=%s, eqn=%ld)\n", StringFromGLEnumerant( pname ), eqn); +#endif + glGetClipPlanex(pname, eqn); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetClipPlanex"); +#endif +} + +// void glGenBuffers (GLsizei n, GLuint *buffers); +static inline void qglGenBuffers(GLsizei n, GLuint *buffers) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGenBuffers(n=%ld, buffers=%p)\n", n, buffers); +#endif + glGenBuffers(n, buffers); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGenBuffers"); +#endif +} + +// void glGenTextures (GLsizei n, GLuint *textures); +static inline void qglGenTextures(GLsizei n, GLuint *textures) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGenTextures(n=%ld, textures=%p)\n", n, textures); +#endif + glGenTextures(n, textures); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGenTextures"); +#endif +} + +// GLenum glGetError (void); +static inline GLenum qglGetError(void) +{ + GLenum returnValue; +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetError(void)\n"); +#endif + returnValue = glGetError(); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetError"); +#endif + return returnValue; +} + +// void glGetFixedv (GLenum pname, GLfixed *params); +static inline void qglGetFixedv(GLenum pname, GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetFixedv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glGetFixedv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetFixedv"); +#endif +} + +// void glGetIntegerv (GLenum pname, GLint *params); +static inline void qglGetIntegerv(GLenum pname, GLint *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetIntegerv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glGetIntegerv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetIntegerv"); +#endif +} + +// void glGetLightxv (GLenum light, GLenum pname, GLfixed *params); +static inline void qglGetLightxv(GLenum light, GLenum pname, GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetLightxv(light=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( light ), StringFromGLEnumerant( pname ), params); +#endif + glGetLightxv(light, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetLightxv"); +#endif +} + +// void glGetMaterialxv (GLenum face, GLenum pname, GLfixed *params); +static inline void qglGetMaterialxv(GLenum face, GLenum pname, GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetMaterialxv(face=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( face ), StringFromGLEnumerant( pname ), params); +#endif + glGetMaterialxv(face, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetMaterialxv"); +#endif +} + +// void glGetPointerv (GLenum pname, void **params); +static inline void qglGetPointerv(GLenum pname, void **params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetPointerv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glGetPointerv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetPointerv"); +#endif +} + +// const GLubyte * glGetString (GLenum name); +static inline const GLubyte * qglGetString(GLenum name) +{ + const GLubyte * returnValue; +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetString(name=%s)\n", StringFromGLEnumerant( name )); +#endif + returnValue = glGetString(name); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetString"); +#endif + return returnValue; +} + +// void glGetTexEnviv (GLenum env, GLenum pname, GLint *params); +static inline void qglGetTexEnviv(GLenum env, GLenum pname, GLint *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetTexEnviv(env=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( env ), StringFromGLEnumerant( pname ), params); +#endif + glGetTexEnviv(env, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetTexEnviv"); +#endif +} + +// void glGetTexEnvxv (GLenum env, GLenum pname, GLfixed *params); +static inline void qglGetTexEnvxv(GLenum env, GLenum pname, GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetTexEnvxv(env=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( env ), StringFromGLEnumerant( pname ), params); +#endif + glGetTexEnvxv(env, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetTexEnvxv"); +#endif +} + +// void glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); +static inline void qglGetTexParameteriv(GLenum target, GLenum pname, GLint *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetTexParameteriv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glGetTexParameteriv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetTexParameteriv"); +#endif +} + +// void glGetTexParameterxv (GLenum target, GLenum pname, GLfixed *params); +static inline void qglGetTexParameterxv(GLenum target, GLenum pname, GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glGetTexParameterxv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glGetTexParameterxv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glGetTexParameterxv"); +#endif +} + +// void glHint (GLenum target, GLenum mode); +static inline void qglHint(GLenum target, GLenum mode) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glHint(target=%s, mode=%s)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( mode )); +#endif + glHint(target, mode); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glHint"); +#endif +} + +// GLboolean glIsBuffer (GLuint buffer); +static inline GLboolean qglIsBuffer(GLuint buffer) +{ + GLboolean returnValue; +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glIsBuffer(buffer=%lu)\n", buffer); +#endif + returnValue = glIsBuffer(buffer); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glIsBuffer"); +#endif + return returnValue; +} + +// GLboolean glIsEnabled (GLenum cap); +static inline GLboolean qglIsEnabled(GLenum cap) +{ + GLboolean returnValue; +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glIsEnabled(cap=%s)\n", StringFromGLEnumerant( cap )); +#endif + returnValue = glIsEnabled(cap); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glIsEnabled"); +#endif + return returnValue; +} + +// GLboolean glIsTexture (GLuint texture); +static inline GLboolean qglIsTexture(GLuint texture) +{ + GLboolean returnValue; +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glIsTexture(texture=%lu)\n", texture); +#endif + returnValue = glIsTexture(texture); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glIsTexture"); +#endif + return returnValue; +} + +// void glLightModelx (GLenum pname, GLfixed param); +static inline void qglLightModelx(GLenum pname, GLfixed param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLightModelx(pname=%s, param=%ld)\n", StringFromGLEnumerant( pname ), param); +#endif + glLightModelx(pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLightModelx"); +#endif +} + +// void glLightModelxv (GLenum pname, const GLfixed *params); +static inline void qglLightModelxv(GLenum pname, const GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLightModelxv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glLightModelxv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLightModelxv"); +#endif +} + +// void glLightx (GLenum light, GLenum pname, GLfixed param); +static inline void qglLightx(GLenum light, GLenum pname, GLfixed param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLightx(light=%s, pname=%s, param=%ld)\n", StringFromGLEnumerant( light ), StringFromGLEnumerant( pname ), param); +#endif + glLightx(light, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLightx"); +#endif +} + +// void glLightxv (GLenum light, GLenum pname, const GLfixed *params); +static inline void qglLightxv(GLenum light, GLenum pname, const GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLightxv(light=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( light ), StringFromGLEnumerant( pname ), params); +#endif + glLightxv(light, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLightxv"); +#endif +} + +// void glLineWidthx (GLfixed width); +static inline void qglLineWidthx(GLfixed width) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLineWidthx(width=%ld)\n", width); +#endif + glLineWidthx(width); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLineWidthx"); +#endif +} + +// void glLoadIdentity (void); +static inline void qglLoadIdentity(void) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLoadIdentity(void)\n"); +#endif + glLoadIdentity(); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLoadIdentity"); +#endif +} + +// void glLoadMatrixx (const GLfixed *m); +static inline void qglLoadMatrixx(const GLfixed *m) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLoadMatrixx(m=%p)\n", m); +#endif + glLoadMatrixx(m); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLoadMatrixx"); +#endif +} + +// void glLogicOp (GLenum opcode); +static inline void qglLogicOp(GLenum opcode) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLogicOp(opcode=%s)\n", StringFromGLEnumerant( opcode )); +#endif + glLogicOp(opcode); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLogicOp"); +#endif +} + +// void glMaterialx (GLenum face, GLenum pname, GLfixed param); +static inline void qglMaterialx(GLenum face, GLenum pname, GLfixed param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMaterialx(face=%s, pname=%s, param=%ld)\n", StringFromGLEnumerant( face ), StringFromGLEnumerant( pname ), param); +#endif + glMaterialx(face, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMaterialx"); +#endif +} + +// void glMaterialxv (GLenum face, GLenum pname, const GLfixed *params); +static inline void qglMaterialxv(GLenum face, GLenum pname, const GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMaterialxv(face=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( face ), StringFromGLEnumerant( pname ), params); +#endif + glMaterialxv(face, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMaterialxv"); +#endif +} + +// void glMatrixMode (GLenum mode); +static inline void qglMatrixMode(GLenum mode) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMatrixMode(mode=%s)\n", StringFromGLEnumerant( mode )); +#endif + glMatrixMode(mode); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMatrixMode"); +#endif +} + +// void glMultMatrixx (const GLfixed *m); +static inline void qglMultMatrixx(const GLfixed *m) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMultMatrixx(m=%p)\n", m); +#endif + glMultMatrixx(m); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMultMatrixx"); +#endif +} + +// void glMultiTexCoord4x (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +static inline void qglMultiTexCoord4x(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMultiTexCoord4x(target=%s, s=%ld, t=%ld, r=%ld, q=%ld)\n", StringFromGLEnumerant( target ), s, t, r, q); +#endif + glMultiTexCoord4x(target, s, t, r, q); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMultiTexCoord4x"); +#endif +} + +// void glNormal3x (GLfixed nx, GLfixed ny, GLfixed nz); +static inline void qglNormal3x(GLfixed nx, GLfixed ny, GLfixed nz) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glNormal3x(nx=%ld, ny=%ld, nz=%ld)\n", nx, ny, nz); +#endif + glNormal3x(nx, ny, nz); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glNormal3x"); +#endif +} + +// void glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer); +static inline void qglNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glNormalPointer(type=%s, stride=%ld, pointer=%p)\n", StringFromGLEnumerant( type ), stride, pointer); +#endif + glNormalPointer(type, stride, pointer); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glNormalPointer"); +#endif +} + +// void glOrthox (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); +static inline void qglOrthox(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glOrthox(left=%ld, right=%ld, bottom=%ld, top=%ld, zNear=%ld, zFar=%ld)\n", left, right, bottom, top, zNear, zFar); +#endif + glOrthox(left, right, bottom, top, zNear, zFar); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glOrthox"); +#endif +} + +// void glPixelStorei (GLenum pname, GLint param); +static inline void qglPixelStorei(GLenum pname, GLint param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPixelStorei(pname=%s, param=%ld)\n", StringFromGLEnumerant( pname ), param); +#endif + glPixelStorei(pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPixelStorei"); +#endif +} + +// void glPointParameterx (GLenum pname, GLfixed param); +static inline void qglPointParameterx(GLenum pname, GLfixed param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPointParameterx(pname=%s, param=%ld)\n", StringFromGLEnumerant( pname ), param); +#endif + glPointParameterx(pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPointParameterx"); +#endif +} + +// void glPointParameterxv (GLenum pname, const GLfixed *params); +static inline void qglPointParameterxv(GLenum pname, const GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPointParameterxv(pname=%s, params=%p)\n", StringFromGLEnumerant( pname ), params); +#endif + glPointParameterxv(pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPointParameterxv"); +#endif +} + +// void glPointSizex (GLfixed size); +static inline void qglPointSizex(GLfixed size) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPointSizex(size=%ld)\n", size); +#endif + glPointSizex(size); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPointSizex"); +#endif +} + +// void glPolygonOffsetx (GLfixed factor, GLfixed units); +static inline void qglPolygonOffsetx(GLfixed factor, GLfixed units) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPolygonOffsetx(factor=%ld, units=%ld)\n", factor, units); +#endif + glPolygonOffsetx(factor, units); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPolygonOffsetx"); +#endif +} + +// void glPopMatrix (void); +static inline void qglPopMatrix(void) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPopMatrix(void)\n"); +#endif + glPopMatrix(); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPopMatrix"); +#endif +} + +// void glPushMatrix (void); +static inline void qglPushMatrix(void) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPushMatrix(void)\n"); +#endif + glPushMatrix(); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPushMatrix"); +#endif +} + +// void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); +static inline void qglReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glReadPixels(x=%ld, y=%ld, width=%ld, height=%ld, format=%s, type=%s, pixels=%p)\n", x, y, width, height, StringFromGLEnumerant( format ), StringFromGLEnumerant( type ), pixels); +#endif + glReadPixels(x, y, width, height, format, type, pixels); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glReadPixels"); +#endif +} + +// void glRotatex (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +static inline void qglRotatex(GLfixed angle, GLfixed x, GLfixed y, GLfixed z) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glRotatex(angle=%ld, x=%ld, y=%ld, z=%ld)\n", angle, x, y, z); +#endif + glRotatex(angle, x, y, z); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glRotatex"); +#endif +} + +// void glSampleCoverage (GLclampf value, GLboolean invert); +static inline void qglSampleCoverage(GLclampf value, GLboolean invert) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glSampleCoverage(value=%f, invert=%u)\n", value, invert); +#endif + glSampleCoverage(value, invert); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glSampleCoverage"); +#endif +} + +// void glSampleCoveragex (GLclampx value, GLboolean invert); +static inline void qglSampleCoveragex(GLclampx value, GLboolean invert) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glSampleCoveragex(value=%ld, invert=%u)\n", value, invert); +#endif + glSampleCoveragex(value, invert); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glSampleCoveragex"); +#endif +} + +// void glScalex (GLfixed x, GLfixed y, GLfixed z); +static inline void qglScalex(GLfixed x, GLfixed y, GLfixed z) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glScalex(x=%ld, y=%ld, z=%ld)\n", x, y, z); +#endif + glScalex(x, y, z); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glScalex"); +#endif +} + +// void glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +static inline void qglScissor(GLint x, GLint y, GLsizei width, GLsizei height) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glScissor(x=%ld, y=%ld, width=%ld, height=%ld)\n", x, y, width, height); +#endif + // fixme + int vidHeight = 320; +glScissor(vidHeight - y - height, x, height, width); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glScissor"); +#endif +} + +// void glShadeModel (GLenum mode); +static inline void qglShadeModel(GLenum mode) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glShadeModel(mode=%s)\n", StringFromGLEnumerant( mode )); +#endif + glShadeModel(mode); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glShadeModel"); +#endif +} + +// void glStencilFunc (GLenum func, GLint ref, GLuint mask); +static inline void qglStencilFunc(GLenum func, GLint ref, GLuint mask) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glStencilFunc(func=%s, ref=%ld, mask=%lu)\n", StringFromGLEnumerant( func ), ref, mask); +#endif + glStencilFunc(func, ref, mask); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glStencilFunc"); +#endif +} + +// void glStencilMask (GLuint mask); +static inline void qglStencilMask(GLuint mask) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glStencilMask(mask=%lu)\n", mask); +#endif + glStencilMask(mask); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glStencilMask"); +#endif +} + +// void glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +static inline void qglStencilOp(GLenum fail, GLenum zfail, GLenum zpass) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glStencilOp(fail=%s, zfail=%s, zpass=%s)\n", StringFromGLEnumerant( fail ), StringFromGLEnumerant( zfail ), StringFromGLEnumerant( zpass )); +#endif + glStencilOp(fail, zfail, zpass); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glStencilOp"); +#endif +} + +// void glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +static inline void qglTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexCoordPointer(size=%ld, type=%s, stride=%ld, pointer=%p)\n", size, StringFromGLEnumerant( type ), stride, pointer); +#endif + glTexCoordPointer(size, type, stride, pointer); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexCoordPointer"); +#endif +} + +// void glTexEnvi (GLenum target, GLenum pname, GLint param); +static inline void qglTexEnvi(GLenum target, GLenum pname, GLint param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexEnvi(target=%s, pname=%s, param=%ld)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), param); +#endif + glTexEnvi(target, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexEnvi"); +#endif +} + +// void glTexEnvx (GLenum target, GLenum pname, GLfixed param); +static inline void qglTexEnvx(GLenum target, GLenum pname, GLfixed param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexEnvx(target=%s, pname=%s, param=%ld)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), param); +#endif + glTexEnvx(target, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexEnvx"); +#endif +} + +// void glTexEnviv (GLenum target, GLenum pname, const GLint *params); +static inline void qglTexEnviv(GLenum target, GLenum pname, const GLint *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexEnviv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glTexEnviv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexEnviv"); +#endif +} + +// void glTexEnvxv (GLenum target, GLenum pname, const GLfixed *params); +static inline void qglTexEnvxv(GLenum target, GLenum pname, const GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexEnvxv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glTexEnvxv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexEnvxv"); +#endif +} + +// void glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +static inline void qglTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexImage2D(target=%s, level=%ld, internalformat=%ld, width=%ld, height=%ld, border=%ld, format=%s, type=%s, pixels=%p)\n", StringFromGLEnumerant( target ), level, internalformat, width, height, border, StringFromGLEnumerant( format ), StringFromGLEnumerant( type ), pixels); +#endif + glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexImage2D"); +#endif +} + +// void glTexParameteri (GLenum target, GLenum pname, GLint param); +static inline void qglTexParameteri(GLenum target, GLenum pname, GLint param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexParameteri(target=%s, pname=%s, param=%ld)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), param); +#endif + glTexParameteri(target, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexParameteri"); +#endif +} + +// void glTexParameterx (GLenum target, GLenum pname, GLfixed param); +static inline void qglTexParameterx(GLenum target, GLenum pname, GLfixed param) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexParameterx(target=%s, pname=%s, param=%ld)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), param); +#endif + glTexParameterx(target, pname, param); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexParameterx"); +#endif +} + +// void glTexParameteriv (GLenum target, GLenum pname, const GLint *params); +static inline void qglTexParameteriv(GLenum target, GLenum pname, const GLint *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexParameteriv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glTexParameteriv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexParameteriv"); +#endif +} + +// void glTexParameterxv (GLenum target, GLenum pname, const GLfixed *params); +static inline void qglTexParameterxv(GLenum target, GLenum pname, const GLfixed *params) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexParameterxv(target=%s, pname=%s, params=%p)\n", StringFromGLEnumerant( target ), StringFromGLEnumerant( pname ), params); +#endif + glTexParameterxv(target, pname, params); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexParameterxv"); +#endif +} + +// void glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +static inline void qglTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTexSubImage2D(target=%s, level=%ld, xoffset=%ld, yoffset=%ld, width=%ld, height=%ld, format=%s, type=%s, pixels=%p)\n", StringFromGLEnumerant( target ), level, xoffset, yoffset, width, height, StringFromGLEnumerant( format ), StringFromGLEnumerant( type ), pixels); +#endif + glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTexSubImage2D"); +#endif +} + +// void glTranslatex (GLfixed x, GLfixed y, GLfixed z); +static inline void qglTranslatex(GLfixed x, GLfixed y, GLfixed z) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glTranslatex(x=%ld, y=%ld, z=%ld)\n", x, y, z); +#endif + glTranslatex(x, y, z); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glTranslatex"); +#endif +} + +// void glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +static inline void qglVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glVertexPointer(size=%ld, type=%s, stride=%ld, pointer=%p)\n", size, StringFromGLEnumerant( type ), stride, pointer); +#endif + glVertexPointer(size, type, stride, pointer); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glVertexPointer"); +#endif +} + +// void glViewport (GLint x, GLint y, GLsizei width, GLsizei height); +static inline void qglViewport(GLint x, GLint y, GLsizei width, GLsizei height) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glViewport(x=%ld, y=%ld, width=%ld, height=%ld)\n", x, y, width, height); +#endif +//extern glconfig_t glConfig; + int vidHeight = 320; + glViewport(vidHeight - y - height, x, height, width); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glViewport"); +#endif +} + +// void glCurrentPaletteMatrixOES (GLuint matrixpaletteindex); +static inline void qglCurrentPaletteMatrixOES(GLuint matrixpaletteindex) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glCurrentPaletteMatrixOES(matrixpaletteindex=%lu)\n", matrixpaletteindex); +#endif + glCurrentPaletteMatrixOES(matrixpaletteindex); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glCurrentPaletteMatrixOES"); +#endif +} + +// void glLoadPaletteFromModelViewMatrixOES (void); +static inline void qglLoadPaletteFromModelViewMatrixOES(void) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glLoadPaletteFromModelViewMatrixOES(void)\n"); +#endif + glLoadPaletteFromModelViewMatrixOES(); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glLoadPaletteFromModelViewMatrixOES"); +#endif +} + +// void glMatrixIndexPointerOES (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +static inline void qglMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glMatrixIndexPointerOES(size=%ld, type=%s, stride=%ld, pointer=%p)\n", size, StringFromGLEnumerant( type ), stride, pointer); +#endif + glMatrixIndexPointerOES(size, type, stride, pointer); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glMatrixIndexPointerOES"); +#endif +} + +// void glWeightPointerOES (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +static inline void qglWeightPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glWeightPointerOES(size=%ld, type=%s, stride=%ld, pointer=%p)\n", size, StringFromGLEnumerant( type ), stride, pointer); +#endif + glWeightPointerOES(size, type, stride, pointer); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glWeightPointerOES"); +#endif +} + +// void glPointSizePointerOES (GLenum type, GLsizei stride, const GLvoid *pointer); +static inline void qglPointSizePointerOES(GLenum type, GLsizei stride, const GLvoid *pointer) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glPointSizePointerOES(type=%s, stride=%ld, pointer=%p)\n", StringFromGLEnumerant( type ), stride, pointer); +#endif + glPointSizePointerOES(type, stride, pointer); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glPointSizePointerOES"); +#endif +} + +// void glDrawTexsOES (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height); +static inline void qglDrawTexsOES(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawTexsOES(x=%d, y=%d, z=%d, width=%d, height=%d)\n", x, y, z, width, height); +#endif + glDrawTexsOES(x, y, z, width, height); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawTexsOES"); +#endif +} + +// void glDrawTexiOES (GLint x, GLint y, GLint z, GLint width, GLint height); +static inline void qglDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawTexiOES(x=%ld, y=%ld, z=%ld, width=%ld, height=%ld)\n", x, y, z, width, height); +#endif + glDrawTexiOES(x, y, z, width, height); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawTexiOES"); +#endif +} + +// void glDrawTexxOES (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height); +static inline void qglDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawTexxOES(x=%ld, y=%ld, z=%ld, width=%ld, height=%ld)\n", x, y, z, width, height); +#endif + glDrawTexxOES(x, y, z, width, height); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawTexxOES"); +#endif +} + +// void glDrawTexsvOES (const GLshort *coords); +static inline void qglDrawTexsvOES(const GLshort *coords) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawTexsvOES(coords=%p)\n", coords); +#endif + glDrawTexsvOES(coords); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawTexsvOES"); +#endif +} + +// void glDrawTexivOES (const GLint *coords); +static inline void qglDrawTexivOES(const GLint *coords) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawTexivOES(coords=%p)\n", coords); +#endif + glDrawTexivOES(coords); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawTexivOES"); +#endif +} + +// void glDrawTexxvOES (const GLfixed *coords); +static inline void qglDrawTexxvOES(const GLfixed *coords) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawTexxvOES(coords=%p)\n", coords); +#endif + glDrawTexxvOES(coords); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawTexxvOES"); +#endif +} + +// void glDrawTexfOES (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); +static inline void qglDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawTexfOES(x=%f, y=%f, z=%f, width=%f, height=%f)\n", x, y, z, width, height); +#endif + glDrawTexfOES(x, y, z, width, height); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawTexfOES"); +#endif +} + +// void glDrawTexfvOES (const GLfloat *coords); +static inline void qglDrawTexfvOES(const GLfloat *coords) +{ +#if !defined(NDEBUG) && defined(QGL_LOG_GL_CALLS) + if (QGLLogGLCalls) + fprintf(QGLDebugFile(), "glDrawTexfvOES(coords=%p)\n", coords); +#endif + glDrawTexfvOES(coords); +#if !defined(NDEBUG) && defined(QGL_CHECK_GL_ERRORS) + if (!QGLBeginStarted) + QGLCheckError("glDrawTexfvOES"); +#endif +} + +// Prevent calls to the 'normal' GL functions +#define glAlphaFunc CALL_THE_QGL_VERSION_OF_glAlphaFunc +#define glClearColor CALL_THE_QGL_VERSION_OF_glClearColor +#define glClearDepthf CALL_THE_QGL_VERSION_OF_glClearDepthf +#define glClipPlanef CALL_THE_QGL_VERSION_OF_glClipPlanef +#define glDepthRangef CALL_THE_QGL_VERSION_OF_glDepthRangef +#define glFogf CALL_THE_QGL_VERSION_OF_glFogf +#define glFogfv CALL_THE_QGL_VERSION_OF_glFogfv +#define glFrustumf CALL_THE_QGL_VERSION_OF_glFrustumf +#define glGetClipPlanef CALL_THE_QGL_VERSION_OF_glGetClipPlanef +#define glGetFloatv CALL_THE_QGL_VERSION_OF_glGetFloatv +#define glGetLightfv CALL_THE_QGL_VERSION_OF_glGetLightfv +#define glGetMaterialfv CALL_THE_QGL_VERSION_OF_glGetMaterialfv +#define glGetTexEnvfv CALL_THE_QGL_VERSION_OF_glGetTexEnvfv +#define glGetTexParameterfv CALL_THE_QGL_VERSION_OF_glGetTexParameterfv +#define glLightModelf CALL_THE_QGL_VERSION_OF_glLightModelf +#define glLightModelfv CALL_THE_QGL_VERSION_OF_glLightModelfv +#define glLightf CALL_THE_QGL_VERSION_OF_glLightf +#define glLightfv CALL_THE_QGL_VERSION_OF_glLightfv +#define glLineWidth CALL_THE_QGL_VERSION_OF_glLineWidth +#define glLoadMatrixf CALL_THE_QGL_VERSION_OF_glLoadMatrixf +#define glMaterialf CALL_THE_QGL_VERSION_OF_glMaterialf +#define glMaterialfv CALL_THE_QGL_VERSION_OF_glMaterialfv +#define glMultMatrixf CALL_THE_QGL_VERSION_OF_glMultMatrixf +#define glMultiTexCoord4f CALL_THE_QGL_VERSION_OF_glMultiTexCoord4f +#define glNormal3f CALL_THE_QGL_VERSION_OF_glNormal3f +#define glOrthof CALL_THE_QGL_VERSION_OF_glOrthof +#define glPointParameterf CALL_THE_QGL_VERSION_OF_glPointParameterf +#define glPointParameterfv CALL_THE_QGL_VERSION_OF_glPointParameterfv +#define glPointSize CALL_THE_QGL_VERSION_OF_glPointSize +#define glPolygonOffset CALL_THE_QGL_VERSION_OF_glPolygonOffset +#define glRotatef CALL_THE_QGL_VERSION_OF_glRotatef +#define glScalef CALL_THE_QGL_VERSION_OF_glScalef +#define glTexEnvf CALL_THE_QGL_VERSION_OF_glTexEnvf +#define glTexEnvfv CALL_THE_QGL_VERSION_OF_glTexEnvfv +#define glTexParameterf CALL_THE_QGL_VERSION_OF_glTexParameterf +#define glTexParameterfv CALL_THE_QGL_VERSION_OF_glTexParameterfv +#define glTranslatef CALL_THE_QGL_VERSION_OF_glTranslatef +#define glActiveTexture CALL_THE_QGL_VERSION_OF_glActiveTexture +#define glAlphaFuncx CALL_THE_QGL_VERSION_OF_glAlphaFuncx +#define glBindBuffer CALL_THE_QGL_VERSION_OF_glBindBuffer +#define glBindTexture CALL_THE_QGL_VERSION_OF_glBindTexture +#define glBlendFunc CALL_THE_QGL_VERSION_OF_glBlendFunc +#define glBufferData CALL_THE_QGL_VERSION_OF_glBufferData +#define glBufferSubData CALL_THE_QGL_VERSION_OF_glBufferSubData +#define glClear CALL_THE_QGL_VERSION_OF_glClear +#define glClearColorx CALL_THE_QGL_VERSION_OF_glClearColorx +#define glClearDepthx CALL_THE_QGL_VERSION_OF_glClearDepthx +#define glClearStencil CALL_THE_QGL_VERSION_OF_glClearStencil +#define glClientActiveTexture CALL_THE_QGL_VERSION_OF_glClientActiveTexture +#define glClipPlanex CALL_THE_QGL_VERSION_OF_glClipPlanex +#define glColor4ub CALL_THE_QGL_VERSION_OF_glColor4ub +#define glColor4x CALL_THE_QGL_VERSION_OF_glColor4x +#define glColorMask CALL_THE_QGL_VERSION_OF_glColorMask +#define glColorPointer CALL_THE_QGL_VERSION_OF_glColorPointer +#define glCompressedTexImage2D CALL_THE_QGL_VERSION_OF_glCompressedTexImage2D +#define glCompressedTexSubImage2D CALL_THE_QGL_VERSION_OF_glCompressedTexSubImage2D +#define glCopyTexImage2D CALL_THE_QGL_VERSION_OF_glCopyTexImage2D +#define glCopyTexSubImage2D CALL_THE_QGL_VERSION_OF_glCopyTexSubImage2D +#define glCullFace CALL_THE_QGL_VERSION_OF_glCullFace +#define glDeleteBuffers CALL_THE_QGL_VERSION_OF_glDeleteBuffers +#define glDeleteTextures CALL_THE_QGL_VERSION_OF_glDeleteTextures +#define glDepthFunc CALL_THE_QGL_VERSION_OF_glDepthFunc +#define glDepthMask CALL_THE_QGL_VERSION_OF_glDepthMask +#define glDepthRangex CALL_THE_QGL_VERSION_OF_glDepthRangex +#define glDisable CALL_THE_QGL_VERSION_OF_glDisable +#define glDisableClientState CALL_THE_QGL_VERSION_OF_glDisableClientState +#define glDrawArrays CALL_THE_QGL_VERSION_OF_glDrawArrays +#define glDrawElements CALL_THE_QGL_VERSION_OF_glDrawElements +#define glEnable CALL_THE_QGL_VERSION_OF_glEnable +#define glEnableClientState CALL_THE_QGL_VERSION_OF_glEnableClientState +#define glFinish CALL_THE_QGL_VERSION_OF_glFinish +#define glFlush CALL_THE_QGL_VERSION_OF_glFlush +#define glFogx CALL_THE_QGL_VERSION_OF_glFogx +#define glFogxv CALL_THE_QGL_VERSION_OF_glFogxv +#define glFrontFace CALL_THE_QGL_VERSION_OF_glFrontFace +#define glFrustumx CALL_THE_QGL_VERSION_OF_glFrustumx +#define glGetBooleanv CALL_THE_QGL_VERSION_OF_glGetBooleanv +#define glGetBufferParameteriv CALL_THE_QGL_VERSION_OF_glGetBufferParameteriv +#define glGetClipPlanex CALL_THE_QGL_VERSION_OF_glGetClipPlanex +#define glGenBuffers CALL_THE_QGL_VERSION_OF_glGenBuffers +#define glGenTextures CALL_THE_QGL_VERSION_OF_glGenTextures +#define glGetError CALL_THE_QGL_VERSION_OF_glGetError +#define glGetFixedv CALL_THE_QGL_VERSION_OF_glGetFixedv +#define glGetIntegerv CALL_THE_QGL_VERSION_OF_glGetIntegerv +#define glGetLightxv CALL_THE_QGL_VERSION_OF_glGetLightxv +#define glGetMaterialxv CALL_THE_QGL_VERSION_OF_glGetMaterialxv +#define glGetPointerv CALL_THE_QGL_VERSION_OF_glGetPointerv +#define glGetString CALL_THE_QGL_VERSION_OF_glGetString +#define glGetTexEnviv CALL_THE_QGL_VERSION_OF_glGetTexEnviv +#define glGetTexEnvxv CALL_THE_QGL_VERSION_OF_glGetTexEnvxv +#define glGetTexParameteriv CALL_THE_QGL_VERSION_OF_glGetTexParameteriv +#define glGetTexParameterxv CALL_THE_QGL_VERSION_OF_glGetTexParameterxv +#define glHint CALL_THE_QGL_VERSION_OF_glHint +#define glIsBuffer CALL_THE_QGL_VERSION_OF_glIsBuffer +#define glIsEnabled CALL_THE_QGL_VERSION_OF_glIsEnabled +#define glIsTexture CALL_THE_QGL_VERSION_OF_glIsTexture +#define glLightModelx CALL_THE_QGL_VERSION_OF_glLightModelx +#define glLightModelxv CALL_THE_QGL_VERSION_OF_glLightModelxv +#define glLightx CALL_THE_QGL_VERSION_OF_glLightx +#define glLightxv CALL_THE_QGL_VERSION_OF_glLightxv +#define glLineWidthx CALL_THE_QGL_VERSION_OF_glLineWidthx +#define glLoadIdentity CALL_THE_QGL_VERSION_OF_glLoadIdentity +#define glLoadMatrixx CALL_THE_QGL_VERSION_OF_glLoadMatrixx +#define glLogicOp CALL_THE_QGL_VERSION_OF_glLogicOp +#define glMaterialx CALL_THE_QGL_VERSION_OF_glMaterialx +#define glMaterialxv CALL_THE_QGL_VERSION_OF_glMaterialxv +#define glMatrixMode CALL_THE_QGL_VERSION_OF_glMatrixMode +#define glMultMatrixx CALL_THE_QGL_VERSION_OF_glMultMatrixx +#define glMultiTexCoord4x CALL_THE_QGL_VERSION_OF_glMultiTexCoord4x +#define glNormal3x CALL_THE_QGL_VERSION_OF_glNormal3x +#define glNormalPointer CALL_THE_QGL_VERSION_OF_glNormalPointer +#define glOrthox CALL_THE_QGL_VERSION_OF_glOrthox +#define glPixelStorei CALL_THE_QGL_VERSION_OF_glPixelStorei +#define glPointParameterx CALL_THE_QGL_VERSION_OF_glPointParameterx +#define glPointParameterxv CALL_THE_QGL_VERSION_OF_glPointParameterxv +#define glPointSizex CALL_THE_QGL_VERSION_OF_glPointSizex +#define glPolygonOffsetx CALL_THE_QGL_VERSION_OF_glPolygonOffsetx +#define glPopMatrix CALL_THE_QGL_VERSION_OF_glPopMatrix +#define glPushMatrix CALL_THE_QGL_VERSION_OF_glPushMatrix +#define glReadPixels CALL_THE_QGL_VERSION_OF_glReadPixels +#define glRotatex CALL_THE_QGL_VERSION_OF_glRotatex +#define glSampleCoverage CALL_THE_QGL_VERSION_OF_glSampleCoverage +#define glSampleCoveragex CALL_THE_QGL_VERSION_OF_glSampleCoveragex +#define glScalex CALL_THE_QGL_VERSION_OF_glScalex +#define glScissor CALL_THE_QGL_VERSION_OF_glScissor +#define glShadeModel CALL_THE_QGL_VERSION_OF_glShadeModel +#define glStencilFunc CALL_THE_QGL_VERSION_OF_glStencilFunc +#define glStencilMask CALL_THE_QGL_VERSION_OF_glStencilMask +#define glStencilOp CALL_THE_QGL_VERSION_OF_glStencilOp +#define glTexCoordPointer CALL_THE_QGL_VERSION_OF_glTexCoordPointer +#define glTexEnvi CALL_THE_QGL_VERSION_OF_glTexEnvi +#define glTexEnvx CALL_THE_QGL_VERSION_OF_glTexEnvx +#define glTexEnviv CALL_THE_QGL_VERSION_OF_glTexEnviv +#define glTexEnvxv CALL_THE_QGL_VERSION_OF_glTexEnvxv +#define glTexImage2D CALL_THE_QGL_VERSION_OF_glTexImage2D +#define glTexParameteri CALL_THE_QGL_VERSION_OF_glTexParameteri +#define glTexParameterx CALL_THE_QGL_VERSION_OF_glTexParameterx +#define glTexParameteriv CALL_THE_QGL_VERSION_OF_glTexParameteriv +#define glTexParameterxv CALL_THE_QGL_VERSION_OF_glTexParameterxv +#define glTexSubImage2D CALL_THE_QGL_VERSION_OF_glTexSubImage2D +#define glTranslatex CALL_THE_QGL_VERSION_OF_glTranslatex +#define glVertexPointer CALL_THE_QGL_VERSION_OF_glVertexPointer +#define glViewport CALL_THE_QGL_VERSION_OF_glViewport +#define glCurrentPaletteMatrixOES CALL_THE_QGL_VERSION_OF_glCurrentPaletteMatrixOES +#define glLoadPaletteFromModelViewMatrixOES CALL_THE_QGL_VERSION_OF_glLoadPaletteFromModelViewMatrixOES +#define glMatrixIndexPointerOES CALL_THE_QGL_VERSION_OF_glMatrixIndexPointerOES +#define glWeightPointerOES CALL_THE_QGL_VERSION_OF_glWeightPointerOES +#define glPointSizePointerOES CALL_THE_QGL_VERSION_OF_glPointSizePointerOES +#define glDrawTexsOES CALL_THE_QGL_VERSION_OF_glDrawTexsOES +#define glDrawTexiOES CALL_THE_QGL_VERSION_OF_glDrawTexiOES +#define glDrawTexxOES CALL_THE_QGL_VERSION_OF_glDrawTexxOES +#define glDrawTexsvOES CALL_THE_QGL_VERSION_OF_glDrawTexsvOES +#define glDrawTexivOES CALL_THE_QGL_VERSION_OF_glDrawTexivOES +#define glDrawTexxvOES CALL_THE_QGL_VERSION_OF_glDrawTexxvOES +#define glDrawTexfOES CALL_THE_QGL_VERSION_OF_glDrawTexfOES +#define glDrawTexfvOES CALL_THE_QGL_VERSION_OF_glDrawTexfvOES + +#endif // _IPHONE_QGL_H_ diff --git a/src/sdl/iphone/iphone_qgl_enumerants.h b/src/sdl/iphone/iphone_qgl_enumerants.h new file mode 100755 index 000000000..01892dd15 --- /dev/null +++ b/src/sdl/iphone/iphone_qgl_enumerants.h @@ -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 + +#ifdef __cplusplus +extern "C" { +#endif + + const char *StringFromGLEnumerant( GLenum enumerant ); + +#ifdef __cplusplus +} +#endif + +#endif // QGL_LOG_GL_CALLS + +#endif // IPHONE_QGL_ENUMERANTS_H \ No newline at end of file diff --git a/src/sdl/iphone/iphone_wolf.h b/src/sdl/iphone/iphone_wolf.h new file mode 100755 index 000000000..5314edf60 --- /dev/null +++ b/src/sdl/iphone/iphone_wolf.h @@ -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 ); + diff --git a/src/sdl/iphone/main.m b/src/sdl/iphone/main.m new file mode 100755 index 000000000..189bf40cf --- /dev/null +++ b/src/sdl/iphone/main.m @@ -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 +#include +#include + +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; +} diff --git a/src/sdl/iphone/wolf3dAppDelegate.h b/src/sdl/iphone/wolf3dAppDelegate.h new file mode 100755 index 000000000..be67d5b5f --- /dev/null +++ b/src/sdl/iphone/wolf3dAppDelegate.h @@ -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 +#import + +#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 { + 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 + diff --git a/src/sdl/iphone/wolf3dAppDelegate.m b/src/sdl/iphone/wolf3dAppDelegate.m new file mode 100755 index 000000000..84fa5744c --- /dev/null +++ b/src/sdl/iphone/wolf3dAppDelegate.m @@ -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 + +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 + + +