Ejemplo n.º 1
0
        /// <summary>
        /// This gets called when the TizenGameApplication has been created.
        /// </summary>
        protected override void OnCreate()
        {
            Window.RenderFrame += OnRenderFrame;
            Window.KeyDown     += OnKeyEvent;
            //Mouse movement event handling
            Window.MouseMove += (sender, e) =>
            {
                if (e.Mouse[MouseButton.Left])
                {
                    float x = (float)(e.XDelta);
                    float y = (float)(e.YDelta);
                    MatrixState.Rotate(x, 0, 10f);
                    Draw();
                }
            };
            InitVertexData();
            GetProgram();
            aPositionLocation = GL.GetAttribLocation(program, "aPosition");
            uMatrixLocation   = GL.GetUniformLocation(program, "uMVPMatrix");
            InitTexture();
            GL.VertexAttribPointer(aPositionLocation, 3, VertexAttribPointerType.Float, false, 3 * sizeof(float), vertices);
            GL.VertexAttribPointer(aTextureCoordinates, 2, VertexAttribPointerType.Float, false, 2 * sizeof(float), textures);

            GL.EnableVertexAttribArray(aPositionLocation);
            GL.EnableVertexAttribArray(aTextureCoordinates);
            GL.ClearColor(Color4.Gray);
            sPlayer.SetSource(DirectoryInfo.Resource + "1.m4a");
            sPlayer.ToPlay(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// To draw
        /// </summary>
        public void Draw()
        {
            umatrix = MatrixState.Get360Matrix(Window.Height, Window.Width);

            GL.UniformMatrix4(uMatrixLocation, false, ref umatrix);
            GL.DrawArrays(PrimitiveType.Triangles, 0, vCount);
            GL.Finish();
            Window.SwapBuffers();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This well be called when key pressed down
        /// </summary>
        /// <param name="sender">Key instance</param>
        /// <param name="e">Key's args</param>
        public void OnKeyEvent(object sender, KeyboardKeyEventArgs e)
        {
            //right key pressed, the scene will turn right
            if (e.Key == Key.Right)
            {
                MatrixState.Rotate(-60f, 0f, 360f);
            }
            //Left key pressed, the scene will turn Left
            else if (e.Key == Key.Left)
            {
                MatrixState.Rotate(60f, 0f, 360f);
            }
            //return key pressed, the App will exit
            else if (e.Key == Key.Escape)
            {
                Exit();
            }

            Draw();
        }