Esempio n. 1
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            base.OnUpdateFrame(e);

            if (OTKInput.MouseRelease(OpenTK.Input.MouseButton.Left))
            {
                NTRInput.TouchscreenRelease();
            }
            else if (OTKInput.MouseDown(OpenTK.Input.MouseButton.Left))
            {
                int width  = screenWidth;
                int height = (int)((float)width / targetAspectRatio + 0.5f);

                if (height > screenHeight)
                {
                    height = screenHeight;
                    width  = (int)((float)height * targetAspectRatio + 0.5f);
                }

                int vpX = (screenWidth / 2) - (width / 2);
                int vpY = (screenHeight / 2) - (height / 2);

                //--

                if (height >= screenHeight)
                {
                    if (OTKInput.MouseX >= vpX)
                    {
                        int X = OTKInput.MouseX - vpX;
                        int Y = OTKInput.MouseY;

                        if (X <= width)
                        {
                            X = (int)(((double)X / (double)width) * (double)virtualWidth);
                            Y = (int)(((double)Y / (double)height) * (double)virtualHeight);

                            NTRInput.TouchscreenClick(X, Y);

                            //Pillarbox, subtract left/right
                            //Console.WriteLine("BOTTOM P vp " + vpX + " " + vpY);
                            //Console.WriteLine("BOTTOM P Click " + X + " " + Y);
                        }
                    }
                }
                else
                {
                    if (OTKInput.MouseY >= vpY)
                    {
                        int X = OTKInput.MouseX;
                        int Y = OTKInput.MouseY - vpY;

                        if (Y <= height)
                        {
                            X = (int)(((double)X / (double)width) * (double)virtualWidth);
                            Y = (int)(((double)Y / (double)height) * (double)virtualHeight);

                            NTRInput.TouchscreenClick(X, Y);

                            //Letterbox, subtract top/bottom
                            //Console.WriteLine("BOTTOM L vp " + vpX + " " + vpY);
                            //Console.WriteLine("BOTTOM L Click " + X + " " + Y);
                        }
                    }
                }
            }

            OTKInput.Update();
        }
Esempio n. 2
0
        public ViewerBottom(int width, int height) : base(width, height, OpenTK.Graphics.GraphicsMode.Default, title)
        {
            screenWidth  = width; // Doesn't really matter, gets changed later anyway
            screenHeight = height;

            this.Y += 172;

            #region Init Textures
            //FPS
            overlay2d        = new Bitmap(200, 100);
            textureOverlay2d = GL.GenTexture();

            GL.BindTexture(TextureTarget.Texture2D, textureOverlay2d);

            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Linear);

            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, overlay2d.Width, overlay2d.Height, 0,
                          OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); // just allocate memory, so we can update efficiently using TexSubImage2D

            //--

            textureBottom = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, textureBottom);
            GL.TexImage2D(TextureTarget.Texture2D, 0,
                          PixelInternalFormat.Rgba,
                          320, 240, 0, //W, H, Border
                          OpenTK.Graphics.OpenGL.PixelFormat.Bgra,
                          PixelType.UnsignedByte, IntPtr.Zero);

            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Clamp);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Clamp);

            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            #endregion

            GL.EnableClientState(ArrayCap.VertexArray);
            GL.EnableClientState(ArrayCap.TextureCoordArray);
            GL.Enable(EnableCap.Texture2D);

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);

            OTKInput.Initialize(this);
            //this.KeyPress += HandleKeyPress;
            this.KeyDown += HandleKeyDown;

            displayFPS = false;
            fps        = new FPSCounter();

            //--

            vertBufferScreen = new Vector2[8] {
                new Vector2(0, 0), new Vector2(1, 0),
                new Vector2(320, 0), new Vector2(1, 1),
                new Vector2(320, 240), new Vector2(0, 1),
                new Vector2(0, 240), new Vector2(0, 0)
            };
            VBOScreen = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ArrayBuffer, VBOScreen);
            GL.BufferData <Vector2>(BufferTarget.ArrayBuffer, (IntPtr)(Vector2.SizeInBytes * vertBufferScreen.Length), vertBufferScreen, BufferUsageHint.StaticDraw);

            vertBufferFps = new Vector2[8] {
                new Vector2(0, 100), new Vector2(0, 1),
                new Vector2(200, 100), new Vector2(1, 1),
                new Vector2(200, 0), new Vector2(1, 0),
                new Vector2(0, 0), new Vector2(0, 0)
            };
            VBOFps = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ArrayBuffer, VBOFps);
            GL.BufferData <Vector2>(BufferTarget.ArrayBuffer, (IntPtr)(Vector2.SizeInBytes * vertBufferFps.Length), vertBufferFps, BufferUsageHint.StaticDraw);
        }
Esempio n. 3
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            base.OnUpdateFrame(e);

            OTKInput.Update();
        }