예제 #1
0
 private static int GetTextSizeIndex(Uniform height)
 {
     if (height.Value < 0.1)
       return 0;
     if (height.Value < 0.2)
       return 1;
     if (height.Value < 0.4)
       return 2;
     return 3;
 }
예제 #2
0
        public void Render(IRenderer renderer)
        {
            Game g = (Game)game;
              g.Render(renderer);

              //StateUtil.RenderNiceCenterText(renderer, "Simulating game!");

              Uniform y1 = new Uniform(0.05);
              Uniform y2 = new Uniform(0.10);
              Uniform x1 = new Uniform(0.15);
              Uniform x2 = new Uniform(0.85);
              Uniform h1 = new Uniform(0.05);
              Uniform h2 = new Uniform(0.1);

              string left = game.PlayerOnePlanes.ToString();
              string right = game.PlayerTwoPlanes.ToString();

              renderer.Color(Color.Red);
              renderer.TextAt("Planes Left",
            x1, y1, h1, Anchor.Center);
              renderer.TextAt(left,
            x1, y2, h2, Anchor.Center);

              renderer.Color(Color.Yellow);
              renderer.TextAt("Planes Right",
            x2, y1, h1, Anchor.Center);
              renderer.TextAt(right,
            x2, y2, h2, Anchor.Center);

             // renderer.DrawMesh(Mesh.Backdrop);
        }
예제 #3
0
            public void TextAt(string text, Uniform x, Uniform y, Uniform height, Anchor anchor)
            {
                GL.MatrixMode(MatrixMode.Projection);
                GL.PushMatrix();
                GL.MatrixMode(MatrixMode.Modelview);

                GL.PushAttrib(AttribMask.AllAttribBits);
                GL.PushMatrix();
                GL.PushClientAttrib(ClientAttribMask.ClientAllAttribBits);
                GL.Disable(EnableCap.DepthTest);
                GL.DepthMask(false);

                GL.Disable(EnableCap.Lighting);

                int fontIndex = GetTextSizeIndex(height);
                TextureFont font = fonts[fontIndex];
                string textName = text + "_" + fontIndex.ToString();
                TextHandle handle = GetTextHandle(text, font);
                printer.Begin();
                GL.Translate((float)(x.Value * ctrl.Width), (float)(y.Value * ctrl.Height), 0);
                if (anchor == Dogfight2008.Anchor.Center)
                {
                  float txWidth, txHeight;
                  font.MeasureString(text, out txWidth, out txHeight);
                  GL.Translate(-txWidth / 2, -txHeight / 2, 0);
                }
                printer.Draw(handle);
                printer.End();

                GL.Enable(EnableCap.Lighting);

                GL.DepthMask(true);
                GL.Enable(EnableCap.DepthTest);
                GL.PopClientAttrib();
                GL.PopMatrix();
                GL.PopAttrib();

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