protected override void OnLoad(EventArgs e) { base.OnLoad(e); this.KeyPress += new EventHandler <OpenTK.KeyPressEventArgs>(OpenTKGameWindow_KeyPress); Keyboard.KeyDown += new EventHandler <OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyDown); Keyboard.KeyUp += new EventHandler <OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyUp); Mouse.WheelChanged += new EventHandler <OpenTK.Input.MouseWheelEventArgs>(Mouse_WheelChanged); Mouse.ButtonDown += new EventHandler <OpenTK.Input.MouseButtonEventArgs>(Mouse_ButtonDown); Mouse.ButtonUp += new EventHandler <OpenTK.Input.MouseButtonEventArgs>(Mouse_ButtonUp); Mouse.Move += new EventHandler <OpenTK.Input.MouseMoveEventArgs>(Mouse_Move); GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f); Console.WriteLine("\n\n*************************************"); Console.WriteLine("GL version: " + GL.GetString(StringName.Version)); Console.WriteLine("GL vendor: " + GL.GetString(StringName.Vendor)); Console.WriteLine("GLSL version: " + GL.GetString(StringName.ShadingLanguageVersion)); Console.WriteLine("*************************************\n"); projection = OpenTK.Matrix4.CreateOrthographicOffCenter(-0.5f, 0.5f, -0.5f, 0.5f, 1, -1); shader = new Shader(); quad = new Crow.vaoMesh(0, 0, 0, 1, 1, 1, -1); }
public virtual void initGL() { projection = OpenTK.Matrix4.CreateOrthographicOffCenter(-0.5f, 0.5f, -0.5f, 0.5f, 1, -1); quad = new Crow.vaoMesh(0, 0, 0, 1, 1, 1, -1); createContext(); }
public virtual void initGL() { projection = OpenTK.Matrix4.CreateOrthographicOffCenter (-0.5f, 0.5f, -0.5f, 0.5f, 1, -1); quad = new Crow.vaoMesh (0, 0, 0, 1, 1, 1, -1); createContext (); }
void initGL() { GL.Enable (EnableCap.CullFace); GL.Enable (EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); cube = vaoMesh.CreateCube (); texture = new Texture ("image/textest.png"); }
void initGrid() { const float z = 0.0f; const int IdxPrimitiveRestart = int.MaxValue; Vector3[] positionVboData; int[] indicesVboData; Vector2[] texVboData; positionVboData = new Vector3[_gridSize * _gridSize]; texVboData = new Vector2[_gridSize * _gridSize]; indicesVboData = new int[(_gridSize * 2 + 1) * _gridSize]; for (int y = 0; y < _gridSize; y++) { for (int x = 0; x < _gridSize; x++) { positionVboData [_gridSize * y + x] = new Vector3 (x, y, z); texVboData [_gridSize * y + x] = new Vector2 ((float)x*1.0f, (float)y*1.0f); if (y < _gridSize-1) { indicesVboData [(_gridSize * 2 + 1) * y + x*2+ 1] = _gridSize * y + x; indicesVboData [(_gridSize * 2 + 1) * y + x*2] = _gridSize * (y+1) + x; } if (x == _gridSize-1) { indicesVboData [(_gridSize * 2 + 1) * y + x*2 + 2] = IdxPrimitiveRestart; } } } gridMesh = new vaoMesh (positionVboData, texVboData, indicesVboData); Tetra.Texture.DefaultWrapMode = TextureWrapMode.Repeat; gridShader.DiffuseTexture = Tetra.Texture.Load (TextureTarget.Texture2DArray, groundTextures); Tetra.Texture.ResetToDefaultLoadingParams (); hmData = new byte[_hmSize*_hmSize*4]; getHeightMapData (); }
void initGL() { GL.Enable (EnableCap.CullFace); GL.Enable (EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); cube = vaoMesh.CreateCube (); texture = new Texture ("image/textest.png"); projection = Matrix4.CreatePerspectiveFieldOfView ( MathHelper.PiOver4, ClientRectangle.Width / (float)ClientRectangle.Height, 1.0f, 10.0f); modelview = Matrix4.LookAt(new Vector3(5,5,5), Vector3.Zero, Vector3.UnitZ); }
public static vaoMesh CreateCube() { vaoMesh tmp = new vaoMesh(); tmp.positions = new Vector3[] { new Vector3(-1.0f, -1.0f, -1.0f), new Vector3(-1.0f, -1.0f, 1.0f), new Vector3(1.0f, -1.0f, -1.0f), new Vector3(1.0f, -1.0f, 1.0f), new Vector3(1.0f, 1.0f, -1.0f), new Vector3(1.0f, 1.0f, 1.0f), new Vector3(-1.0f, 1.0f, -1.0f), new Vector3(-1.0f, 1.0f, 1.0f) }; tmp.indices = new int[] { // front face 0, 2, 1, 1, 2, 3, // top face 2, 4, 3, 3, 4, 5, // back face 4, 6, 5, 5, 6, 7, // left face 6, 0, 7, 7, 0, 1, // bottom face 1, 3, 7, 7, 3, 5, // right face // 1, 5, 6, 6, 2, 1, }; tmp.texCoords = new Vector2[] { new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 0), new Vector2(1, 1), }; tmp.CreateBuffers(); return(tmp); // Normals = new Vector3[] // { // new Vector3(-1.0f, -1.0f, 1.0f), // new Vector3( 1.0f, -1.0f, 1.0f), // new Vector3( 1.0f, 1.0f, 1.0f), // new Vector3(-1.0f, 1.0f, 1.0f), // new Vector3(-1.0f, -1.0f, -1.0f), // new Vector3( 1.0f, -1.0f, -1.0f), // new Vector3( 1.0f, 1.0f, -1.0f), // new Vector3(-1.0f, 1.0f, -1.0f), // }; // // Colors = new int[] // { // Utilities.ColorToRgba32(Color.DarkRed), // Utilities.ColorToRgba32(Color.DarkRed), // Utilities.ColorToRgba32(Color.Gold), // Utilities.ColorToRgba32(Color.Gold), // Utilities.ColorToRgba32(Color.DarkRed), // Utilities.ColorToRgba32(Color.DarkRed), // Utilities.ColorToRgba32(Color.Gold), // Utilities.ColorToRgba32(Color.Gold), // }; }
void initGL(){ GL.Enable(EnableCap.DepthTest); GL.DepthFunc(DepthFunction.Less); // GL.Enable(EnableCap.CullFace); GL.PrimitiveRestartIndex (int.MaxValue); GL.Enable (EnableCap.PrimitiveRestart); GL.Enable (EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); mesh = new vaoMesh (0f, 0f, 0f, 100f, 100f); tex = Tetra.Texture.Load ("images/test.jpg"); }
public static vaoMesh CreateCube() { vaoMesh tmp = new vaoMesh (); tmp.positions = new Vector3[] { new Vector3(-1.0f, -1.0f, -1.0f), new Vector3( -1.0f, -1.0f, 1.0f), new Vector3( 1.0f, -1.0f, -1.0f), new Vector3(1.0f, -1.0f, 1.0f), new Vector3(1.0f, 1.0f, -1.0f), new Vector3( 1.0f, 1.0f, 1.0f), new Vector3( -1.0f, 1.0f, -1.0f), new Vector3(-1.0f, 1.0f, 1.0f) }; tmp.indices = new int[] { // front face 0, 2, 1, 1, 2, 3, // top face 2, 4, 3, 3, 4, 5, // back face 4, 6, 5, 5, 6, 7, // left face 6, 0, 7, 7, 0, 1, // bottom face 1, 3, 7, 7, 3, 5, // right face // 1, 5, 6, 6, 2, 1, }; tmp.texCoords = new Vector2[] { new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 0), new Vector2(0, 1), new Vector2(1, 0), new Vector2(1, 1), }; tmp.CreateBuffers (); return tmp; // Normals = new Vector3[] // { // new Vector3(-1.0f, -1.0f, 1.0f), // new Vector3( 1.0f, -1.0f, 1.0f), // new Vector3( 1.0f, 1.0f, 1.0f), // new Vector3(-1.0f, 1.0f, 1.0f), // new Vector3(-1.0f, -1.0f, -1.0f), // new Vector3( 1.0f, -1.0f, -1.0f), // new Vector3( 1.0f, 1.0f, -1.0f), // new Vector3(-1.0f, 1.0f, -1.0f), // }; // // Colors = new int[] // { // Utilities.ColorToRgba32(Color.DarkRed), // Utilities.ColorToRgba32(Color.DarkRed), // Utilities.ColorToRgba32(Color.Gold), // Utilities.ColorToRgba32(Color.Gold), // Utilities.ColorToRgba32(Color.DarkRed), // Utilities.ColorToRgba32(Color.DarkRed), // Utilities.ColorToRgba32(Color.Gold), // Utilities.ColorToRgba32(Color.Gold), // }; }