Viewport() public static méthode

public static Viewport ( OpenTK rectangle ) : void
rectangle OpenTK
Résultat void
Exemple #1
0
        private void DrawBegin(RectangleF dstRect)
        {
            GL.Enable(EnableCap.AlphaTest);
            GL.Disable(EnableCap.DepthTest);
            GL.Color4(Color);
            GL.Viewport(0, 0, Width, Height);

            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            var w = MMW.Width;
            var h = MMW.Height;

            GL.Ortho(0, w, h, 0, -1, 1);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            var trans = new Vector3(dstRect.X + dstRect.Width * CenterPivot.X, dstRect.Y + dstRect.Height * CenterPivot.Y, 0.0f);

            GL.Translate(trans);
            GL.Scale(Scale.X, Scale.Y, 1.0f);
            GL.Rotate(Rotate.Z, 0.0f, 0.0f, 1.0f);
            GL.Rotate(Rotate.X, 1.0f, 0.0f, 0.0f);
            GL.Rotate(Rotate.Y, 0.0f, 1.0f, 0.0f);
            GL.Translate(-trans);
            GL.Translate(dstRect.X - 0.5f, dstRect.Y - 0.5f, 0.0f);
        }
Exemple #2
0
        // Penguin
        private void Render()
        {
            if (this.image.ActualWidth <= 0 || this.image.ActualHeight <= 0)
            {
                return;
            }

            this.framebufferHandler.Prepare(new Size((int)this.ActualWidth, (int)this.ActualHeight));

            GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Projection);
            GL.LoadIdentity();
            float halfWidth  = (float)(this.ActualWidth / 2);
            float halfHeight = (float)(this.ActualHeight / 2);

            GL.Ortho(-halfWidth, halfWidth, halfHeight, -halfHeight, 1000, -1000);
            GL.Viewport(0, 0, (int)this.ActualWidth, (int)this.ActualHeight);

            string filename2   = "C:\\Users\\hp\\image.bmp";
            int    loadTexture = LoadTexture(filename2);

            //DrawImage(loadTexture);

            this.renderer.Render();

            GL.Finish();

            this.framebufferHandler.Cleanup(ref this.backbuffer);

            if (this.backbuffer != null)
            {
                this.image.Source = this.backbuffer;
            }

            this.frames++;
        }
Exemple #3
0
        protected override void OnResize(EventArgs e)
        {
            GL.Viewport(0, 0, Width, Height);

            aspect_ratio = Width / (float)Height;
            perspective  = Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspect_ratio, 1, 64);
            GL.MatrixMode(TK.MatrixMode.Projection);
            GL.LoadMatrix(ref perspective);
        }
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            GL.Viewport(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height);
            Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4f, Width / (float)Height, 1.0f, 60000.0f);

            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadMatrix(ref projection);
            ResizeObjects(ClientRectangle.Width, ClientRectangle.Height);
        }
Exemple #5
0
        protected override void _DoResize()
        {
            _H = _Control.Height;
            _W = _Control.Width;
            _CurrentAlignment = CConfig.Config.Graphics.ScreenAlignment;

            if (CConfig.Config.Graphics.Stretch != EOffOn.TR_CONFIG_ON)
            {
                _AdjustAspect(true);
            }

            _AdjustNewBorders();
            GL.Viewport(_X, _Y, _W, _H);
        }
Exemple #6
0
        private void SetupViewport()
        {
            int w = glControl1.Width;
            int h = glControl1.Height;

            Visual1 = new GraphMain(w, h);
            //Visual2 = new GraphMain(w, h);
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(-w, w, -h, h, -100, 100);
            GL.MatrixMode(MatrixMode.Modelview);

            GL.Viewport(0, 0, w, h);
        }
Exemple #7
0
 private void GameResize(float scaling)
 {
     _currentScale = scaling;
     _graphObject.Resize(Settings.WindowWidth, Settings.WindowHeight, scaling);
     _graphObject.Clip = new Rectangle(0, 0, Convert.ToInt32(Settings.WindowWidth * scaling),
                                       Convert.ToInt32(Settings.WindowHeight * scaling));
     this.ClientSize = new Size(Convert.ToInt32(Settings.WindowWidth * scaling),
                                Convert.ToInt32(Settings.WindowHeight * scaling));
     GL.Viewport(this.ClientSize);
     if (_gameMenu != null)
     {
         _gameMenu.Scaling = scaling;
     }
     if (_game != null)
     {
         _game.Scaling = scaling;
     }
 }
Exemple #8
0
        protected override void OnResize(EventArgs e)
        {
            if (ClientSize.Width < 640)
            {
                ClientSize = new Size(640, ClientSize.Height);
            }
            if (ClientSize.Height < 480)
            {
                ClientSize = new Size(ClientSize.Width, 480);
            }

            base.OnResize(e);

            GL.Viewport(ClientRectangle);
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(0, ClientRectangle.Width, ClientRectangle.Height, 0, gameRenderer.NEAR_PLANE,
                     gameRenderer.FAR_PLANE);

            ShaderManager.updateProjectionMatrix();
        }
Exemple #9
0
        internal void Prepare(Size framebuffersize)
        {
            if (GraphicsContext.CurrentContext != this.glControl.Context)
            {
                this.glControl.MakeCurrent();
            }

            if (framebuffersize != this.size || this.loaded == false)
            {
                this.size = framebuffersize;
                this.CreateFramebuffer();

                GL.Viewport(0, 0, framebuffersize.Width, framebuffersize.Height);
                this.scene.Camera.ResizeViewport(framebuffersize.Width, framebuffersize.Height);
                Matrix4 projMatrix = scene.Camera.ProjMatrix;
                GL.MatrixMode(MatrixMode.Projection);
                GL.LoadMatrix(ref projMatrix);
            }

            GL.BindFramebuffer(FramebufferTarget.Framebuffer, this.framebufferId);
        }
Exemple #10
0
 public static void Viewport(LayoutFarm.Drawing.Size size)
 {
     GL.Viewport(0, 0, size.Width, size.Height);
 }
Exemple #11
0
 protected override void OnResize(ResizeEventArgs e)
 {
     GL.Viewport(0, 0, Size.X, Size.Y);
 }
Exemple #12
0
 public static void Viewport(System.Drawing.Size size)
 {
     GL.Viewport(0, 0, size.Width, size.Height);
 }
Exemple #13
0
 public static void Viewport(System.Drawing.Point location, System.Drawing.Size size)
 {
     GL.Viewport(location.X, location.Y, size.Width, size.Height);
 }
Exemple #14
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);

            GL.Material(TK.MaterialFace.Front, TK.MaterialParameter.Specular, mat_specular);
            GL.Material(TK.MaterialFace.Front, TK.MaterialParameter.Shininess, mat_shininess);
            GL.Light(TK.LightName.Light0, TK.LightParameter.Position, light_position);
            GL.Light(TK.LightName.Light0, TK.LightParameter.Ambient, light_ambient);
            GL.Light(TK.LightName.Light0, TK.LightParameter.Diffuse, mat_specular);

            GL.Enable(TK.EnableCap.CullFace);
            GL.Enable(TK.EnableCap.DepthTest);
            GL.ShadeModel(TK.ShadingModel.Smooth);
            GL.Enable(TK.EnableCap.ColorMaterial);
            GL.Enable(TK.EnableCap.Blend);
            GL.BlendFunc(TK.BlendingFactorSrc.SrcAlpha, TK.BlendingFactorDest.OneMinusSrcAlpha);
            GL.PolygonMode(TK.MaterialFace.FrontAndBack, TK.PolygonMode.Fill);

            GL.Viewport(0, 0, Width, Height);
            aspect_ratio = Width / (float)Height;
            checkAspectRatio();
            width  *= wp_scale_factor;
            height *= wp_scale_factor;

            VSync  = VSyncMode.On;
            eye    = new Vector3(0, 0, height * 1.5f);
            target = new Vector3(0, 0, 0);
            up     = new Vector3(0, 1, 0);
            fov    = (int)Math.Round(height * 0.75f);

            old_mouse = OpenTK.Input.Mouse.GetState();
            old_key   = OpenTK.Input.Keyboard.GetState();

            bodies = new List <Body>();

            generateRandomBodies(number_of_bodies, true);
            calculateGridEdge();
            foreach (Body body in bodies)
            {
                body.updateBoundingSphere();
                body.getBSphere().checkForCellIntersection();
            }

            mouse        = OpenTK.Input.Mouse.GetState();
            coord_transf = Screen.PrimaryScreen.Bounds.Height / 27f;

            timeSinceStart = new Stopwatch();
            timeSinceStart.Start();
            elaspedTime = timeSinceStart.ElapsedMilliseconds;
            Program.cd.InitializePlatformPropertiesAndDevices();
            Program.cd.deviceSpecs();
            Program.cd.ReadAllSources();
            Program.cd.CreateCollisionCellArray();
            Program.t.Start();
            while (Program.ready == false)
            {
                ;
            }
        }
Exemple #15
0
 public static void Viewport(System.Drawing.Rectangle rectangle)
 {
     GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
 }
Exemple #16
0
        static void Main()
        {
            Console.WriteLine("Entering");

            using (var game = new GameWindow(1920, 1080, new GraphicsMode(ColorFormat.Empty, 8, 0, 6), "Heart of Gold", GameWindowFlags.Default)) {
                game.Icon = Icon.ExtractAssociatedIcon(Assembly.GetEntryAssembly().Location);
                var size = 500;
                var zoom = 1.0;
                game.Load += (sender, e) => { game.VSync = VSyncMode.On;
                                              GL.PointSize(10); };
                game.MouseWheel += delegate(object sender, MouseWheelEventArgs args) {
                    if (args.Delta > 0)
                    {
                        zoom *= 1.1;
                    }
                    //zoom += args.Delta/10.0;
                    else
                    {
                        zoom /= 1.1;
                    }
                    //zoom += args.Delta/10.0;

                    if (zoom <= 0.1)
                    {
                        zoom = 0.1;
                    }

                    //var aspect = game.Width / (double)game.Height;

                    //GL.Viewport(0, 0, game.Width, game.Height);
                    //GL.Ortho(-xsize, xsize, ysize, -ysize, 0, 4.0);
                };
                game.Resize += (sender, e) =>
                               GL.Viewport(0, 0, game.Width, game.Height);

                #region Heights

                var matrix = new double[size, size];
                //var r = new Random();

                #endregion


                #region Color

                Console.WriteLine("Initializing color...");
                var cmatrix = new Color[size, size];
                using (var b = (Bitmap)Image.FromFile(@"E:\Downloads\Untitled5.png")) {
                    for (var i = 0; i < size; i++)
                    {
                        Console.Write($"\rOn column {i,4} of {size}");
                        for (var j = 0; j < size; j++)
                        {
                            matrix[i, j]  = ((double)b.GetPixel(i, j).A + 1);                           // / 8.0;
                            cmatrix[i, j] = Color.FromArgb(255, b.GetPixel(i, j));
                        }
                    }
                }
                Console.WriteLine();
                #endregion


                bool wDown = false,
                     aDown = false,
                     sDown = false,
                     dDown = false;
                game.KeyDown += (sender, args) => {
                    switch (args.Key)
                    {
                    case Key.W:
                        wDown = true;
                        break;

                    case Key.A:
                        aDown = true;
                        break;

                    case Key.S:
                        sDown = true;
                        break;

                    case Key.D:
                        dDown = true;
                        break;
                    }
                };
                var translate = Vector2.Zero;
                game.KeyUp += (sender, args) => {
                    switch (args.Key)
                    {
                    case Key.Escape:
                        game.Exit();
                        break;

                    case Key.R:
                        zoom = 1;
                        break;

                    case Key.W:
                        if (wDown)
                        {
                            translate += new Vector2(1f, 1f);
                        }
                        wDown = false;
                        break;

                    case Key.A:
                        if (aDown)
                        {
                            translate += new Vector2(1f, -1f);
                        }
                        aDown = false;
                        break;

                    case Key.S:
                        if (sDown)
                        {
                            translate += new Vector2(-1f, -1f);
                        }
                        sDown = false;
                        break;

                    case Key.D:
                        if (dDown)
                        {
                            translate += new Vector2(-1f, 1f);
                        }
                        dDown = false;
                        break;
                    }
                };

                double time = 0, sin = 0;

                game.UpdateFrame +=
                    (sender, e) => {
                    time      += e.Time;
                    sin        = (Math.Sin(time / 4) + 1) / 2;
                    game.Title = $"Heart of Gold - {game.RenderFrequency:000.00}fps - {game.UpdateFrequency:000.00}tps";
                };

                var items = new List <BufferElement>(size * size * 12);
                Console.WriteLine("Prepping buffer elements...");
                //First half
                var side = matrix.GetLength(0);
                var half = side / 2;
                for (var i = 0; i < side; i++)
                {
                    Console.Write($"\rCreating row {i,4} of {side}");
                    int x = i, y = 0;
                    while (x >= 0)
                    {
                        var hasleft  = y != side - 1;
                        var hasright = x != side - 1;
                        var left     = hasleft ? (double?)matrix[x, y + 1] : -2;
                        var right    = hasright ? (double?)matrix[x + 1, y] : -2;
                        items.AddRange(AddOne(matrix[x, y], x - half, y - half, cmatrix[x--, y++], left, right));
                    }
                }
                // Pt 2
                for (var i = 1; i <= side - 1; i++)
                {
                    Console.Write($"\rCreating column {i,4} of {side}");
                    int x = side - 1, y = i;
                    while (y < side)
                    {
                        var hasleft = y != side - 1; var hasright = x != side - 1;
                        var left  = hasleft ? (double?)matrix[x, y + 1] : -2;
                        var right = hasright ? (double?)matrix[x + 1, y] : -2;
                        items.AddRange(AddOne(matrix[x, y], x - half, y - half, cmatrix[x--, y++], left, right));
                    }
                }
                Console.WriteLine("\rCreating vertex buffer object...           ");
                Action a = delegate {
                    GL.EnableClientState(ArrayCap.VertexArray);
                    GL.EnableClientState(ArrayCap.ColorArray);
                    GL.VertexPointer(3, VertexPointerType.Float, BufferElement.SizeInBytes, new IntPtr(0));
                    GL.ColorPointer(3, ColorPointerType.Float, BufferElement.SizeInBytes, new IntPtr(Vector3.SizeInBytes));
                };
                var terrain = new VertexBuffer <BufferElement>(items.ToArray(), a, BufferUsageHint.StaticDraw);
                Console.WriteLine("Done!");
                game.RenderFrame += delegate {
                    // render graphics
                    GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
                    GL.MatrixMode(MatrixMode.Projection);
                    GL.LoadIdentity();

                    GL.Ortho(size, -size, size, -size, -double.MaxValue, double.MaxValue);

                    GL.Scale(1 * zoom, (game.Width / (double)game.Height) * zoom, 1 * zoom);
                    GL.Rotate(90 * sin, 1, 0, 0);
                    GL.Rotate(45, 0, 0, 1);
                    GL.Translate(translate.X, translate.Y, -matrix[(int)-translate.X + half, (int)-translate.Y + half]);

                    terrain.Render(PrimitiveType.Quads);

                    //GL.Begin(PrimitiveType.LineLoop);

                    //DrawOne(matrix[(int) -translate.X + half, (int) -translate.Y + half], (int) -translate.X, (int) -translate.Y,
                    //	Color.Black);
                    //GL.End();

                    game.SwapBuffers();
                };
                game.WindowState = WindowState.Maximized;
                game.Run(60.0, 60);
            }
        }
Exemple #17
0
 public void Viewport(int x, int y, int width, int height)
 {
     GL.Viewport(x, y, width, height);
 }
Exemple #18
0
 public static void Viewport(LayoutFarm.Drawing.Point location, LayoutFarm.Drawing.Size size)
 {
     GL.Viewport(location.X, location.Y, size.Width, size.Height);
 }
Exemple #19
0
 public static void Viewport(OpenTK.Rectangle rectangle)
 {
     GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
 }
Exemple #20
0
 public static void Viewport(OpenTK.Point location, OpenTK.Size size)
 {
     GL.Viewport(location.X, location.Y, size.Width, size.Height);
 }
Exemple #21
0
 public static void Viewport(Size size)
 {
     GL.Viewport(0, 0, size.Width, size.Height);
 }