0
我想畫一個三角形打招呼(或四)與GLViewController就像在this Xamarin例如對所有OpenGL戰平OpenGL和GLKViewController一個三角形與Xamarin
的例子創建自己的幀緩存和其他邏輯,作爲我的理解已經由GLView做閱讀here
我使用的是從GLKViewController派生的類是在主故事板
類應明確與動畫黑色的背景,紅色的蘋果文檔(這是actuallly工作)並繪製在屏幕上四(是不是)
這是我走到這一步,代碼:
partial class GpuImageView : MonoTouch.GLKit.GLKViewController
{
public GpuImageView (IntPtr handle) : base (handle)
{
}
GLKView glkView;
EAGLContext Context;
public override void ViewDidLoad()
{
base.ViewDidLoad();
//create the rendering context
Context = new EAGLContext(EAGLRenderingAPI.OpenGLES2);
//get the view:
glkView = (GLKView)this.View;
glkView.Context = Context;
glkView.MultipleTouchEnabled = true;
glkView.DrawInRect += Draw;
}
public override void Update()
{
color = (color > 1.0F) ? (0F) : (color + 1.0F/30.0F);
}
float color ;
void Draw (object sender, GLKViewDrawEventArgs e)
{
GL.Viewport(0, 0, glkView.DrawableWidth, glkView.DrawableHeight);
//this matrix initialization is copied from the OpenGLES example:
GL.MatrixMode (All.Projection);
GL.LoadIdentity();
GL.Ortho (-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f);
GL.MatrixMode(All.Modelview);
GL.LoadIdentity();
float[] squareVertices = {
-0.5f, -0.5f,
0.5f, -0.5f,
-0.5f, 0.5f,
0.5f, 0.5f,
};
byte[] squareColors = {
255, 255, 0, 255,
0, 255, 255, 255,
0, 0, 0, 0,
255, 0, 255, 255,
};
//The color clear is working fine :)
GL.ClearColor(color, 0F, 0F, 1F);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
//The quad never draws:
GL.VertexPointer (2, All.Float, 0, squareVertices);
GL.EnableClientState (All.VertexArray);
GL.ColorPointer (4, All.UnsignedByte, 0, squareColors);
GL.EnableClientState (All.ColorArray);
GL.DrawArrays (All.TriangleStrip, 0, 4);
}
這是我是圖書館使用(增加了 「OpenTK-1.0」 的項目):
using System;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System.CodeDom.Compiler;
using MonoTouch.OpenGLES;
using MonoTouch.GLKit;
using OpenTK.Graphics.ES11;
using MonoTouch.CoreAnimation;