示例#1
0
        private void glControl1_Load(object sender, EventArgs e)
        {
            loaded = true;
            displayFont = new Font(FontFamily.GenericSansSerif, 10.0f);
            OpenTK.Graphics.GraphicsContext.CurrentContext.SwapInterval = 1000;
            Application.Idle += Application_Idle;
            OpenTK.Graphics.OpenGL.GL.ClearColor(Color.Black);

            SetupViewport();
            if (TrackLayout.Track.Count > 0)
            {
                camera = new Camera2D(new OpenTK.Vector2(TrackLayout.Track[0].BrakeLocation, 0), new OpenTK.Vector2(WIDTH, HEIGHT));
            }
            else
            {
                camera = new Camera2D(new OpenTK.Vector2(0, 0), new OpenTK.Vector2(WIDTH, HEIGHT));
            }


            //writer = new Signal_Block_Design_Tool.Text.TextWriter(new Rectangle(0, 0, WIDTH, HEIGHT).Size, new Rectangle(0, 0, WIDTH, HEIGHT).Size);

            //writer.AddLine("FPS " + idleCounter.ToString(), new PointF(10, 10), Brushes.Red);

            //for (int i = 0; i < TrackLayout.Track.Count; i++)
            //{
            //    writer.AddLine(TrackLayout.Track[i].TrackCircuit.ToString(), new PointF(TrackLayout.Track[i].brakeLocation, i * 15), Brushes.Red);
            //}

        }
示例#2
0
        public void Draw(Camera2D camera)
        {
            GL.PushMatrix();
            GL.LoadIdentity();

            Matrix4 ortho_projection = Matrix4.CreateOrthographicOffCenter(0, _clientSize.Width, _clientSize.Height, 0, -1, 1);
            GL.MatrixMode(MatrixMode.Projection);

            //Matrix4 projection = camera.getTransformation();
            //OpenTK.Graphics.GL.MatrixMode(OpenTK.Graphics.MatrixMode.Projection);

            GL.PushMatrix();
            GL.LoadMatrix(ref ortho_projection);

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.DstColor);
            GL.Enable(EnableCap.Texture2D);
            GL.BindTexture(TextureTarget.Texture2D, _textureId);

            GL.Begin(PrimitiveType.Quads);
            GL.TexCoord2(0, 0);
            GL.Vertex2(0, 0);
            GL.TexCoord2(1, 0);
            GL.Vertex2(TextBitmap.Width, 0);
            GL.TexCoord2(1, 1);
            GL.Vertex2(TextBitmap.Width, TextBitmap.Height);
            GL.TexCoord2(0, 1);
            GL.Vertex2(0, TextBitmap.Height);
            GL.End();
            GL.PopMatrix();

            GL.Disable(EnableCap.Blend);
            GL.Disable(EnableCap.Texture2D);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.PopMatrix();
        }