protected override void OnRenderFrame(FrameEventArgs e)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            Utilitys.CheckGLError("GL.Clear");

            if (EngineIsReady)
            {
                gl.Enable(EnableCap.DepthTest);
                OGame.Draw(e);
                gl.Disable(EnableCap.DepthTest);
                _GUIRender.TickRender();
            }

            SwapBuffers();
            Utilitys.CheckGLError("Window SwapBuffers");

            Time.FPS = (int)(1f / e.Time);

            Time._Time++;
            Time._Tick = Time._Time % 60;

            if (Time._Time >= double.MaxValue)
            {
                Time._Time = -Time._Time;
            }
            Thread.Sleep(60 / 5);
            base.OnRenderFrame(e);
        }
 public void Draw(FrameEventArgs e)
 {
     if (_isPlaying)
     {
         _GamePlayManager.TickRender();
         _RenderSystem.RenderTick((float)e.Time);
         Utilitys.CheckGLError("End Of DrawUpdate");
     }
     else//Menu Draw
     {
     }
 }
        protected override void OnLoad(EventArgs e)//Load the Window, but not the systems, loading only the splash screen
        {
            gl.ClearColor(Color.Black);
            Utilitys.CheckGLError("Set ClearColor");

            //Start GL Frame Buffer

            GlobalData.TargetFrameRate = 60;

            VSync        = VSyncMode.Off;
            WindowBorder = WindowBorder.Resizable;

            _SplashScreen = new SplashScreen();

            currentDomain = AppDomain.CurrentDomain;
            currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);

            base.OnLoad(e);
        }
        public void UpdateMeshRender(Mesh mesh)
        {
            if (isReady)
            {
                /*_mesh.Clear();
                 * _mesh = null;
                 *
                 * _shader = null;
                 * _texture = null;*/

                GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
                GL.BindVertexArray(0);

                GL.BindVertexArray(0);
                GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
                GL.DisableVertexAttribArray(0);

                GL.BindVertexArray(0);
                GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
                GL.DisableVertexAttribArray(1);

                GL.BindVertexArray(0);
                GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
                GL.DisableVertexAttribArray(2);

                GL.BindVertexArray(0);
                GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
                GL.DisableVertexAttribArray(3);

                /*GL.DeleteBuffer(IBO);
                 *
                 * GL.DeleteBuffer(vbo);
                 * GL.DeleteBuffer(dbo);
                 * GL.DeleteBuffer(tbo);
                 * GL.DeleteBuffer(nbo);
                 *
                 * GL.DeleteVertexArray(VAO);*/
                Utilitys.CheckGLError("Destroy Chunk MeshRender");
                isReady = false;

                _Mesh.Dispose();
                _Mesh = null;
            }

            _Mesh = new Mesh(mesh);

            if (_Mesh != null)
            {
                IndiceLength = _Mesh._indices.Length;

                /*IBO = GL.GenBuffer();
                *  VAO = GL.GenVertexArray();
                *
                *  vbo = GL.GenBuffer();
                *  dbo = GL.GenBuffer();
                *  tbo = GL.GenBuffer();
                *  nbo = GL.GenBuffer();*/

                GL.BindBuffer(BufferTarget.ElementArrayBuffer, IBO);
                GL.BufferData(BufferTarget.ElementArrayBuffer, _Mesh._indices.Length * sizeof(int), _Mesh._indices, BufferUsageHint.StreamDraw);

                GL.BindVertexArray(VAO);

                //Vertices(Vector3)
                GL.BindBuffer(BufferTarget.ArrayBuffer, vbo);
                GL.BufferData(BufferTarget.ArrayBuffer, _Mesh._vertices.Length * Vector3.SizeInBytes, _Mesh._vertices, BufferUsageHint.StreamDraw);
                GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(0);

                //Colors(Vectro4|Color)
                GL.BindBuffer(BufferTarget.ArrayBuffer, dbo);
                GL.BufferData(BufferTarget.ArrayBuffer, _Mesh._Colors.Length * Vector4.SizeInBytes, _Mesh._Colors, BufferUsageHint.StreamDraw);
                GL.VertexAttribPointer(1, 4, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(1);

                //Texture(Vector2)
                GL.BindBuffer(BufferTarget.ArrayBuffer, tbo);
                GL.BufferData(BufferTarget.ArrayBuffer, _Mesh._texCoords.Length * Vector2.SizeInBytes, _Mesh._texCoords, BufferUsageHint.StreamDraw);
                GL.VertexAttribPointer(2, 2, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(2);

                //Mesh Normals(Vector3)
                GL.BindBuffer(BufferTarget.ArrayBuffer, nbo);
                GL.BufferData(BufferTarget.ArrayBuffer, _Mesh._Normals.Length * Vector3.SizeInBytes, _Mesh._Normals, BufferUsageHint.StreamDraw);
                GL.VertexAttribPointer(3, 3, VertexAttribPointerType.Float, false, 0, 0);
                GL.EnableVertexAttribArray(3);

                isReady = true;
            }
        }