Permalink
Browse files

Initial commit

  • Loading branch information...
1 parent f82fbff commit a7133fe684d74cf7641e902ce7a80a2957eb0078 @sixman9 committed Feb 7, 2011
View
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBO-OpenTK-Forum", "VBO-OpenTK-Forum\VBO-OpenTK-Forum.csproj", "{A96A3892-7D2E-47B7-B4B1-33A9A46B5B4C}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|iPhoneSimulator = Debug|iPhoneSimulator
+ Release|iPhoneSimulator = Release|iPhoneSimulator
+ Debug|iPhone = Debug|iPhone
+ Release|iPhone = Release|iPhone
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A96A3892-7D2E-47B7-B4B1-33A9A46B5B4C}.Debug|iPhone.ActiveCfg = Debug|iPhone
+ {A96A3892-7D2E-47B7-B4B1-33A9A46B5B4C}.Debug|iPhone.Build.0 = Debug|iPhone
+ {A96A3892-7D2E-47B7-B4B1-33A9A46B5B4C}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
+ {A96A3892-7D2E-47B7-B4B1-33A9A46B5B4C}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
+ {A96A3892-7D2E-47B7-B4B1-33A9A46B5B4C}.Release|iPhone.ActiveCfg = Release|iPhone
+ {A96A3892-7D2E-47B7-B4B1-33A9A46B5B4C}.Release|iPhone.Build.0 = Release|iPhone
+ {A96A3892-7D2E-47B7-B4B1-33A9A46B5B4C}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
+ {A96A3892-7D2E-47B7-B4B1-33A9A46B5B4C}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = VBO-OpenTK-Forum\VBO-OpenTK-Forum.csproj
+ EndGlobalSection
+EndGlobal
View
@@ -0,0 +1,13 @@
+<Properties>
+ <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|iPhoneSimulator" />
+ <MonoDevelop.Ide.Workbench ActiveDocument="VBO-OpenTK-Forum/EAGLView.cs">
+ <Files>
+ <File FileName="VBO-OpenTK-Forum/Main.cs" Line="1" Column="1" />
+ <File FileName="VBO-OpenTK-Forum/EAGLView.cs" Line="77" Column="4" />
+ </Files>
+ </MonoDevelop.Ide.Workbench>
+ <MonoDevelop.Ide.DebuggingService.Breakpoints>
+ <BreakpointStore />
+ </MonoDevelop.Ide.DebuggingService.Breakpoints>
+ <MonoDevelop.Ide.DebuggingService.PinnedWatches />
+</Properties>
@@ -0,0 +1,133 @@
+using System;
+using OpenTK.Platform.iPhoneOS;
+using MonoTouch.CoreAnimation;
+using OpenTK;
+using OpenTK.Graphics.ES11;
+using MonoTouch.Foundation;
+using MonoTouch.ObjCRuntime;
+using MonoTouch.OpenGLES;
+
+//See http://forums.monotouch.net/yaf_postsm1587.aspx#post1587
+
+namespace VBOOpenTKForum
+{
+ public partial class EAGLView : iPhoneOSGameView
+ {
+ [Export("layerClass")]
+ static Class LayerClass ()
+ {
+ return iPhoneOSGameView.GetLayerClass ();
+ }
+
+ [Export("initWithCoder:")]
+ public EAGLView (NSCoder coder) : base(coder)
+ {
+ LayerRetainsBacking = false;
+ LayerColorFormat = EAGLColorFormat.RGBA8;
+ ContextRenderingApi = EAGLRenderingAPI.OpenGLES1;
+ }
+
+ protected override void ConfigureLayer (CAEAGLLayer eaglLayer)
+ {
+ eaglLayer.Opaque = true;
+ }
+
+ private float[] vertArray = {
+ -53.69261f, 53.29295f, 57.87402f,
+ -53.69261f, -53.00626f, -73.22835f,
+ -53.69261f, -53.00626f, -6.299212f,
+ 41.97668f, 53.29295f, -44.94617f,
+ 41.97668f, 53.29295f, 57.87402f,
+ 41.97668f, -53.00626f, -64.17323f,
+ 41.97668f, -53.00626f, -6.299212f
+ };
+
+ private byte[] colorArray = {
+ 255, 255, 255, 255,
+ 255, 255, 255, 255,
+ 255, 255, 255, 255,
+ 255, 255, 255, 255,
+ 255, 255, 255, 255,
+ 255, 255, 255, 255,
+ 255, 255, 255, 255
+ };
+
+ private ushort[] indcArray = {
+ 0, 1, 2,
+ 3, 0, 4,
+ 3, 5, 1,
+ 3, 1, 0,
+ 2, 4, 0,
+ 4, 2, 6,
+ 5, 2, 1,
+ 2, 5, 6,
+ 3, 6, 5,
+ 6, 3, 4
+ };
+
+ private uint vertexBuffer = 0;
+ private uint colorBuffer = 0;
+ private uint indexBuffer = 0;
+
+ protected override void CreateFrameBuffer ()
+ {
+ base.CreateFrameBuffer ();
+ GL.Viewport (0, 0, Size.Width, Size.Height);
+ GL.MatrixMode (All.Projection);
+ GL.LoadIdentity ();
+ Matrix4 perspective = Matrix4.CreatePerspectiveFieldOfView (MathHelper.DegreesToRadians (45f), ((float)Size.Width / (float)Size.Height), 0.1f, 10000f);
+
+ unsafe {
+ GL.LoadMatrix (&perspective.Row0.X);
+ }
+
+ GL.Rotate (270f, 0f, 0f, 1f);
+ GL.ShadeModel (All.Flat);
+ GL.ClearDepth (1f);
+ GL.Enable (All.DepthTest);
+ GL.DepthFunc (All.Lequal);
+ GL.Hint (All.PerspectiveCorrectionHint, All.Nicest);
+ GL.GenBuffers (1, ref this.vertexBuffer);
+ GL.BindBuffer (All.ArrayBuffer, this.vertexBuffer);
+ GL.BufferData (All.ArrayBuffer, new IntPtr ((sizeof(float) * this.vertArray.Length)), this.vertArray, All.StaticDraw);
+ GL.GenBuffers (1, ref this.colorBuffer);
+ GL.BindBuffer (All.ArrayBuffer, this.colorBuffer);
+ GL.BufferData (All.ArrayBuffer, new IntPtr ((sizeof(byte) * this.colorArray.Length)), this.colorArray, All.StaticDraw);
+ GL.GenBuffers (1, ref this.indexBuffer);
+ GL.BindBuffer (All.ElementArrayBuffer, this.indexBuffer);
+ GL.BufferData (All.ElementArrayBuffer, new IntPtr ((sizeof(ushort) * this.indcArray.Length)), this.indcArray, All.StaticDraw);
+ }
+
+ protected override void OnRenderFrame (FrameEventArgs e)
+ {
+ base.OnRenderFrame (e);
+ MakeCurrent ();
+ GL.ClearColor (0.5f, 0.5f, 0.5f, 1f);
+ GL.Clear ((uint)All.ColorBufferBit);
+ GL.MatrixMode (All.Modelview);
+ Matrix4 matrix = Matrix4.LookAt (100f, 100f, 100f, 0f, 0f, 0f, 0f, 0f, 1f);
+ unsafe {
+ GL.LoadMatrix (&matrix.Row0.X);
+ }
+ GL.BindBuffer (All.ArrayBuffer, this.vertexBuffer);
+ GL.EnableClientState (All.VertexArray);
+ GL.VertexPointer (3, All.Float, 0, IntPtr.Zero);
+ GL.BindBuffer (All.ArrayBuffer, this.colorBuffer);
+ GL.EnableClientState (All.ColorArray);
+ GL.ColorPointer (4, All.UnsignedByte, 0, IntPtr.Zero);
+ GL.BindBuffer (All.ElementArrayBuffer, this.indexBuffer);
+ GL.DrawElements (All.Triangles, this.indcArray.Length, All.UnsignedShort, IntPtr.Zero);
+ GL.DisableClientState (All.VertexArray);
+ GL.DisableClientState (All.ColorArray);
+ SwapBuffers ();
+ }
+
+ protected override void DestroyFrameBuffer ()
+ {
+ GL.DeleteBuffers (1, ref vertexBuffer);
+ GL.DeleteBuffers (1, ref colorBuffer);
+ GL.DeleteBuffers (1, ref indexBuffer);
+ base.DestroyFrameBuffer ();
+ }
+ }
+}
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+</dict>
+</plist>
View
@@ -0,0 +1,41 @@
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using MonoTouch.Foundation;
+using MonoTouch.UIKit;
+
+namespace VBOOpenTKForum
+{
+ public class Application
+ {
+ static void Main (string[] args)
+ {
+ UIApplication.Main (args);
+ }
+ }
+
+ // The name AppDelegate is referenced in the MainWindow.xib file.
+ public partial class AppDelegate : UIApplicationDelegate
+ {
+ // This method is invoked when the application has loaded its UI and is ready to run
+ public override void FinishedLaunching (UIApplication app)
+ {
+ glView.Run (60.0);
+ }
+
+ public override void OnResignActivation (UIApplication app)
+ {
+ glView.Stop ();
+ glView.Run (5.0);
+ }
+
+ // This method is required in iPhoneOS 3.0
+ public override void OnActivated (UIApplication app)
+ {
+ glView.Stop ();
+ glView.Run (60.0);
+ }
+ }
+}
+
Oops, something went wrong.

0 comments on commit a7133fe

Please sign in to comment.