// 実際に表示されているアプリケーションの画面のどの領域に表示するかを指定 GL.Viewport(0, Width, 0, Height); // 基本形 //画面描画で実行される。 protected override void OnRenderFrame(FrameEventArgs e) { base.OnRenderFrame(e); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); // [クリッピング座標系] クリッピング空間の指定. カメラの表示画角を指定するだけ (順不動) GL.MatrixMode(MatrixMode.Projection); Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4, (float)glControl.Size.Width / (float)glControl.Size.Height, 1.0f, 64.0f); GL.LoadMatrix(ref projection); // [ビュー座標系] カメラの位置,方向,を指定するだけ (順不動) GL.MatrixMode(MatrixMode.Modelview); Matrix4 modelview = Matrix4.LookAt(Vector3.Zero, Vector3.UnitZ, Vector3.UnitY); GL.LoadMatrix(ref modelview); // ワールド座標系でオブジェクトを配置 GL.Begin(BeginMode.Quads); GL.Color4(Color4.White); //色名で指定 GL.Vertex3(-1.0f, 1.0f, 4.0f); GL.Color4(new float[] { 1.0f, 0.0f, 0.0f, 1.0f }); //配列で指定 GL.Vertex3(-1.0f, -1.0f, 4.0f); GL.Color4(0.0f, 1.0f, 0.0f, 1.0f); //4つの引数にfloat型で指定 GL.Vertex3(1.0f, -1.0f, 4.0f); GL.Color4((byte)0, (byte)0, (byte)255, (byte)255); //byte型で指定 GL.Vertex3(1.0f, 1.0f, 4.0f); GL.End(); SwapBuffers(); }