Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- initial commit to Repository

  • Loading branch information...
commit 50364fb87645d615c8522ac05d96d46eb130372a 0 parents
jlamarche authored
Showing with 42,475 additions and 0 deletions.
  1. +12 −0 .gitignore
  2. +120 −0 Blender Export/objc-export-2.4.9/objc.py
  3. +50 −0 Blender Export/objc-export-2.5/objc.py
  4. +18 −0 Categories/UIColor-OpenGL.h
  5. +79 −0 Categories/UIColor-OpenGL.m
  6. +18 −0 Classes/JDLGLUtils.h
  7. +58 −0 Classes/JDLGLUtils.m
  8. +33 −0 OpenGL ES 1.1 Project Template/Classes/ConstantsAndMacros.h
  9. +41 −0 OpenGL ES 1.1 Project Template/Classes/GLView.h
  10. +15 −0 OpenGL ES 1.1 Project Template/Classes/GLViewController.h
  11. +40 −0 OpenGL ES 1.1 Project Template/Classes/GLViewController.m
  12. +1,040 −0 OpenGL ES 1.1 Project Template/Classes/OpenGLCommon.h
  13. +22 −0 OpenGL ES 1.1 Project Template/Classes/OpenGLTexture3D.h
  14. +88 −0 OpenGL ES 1.1 Project Template/Classes/OpenGLTexture3D.m
  15. +22 −0 OpenGL ES 1.1 Project Template/Classes/___PROJECTNAMEASIDENTIFIER___AppDelegate.h
  16. +40 −0 OpenGL ES 1.1 Project Template/Classes/___PROJECTNAMEASIDENTIFIER___AppDelegate.m
  17. +156 −0 OpenGL ES 1.1 Project Template/GLView.m
  18. +500 −0 OpenGL ES 1.1 Project Template/MainWindow.xib
  19. +516 −0 OpenGL ES 1.1 Project Template/Resources-iPad/MainWindow-iPad.xib
  20. +32 −0 OpenGL ES 1.1 Project Template/___PROJECTNAMEASIDENTIFIER___-Info.plist
  21. +9 −0 OpenGL ES 1.1 Project Template/___PROJECTNAMEASIDENTIFIER____Prefix.pch
  22. BIN  OpenGL ES 1.1 Project Template/___PROJECTNAME___.xcodeproj/TemplateIcon.icns
  23. +8 −0 OpenGL ES 1.1 Project Template/___PROJECTNAME___.xcodeproj/TemplateInfo.plist
  24. +289 −0 OpenGL ES 1.1 Project Template/___PROJECTNAME___.xcodeproj/project.pbxproj
  25. +17 −0 OpenGL ES 1.1 Project Template/main.m
  26. +23 −0 README
  27. BIN  Simple OpenGL ES 1.1 example/.zip
  28. +18 −0 Simple OpenGL ES 1.1 example/Classes/ConstantsAndMacros.h
  29. +40 −0 Simple OpenGL ES 1.1 example/Classes/GLView.h
  30. +203 −0 Simple OpenGL ES 1.1 example/Classes/GLView.m
  31. +21 −0 Simple OpenGL ES 1.1 example/Classes/GLViewController.h
  32. +189 −0 Simple OpenGL ES 1.1 example/Classes/GLViewController.m
  33. +669 −0 Simple OpenGL ES 1.1 example/Classes/OpenGLCommon.h
  34. +18 −0 Simple OpenGL ES 1.1 example/Classes/Part6ProjectAppDelegate.h
  35. +45 −0 Simple OpenGL ES 1.1 example/Classes/Part6ProjectAppDelegate.m
  36. +28 −0 Simple OpenGL ES 1.1 example/Info.plist
  37. +189 −0 Simple OpenGL ES 1.1 example/MainWindow.xib
  38. +3 −0  Simple OpenGL ES 1.1 example/Part6Project_Prefix.pch
  39. +1,417 −0 Simple OpenGL ES 1.1 example/Part8Project.xcodeproj/jeff.mode1v3
  40. +320 −0 Simple OpenGL ES 1.1 example/Part8Project.xcodeproj/jeff.pbxuser
  41. +1,524 −0 Simple OpenGL ES 1.1 example/Part8Project.xcodeproj/jeff.perspectivev3
  42. +291 −0 Simple OpenGL ES 1.1 example/Part8Project.xcodeproj/project.pbxproj
  43. +18 −0 Simple OpenGL ES 1.1 example/main.m
  44. +302 −0 Simple OpenGL ES 2.0 Example/Classes/GLCommon.h
  45. +18 −0 Simple OpenGL ES 2.0 Example/Classes/GLProgram.h
  46. +182 −0 Simple OpenGL ES 2.0 Example/Classes/GLProgram.m
  47. +22 −0 Simple OpenGL ES 2.0 Example/Classes/GLTexture.h
  48. +80 −0 Simple OpenGL ES 2.0 Example/Classes/GLTexture.m
  49. +17 −0 Simple OpenGL ES 2.0 Example/Classes/GLView.h
  50. +189 −0 Simple OpenGL ES 2.0 Example/Classes/GLView.m
  51. +14 −0 Simple OpenGL ES 2.0 Example/Classes/GLViewController.h
  52. +252 −0 Simple OpenGL ES 2.0 Example/Classes/GLViewController.m
  53. +20 −0 Simple OpenGL ES 2.0 Example/Classes/Hello_GLAppDelegate.h
  54. +27 −0 Simple OpenGL ES 2.0 Example/Classes/Hello_GLAppDelegate.m
  55. BIN  Simple OpenGL ES 2.0 Example/DieTexture.png
  56. +30 −0 Simple OpenGL ES 2.0 Example/Hello_GL-Info.plist
  57. +8 −0 Simple OpenGL ES 2.0 Example/Hello_GL_Prefix.pch
  58. BIN  Simple OpenGL ES 2.0 Example/IcoTexture.jpg
  59. +372 −0 Simple OpenGL ES 2.0 Example/Icosahedron.xcodeproj/jeff.pbxuser
  60. +1,530 −0 Simple OpenGL ES 2.0 Example/Icosahedron.xcodeproj/jeff.perspectivev3
  61. +304 −0 Simple OpenGL ES 2.0 Example/Icosahedron.xcodeproj/project.pbxproj
  62. +6 −0 Simple OpenGL ES 2.0 Example/Icosahedron.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  63. +6,899 −0 ....0 Example/Icosahedron.xcodeproj/project.xcworkspace/xcuserdata/jeff.xcuserdatad/WorkspaceState.xcuserstate
  64. +4 −0 ...penGL ES 2.0 Example/Icosahedron.xcodeproj/xcuserdata/jeff.xcuserdatad/xcbreakpoints/Breakpoints.xcbkptlist
  65. +20 −0 Simple OpenGL ES 2.0 Example/Icosahedron.xcodeproj/xcuserdata/jeff.xcuserdatad/xcschemes/Hello GL.xcscheme
  66. +19 −0 ... OpenGL ES 2.0 Example/Icosahedron.xcodeproj/xcuserdata/jeff.xcuserdatad/xcschemes/xcschememanagement.plist
  67. +270 −0 Simple OpenGL ES 2.0 Example/MainWindow.xib
  68. +6 −0 Simple OpenGL ES 2.0 Example/Shader.fsh
  69. +9 −0 Simple OpenGL ES 2.0 Example/Shader.vsh
  70. +17 −0 Simple OpenGL ES 2.0 Example/main.m
  71. +23 −0 Wavefront OBJ Loader/Classes/ConstantsAndMacros.h
  72. +40 −0 Wavefront OBJ Loader/Classes/GLView.h
  73. +204 −0 Wavefront OBJ Loader/Classes/GLView.m
  74. +31 −0 Wavefront OBJ Loader/Classes/GLViewController.h
  75. +146 −0 Wavefront OBJ Loader/Classes/GLViewController.m
  76. +21 −0 Wavefront OBJ Loader/Classes/OpenGLTexture3D.h
  77. +80 −0 Wavefront OBJ Loader/Classes/OpenGLTexture3D.m
  78. +308 −0 Wavefront OBJ Loader/Classes/OpenGLWaveFrontCommon.h
  79. +35 −0 Wavefront OBJ Loader/Classes/OpenGLWaveFrontGroup.h
  80. +44 −0 Wavefront OBJ Loader/Classes/OpenGLWaveFrontGroup.m
  81. +35 −0 Wavefront OBJ Loader/Classes/OpenGLWaveFrontMaterial.h
  82. +169 −0 Wavefront OBJ Loader/Classes/OpenGLWaveFrontMaterial.m
  83. +49 −0 Wavefront OBJ Loader/Classes/OpenGLWaveFrontObject.h
  84. +387 −0 Wavefront OBJ Loader/Classes/OpenGLWaveFrontObject.m
  85. +18 −0 Wavefront OBJ Loader/Classes/Wavefront_OBJ_LoaderAppDelegate.h
  86. +50 −0 Wavefront OBJ Loader/Classes/Wavefront_OBJ_LoaderAppDelegate.m
  87. +47 −0 Wavefront OBJ Loader/Classes/gluLookAt.h
  88. +85 −0 Wavefront OBJ Loader/Classes/gluLookAt.m
  89. +28 −0 Wavefront OBJ Loader/Info.plist
  90. +189 −0 Wavefront OBJ Loader/MainWindow.xib
  91. BIN  Wavefront OBJ Loader/Models/cube_template_Cube-256.pvr4
  92. BIN  Wavefront OBJ Loader/Models/cube_template_Cube.tga
  93. +72 −0 Wavefront OBJ Loader/Models/cylinder2.mtl
  94. +342 −0 Wavefront OBJ Loader/Models/cylinder2.obj
  95. +12 −0 Wavefront OBJ Loader/Models/earth.mtl
  96. +180 −0 Wavefront OBJ Loader/Models/earth.obj
  97. +52 −0 Wavefront OBJ Loader/Models/plane3.mtl
  98. +17,207 −0 Wavefront OBJ Loader/Models/plane3.obj
  99. BIN  Wavefront OBJ Loader/Models/sphere-256.pvr4
  100. BIN  Wavefront OBJ Loader/Models/texture1-128.pvr4
  101. +13 −0 Wavefront OBJ Loader/Models/uvcube2.mtl
  102. +47 −0 Wavefront OBJ Loader/Models/uvcube2.obj
  103. +1,457 −0 Wavefront OBJ Loader/Wavefront OBJ Loader.xcodeproj/jeff.mode1v3
  104. +338 −0 Wavefront OBJ Loader/Wavefront OBJ Loader.xcodeproj/jeff.pbxuser
  105. +1,538 −0 Wavefront OBJ Loader/Wavefront OBJ Loader.xcodeproj/jeff.perspectivev3
  106. +351 −0 Wavefront OBJ Loader/Wavefront OBJ Loader.xcodeproj/project.pbxproj
  107. +3 −0  Wavefront OBJ Loader/Wavefront_OBJ_Loader_Prefix.pch
  108. +18 −0 Wavefront OBJ Loader/main.m
12 .gitignore
@@ -0,0 +1,12 @@
+build
+*.xcodeproj/*.pbxuser
+*.xcodeproj/*.perspectivev3
+.DS_Store
+.Spotlight-V100
+*.hidden
+*.Trash
+/tmp/**
+*.hotfiles.btree
+/.vol
+.svn
+.svn/*
120 Blender Export/objc-export-2.4.9/objc.py
@@ -0,0 +1,120 @@
+#!BPY
+
+"""
+Name: 'Objective-C Header (.h)'
+Blender: 244
+Group: 'Export'
+Tooltip: 'Exports header file for use with the OpenGL ES template for iPhone available from http://iphonedevelopment.blogspot.com/'
+"""
+import Blender
+from Blender import *
+import bpy
+import bpy
+import os
+
+
+def write_obj(filepath):
+ out = file(filepath, 'w')
+ sce = bpy.data.scenes.active
+ ob = sce.objects.active
+ mesh = Mesh.New()
+ mesh.getFromObject(ob.name)
+
+ editmode = Window.EditMode()
+ if editmode: Window.EditMode(0)
+ has_quads = False
+ for f in mesh.faces:
+ if len(f) == 4:
+ has_quads = True
+ break
+
+ if has_quads:
+ oldmode = Mesh.Mode()
+ Mesh.Mode(Mesh.SelectModes['FACE'])
+
+ mesh.sel = True
+ tempob = sce.objects.new(mesh)
+ mesh.quadToTriangle(0) # more=0 shortest length
+ oldmode = Mesh.Mode(oldmode)
+ sce.objects.unlink(tempob)
+
+ Mesh.Mode(oldmode)
+
+ objectname = ob.getData(True)
+ basename = objectname.capitalize()
+
+ out.write('#import "OpenGLCommon.h"\n\n\n')
+
+ if (mesh.faceUV):
+ out.write('static const TexturedVertexData3D %sVertexData[] = {\n' % basename)
+ for face in mesh.faces:
+ for (vert, uvert) in zip(face.verts, face.uv):
+ out.write('\t{/*v:*/{%f, %f, %f}, ' % (vert.co.x, vert.co.y, vert.co.z) )
+ out.write('/*n:*/{%f, %f, %f}, ' % (vert.no.x, vert.no.y, vert.no.z))
+ out.write('/*t:*/{%f, %f}' % ( uvert.x, uvert.y ) )
+ out.write('},\n')
+ out.write('};\n\n')
+ elif (mesh.vertexColors):
+ out.write('static const ColoredVertexData3D %sVertexData[] = {\n' % basename)
+ for face in mesh.faces:
+ for (vert, color) in zip(face.verts, face.col):
+ out.write('\t{/*v:*/{%f, %f, %f}, ' % (vert.co.x, vert.co.y, vert.co.z) )
+ out.write('/*n:*/{%f, %f, %f}, ' % (vert.no.x, vert.no.y, vert.no.z))
+ out.write('/*c:*/{%f, %f, %f, %f}' % ( color.r / 255.0, color.g / 255.0, color.b / 255.0, color.a / 255.0) )
+ out.write('},\n')
+ out.write('};\n\n')
+ else:
+ out.write
+ out.write('static const VertexData3D %sVertexData[] = {\n' % basename)
+ for face in mesh.faces:
+ for vert in face.verts:
+ out.write('\t{/*v:*/{%f, %f, %f}, ' % (vert.co.x, vert.co.y, vert.co.z) )
+ out.write('/*n:*/{%f, %f, %f} ' % (vert.no.x, vert.no.y, vert.no.z))
+ out.write('},\n')
+ out.write('};\n\n')
+
+ if editmode: Window.EditMode(1)
+ out.write('#define k%sNumberOfVertices\t%i\n' % (basename, len(mesh.faces) * 3) )
+
+ out.write('// Drawing Code:\n')
+ out.write('// glEnableClientState(GL_VERTEX_ARRAY);\n')
+ if (mesh.faceUV):
+ out.write('// glEnableClientState(GL_TEXTURE_COORD_ARRAY);\n')
+ elif (mesh.vertexColors):
+ out.write('// glEnableClientState(GL_COLOR_ARRAY);\n')
+ out.write('// glEnable(GL_COLOR_MATERIAL)\n')
+ out.write('// glEnableClientState(GL_NORMAL_ARRAY);\n')
+ out.write('// glVertexPointer(3, GL_FLOAT, sizeof(')
+ if (mesh.faceUV):
+ out.write('TexturedVertexData3D')
+ elif (mesh.vertexColors):
+ out.write('ColoredVertexData3D')
+ else:
+ out.write('VertexData3D')
+ out.write('), &%sVertexData[0].vertex);\n' % basename)
+ out.write('// glNormalPointer(GL_FLOAT, sizeof(')
+ if (mesh.faceUV):
+ out.write('TexturedVertexData3D')
+ elif (mesh.vertexColors):
+ out.write('ColoredVertexData3D')
+ else:
+ out.write('VertexData3D')
+ out.write('), &%sVertexData[0].normal);\n' % basename)
+ if (mesh.faceUV):
+ out.write('// glTexCoordPointer(2, GL_FLOAT, sizeof(TexturedVertexData3D), &%sVertexData[0].texCoord);\n' % basename)
+ elif (mesh.vertexColors):
+ out.write('// glColorPointer(4, GL_FLOAT, sizeof(ColoredVertexData3D), &%sVertexData[0].color);\n' % basename)
+ out.write('// glDrawArrays(GL_TRIANGLES, 0, k%sNumberOfVertices);\n' % basename)
+ out.write('// glDisableClientState(GL_VERTEX_ARRAY);\n')
+ if (mesh.faceUV):
+ out.write('// glDisableClientState(GL_TEXTURE_COORD_ARRAY);\n')
+ elif (mesh.vertexColors):
+ out.write('// glDisableClientState(GL_NORMAL_ARRAY);\n')
+ out.write('// glDisable(GL_COLOR_MATERIAL);\n')
+ out.write('// glDisableClientState(GL_NORMAL_ARRAY);\n\n\n')
+
+ out.close()
+
+
+filename = os.path.splitext(Blender.Get('filename'))[0]
+Blender.Window.FileSelector(write_obj, "Export", '%s.h' % filename)
50 Blender Export/objc-export-2.5/objc.py
@@ -0,0 +1,50 @@
+#!BPY
+
+"""
+Name: 'Objective-C Header (.h)'
+Blender: 244
+Group: 'Export'
+Tooltip: 'Exports header file for use with the OpenGL ES template for iPhone available from http://iphonedevelopment.blogspot.com/'
+"""
+import Blender
+from Blender import Mathutils
+from Blender.Mathutils import *
+import bpy
+import os
+
+def write_obj(filepath):
+ out = file(filepath, 'w')
+ sce = bpy.data.scenes.active
+ ob = sce.objects.active
+ mesh = ob.getData(mesh=1)
+ objectname = ob.getData(True)
+ basename = objectname.capitalize()
+
+ out.write('#import "OpenGLCommon.h"\n\n\n')
+ out.write('static const TexturedVertexData3D %sVertexData[] = {\n' % basename)
+ for face in mesh.faces:
+ for (vert, uvert) in zip(face.v, face.uv):
+ out.write('\t{/*v:*/{%f, %f, %f}, ' % (vert.co.x, vert.co.y, vert.co.z) )
+ out.write('/*n:*/{%f, %f, %f}, ' % (vert.no.x, vert.no.y, vert.no.z))
+ out.write('/*t:*/{%f, %f}' % ( uvert.x, uvert.y ) )
+ out.write('},\n')
+ out.write('};\n\n')
+
+ out.write('#define k%sNumberOfVertices\t%i\n' % (basename, len(mesh.faces) * 3) )
+
+ out.write('// Drawing Code:')
+ out.write('// glEnableClientState(GL_VERTEX_ARRAY);\n')
+ out.write('// glEnableClientState(GL_TEXTURE_COORD_ARRAY);\n')
+ out.write('// glEnableClientState(GL_NORMAL_ARRAY);\n')
+ out.write('// glVertexPointer(3, GL_FLOAT, sizeof(TexturedVertexData3D), &%sVertexData[0].vertex);\n' % basename)
+ out.write('// glNormalPointer(GL_FLOAT, sizeof(TexturedVertexData3D), &%sVertexData[0].normal);\n' % basename)
+ out.write('// glTexCoordPointer(2, GL_FLOAT, sizeof(TexturedVertexData3D), &%sVertexData[0].texCoord);\n' % basename)
+ out.write('// glDrawArrays(GL_TRIANGLES, 0, k%sNumberOfVertices);\n' % basename)
+ out.write('// glDisableClientState(GL_VERTEX_ARRAY);\n')
+ out.write('// glDisableClientState(GL_TEXTURE_COORD_ARRAY);\n')
+ out.write('// glDisableClientState(GL_NORMAL_ARRAY);\n\n\n')
+
+ out.close()
+
+filename = os.path.splitext(Blender.Get('filename'))[0]
+Blender.Window.FileSelector(write_obj, "Export", '%s.h' % filename
18 Categories/UIColor-OpenGL.h
@@ -0,0 +1,18 @@
+//
+// UIColor-OpenGL.h
+// GLTest
+//
+// Created by Jeff LaMarche on 8/21/08.
+// Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import <OpenGLES/EAGL.h>
+#import <OpenGLES/ES1/gl.h>
+#import <OpenGLES/ES1/glext.h>
+#import <OpenGLES/EAGLDrawable.h>
+
+@interface UIColor(OpenGL)
+- (void)setOpenGLColor;
+- (void)setColorArrayToColor:(UIColor *)toColor;
+@end
79 Categories/UIColor-OpenGL.m
@@ -0,0 +1,79 @@
+//
+// UIColor-OpenGL.m
+// GLTest
+//
+// Created by Jeff LaMarche on 8/21/08.
+// Copyright 2008 __MyCompanyName__. All rights reserved.
+//
+
+#import "UIColor-OpenGL.h"
+
+@implementation UIColor(OpenGL)
+- (void)setOpenGLColor
+{
+ int numComponents = CGColorGetNumberOfComponents(self.CGColor);
+ const CGFloat *components = CGColorGetComponents(self.CGColor);
+ if (numComponents == 2)
+ {
+ CGFloat all = components[0];
+ CGFloat alpha = components[1];
+ glColor4f(all,all, all, alpha);
+ }
+ else
+ {
+
+ CGFloat red = components[0];
+ CGFloat green = components[1];
+ CGFloat blue = components[2];
+ CGFloat alpha = components[3];
+ glColor4f(red,green, blue, alpha);
+ }
+
+}
+- (void)setColorArrayToColor:(UIColor *)toColor
+{
+ GLfloat *colorArray = malloc(sizeof(GLfloat) * 8);
+
+ int numComponents = CGColorGetNumberOfComponents(self.CGColor);
+ const CGFloat *components = CGColorGetComponents(self.CGColor);
+
+
+ if (numComponents == 2)
+ {
+ colorArray[0] = components[0];
+ colorArray[1] = components[0];
+ colorArray[2] = components[0];
+ colorArray[3] = components[1];
+ }
+ else
+ {
+ // Assuming RGBA if not grayscale
+ colorArray[0] = components[0];
+ colorArray[1] = components[1];
+ colorArray[2] = components[2];
+ colorArray[3] = components[3];
+ }
+
+ int otherColorNumComponents = CGColorGetNumberOfComponents(toColor.CGColor);
+ const CGFloat *otherComponents = CGColorGetComponents(toColor.CGColor);
+ if (otherColorNumComponents == 2)
+ {
+ colorArray[4] = otherComponents[0];
+ colorArray[5] = otherComponents[0];
+ colorArray[6] = otherComponents[0];
+ colorArray[7] = otherComponents[1];
+ }
+ else
+ {
+ // Assuming RGBA if not grayscale
+ colorArray[4] = otherComponents[0];
+ colorArray[5] = otherComponents[1];
+ colorArray[6] = otherComponents[2];
+ colorArray[7] = otherComponents[3];
+ }
+
+ glColorPointer (4, GL_FLOAT, 4*sizeof(GLfloat), colorArray);
+ free(colorArray);
+
+}
+@end
18 Classes/JDLGLUtils.h
@@ -0,0 +1,18 @@
+/*
+ * JDLGLUtils.h
+ * Space Castle
+ *
+ * Created by Jeff LaMarche on 9/27/08.
+ * Copyright 2008 __MyCompanyName__. All rights reserved.
+ *
+ */
+#import <Foundation/Foundation.h>
+#import <OpenGLES/ES1/gl.h>
+#import <CoreGraphics/CoreGraphics.h>
+
+
+void GLDrawCircle (int circleSegments, CGFloat circleSize, CGPoint center, bool filled);
+void GLDrawEllipse (int segments, CGFloat width, CGFloat height, CGPoint center, bool filled);
+void GLDrawSpokes (int spokeCount, CGFloat radius, CGPoint center);
+void GLDrawEllipticalSpokes(int spokeCount, CGFloat width, CGFloat height, CGPoint center);
+void GLDrawEllipticalSpokesWithGradient(int spokeCount, CGFloat width, CGFloat height, CGPoint center, UIColor *innerColor, UIColor *outerColor);
58 Classes/JDLGLUtils.m
@@ -0,0 +1,58 @@
+/*
+ * JDLGLUtils.c
+ * Space Castle
+ *
+ * Created by Jeff LaMarche on 9/27/08.
+ * Copyright 2008 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include "JDLGLUtils.h"
+#include <math.h>
+#include "Constants.h"
+#include "UIColor-OpenGL.h"
+
+void GLDrawCircle (int circleSegments, CGFloat circleSize, CGPoint center, bool filled)
+{
+ GLDrawEllipse(circleSegments, circleSize, circleSize, center, filled);
+}
+void GLDrawEllipse (int segments, CGFloat width, CGFloat height, CGPoint center, bool filled)
+{
+ glTranslatef(center.x, center.y, 0.0);
+ GLfloat vertices[segments*2];
+ int count=0;
+ for (GLfloat i = 0; i < 360.0f; i+=(360.0f/segments))
+ {
+ vertices[count++] = (cos(degreesToRadian(i))*width);
+ vertices[count++] = (sin(degreesToRadian(i))*height);
+ }
+ glVertexPointer (2, GL_FLOAT , 0, vertices);
+ glDrawArrays ((filled) ? GL_TRIANGLE_FAN : GL_LINE_LOOP, 0, segments);
+}
+void GLDrawSpokes (int spokeCount, CGFloat radius, CGPoint center)
+{
+ GLDrawEllipticalSpokes(spokeCount, radius, radius, center);
+}
+void GLDrawEllipticalSpokes(int spokeCount, CGFloat width, CGFloat height, CGPoint center)
+{
+ glTranslatef(center.x, center.y, 0.0);
+ for (GLfloat i = 0; i < 360.0f; i+=(360.0f/spokeCount))
+ {
+ GLfloat vertices[4] = {0.0, 0.0, cos(degreesToRadian(i))*width, sin(degreesToRadian(i))*height};
+ glVertexPointer(2, GL_FLOAT, 0, vertices);
+ glDrawArrays (GL_LINES, 0, 2);
+ }
+}
+void GLDrawEllipticalSpokesWithGradient(int spokeCount, CGFloat width, CGFloat height, CGPoint center, UIColor *innerColor, UIColor *outerColor)
+{
+ glTranslatef(center.x, center.y, 0.0);
+ for (GLfloat i = 0; i < 360.0f; i+=(360.0f/spokeCount))
+ {
+ glEnableClientState (GL_COLOR_ARRAY);
+ [innerColor setColorArrayToColor:outerColor];
+ GLfloat vertices[4] = {0.0, 0.0, cos(degreesToRadian(i))*width, sin(degreesToRadian(i))*height};
+ glVertexPointer(2, GL_FLOAT, 0, vertices);
+ glDrawArrays (GL_LINES, 0, 2);
+ glDisableClientState(GL_COLOR_ARRAY);
+ }
+}
33 OpenGL ES 1.1 Project Template/Classes/ConstantsAndMacros.h
@@ -0,0 +1,33 @@
+//
+// ConstantsAndMacros.h
+// Particles
+//
+
+// How many times a second to refresh the screen
+#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
+#define kRenderingFrequency 15.0
+#define kInactiveRenderingFrequency 5.0
+#else
+#define kRenderingFrequency 30.0
+#define kInactiveRenderingFrequency 3.0
+#endif
+// For setting up perspective, define near, far, and angle of view
+#define kZNear 0.01
+#define kZFar 1000.0
+#define kFieldOfView 45.0
+// Defines whether to setup and use a depth buffer
+#define USE_DEPTH_BUFFER 1
+// Set to 1 if you want it to attempt to create a 2.0 context
+#define kAttemptToUseOpenGLES2 0
+
+#define QUATERNION_TRACE_ZERO_TOLERANCE 0.1
+
+// Macros
+#define DEGREES_TO_RADIANS(__ANGLE__) ((__ANGLE__) / 180.0 * M_PI)
+
+// Debug Loggers
+#define NSStubLog() NSLog(@"%s", __PRETTY_FUNCTION__)
+#define NSDebugPrintMatrix(matrix) for (int i = 0; i < 4; i ++) \
+ NSLog(@"[%f] [%f] [%f] [%f]", matrix[i], matrix[i+4], matrix[i+8], matrix[i+12])
+
+#define NSDebugPrintQuaternion(quat) NSLog(@"Quaternion: [%f] [%f] [%f] [%f]", quat.x, quat.y, quat.z, quat.w)
41 OpenGL ES 1.1 Project Template/Classes/GLView.h
@@ -0,0 +1,41 @@
+//
+// GLView.h
+// ___PROJECTNAME___
+//
+// Created by ___FULLUSERNAME___ on ___DATE___.
+// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import <OpenGLES/EAGL.h>
+#import <OpenGLES/ES1/gl.h>
+#import <OpenGLES/ES1/glext.h>
+
+@protocol GLViewDelegate
+- (void)drawView:(UIView *)theView;
+- (void)setupView:(UIView *)theView;
+@end
+
+@interface GLView : UIView
+{
+
+@private
+
+ GLint backingWidth;
+ GLint backingHeight;
+
+ EAGLContext *context;
+ GLuint viewRenderbuffer, viewFramebuffer;
+ GLuint depthRenderbuffer;
+
+ NSTimer *animationTimer;
+ NSTimeInterval animationInterval;
+
+ id <GLViewDelegate> delegate;
+}
+@property NSTimeInterval animationInterval;
+@property (assign) /* weak ref */ id <GLViewDelegate> delegate;
+- (void)startAnimation;
+- (void)stopAnimation;
+- (void)drawView;
+@end
15 OpenGL ES 1.1 Project Template/Classes/GLViewController.h
@@ -0,0 +1,15 @@
+//
+// GLViewController.h
+// ___PROJECTNAME___
+//
+// Created by ___FULLUSERNAME___ on ___DATE___.
+// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "GLView.h"
+
+@interface GLViewController : UIViewController <GLViewDelegate>
+{
+}
+@end
40 OpenGL ES 1.1 Project Template/Classes/GLViewController.m
@@ -0,0 +1,40 @@
+//
+// GLViewController.m
+// ___PROJECTNAME___
+//
+// Created by ___FULLUSERNAME___ on ___DATE___.
+// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
+//
+
+#import "GLViewController.h"
+#import "ConstantsAndMacros.h"
+#import "OpenGLCommon.h"
+@implementation GLViewController
+- (void)drawView:(UIView *)theView
+{
+ glColor4f(0.0, 0.0, 0.0, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ // Drawing code here
+
+}
+-(void)setupView:(GLView*)view
+{
+ const GLfloat zNear = 0.01, zFar = 1000.0, fieldOfView = 45.0;
+ GLfloat size;
+ glEnable(GL_DEPTH_TEST);
+ glMatrixMode(GL_PROJECTION);
+ size = zNear * tanf(DEGREES_TO_RADIANS(fieldOfView) / 2.0);
+ CGRect rect = view.bounds;
+ glFrustumf(-size, size, -size / (rect.size.width / rect.size.height), size /
+ (rect.size.width / rect.size.height), zNear, zFar);
+ glViewport(0, 0, rect.size.width, rect.size.height);
+ glMatrixMode(GL_MODELVIEW);
+
+ glLoadIdentity();
+}
+- (void)dealloc
+{
+ [super dealloc];
+}
+@end
1,040 OpenGL ES 1.1 Project Template/Classes/OpenGLCommon.h
@@ -0,0 +1,1040 @@
+// OpenGLCommon.h
+// QuatTest
+//
+// Created by jeff on 4/27/10.
+// Copyright __MyCompanyName__ 2010. All rights reserved.
+//
+
+#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR || TARGET_OS_EMBEDDED
+#import <OpenGLES/EAGL.h>
+#import <OpenGLES/ES1/gl.h>
+#import <OpenGLES/ES1/glext.h>
+#else
+#import <OpenGL/OpenGL.h>
+#endif
+#import "ConstantsAndMacros.h"
+
+@class OpenGLWaveFrontMaterial;
+#pragma mark -
+#pragma mark Color3D
+#pragma mark -
+typedef struct {
+ GLfloat red;
+ GLfloat green;
+ GLfloat blue;
+ GLfloat alpha;
+} Color3D;
+static inline Color3D Color3DMake(CGFloat inRed, CGFloat inGreen, CGFloat inBlue, CGFloat inAlpha)
+{
+ Color3D ret;
+ ret.red = inRed;
+ ret.green = inGreen;
+ ret.blue = inBlue;
+ ret.alpha = inAlpha;
+ return ret;
+}
+static inline void Color3DSet(Color3D *color, CGFloat inRed, CGFloat inGreen, CGFloat inBlue, CGFloat inAlpha)
+{
+ color->red = inRed;
+ color->green = inGreen;
+ color->blue = inBlue;
+ color->alpha = inAlpha;
+}
+static inline Color3D Color3DInterpolate(Color3D color1, Color3D color2, GLfloat percent)
+{
+ Color3D ret;
+ ret.red = color1.red + ((color2.red - color1.red) * percent);
+ ret.blue = color1.blue + ((color2.blue - color1.blue) * percent);
+ ret.green = color1.green + ((color2.green - color1.green) * percent);
+ ret.alpha = color1.alpha + ((color2.alpha - color1.alpha) * percent);
+
+ if (ret.red > 1.0)
+ ret.red -= 1.0;
+ if (ret.green > 1.0)
+ ret.green -= 1.0;
+ if (ret.blue > 1.0)
+ ret.blue -= 1.0;
+ if (ret.alpha > 1.0)
+ ret.alpha = 1.0;
+ if (ret.red < 0.0)
+ ret.red += 1.0;
+ if (ret.green < 0.0)
+ ret.green += 1.0;
+ if (ret.blue < 0.0)
+ ret.blue += 1.0;
+ if (ret.alpha < 0.0)
+ ret.alpha += 1.0;
+ return ret;
+}
+#pragma mark -
+#pragma mark Vertex3D
+#pragma mark -
+typedef struct {
+ GLfloat x;
+ GLfloat y;
+ GLfloat z;
+} Vertex3D;
+
+static inline Vertex3D Vertex3DMake(CGFloat inX, CGFloat inY, CGFloat inZ)
+{
+ Vertex3D ret;
+ ret.x = inX;
+ ret.y = inY;
+ ret.z = inZ;
+ return ret;
+}
+static inline void Vertex3DSet(Vertex3D *vertex, CGFloat inX, CGFloat inY, CGFloat inZ)
+{
+ vertex->x = inX;
+ vertex->y = inY;
+ vertex->z = inZ;
+}
+#pragma mark -
+#pragma mark Vector3D
+#pragma mark -
+typedef Vertex3D Vector3D;
+#define Vector3DMake(x,y,z) (Vector3D)Vertex3DMake(x, y, z)
+#define Vector3DSet(vector,x,y,z) Vertex3DSet(vector, x, y, z)
+static inline GLfloat Vector3DMagnitude(Vector3D vector)
+{
+ return sqrtf((vector.x * vector.x) + (vector.y * vector.y) + (vector.z * vector.z));
+}
+static inline void Vector3DNormalize(Vector3D *vector)
+{
+ GLfloat vecMag = Vector3DMagnitude(*vector);
+ if ( vecMag == 0.0 )
+ {
+ vector->x = 1.0;
+ vector->y = 0.0;
+ vector->z = 0.0;
+ return;
+ }
+ vector->x /= vecMag;
+ vector->y /= vecMag;
+ vector->z /= vecMag;
+}
+static inline GLfloat Vector3DDotProduct(Vector3D vector1, Vector3D vector2)
+{
+ return vector1.x*vector2.x + vector1.y*vector2.y + vector1.z*vector2.z;
+
+}
+static inline Vector3D Vector3DCrossProduct(Vector3D vector1, Vector3D vector2)
+{
+ Vector3D ret;
+ ret.x = (vector1.y * vector2.z) - (vector1.z * vector2.y);
+ ret.y = (vector1.z * vector2.x) - (vector1.x * vector2.z);
+ ret.z = (vector1.x * vector2.y) - (vector1.y * vector2.x);
+ return ret;
+}
+static inline Vector3D Vector3DMakeWithStartAndEndPoints(Vertex3D start, Vertex3D end)
+{
+ Vector3D ret;
+ ret.x = end.x - start.x;
+ ret.y = end.y - start.y;
+ ret.z = end.z - start.z;
+ Vector3DNormalize(&ret);
+ return ret;
+}
+static inline Vector3D Vector3DAdd(Vector3D vector1, Vector3D vector2)
+{
+ Vector3D ret;
+ ret.x = vector1.x + vector2.x;
+ ret.y = vector1.y + vector2.y;
+ ret.z = vector1.z + vector2.z;
+ return ret;
+}
+static inline void Vector3DFlip (Vector3D *vector)
+{
+ vector->x = -vector->x;
+ vector->y = -vector->y;
+ vector->z = -vector->z;
+}
+static inline void Vector3DRotateToDirection (GLfloat pitch, GLfloat azimuth, Vector3D *vector)
+{
+ vector->x = -sin(DEGREES_TO_RADIANS(azimuth)) * cos(DEGREES_TO_RADIANS(pitch));
+ vector->y = sin(DEGREES_TO_RADIANS(pitch));
+ vector->z = cos(DEGREES_TO_RADIANS(pitch)) * cos(DEGREES_TO_RADIANS(azimuth));
+}
+#pragma mark -
+#pragma mark Rotation3D
+#pragma mark -
+// A Rotation3D is just a Vertex3D used to store three angles (pitch, yaw, roll) instead of cartesian coordinates.
+// For simplicity, we just reuse the Vertex3D, even though the member names should probably be either xRot, yRot,
+// and zRot, or else pitch, yaw, roll.
+typedef Vertex3D Rotation3D;
+#define Rotation3DMake(x,y,z) (Rotation3D)Vertex3DMake(x, y, z)
+#pragma mark -
+#pragma mark Face3D
+#pragma mark -
+// Face3D is used to hold three integers which will be integer index values to another array
+typedef struct {
+ GLushort v1;
+ GLushort v2;
+ GLushort v3;
+} Face3D;
+static inline Face3D Face3DMake(int v1, int v2, int v3)
+{
+ Face3D ret;
+ ret.v1 = v1;
+ ret.v2 = v2;
+ ret.v3 = v3;
+ return ret;
+}
+#pragma mark -
+#pragma mark Triangle3D
+#pragma mark -
+typedef struct {
+ Vertex3D v1;
+ Vertex3D v2;
+ Vertex3D v3;
+} Triangle3D;
+static inline Triangle3D Triangle3DMake(Vertex3D inV1, Vertex3D inV2, Vertex3D inV3)
+{
+ Triangle3D ret;
+ ret.v1 = inV1;
+ ret.v2 = inV2;
+ ret.v3 = inV3;
+ return ret;
+}
+static inline Vector3D Triangle3DCalculateSurfaceNormal(Triangle3D triangle)
+{
+ Vector3D u = Vector3DMakeWithStartAndEndPoints(triangle.v2, triangle.v1);
+ Vector3D v = Vector3DMakeWithStartAndEndPoints(triangle.v3, triangle.v1);
+
+ Vector3D ret;
+ ret.x = (u.y * v.z) - (u.z * v.y);
+ ret.y = (u.z * v.x) - (u.x * v.z);
+ ret.z = (u.x * v.y) - (u.y * v.x);
+ return ret;
+}
+#pragma mark -
+#pragma mark Interleaving
+#pragma mark -
+typedef struct {
+ GLfloat s;
+ GLfloat t;
+} TextureCoord3D;
+
+typedef struct {
+ Vertex3D vertex;
+ Vector3D normal;
+} VertexData3D;
+typedef struct {
+ Vertex3D vertex;
+ Vector3D normal;
+ TextureCoord3D texCoord;
+} TexturedVertexData3D;
+typedef struct {
+ Vertex3D vertex;
+ Vector3D normal;
+ Color3D color;
+} ColoredVertexData3D;
+
+#pragma mark -
+#pragma mark Matrices
+#pragma mark -
+
+typedef GLfloat Matrix3D[16];
+// OpenGL ES hardware accelerates Vector * Matrix but not Matrix * Matrix
+/*
+ These defines, the fast sine function, and the vectorized version of the
+ matrix multiply function below are based on the Matrix4Mul method from
+ the vfp-math-library. Thi code has been modified, and are subject to
+ the original license terms and ownership as follow:
+
+ VFP math library for the iPhone / iPod touch
+
+ Copyright (c) 2007-2008 Wolfgang Engel and Matthias Grundmann
+ http://code.google.com/p/vfpmathlibrary/
+
+ This software is provided 'as-is', without any express or implied warranty.
+ In no event will the authors be held liable for any damages arising
+ from the use of this software.
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it freely,
+ subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product documentation
+ would be appreciated but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must
+ not be misrepresented as being the original software.
+
+ 3. This notice may not be removed or altered from any source distribution.
+ */
+static inline float fastAbs(float x) { return (x < 0) ? -x : x; }
+static inline GLfloat fastSinf(GLfloat x)
+{
+ // fast sin function; maximum error is 0.001
+ const float P = 0.225;
+
+ x = x * M_1_PI;
+ int k = (int) round(x);
+ x = x - k;
+
+ float y = (4 - 4 * fastAbs(x)) * x;
+
+ y = P * (y * fastAbs(y) - y) + y;
+
+ return (k&1) ? -y : y;
+}
+
+#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
+#define VFP_CLOBBER_S0_S31 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", \
+"s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", \
+"s17", "s18", "s19", "s20", "s21", "s22", "s23", "s24", \
+"s25", "s26", "s27", "s28", "s29", "s30", "s31"
+#define VFP_VECTOR_LENGTH(VEC_LENGTH) "fmrx r0, fpscr \n\t" \
+"bic r0, r0, #0x00370000 \n\t" \
+"orr r0, r0, #0x000" #VEC_LENGTH "0000 \n\t" \
+"fmxr fpscr, r0 \n\t"
+#define VFP_VECTOR_LENGTH_ZERO "fmrx r0, fpscr \n\t" \
+"bic r0, r0, #0x00370000 \n\t" \
+"fmxr fpscr, r0 \n\t"
+#endif
+static inline void Matrix3DMultiply(Matrix3D m1, Matrix3D m2, Matrix3D result)
+{
+#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
+ __asm__ __volatile__ ( VFP_VECTOR_LENGTH(3)
+
+ // Interleaving loads and adds/muls for faster calculation.
+ // Let A:=src_ptr_1, B:=src_ptr_2, then
+ // function computes A*B as (B^T * A^T)^T.
+
+ // Load the whole matrix into memory.
+ "fldmias %2, {s8-s23} \n\t"
+ // Load first column to scalar bank.
+ "fldmias %1!, {s0-s3} \n\t"
+ // First column times matrix.
+ "fmuls s24, s8, s0 \n\t"
+ "fmacs s24, s12, s1 \n\t"
+
+ // Load second column to scalar bank.
+ "fldmias %1!, {s4-s7} \n\t"
+
+ "fmacs s24, s16, s2 \n\t"
+ "fmacs s24, s20, s3 \n\t"
+ // Save first column.
+ "fstmias %0!, {s24-s27} \n\t"
+
+ // Second column times matrix.
+ "fmuls s28, s8, s4 \n\t"
+ "fmacs s28, s12, s5 \n\t"
+
+ // Load third column to scalar bank.
+ "fldmias %1!, {s0-s3} \n\t"
+
+ "fmacs s28, s16, s6 \n\t"
+ "fmacs s28, s20, s7 \n\t"
+ // Save second column.
+ "fstmias %0!, {s28-s31} \n\t"
+
+ // Third column times matrix.
+ "fmuls s24, s8, s0 \n\t"
+ "fmacs s24, s12, s1 \n\t"
+
+ // Load fourth column to scalar bank.
+ "fldmias %1, {s4-s7} \n\t"
+
+ "fmacs s24, s16, s2 \n\t"
+ "fmacs s24, s20, s3 \n\t"
+ // Save third column.
+ "fstmias %0!, {s24-s27} \n\t"
+
+ // Fourth column times matrix.
+ "fmuls s28, s8, s4 \n\t"
+ "fmacs s28, s12, s5 \n\t"
+ "fmacs s28, s16, s6 \n\t"
+ "fmacs s28, s20, s7 \n\t"
+ // Save fourth column.
+ "fstmias %0!, {s28-s31} \n\t"
+
+ VFP_VECTOR_LENGTH_ZERO
+ : "=r" (result), "=r" (m2)
+ : "r" (m1), "0" (result), "1" (m2)
+ : "r0", "cc", "memory", VFP_CLOBBER_S0_S31
+ );
+#else
+ result[0] = m1[0] * m2[0] + m1[4] * m2[1] + m1[8] * m2[2] + m1[12] * m2[3];
+ result[1] = m1[1] * m2[0] + m1[5] * m2[1] + m1[9] * m2[2] + m1[13] * m2[3];
+ result[2] = m1[2] * m2[0] + m1[6] * m2[1] + m1[10] * m2[2] + m1[14] * m2[3];
+ result[3] = m1[3] * m2[0] + m1[7] * m2[1] + m1[11] * m2[2] + m1[15] * m2[3];
+
+ result[4] = m1[0] * m2[4] + m1[4] * m2[5] + m1[8] * m2[6] + m1[12] * m2[7];
+ result[5] = m1[1] * m2[4] + m1[5] * m2[5] + m1[9] * m2[6] + m1[13] * m2[7];
+ result[6] = m1[2] * m2[4] + m1[6] * m2[5] + m1[10] * m2[6] + m1[14] * m2[7];
+ result[7] = m1[3] * m2[4] + m1[7] * m2[5] + m1[11] * m2[6] + m1[15] * m2[7];
+
+ result[8] = m1[0] * m2[8] + m1[4] * m2[9] + m1[8] * m2[10] + m1[12] * m2[11];
+ result[9] = m1[1] * m2[8] + m1[5] * m2[9] + m1[9] * m2[10] + m1[13] * m2[11];
+ result[10] = m1[2] * m2[8] + m1[6] * m2[9] + m1[10] * m2[10] + m1[14] * m2[11];
+ result[11] = m1[3] * m2[8] + m1[7] * m2[9] + m1[11] * m2[10] + m1[15] * m2[11];
+
+ result[12] = m1[0] * m2[12] + m1[4] * m2[13] + m1[8] * m2[14] + m1[12] * m2[15];
+ result[13] = m1[1] * m2[12] + m1[5] * m2[13] + m1[9] * m2[14] + m1[13] * m2[15];
+ result[14] = m1[2] * m2[12] + m1[6] * m2[13] + m1[10] * m2[14] + m1[14] * m2[15];
+ result[15] = m1[3] * m2[12] + m1[7] * m2[13] + m1[11] * m2[14] + m1[15] * m2[15];
+#endif
+
+}
+static inline void Matrix3DSetIdentity(Matrix3D matrix)
+{
+ matrix[0] = matrix[5] = matrix[10] = matrix[15] = 1.0;
+ matrix[1] = matrix[2] = matrix[3] = matrix[4] = 0.0;
+ matrix[6] = matrix[7] = matrix[8] = matrix[9] = 0.0;
+ matrix[11] = matrix[12] = matrix[13] = matrix[14] = 0.0;
+}
+static inline void Matrix3DSetTranslation(Matrix3D matrix, GLfloat xTranslate, GLfloat yTranslate, GLfloat zTranslate)
+{
+ matrix[0] = matrix[5] = matrix[10] = matrix[15] = 1.0;
+ matrix[1] = matrix[2] = matrix[3] = matrix[4] = 0.0;
+ matrix[6] = matrix[7] = matrix[8] = matrix[9] = 0.0;
+ matrix[11] = 0.0;
+ matrix[12] = xTranslate;
+ matrix[13] = yTranslate;
+ matrix[14] = zTranslate;
+}
+static inline void Matrix3DSetScaling(Matrix3D matrix, GLfloat xScale, GLfloat yScale, GLfloat zScale)
+{
+ matrix[1] = matrix[2] = matrix[3] = matrix[4] = 0.0;
+ matrix[6] = matrix[7] = matrix[8] = matrix[9] = 0.0;
+ matrix[11] = matrix[12] = matrix[13] = matrix[14] = 0.0;
+ matrix[0] = xScale;
+ matrix[5] = yScale;
+ matrix[10] = zScale;
+ matrix[15] = 1.0;
+}
+static inline void Matrix3DSetUniformScaling(Matrix3D matrix, GLfloat scale)
+{
+ Matrix3DSetScaling(matrix, scale, scale, scale);
+}
+static inline void Matrix3DSetXRotationUsingRadians(Matrix3D matrix, GLfloat degrees)
+{
+ matrix[0] = matrix[15] = 1.0;
+ matrix[1] = matrix[2] = matrix[3] = matrix[4] = 0.0;
+ matrix[7] = matrix[8] = 0.0;
+ matrix[11] = matrix[12] = matrix[13] = matrix[14] = 0.0;
+
+ matrix[5] = cosf(degrees);
+ matrix[6] = -fastSinf(degrees);
+ matrix[9] = -matrix[6];
+ matrix[10] = matrix[5];
+}
+static inline void Matrix3DSetXRotationUsingDegrees(Matrix3D matrix, GLfloat degrees)
+{
+ Matrix3DSetXRotationUsingRadians(matrix, degrees * M_PI / 180.0);
+}
+static inline void Matrix3DSetYRotationUsingRadians(Matrix3D matrix, GLfloat degrees)
+{
+ matrix[0] = cosf(degrees);
+ matrix[2] = fastSinf(degrees);
+ matrix[8] = -matrix[2];
+ matrix[10] = matrix[0];
+ matrix[1] = matrix[3] = matrix[4] = matrix[6] = matrix[7] = 0.0;
+ matrix[9] = matrix[11] = matrix[13] = matrix[12] = matrix[14] = 0.0;
+ matrix[5] = matrix[15] = 1.0;
+}
+static inline void Matrix3DSetYRotationUsingDegrees(Matrix3D matrix, GLfloat degrees)
+{
+ Matrix3DSetYRotationUsingRadians(matrix, degrees * M_PI / 180.0);
+}
+static inline void Matrix3DSetZRotationUsingRadians(Matrix3D matrix, GLfloat degrees)
+{
+ matrix[0] = cosf(degrees);
+ matrix[1] = fastSinf(degrees);
+ matrix[4] = -matrix[1];
+ matrix[5] = matrix[0];
+ matrix[2] = matrix[3] = matrix[6] = matrix[7] = matrix[8] = 0.0;
+ matrix[9] = matrix[11] = matrix[12] = matrix[13] = matrix[14] = 0.0;
+ matrix[10] = matrix[15] = 1.0;
+}
+static inline void Matrix3DSetZRotationUsingDegrees(Matrix3D matrix, GLfloat degrees)
+{
+ Matrix3DSetZRotationUsingRadians(matrix, degrees * M_PI / 180.0);
+}
+static inline void Matrix3DSetRotationByRadians(Matrix3D matrix, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
+{
+ GLfloat mag = sqrtf((x*x) + (y*y) + (z*z));
+ if (mag == 0.0)
+ {
+ x = 1.0;
+ y = 0.0;
+ z = 0.0;
+ }
+ else if (mag != 1.0)
+ {
+ x /= mag;
+ y /= mag;
+ z /= mag;
+ }
+
+ GLfloat c = cosf(angle);
+ GLfloat s = fastSinf(angle);
+ matrix[3] = matrix[7] = matrix[11] = matrix[12] = matrix[13] = matrix[14] = 0.0;
+ matrix[15] = 1.0;
+
+
+ matrix[0] = (x*x)*(1-c) + c;
+ matrix[1] = (y*x)*(1-c) + (z*s);
+ matrix[2] = (x*z)*(1-c) - (y*s);
+ matrix[4] = (x*y)*(1-c)-(z*s);
+ matrix[5] = (y*y)*(1-c)+c;
+ matrix[6] = (y*z)*(1-c)+(x*s);
+ matrix[8] = (x*z)*(1-c)+(y*s);
+ matrix[9] = (y*z)*(1-c)-(x*s);
+ matrix[10] = (z*z)*(1-c)+c;
+
+}
+static inline void Matrix3DSetRotationByDegrees(Matrix3D matrix, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
+{
+ Matrix3DSetRotationByRadians(matrix, angle * M_PI / 180.0, x, y, z);
+}
+static inline void Matrix3DSetShear(Matrix3D matrix, GLfloat xShear, GLfloat yShear)
+{
+ matrix[0] = matrix[5] = matrix[10] = matrix[15] = 1.0;
+ matrix[1] = matrix[2] = matrix[3] = 0.0;
+ matrix[6] = matrix[7] = matrix[8] = matrix[9] = 0.0;
+ matrix[11] = matrix[12] = matrix[13] = matrix[14] = 0.0;
+ matrix[1] = xShear;
+ matrix[4] = yShear;
+}
+#pragma mark -
+#pragma mark Quaternions
+#pragma mark -
+typedef struct {
+ GLfloat x;
+ GLfloat y;
+ GLfloat z;
+ GLfloat w;
+} Quaternion3D;
+static inline void Quaternion3DNormalize(Quaternion3D *quaternion)
+{
+ GLfloat magnitude;
+
+ magnitude = sqrtf((quaternion->x * quaternion->x) +
+ (quaternion->y * quaternion->y) +
+ (quaternion->z * quaternion->z) +
+ (quaternion->w * quaternion->w));
+
+ quaternion->x /= magnitude;
+ quaternion->y /= magnitude;
+ quaternion->z /= magnitude;
+ quaternion->w /= magnitude;
+}
+static inline Quaternion3D Quaternion3DMakeWithMatrix3D(Matrix3D matrix)
+{
+ Quaternion3D quat;
+ GLfloat trace, s;
+
+ // Trace of diagonal
+ trace = matrix[0] + matrix[5] + matrix[10];
+ if (trace > 0.0f)
+ {
+ s = sqrtf(trace + 1.0f);
+ quat.w = s * 0.5f;
+ s = 0.5f / s;
+
+ quat.x = (matrix[9] - matrix[6]) * s;
+ quat.y = (matrix[2] - matrix[8]) * s;
+ quat.z = (matrix[4] - matrix[1]) * s;
+ }
+ else
+ {
+ NSInteger biggest;
+ enum {A,E,I};
+ if (matrix[0] > matrix[5])
+ if (matrix[10] > matrix[0])
+ biggest = I;
+ else
+ biggest = A;
+ else
+ if (matrix[10] > matrix[0])
+ biggest = I;
+ else
+ biggest = E;
+
+ switch (biggest)
+ {
+ case A:
+ s = sqrtf(matrix[0] - (matrix[5] + matrix[10]) + 1.0f);
+ if (s > QUATERNION_TRACE_ZERO_TOLERANCE)
+ {
+ quat.x = s * 0.5f;
+ s = 0.5f / s;
+ quat.w = (matrix[9] - matrix[6]) * s;
+ quat.y = (matrix[1] + matrix[4]) * s;
+ quat.z = (matrix[2] + matrix[8]) * s;
+ break;
+ }
+ s = sqrtf(matrix[10] - (matrix[0] + matrix[5]) + 1.0f);
+ if (s > QUATERNION_TRACE_ZERO_TOLERANCE)
+ {
+ quat.z = s * 0.5f;
+ s = 0.5f / s;
+ quat.w = (matrix[4] - matrix[1]) * s;
+ quat.x = (matrix[8] + matrix[2]) * s;
+ quat.y = (matrix[9] + matrix[6]) * s;
+ break;
+ }
+ s = sqrtf(matrix[5] - (matrix[10] + matrix[0]) + 1.0f);
+ if (s > QUATERNION_TRACE_ZERO_TOLERANCE)
+ {
+ quat.y = s * 0.5f;
+ s = 0.5f / s;
+ quat.w = (matrix[2] - matrix[8]) * s;
+ quat.z = (matrix[6] + matrix[9]) * s;
+ quat.x = (matrix[4] + matrix[1]) * s;
+ break;
+ }
+ break;
+
+ case E:
+ s = sqrtf(matrix[5] - (matrix[10] + matrix[0]) + 1.0f);
+ if (s > QUATERNION_TRACE_ZERO_TOLERANCE)
+ {
+ quat.y = s * 0.5f;
+ s = 0.5f / s;
+ quat.w = (matrix[2] - matrix[8]) * s;
+ quat.z = (matrix[6] + matrix[9]) * s;
+ quat.x = (matrix[4] + matrix[1]) * s;
+ break;
+ }
+ s = sqrtf(matrix[10] - (matrix[0] + matrix[5]) + 1.0f);
+ if (s > QUATERNION_TRACE_ZERO_TOLERANCE)
+ {
+ quat.z = s * 0.5f;
+ s = 0.5f / s;
+ quat.w = (matrix[4] - matrix[1]) * s;
+ quat.x = (matrix[8] + matrix[2]) * s;
+ quat.y = (matrix[9] + matrix[6]) * s;
+ break;
+ }
+ s = sqrtf(matrix[0] - (matrix[5] + matrix[10]) + 1.0f);
+ if (s > QUATERNION_TRACE_ZERO_TOLERANCE)
+ {
+ quat.x = s * 0.5f;
+ s = 0.5f / s;
+ quat.w = (matrix[9] - matrix[6]) * s;
+ quat.y = (matrix[1] + matrix[4]) * s;
+ quat.z = (matrix[2] + matrix[8]) * s;
+ break;
+ }
+ break;
+
+ case I:
+ s = sqrtf(matrix[10] - (matrix[0] + matrix[5]) + 1.0f);
+ if (s > QUATERNION_TRACE_ZERO_TOLERANCE)
+ {
+ quat.z = s * 0.5f;
+ s = 0.5f / s;
+ quat.w = (matrix[4] - matrix[1]) * s;
+ quat.x = (matrix[8] + matrix[2]) * s;
+ quat.y = (matrix[9] + matrix[6]) * s;
+ break;
+ }
+ s = sqrtf(matrix[0] - (matrix[5] + matrix[10]) + 1.0f);
+ if (s > QUATERNION_TRACE_ZERO_TOLERANCE)
+ {
+ quat.x = s * 0.5f;
+ s = 0.5f / s;
+ quat.w = (matrix[9] - matrix[6]) * s;
+ quat.y = (matrix[1] + matrix[4]) * s;
+ quat.z = (matrix[2] + matrix[8]) * s;
+ break;
+ }
+ s = sqrtf(matrix[5] - (matrix[10] + matrix[0]) + 1.0f);
+ if (s > QUATERNION_TRACE_ZERO_TOLERANCE)
+ {
+ quat.y = s * 0.5f;
+ s = 0.5f / s;
+ quat.w = (matrix[2] - matrix[8]) * s;
+ quat.z = (matrix[6] + matrix[9]) * s;
+ quat.x = (matrix[4] + matrix[1]) * s;
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ return quat;
+}
+static inline void Matrix3DSetUsingQuaternion3D(Matrix3D matrix, Quaternion3D quat)
+{
+ matrix[0] = (1.0f - (2.0f * ((quat.y * quat.y) + (quat.z * quat.z))));
+ matrix[1] = (2.0f * ((quat.x * quat.y) - (quat.z * quat.w)));
+ matrix[2] = (2.0f * ((quat.x * quat.z) + (quat.y * quat.w)));
+ matrix[3] = 0.0f;
+ matrix[4] = (2.0f * ((quat.x * quat.y) + (quat.z * quat.w)));
+ matrix[5] = (1.0f - (2.0f * ((quat.x * quat.x) + (quat.z * quat.z))));
+ matrix[6] = (2.0f * ((quat.y * quat.z) - (quat.x * quat.w)));
+ matrix[7] = 0.0f;
+ matrix[8] = (2.0f * ((quat.x * quat.z) - (quat.y * quat.w)));
+ matrix[9] = (2.0f * ((quat.y * quat.z) + (quat.x * quat.w)));
+ matrix[10] = (1.0f - (2.0f * ((quat.x * quat.x) + (quat.y * quat.y))));
+ matrix[11] = 0.0f;
+ matrix[12] = 0.0f;
+ matrix[13] = 0.0f;
+ matrix[14] = 0.0f;
+ matrix[15] = 1.0f;
+}
+static inline Quaternion3D Quaternion3DMakeWithAxisAndAngle(Vector3D axis, GLfloat angle)
+{
+ Quaternion3D quat;
+ GLfloat sinAngle;
+
+ angle *= 0.5f;
+ Vector3DNormalize(&axis);
+ sinAngle = sinf(angle);
+ quat.x = (axis.x * sinAngle);
+ quat.y = (axis.y * sinAngle);
+ quat.z = (axis.z * sinAngle);
+ quat.w = cos(angle);
+
+ return quat;
+}
+static inline void Quaternion3DExtractAxisAndAngle(Quaternion3D quat, Vector3D *axis, GLfloat *angle)
+{
+ GLfloat s;
+ Quaternion3DNormalize(&quat);
+ s = sqrtf(1.0f - (quat.w * quat.w));
+
+ if (fabs(s) < 0.0005f) s = 1.0f;
+
+ if (axis != NULL)
+ {
+ axis->x = (quat.x / s);
+ axis->y = (quat.y / s);
+ axis->z = (quat.z / s);
+ }
+
+ if (angle != NULL)
+ *angle = (acosf(quat.w) * 2.0f);
+}
+static inline void Quaternion3DMultiply(Quaternion3D *quat1, Quaternion3D *quat2)
+{
+ Vector3D v1, v2, cp;
+ float angle;
+
+ v1.x = quat1->x;
+ v1.y = quat1->y;
+ v1.z = quat1->z;
+ v2.x = quat2->x;
+ v2.y = quat2->y;
+ v2.z = quat2->z;
+ angle = (quat1->w * quat2->w) - Vector3DDotProduct(v1, v2);
+
+ cp = Vector3DCrossProduct(v1, v2);
+ v1.x *= quat2->w;
+ v1.y *= quat2->w;
+ v1.z *= quat2->w;
+ v2.x *= quat1->w;
+ v2.y *= quat1->w;
+ v2.z *= quat1->w;
+
+ quat1->x = v1.x + v2.x + cp.x;
+ quat1->y = v1.y + v2.y + cp.y;
+ quat1->z = v1.z + v2.z + cp.z;
+ quat1->w = angle;
+}
+static inline void Quaternion3DInvert(Quaternion3D *quat)
+{
+ GLfloat length = 1.0f / ((quat->x * quat->x) +
+ (quat->y * quat->y) +
+ (quat->z * quat->z) +
+ (quat->w * quat->w));
+ quat->x *= -length;
+ quat->y *= -length;
+ quat->z *= -length;
+ quat->w *= length;
+}
+static inline Quaternion3D Quaternion3DMakeWithEulerAngles(GLfloat x, GLfloat y, GLfloat z)
+{
+ Vector3D vx = Vector3DMake(1.f, 0.f, 0.f);
+ Vector3D vy = Vector3DMake(0.f, 1.f, 0.f);
+ Vector3D vz = Vector3DMake(0.f, 0.f, 1.f);
+
+ Quaternion3D qx = Quaternion3DMakeWithAxisAndAngle(vx, x);
+ Quaternion3D qy = Quaternion3DMakeWithAxisAndAngle(vy, y);
+ Quaternion3D qz = Quaternion3DMakeWithAxisAndAngle(vz, z);
+
+
+
+ Quaternion3DMultiply(&qx, &qy );
+ Quaternion3DMultiply(&qx, &qz );
+ return qx;
+}
+static inline Quaternion3D Quaternion3DMakeWithNLERP(Quaternion3D *start, Quaternion3D *finish, GLclampf progress)
+{
+ Quaternion3D ret;
+ GLfloat inverseProgress = 1.0f - progress;
+ ret.x = (start->x * inverseProgress) + (finish->x * progress);
+ ret.y = (start->y * inverseProgress) + (finish->y * progress);
+ ret.z = (start->z * inverseProgress) + (finish->z * progress);
+ ret.w = (start->w * inverseProgress) + (finish->w * progress);
+ Quaternion3DNormalize(&ret);
+ return ret;
+}
+static inline GLfloat Quaternion3DDotProduct(Quaternion3D *quart1, Quaternion3D *quart2)
+{
+ return quart1->x * quart2->x + quart2->y * quart2->y + quart1->z * quart2->z + quart1->w * quart2->w;
+}
+static inline Quaternion3D Quaternion3DMakeWithSLERP(Quaternion3D *start, Quaternion3D *finish, GLclampf progress)
+{
+ GLfloat startWeight, finishWeight, difference;
+ Quaternion3D ret;
+
+ difference = ((start->x * finish->x) + (start->y * finish->y) + (start->z * finish->z) + (start->w * finish->w));
+ if ((1.f - fabs(difference)) > .01f)
+ {
+ GLfloat theta, oneOverSinTheta;
+
+ theta = acosf(fabsf(difference));
+ oneOverSinTheta = (1.f / sinf(theta));
+ startWeight = (sinf(theta * (1.f - progress)) * oneOverSinTheta);
+ finishWeight = (sinf(theta * progress) * oneOverSinTheta);
+ if (difference < 0.f)
+ startWeight = -startWeight;
+ } else
+ {
+ startWeight = (1.f - progress);
+ finishWeight = progress;
+ }
+ ret.x = (start->x * startWeight) + (finish->x * finishWeight);
+ ret.y = (start->y * startWeight) + (finish->y * finishWeight);
+ ret.z = (start->z * startWeight) + (finish->z * finishWeight);
+ ret.w = (start->w * startWeight) + (finish->w * finishWeight);
+ Quaternion3DNormalize(&ret);
+
+ return ret;
+}
+
+#pragma mark -
+#pragma mark VertexTextureCombinations
+#pragma mark -
+// This implements a binary search tree that will help us determine which vertices need to be duplicated. In
+// OpenGL, each vertex has to have one and only one set of texture coordinates, so if a single vertex is shared
+// by multiple triangles and has different texture coordinates in each, those vertices need to be duplicated
+// so that there is one copy of that vertex for every distinct set of texture coordinates.
+
+// This works with index values, not actual Vertex3D values, for speed, and because that's the way the
+// OBJ file format tells us about them
+//
+// An actualVertex value of UINT_MAX means that the actual integer value hasn't been determined yet.
+typedef struct {
+ GLuint originalVertex;
+ GLuint textureCoords;
+ GLuint actualVertex;
+ void *greater;
+ void *lesser;
+
+} VertexTextureIndex;
+static inline VertexTextureIndex * VertexTextureIndexMake (GLuint inVertex, GLuint inTextureCoords, GLuint inActualVertex)
+{
+ VertexTextureIndex *ret = malloc(sizeof(VertexTextureIndex));
+ ret->originalVertex = inVertex;
+ ret->textureCoords = inTextureCoords;
+ ret->actualVertex = inActualVertex;
+ ret->greater = NULL;
+ ret->lesser = NULL;
+ return ret;
+}
+#define VertexTextureIndexMakeEmpty(x,y) VertexTextureIndexMake(x, y, UINT_MAX)
+// recursive search function - looks for a match for a given combination of vertex and
+// texture coordinates. If not found, returns UINT_MAX
+static inline GLuint VertexTextureIndexMatch(VertexTextureIndex *node, GLuint matchVertex, GLuint matchTextureCoords)
+{
+ if (node->originalVertex == matchVertex && node->textureCoords == matchTextureCoords)
+ return node->actualVertex;
+
+ if (node->greater != NULL)
+ {
+ GLuint greaterIndex = VertexTextureIndexMatch(node->greater, matchVertex, matchTextureCoords);
+ if (greaterIndex != UINT_MAX)
+ return greaterIndex;
+ }
+
+ if (node->lesser != NULL)
+ {
+ GLuint lesserIndex = VertexTextureIndexMatch(node->lesser, matchVertex, matchTextureCoords);
+ return lesserIndex;
+ }
+ return UINT_MAX;
+}
+static inline VertexTextureIndex * VertexTextureIndexAddNode(VertexTextureIndex *node, GLuint newVertex, GLuint newTextureCoords)
+{
+ // If requested new node matches the one being added to, then don't add, just return pointer to match
+ if (node->originalVertex == newVertex && node->textureCoords == newTextureCoords)
+ return node;
+ if (node->originalVertex > newVertex || (node->originalVertex == newVertex && node->textureCoords > newTextureCoords))
+ {
+ if (node->lesser != NULL)
+ return VertexTextureIndexAddNode(node->lesser, newVertex, newTextureCoords);
+ else
+ {
+ VertexTextureIndex *newNode = VertexTextureIndexMakeEmpty(newVertex, newTextureCoords);
+ node->lesser = newNode;
+ return node->lesser;
+ }
+ }
+ else
+ {
+ if (node->greater != NULL)
+ return VertexTextureIndexAddNode(node->greater, newVertex, newTextureCoords);
+ else
+ {
+ VertexTextureIndex *newNode = VertexTextureIndexMakeEmpty(newVertex, newTextureCoords);
+ node->greater = newNode;
+ return node->greater;
+ }
+ }
+ return NULL; // shouldn't ever reach here.
+}
+static inline BOOL VertexTextureIndexContainsVertexIndex(VertexTextureIndex *node, GLuint matchVertex)
+{
+ if (node->originalVertex == matchVertex)
+ return YES;
+
+ BOOL greaterHas = NO;
+ BOOL lesserHas = NO;
+
+ if (node->greater != NULL)
+ greaterHas = VertexTextureIndexContainsVertexIndex(node->greater, matchVertex);
+ if (node->lesser != NULL)
+ lesserHas = VertexTextureIndexContainsVertexIndex(node->lesser, matchVertex);
+ return lesserHas || greaterHas;
+}
+static inline void VertexTextureIndexFree(VertexTextureIndex *node)
+{
+ if (node != NULL)
+ {
+ if (node->greater != NULL)
+ VertexTextureIndexFree(node->greater);
+ if (node->lesser != NULL)
+ VertexTextureIndexFree(node->lesser);
+ free(node);
+ }
+
+}
+static inline GLuint VertexTextureIndexCountNodes(VertexTextureIndex *node)
+{
+ GLuint ret = 0;
+
+ if (node)
+ {
+ ret++; // count this node
+
+ // Add the children
+ if (node->greater != NULL)
+ ret += VertexTextureIndexCountNodes(node->greater);
+ if (node->lesser != NULL)
+ ret += VertexTextureIndexCountNodes(node->lesser);
+ }
+ return ret;
+}
+#pragma mark -
+#pragma mark Missing GLUT Functionality
+// This is a modified version of the function of the same name from
+// the Mesa3D project ( http://mesa3d.org/ ), which is licensed
+// under the MIT license, which allows use, modification, and
+// redistribution
+static inline void gluLookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez,
+ GLfloat centerx, GLfloat centery, GLfloat centerz,
+ GLfloat upx, GLfloat upy, GLfloat upz)
+{
+ GLfloat m[16];
+ GLfloat x[3], y[3], z[3];
+ GLfloat mag;
+
+ /* Make rotation matrix */
+
+ /* Z vector */
+ z[0] = eyex - centerx;
+ z[1] = eyey - centery;
+ z[2] = eyez - centerz;
+ mag = sqrtf(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]);
+ if (mag) { /* mpichler, 19950515 */
+ z[0] /= mag;
+ z[1] /= mag;
+ z[2] /= mag;
+ }
+
+ /* Y vector */
+ y[0] = upx;
+ y[1] = upy;
+ y[2] = upz;
+
+ /* X vector = Y cross Z */
+ x[0] = y[1] * z[2] - y[2] * z[1];
+ x[1] = -y[0] * z[2] + y[2] * z[0];
+ x[2] = y[0] * z[1] - y[1] * z[0];
+
+ /* Recompute Y = Z cross X */
+ y[0] = z[1] * x[2] - z[2] * x[1];
+ y[1] = -z[0] * x[2] + z[2] * x[0];
+ y[2] = z[0] * x[1] - z[1] * x[0];
+
+ /* mpichler, 19950515 */
+ /* cross product gives area of parallelogram, which is < 1.0 for
+ * non-perpendicular unit-length vectors; so normalize x, y here
+ */
+
+ mag = sqrtf(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
+ if (mag) {
+ x[0] /= mag;
+ x[1] /= mag;
+ x[2] /= mag;
+ }
+
+ mag = sqrtf(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]);
+ if (mag) {
+ y[0] /= mag;
+ y[1] /= mag;
+ y[2] /= mag;
+ }
+
+#define M(row,col) m[col*4+row]
+ M(0, 0) = x[0];
+ M(0, 1) = x[1];
+ M(0, 2) = x[2];
+ M(0, 3) = 0.0;
+ M(1, 0) = y[0];
+ M(1, 1) = y[1];
+ M(1, 2) = y[2];
+ M(1, 3) = 0.0;
+ M(2, 0) = z[0];
+ M(2, 1) = z[1];
+ M(2, 2) = z[2];
+ M(2, 3) = 0.0;
+ M(3, 0) = 0.0;
+ M(3, 1) = 0.0;
+ M(3, 2) = 0.0;
+ M(3, 3) = 1.0;
+#undef M
+ glMultMatrixf(m);
+
+ /* Translate Eye to Origin */
+ glTranslatef(-eyex, -eyey, -eyez);
+
+}
+#pragma mark -
+#pragma mark Misc
+static inline void billboardCurrentMatrix(void)
+{
+ float modelview[16];
+ glGetFloatv(GL_MODELVIEW_MATRIX , modelview);
+
+
+ for(int i=0; i<3; i++ )
+ {
+ for(int j=0; j<3; j++ )
+ {
+ if ( i==j ) modelview[i*4+j] = 1.0;
+ else modelview[i*4+j] = 0.0;
+ }
+ }
+ glLoadMatrixf(modelview);
+}
22 OpenGL ES 1.1 Project Template/Classes/OpenGLTexture3D.h
@@ -0,0 +1,22 @@
+//
+// OpenGLTexture3D.h
+// NeHe Lesson 06
+//
+// Created by Jeff LaMarche on 12/24/08.
+// Copyright 2008 Jeff LaMarche Consulting. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <OpenGLES/EAGL.h>
+#import <OpenGLES/ES1/gl.h>
+#import <OpenGLES/ES1/glext.h>
+
+@interface OpenGLTexture3D : NSObject {
+ GLuint texture[1];
+ NSString *filename;
+}
+@property (nonatomic, retain) NSString *filename;
+- (id)initWithFilename:(NSString *)inFilename width:(GLuint)inWidth height:(GLuint)inHeight;
+- (void)bind;
++ (void)useDefaultTexture;
+@end
88 OpenGL ES 1.1 Project Template/Classes/OpenGLTexture3D.m
@@ -0,0 +1,88 @@
+//
+// OpenGLTexture3D.m
+// NeHe Lesson 06
+//
+// Created by Jeff LaMarche on 12/24/08.
+// Copyright 2008 Jeff LaMarche Consulting. All rights reserved.
+//
+
+#import "OpenGLTexture3D.h"
+
+
+@implementation OpenGLTexture3D
+@synthesize filename;
+// Height and width are required for pvrt compressed textures. They will be ignored for images that can be used to create UIImage
+- (id)initWithFilename:(NSString *)inFilename width:(GLuint)inWidth height:(GLuint)inHeight;
+{
+ if ((self = [super init]))
+ {
+ glEnable(GL_TEXTURE_2D);
+
+ self.filename = inFilename;
+ glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
+ glGenTextures(1, &texture[0]);
+ glBindTexture(GL_TEXTURE_2D, texture[0]);
+ //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glBlendFunc(GL_ONE, GL_SRC_COLOR);
+
+ NSString *extension = [inFilename pathExtension];
+ NSString *baseFilenameWithExtension = [inFilename lastPathComponent];
+ NSString *baseFilename = [baseFilenameWithExtension substringToIndex:[baseFilenameWithExtension length] - [extension length] - 1];
+
+ NSString *path = [[NSBundle mainBundle] pathForResource:baseFilename ofType:extension];
+ NSData *texData = [[NSData alloc] initWithContentsOfFile:path];
+
+ // Assumes pvr4 is RGB not RGBA, which is how texturetool generates them
+ if ([extension isEqualToString:@"pvr4"])
+ glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, inWidth, inHeight, 0, (inWidth * inHeight) / 2, [texData bytes]);
+ else if ([extension isEqualToString:@"pvr2"])
+ glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, inWidth, inHeight, 0, (inWidth * inHeight) / 2, [texData bytes]);
+ else
+ {
+ UIImage *image = [[UIImage alloc] initWithData:texData];
+ if (image == nil)
+ return nil;
+
+ GLuint width = CGImageGetWidth(image.CGImage);
+ GLuint height = CGImageGetHeight(image.CGImage);
+ CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+ void *imageData = malloc( height * width * 4 );
+ CGContextRef context = CGBitmapContextCreate( imageData, width, height, 8, 4 * width, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big );
+ CGColorSpaceRelease( colorSpace );
+ CGContextClearRect( context, CGRectMake( 0, 0, width, height ) );
+ CGContextDrawImage( context, CGRectMake( 0, 0, width, height ), image.CGImage );
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData);
+ //GLuint errorcode = glGetError();
+ CGContextRelease(context);
+
+ free(imageData);
+ [image release];
+ }
+ glEnable(GL_BLEND);
+
+ }
+ return self;
+}
++ (void)useDefaultTexture
+{
+ glBindTexture(GL_TEXTURE_2D, 0);
+}
+- (void)bind
+{
+ //NSLog(@"Binding texture: %@ (OGL: %d", filename, texture[0]);
+ glBindTexture(GL_TEXTURE_2D, texture[0]);
+}
+- (void)dealloc
+{
+ glDeleteTextures(1, &texture[0]);
+ [filename release];
+ [super dealloc];
+}
+@end
22 OpenGL ES 1.1 Project Template/Classes/___PROJECTNAMEASIDENTIFIER___AppDelegate.h
@@ -0,0 +1,22 @@
+//
+// ___PROJECTNAMEASIDENTIFIER___AppDelegate.h
+// ___PROJECTNAME___
+//
+// Created by ___FULLUSERNAME___ on ___DATE___.
+// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@class GLView;
+
+@interface ___PROJECTNAMEASIDENTIFIER___AppDelegate : NSObject <UIApplicationDelegate> {
+ UIWindow *window;
+ GLView *glView;
+}
+
+@property (nonatomic, retain) IBOutlet UIWindow *window;
+@property (nonatomic, retain) IBOutlet GLView *glView;
+
+@end
+
40 OpenGL ES 1.1 Project Template/Classes/___PROJECTNAMEASIDENTIFIER___AppDelegate.m
@@ -0,0 +1,40 @@
+//
+// ___PROJECTNAMEASIDENTIFIER___AppDelegate.m
+// ___PROJECTNAME___
+//
+// Created by ___FULLUSERNAME___ on ___DATE___.
+// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
+//
+
+#import "___PROJECTNAMEASIDENTIFIER___AppDelegate.h"
+#import "GLView.h"
+
+@implementation ___PROJECTNAMEASIDENTIFIER___AppDelegate
+
+@synthesize window;
+@synthesize glView;
+
+- (void)applicationDidFinishLaunching:(UIApplication *)application {
+
+ glView.animationInterval = 1.0 / kRenderingFrequency;
+ [glView startAnimation];
+}
+
+
+- (void)applicationWillResignActive:(UIApplication *)application {
+ glView.animationInterval = 1.0 / kInactiveRenderingFrequency;
+}
+
+
+- (void)applicationDidBecomeActive:(UIApplication *)application {
+ glView.animationInterval = 1.0 / 60.0;
+}
+
+
+- (void)dealloc {
+ [window release];
+ [glView release];
+ [super dealloc];
+}
+
+@end
156 OpenGL ES 1.1 Project Template/GLView.m
@@ -0,0 +1,156 @@
+//
+// GLView.h
+// ___PROJECTNAME___
+//
+// Created by ___FULLUSERNAME___ on ___DATE___.
+// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
+//
+
+
+#import <QuartzCore/QuartzCore.h>
+#import <OpenGLES/EAGLDrawable.h>
+
+#import "GLView.h"
+#import "ConstantsAndMacros.h"
+
+
+@interface GLView ()
+@property (nonatomic, retain) EAGLContext *context;
+@property (nonatomic, assign) NSTimer *animationTimer;
+- (BOOL) createFramebuffer;
+- (void) destroyFramebuffer;
+@end
+
+#pragma mark -
+
+@implementation GLView
+
+@synthesize context;
+@synthesize animationTimer;
+@synthesize animationInterval;
+@synthesize delegate;
+
++ (Class)layerClass
+{
+ return [CAEAGLLayer class];
+}
+- (id)initWithCoder:(NSCoder*)coder {
+
+ if ((self = [super initWithCoder:coder])) {
+ // Get the layer
+ CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
+
+ eaglLayer.opaque = YES;
+ eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
+
+#if kAttemptToUseOpenGLES2
+ context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
+ if (context == NULL)
+ {
+#endif
+ context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
+
+ if (!context || ![EAGLContext setCurrentContext:context]) {
+ [self release];
+ return nil;
+ }
+#if kAttemptToUseOpenGLES2
+ }
+#endif
+
+ animationInterval = 1.0 / kRenderingFrequency;
+ }
+ return self;
+}
+- (void)drawView
+{
+ glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
+ [delegate drawView:self];
+ glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
+ [context presentRenderbuffer:GL_RENDERBUFFER_OES];
+}
+- (void)layoutSubviews
+{
+ [EAGLContext setCurrentContext:context];
+ [self destroyFramebuffer];
+ [self createFramebuffer];
+ [self drawView];
+}
+- (BOOL)createFramebuffer
+{
+
+ 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);
+
+ if (USE_DEPTH_BUFFER)
+ {
+ 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));
+ return NO;
+ }
+ [delegate setupView:self];
+ return YES;
+}
+- (void)destroyFramebuffer
+{
+ glDeleteFramebuffersOES(1, &viewFramebuffer);
+ viewFramebuffer = 0;
+ glDeleteRenderbuffersOES(1, &viewRenderbuffer);
+ viewRenderbuffer = 0;
+
+ if(depthRenderbuffer)
+ {
+ glDeleteRenderbuffersOES(1, &depthRenderbuffer);
+ depthRenderbuffer = 0;
+ }
+}
+- (void)startAnimation
+{
+ self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES];
+}
+- (void)stopAnimation
+{
+ self.animationTimer = nil;
+}
+- (void)setAnimationTimer:(NSTimer *)newTimer
+{
+ [animationTimer invalidate];
+ animationTimer = newTimer;
+}
+- (void)setAnimationInterval:(NSTimeInterval)interval
+{
+ animationInterval = interval;
+ if (animationTimer)
+ {
+ [self stopAnimation];
+ [self startAnimation];
+ }
+}
+- (void)dealloc
+{
+ [self stopAnimation];
+
+ if ([EAGLContext currentContext] == context)
+ [EAGLContext setCurrentContext:nil];
+
+ [context release];
+ [super dealloc];
+}
+
+@end
500 OpenGL ES 1.1 Project Template/MainWindow.xib
@@ -0,0 +1,500 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
+ <data>
+ <int key="IBDocument.SystemTarget">768</int>
+ <string key="IBDocument.SystemVersion">10A380</string>
+ <string key="IBDocument.InterfaceBuilderVersion">731</string>
+ <string key="IBDocument.AppKitVersion">1025.2</string>
+ <string key="IBDocument.HIToolboxVersion">427.00</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="NS.object.0">58</string>
+ </object>
+ <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <integer value="10"/>
+ </object>
+ <object class="NSArray" key="IBDocument.PluginDependencies">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </object>
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys" id="0">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBProxyObject" id="841351856">
+ <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
+ </object>
+ <object class="IBProxyObject" id="191355593">
+ <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
+ </object>
+ <object class="IBUICustomObject" id="664661524"/>
+ <object class="IBUIWindow" id="380026005">
+ <reference key="NSNextResponder"/>
+ <int key="NSvFlags">1316</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBUIView" id="773737154">
+ <reference key="NSNextResponder" ref="380026005"/>
+ <int key="NSvFlags">1298</int>
+ <string key="NSFrameSize">{320, 480}</string>
+ <reference key="NSSuperview" ref="380026005"/>
+ <reference key="NSWindow"/>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MQA</bytes>
+ <object class="NSColorSpace" key="NSCustomColorSpace">
+ <int key="NSID">2</int>
+ </object>
+ </object>
+ <bool key="IBUIClearsContextBeforeDrawing">NO</bool>
+ </object>
+ </object>
+ <object class="NSPSMatrix" key="NSFrameMatrix"/>
+ <string key="NSFrameSize">{320, 480}</string>
+ <reference key="NSSuperview"/>
+ <reference key="NSWindow"/>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MSAxIDEAA</bytes>
+ </object>
+ <bool key="IBUIClearsContextBeforeDrawing">NO</bool>
+ <bool key="IBUIVisibleAtLaunch">YES</bool>
+ </object>
+ <object class="IBUIViewController" id="567806615">
+ <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
+ </object>
+ </object>
+ <object class="IBObjectContainer" key="IBDocument.Objects">
+ <object class="NSMutableArray" key="connectionRecords">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="841351856"/>
+ <reference key="destination" ref="664661524"/>
+ </object>
+ <int key="connectionID">4</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">window</string>
+ <reference key="source" ref="664661524"/>
+ <reference key="destination" ref="380026005"/>
+ </object>
+ <int key="connectionID">5</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">glView</string>
+ <reference key="source" ref="664661524"/>
+ <reference key="destination" ref="773737154"/>
+ </object>
+ <int key="connectionID">9</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">view</string>
+ <reference key="source" ref="567806615"/>
+ <reference key="destination" ref="773737154"/>
+ </object>
+ <int key="connectionID">11</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="773737154"/>
+ <reference key="destination" ref="567806615"/>
+ </object>
+ <int key="connectionID">12</int>
+ </object>
+ </object>
+ <object class="IBMutableOrderedSet" key="objectRecords">
+ <object class="NSArray" key="orderedObjects">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBObjectRecord">
+ <int key="objectID">0</int>
+ <reference key="object" ref="0"/>
+ <reference key="children" ref="1000"/>
+ <nil key="parent"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">2</int>
+ <reference key="object" ref="380026005"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="773737154"/>
+ </object>
+ <reference key="parent" ref="0"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-1</int>
+ <reference key="object" ref="841351856"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">File's Owner</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">3</int>
+ <reference key="object" ref="664661524"/>
+ <reference key="parent" ref="0"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">8</int>
+ <reference key="object" ref="773737154"/>
+ <reference key="parent" ref="380026005"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-2</int>
+ <reference key="object" ref="191355593"/>
+ <reference key="parent" ref="0"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">10</int>
+ <reference key="object" ref="567806615"/>
+ <reference key="parent" ref="0"/>
+ </object>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="flattenedProperties">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>-1.CustomClassName</string>
+ <string>-2.CustomClassName</string>
+ <string>10.CustomClassName</string>
+ <string>10.IBEditorWindowLastContentRect</string>
+ <string>10.IBPluginDependency</string>
+ <string>2.IBAttributePlaceholdersKey</string>
+ <string>2.IBEditorWindowLastContentRect</string>
+ <string>2.IBPluginDependency</string>
+ <string>3.CustomClassName</string>
+ <string>3.IBPluginDependency</string>
+ <string>8.CustomClassName</string>
+ <string>8.IBPluginDependency</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>UIApplication</string>
+ <string>UIResponder</string>
+ <string>GLViewController</string>
+ <string>{{0, 665}, {320, 480}}</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <object class="NSMutableDictionary">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference key="dict.sortedKeys" ref="0"/>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <string>{{500, 343}, {320, 480}}</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string>___PROJECTNAMEASIDENTIFIER___AppDelegate</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string>GLView</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="unlocalizedProperties">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference key="dict.sortedKeys" ref="0"/>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <nil key="activeLocalization"/>
+ <object class="NSMutableDictionary" key="localizations">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference key="dict.sortedKeys" ref="0"/>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <nil key="sourceID"/>
+ <int key="maxID">12</int>
+ </object>
+ <object class="IBClassDescriber" key="IBDocument.Classes">
+ <object class="NSMutableArray" key="referencedPartialClassDescriptions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBPartialClassDescription">
+ <string key="className">GLView</string>
+ <string key="superclassName">UIView</string>
+ <object class="NSMutableDictionary" key="outlets">
+ <string key="NS.key.0">delegate</string>
+ <string key="NS.object.0">id</string>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">Classes/GLView.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">GLView</string>
+ <string key="superclassName">UIView</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBUserSource</string>
+ <string key="minorKey"/>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">GLViewController</string>
+ <string key="superclassName">UIViewController</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">Classes/GLViewController.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">___PROJECTNAMEASIDENTIFIER___AppDelegate</string>
+ <string key="superclassName">NSObject</string>
+ <object class="NSMutableDictionary" key="outlets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>glView</string>
+ <string>window</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>GLView</string>
+ <string>UIWindow</string>
+ </object>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">Classes/___PROJECTNAMEASIDENTIFIER___AppDelegate.h</string>
+ </object>
+ </object>
+ </object>
+ <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSError.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSFileManager.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSKeyValueCoding.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSKeyValueObserving.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSKeyedArchiver.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSNetServices.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSObject.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSPort.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSRunLoop.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSStream.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSThread.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSURL.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSURLConnection.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSXMLParser.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">QuartzCore.framework/Headers/CAAnimation.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">QuartzCore.framework/Headers/CALayer.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">UIKit.framework/Headers/UIAccessibility.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">UIKit.framework/Headers/UINibLoading.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier" id="17429196">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">UIKit.framework/Headers/UIResponder.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">UIApplication</string>
+ <string key="superclassName">UIResponder</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">UIKit.framework/Headers/UIApplication.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">UIResponder</string>
+ <string key="superclassName">NSObject</string>
+ <reference key="sourceIdentifier" ref="17429196"/>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">UISearchBar</string>
+ <string key="superclassName">UIView</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">UIKit.framework/Headers/UISearchBar.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">UISearchDisplayController</string>
+ <string key="superclassName">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">UIKit.framework/Headers/UISearchDisplayController.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">UIView</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">UIKit.framework/Headers/UITextField.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">UIView</string>
+ <string key="superclassName">UIResponder</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">UIKit.framework/Headers/UIView.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">UIViewController</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">UIKit.framework/Headers/UINavigationController.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">UIViewController</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">UIKit.framework/Headers/UITabBarController.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">UIViewController</string>
+ <string key="superclassName">UIResponder</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">UIKit.framework/Headers/UIViewController.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">UIWindow</string>
+ <string key="superclassName">UIView</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">UIKit.framework/Headers/UIWindow.h</string>
+ </object>
+ </object>
+ </object>
+ </object>
+ <int key="IBDocument.localizationMode">0</int>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
+ <integer value="768" key="NS.object.0"/>
+ </object>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
+ <integer value="3100" key="NS.object.0"/>
+ </object>
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
+ <string key="IBDocument.LastKnownRelativeProjectPath">___PROJECTNAME___.xcodeproj</string>
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
+ <string key="IBCocoaTouchPluginVersion">3.0</string>
+ </data>
+</archive>
516 OpenGL ES 1.1 Project Template/Resources-iPad/MainWindow-iPad.xib
@@ -0,0 +1,516 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="7.10">
+ <data>
+ <int key="IBDocument.SystemTarget">768</int>
+ <string key="IBDocument.SystemVersion">10D573</string>
+ <string key="IBDocument.InterfaceBuilderVersion">762</string>
+ <string key="IBDocument.AppKitVersion">1038.29</string>
+ <string key="IBDocument.HIToolboxVersion">460.00</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="NS.object.0">87</string>
+ </object>
+ <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSArray" key="IBDocument.PluginDependencies">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </object>
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys" id="0">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBProxyObject" id="841351856">
+ <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ </object>
+ <object class="IBProxyObject" id="191355593">
+ <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ </object>
+ <object class="IBUICustomObject" id="664661524">
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ </object>
+ <object class="IBUIWindow" id="380026005">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">1316</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBUIView" id="773737154">
+ <reference key="NSNextResponder" ref="380026005"/>
+ <int key="NSvFlags">1298</int>
+ <string key="NSFrameSize">{768, 1024}</string>
+ <reference key="NSSuperview" ref="380026005"/>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MQA</bytes>
+ <object class="NSColorSpace" key="NSCustomColorSpace">
+ <int key="NSID">2</int>
+ </object>
+ </object>
+ <bool key="IBUIClearsContextBeforeDrawing">NO</bool>
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ </object>
+ </object>
+ <object class="NSPSMatrix" key="NSFrameMatrix"/>
+ <string key="NSFrameSize">{320, 480}</string>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MSAxIDEAA</bytes>
+ </object>
+ <bool key="IBUIClearsContextBeforeDrawing">NO</bool>
+ <string key="targetRuntimeIdentifier">IBIPadFramework</string>
+ <bool key="IBUIVisibleAtLaunch">YES</bool>
+ <bool key="IBUIResizesToFullScreen">YES</bool>
+ </object>