Esempio n. 1
0
 /// <summary>
 /// Draw the ball.
 /// </summary>
 public void Draw()
 {
     umatrix = MatrixState.GetFinalMatrix(Window.Height, Window.Width);
     GL.UniformMatrix4(uMatrixLocation, false, ref umatrix);
     GL.DrawArrays(PrimitiveType.Triangles, 0, vCount);
     GL.Finish();
     Window.SwapBuffers();
 }
Esempio n. 2
0
        /// <summary>
        /// Called when the key board event coming.
        /// </summary>
        /// <param name="sender">object</param>
        /// <param name="e">Key Event</param>
        public void OnKeyEvent(object sender, KeyboardKeyEventArgs e)
        {
            if (e.Key == Key.Right)
            {
                MatrixState.Rotate(80f, 0f, 360f);
            }

            else if (e.Key == Key.Left)
            {
                MatrixState.Rotate(-80f, 0f, 360f);
            }

            else if (e.Key == Key.Escape)
            {
                Exit();
            }

            Draw();
        }
Esempio n. 3
0
        /// <summary>
        /// This will be called when app created
        /// </summary>
        protected override void OnCreate()
        {
            Window.RenderFrame += OnRenderFrame;
            Window.KeyDown     += OnKeyEvent;
            Window.MouseMove   += (sender, e) =>
            {
                if (e.Mouse[MouseButton.Left])
                {
                    float x = (float)(e.XDelta);
                    float y = (float)(e.YDelta);
                    MatrixState.Rotate(x, 0f, 360f);
                    Draw();
                }
            };
            InitVertexData();
            GetProgram();
            aPositionLocation = GL.GetAttribLocation(program, A_POSITION);
            uMatrixLocation   = GL.GetUniformLocation(program, U_MATRIX);
            InitTexture();
            unsafe
            {
                fixed(float *vVer = vertices)
                {
                    GL.VertexAttribPointer(aPositionLocation, 3, VertexAttribPointerType.Float, false, 3 * sizeof(float), new IntPtr(vVer));
                }

                fixed(float *teture = textures)
                {
                    GL.VertexAttribPointer(aTextureCoordinates, 2, VertexAttribPointerType.Float, false, 2 * sizeof(float), new IntPtr(teture));
                }
            }

            GL.EnableVertexAttribArray(aPositionLocation);
            GL.EnableVertexAttribArray(aTextureCoordinates);
            GL.ClearColor(Color4.SlateGray);
            GL.Enable(EnableCap.CullFace);
            sPlayer.SetSource(DirectoryInfo.Resource + "4.m4a");
            sPlayer.ToPlay(true);
        }