예제 #1
0
파일: TextWidget.cs 프로젝트: ye-man/M3D
        public override void OnRender(GUIHost host)
        {
            host.SetCurFontSize(Size);
            QFont currentFont = host.GetCurrentFont();

            if (currentFont != null)
            {
                currentFont.Options.LockToPixel = true;
                var    width  = (float)Width;
                var    height = currentFont.Measure(text, width, alignment).Height;
                var    num1   = VAlignment != TextVerticalAlignment.Top ? (VAlignment != TextVerticalAlignment.Bottom ? (float)(Height * 0.5 - height * 0.5) + Y_Abs : Y_Abs + (Height - height)) : Y_Abs;
                var    num2   = alignment != QFontAlignment.Centre ? X_Abs : Width * 0.5f + X_Abs;
                Color4 color  = Color;
                if (!Enabled && FadeWhenDisabled)
                {
                    color.A = 0.5f;
                }

                QFont.Begin();
                currentFont.Options.Colour = Color;
                currentFont.Print(text, width, alignment, new Vector2(num2 + off_x, num1 + off_y));
                QFont.End();
            }
            base.OnRender(host);
        }
예제 #2
0
        private void RenderNeuronInfo(NeuronModel neuron, Vector3 screenPosition)
        {
            screenPosition.X += 10;
            screenPosition.Y += 10;

            using (Blender.AveragingBlender())
            {
                GL.PushMatrix();
                GL.Translate(screenPosition);

                GL.Color4(new Color4(100, 100, 100, 220));
                GL.Begin(PrimitiveType.Quads);

                GL.Vertex3(0, 0, 0);
                GL.Vertex3(100, 0, 0);
                GL.Vertex3(100, 30, 0);
                GL.Vertex3(0, 30, 0);

                GL.End();
                GL.PopMatrix();

                QFont.Begin();
                GL.Translate(10, 0, 0);
                GL.Translate(screenPosition);

                m_font.Print($"{neuron.RegionModel.Index} : {neuron.Index}", QFontAlignment.Left);

                QFont.End();
            }
        }
예제 #3
0
        void renderTexts()
        {
            Matrix4 modelview = Matrix4.LookAt(Vector3.Zero, Vector3.UnitZ, Vector3.UnitY);

            GL.PushMatrix();
            GL.Enable(EnableCap.ColorMaterial);
            GL.LoadMatrix(ref modelview);
            float yOffset = 0;

            QFont.Begin();
            PrintComment("Zones chargées: " + scene.zones.Count, ref yOffset);
            PrintComment("Zone Courante: " + precZone, ref yOffset);
            PrintComment("Rayon : " + radius, ref yOffset);
            PrintComment("Va/Vc : " + cmptVertexAfficher + "/" + cmptVertexZone, ref yOffset);
            QFont.End();
            QFont.Begin();
            GL.Begin(BeginMode.Quads);

            GL.Color3(0.0f, 0.0f, 0.0); GL.Vertex2(0, 0);
            GL.Color3(0.0f, 0.0f, 0.0f); GL.Vertex2(Width / 4, 0);
            GL.Color3(0.0f, 0.0f, 0.0f); GL.Vertex2(Width / 4, Height / 5);
            GL.Color3(0.0f, 0.0f, 0.0f); GL.Vertex2(0, Height / 5);

            GL.End();
            QFont.End();
            GL.Disable(EnableCap.Texture2D);
            GL.Disable(EnableCap.Blend);
            GL.Disable(EnableCap.ColorMaterial);
            GL.PopMatrix();
            glEnables();
        }
예제 #4
0
        public void RenderFont(Vec2d off, Vec2d pos, QFont font, string text, Color4 col)
        {
            Vec2d offset = new Vec2d(off);

            offset.Y += INIT_RESOLUTION_HEIGHT;
            float w = font.Measure(text).Width;
            float h = font.Measure(text).Height;

            w /= zoom;
            h /= zoom;

            offset.Y -= h;

            offset.X += pos.X / zoom;
            offset.Y -= pos.Y / zoom;

            RenderColoredRectangle(new Rect2d(offset, w, h), 1, Color.FromArgb(128, 255, 255, 255));


            font.Options.Colour = col;
            font.Options.UseDefaultBlendFunction = false;

            QFont.Begin();
            GL.PushMatrix();

            GL.Translate(0, 0, 1);
            font.Print(text, new Vector2((float)pos.X, (float)pos.Y));

            GL.PopMatrix();
            QFont.End();

            GL.Disable(EnableCap.Texture2D);
            GL.Color3(1.0, 1.0, 1.0);
        }
예제 #5
0
        private void RenderText(GUIHost host)
        {
            if (cursor >= Text.Length)
            {
                cursor = Text.Length;
            }

            var str = textline.GetSize() <= 0 ? hint_text : textline.GetText();

            host.SetCurFontSize(Size);
            my_font = host.GetCurrentFont();
            if (my_font == null)
            {
                return;
            }

            GetStartCharacterIndex(GetCursorLocation(my_font), my_font);
            my_font.Options.LockToPixel = true;
            var width = Width;
            var y     = (float)(Y_Abs + text_window_top_border);
            var x     = (float)(X_Abs + text_window_left_border);

            DrawHighlight(host.GetSimpleRenderer(), my_font);
            QFont.Begin();
            my_font.Options.Colour = Enabled ? Color : new Color4(0.7f, 0.7f, 0.7f, 0.5f);
            my_font.Print(str.Substring(processed_start), Width - (text_window_left_border + text_window_right_border), new Vector2(x, y));
            QFont.End();
        }
예제 #6
0
        public void DrawString(EFonts _font, string _string, float _x, float _y, FColor _color)
        {
            var qFont = m_resourceProvider[_font];

            QFont.Begin();
            qFont.Options.Colour = new Color4(_color.R, _color.G, _color.B, _color.A);
            qFont.Print(_string, new OpenTK.Vector2(_x, _y));
            QFont.End();
        }
예제 #7
0
        public override void Render(float x, float y, float width, float height)
        {
            float xx = x.UnScaleHorizontal();
            float yy = Client.window.Height - Scale.vUnPosScale(y) - height.UnScaleVerticlSize() * .50f;

            QFont.Begin();
            Client.window.Qfont.Options.Colour = color;
            Client.window.Qfont.Print(text + AppendText, Alignment, new Vector2(xx + offsetX, yy + offsetY));
            QFont.End();
        }
예제 #8
0
        public override void OnRender(GUIHost host)
        {
            if (item_count != Items.Count)
            {
                Refresh();
            }

            base.OnRender(host);
            var y = (float)(topbordersize_pixels + Y_Abs);
            var x = (float)(leftbordersize_pixels + X_Abs);

            host.SetCurFontSize(Size);
            QFont currentFont = host.GetCurrentFont();

            QFont.Begin();
            var num = 0;

            for (var startRow = start_row; startRow < Items.Count && num < max_rows_on_screen; ++startRow)
            {
                if (startRow == mouse_over_row && !NoSelect)
                {
                    QFont.End();
                    Simple2DRenderer      simpleRenderer = host.GetSimpleRenderer();
                    Simple2DRenderer.Quad quad1;
                    quad1.x0    = x;
                    quad1.y0    = y;
                    quad1.x1    = x + text_region_width;
                    quad1.y1    = y + rowheight * 0.75f;
                    quad1.color = color_highlighted;
                    Simple2DRenderer.Quad quad2 = quad1;
                    simpleRenderer.DrawQuad(quad2);
                    QFont.Begin();
                }
                if (startRow == selected && !NoSelect)
                {
                    QFont.End();
                    Simple2DRenderer      simpleRenderer = host.GetSimpleRenderer();
                    Simple2DRenderer.Quad quad1;
                    quad1.x0    = x;
                    quad1.y0    = y;
                    quad1.x1    = x + text_region_width;
                    quad1.y1    = y + rowheight * 0.75f;
                    quad1.color = color_selected;
                    Simple2DRenderer.Quad quad2 = quad1;
                    simpleRenderer.DrawQuad(quad2);
                    QFont.Begin();
                }
                currentFont.Options.Colour = Color;
                currentFont.Print(Items[startRow].ToString(), text_region_width, new Vector2(x, y));
                y += rowheight;
                ++num;
            }
            QFont.End();
        }
예제 #9
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            base.OnRenderFrame(e);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            QFont.Begin();
            float width = _quickFont.Measure(_poem).Width;

            _quickFont.Print(_poem, width, QFontAlignment.Left, new Vector2(10, 40));
            GL.Disable(EnableCap.Texture2D);
            QFont.End();
            SwapBuffers();
        }
예제 #10
0
        public void OnRender()
        {
            QFont.Begin();
            GL.PushMatrix();

            GL.Translate(offsetX, y - offsetY, 0);
            steps.Print(logic.Steps.ToString(), QFontAlignment.Left);
            GL.Translate(0, -2 * offsetY - 2, 0);
            steps.Print(step, QFontAlignment.Left);

            GL.PopMatrix();
            QFont.End();
        }
예제 #11
0
        private void RenderDiagnostics()
        {
            QFont.Begin();
            GL.PushMatrix();

            GL.Translate(m_font.MonoSpaceWidth, 0, 0);
            m_font.Print($"fps: {(int) m_fps}", QFontAlignment.Left);

            GL.Translate(0, m_font.LineSpacing, 0);
            m_font.Print($"# of models: {m_modelsDisplayed}", QFontAlignment.Left);

            GL.PopMatrix();
            QFont.End();
        }
예제 #12
0
 public override void RenderFrame(FrameEventArgs e)
 {
     base.RenderFrame(e);
     Font.Options.Colour = Color;
     QFont.Begin();
     if (Dynamic)
     {
         Font.Print(Text, Alignment, Position + PositionAdd);
     }
     else
     {
         Font.Print(_processedText, Position + PositionAdd);
     }
     QFont.End();
 }
예제 #13
0
        public void PrintWithBounds(string text, RectangleF bounds, QFontAlignment alignment)
        {
            if (m_ofntCurFont == null)
            {
                return;
            }

            GL.Disable(EnableCap.Texture2D);
            var width = bounds.Width;

            QFont.Begin();
            m_ofntCurFont.Options.Colour = new Color4(1f, 0.0f, 0.0f, 1f);
            m_ofntCurFont.Print(text, width, alignment, new Vector2(bounds.X, bounds.Y));
            QFont.End();
            GL.Color4(1f, 1f, 1f, 1f);
        }
        /// <summary>
        /// Called per frame update, sets up drawing and then draws all objects in the frame list
        /// </summary>
        public void draw()
        {
            /** First prepare stuff */
            //preDraw();
            /** Draw font shit first */
            QFont.Begin();
            GL.Disable(EnableCap.DepthTest);
            GL.PushMatrix();

            mFont.DrawVBOs();
            GL.PopMatrix();
            QFont.End();

            GL.Enable(EnableCap.DepthTest);
            GL.Disable(EnableCap.Texture2D);


            foreach (IDrawable drawObj in mObjectList)
            {
                drawObj.draw();
            }
        }
예제 #15
0
        /// <summary>
        /// Draw the regular scene. This is what the user sees. That's why this ends with SwapBuffers()
        /// </summary>
        void drawRegular()
        {
            GL.ClearColor(Color.Black);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            GL.PushAttrib(AttribMask.ColorBufferBit); //Needed so text.Print() doesn't clear the screen
            QFont.Begin();
            GL.PushMatrix();
            GL.Translate(30f, 0f, 0f);
            mainText.Print("Test", QFontAlignment.Centre);
            GL.PopMatrix();
            QFont.End();
            GL.PopAttrib();

            //Render each Square
            foreach (KeyValuePair <int, Cell> kvp in cells)
            {
                kvp.Value.Render();
            }

            SwapBuffers();
        }
예제 #16
0
        //static void DrawSprite(IFramePainterInfo frame, int index)
        //{

        //    //prepare
        //    var sprite = frame.spriteList[index];

        //    var settings = SpriteList.All[sprite.Item1];
        //    GL.Enable(EnableCap.Texture2D);
        //    GL.BindTexture(TextureTarget.Texture2D, settings.OpenglTexture);

        //    //opacity
        //    {
        //        var opacity = sprite.Item5 == null || sprite.Item5.opacity == null? settings.Opacity : sprite.Item5.opacity.Value;
        //        GL.Enable(EnableCap.Blend);
        //        GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
        //        GL.Color4(opacity, opacity, opacity, opacity);
        //    }
        //    //go to position
        //    {
        //        GL.MatrixMode(MatrixMode.Modelview);
        //        GL.PushMatrix();
        //        GL.Translate(new Vector3d(sprite.Item3));
        //        GL.Rotate(sprite.Item4, 0, 0, 1);
        //    }

        //    //select texture part by frame and draw it
        //    {
        //        var frameNumber = sprite.Item5 == null || sprite.Item5.frame == null ? 0 : sprite.Item5.frame.Value;
        //        if(frameNumber < 0)
        //            frameNumber = 0;
        //        if(frameNumber > settings.FrameCountVertical * settings.FrameCountHorizontal - 1)
        //            frameNumber = settings.FrameCountHorizontal*settings.FrameCountVertical -1;
        //         int hor = settings.FrameCountHorizontal;
        //        int vert = settings.FrameCountVertical;

        //        double horPart = 1d / hor, vertPart = 1d / vert;
        //        double bottom = 1 - (frameNumber / hor + 1) * vertPart;
        //        double top = 1 - frameNumber / hor * vertPart;
        //        double right = (frameNumber % hor + 1) * horPart;
        //        double left = frameNumber % hor * horPart;

        //        Vector2d? size = null;
        //        if(size == null && sprite.Item5 != null && sprite.Item5.size != null)
        //            size = sprite.Item5.size;
        //        if(size == null && settings.Size != null)
        //            size = settings.Size;
        //        if(size == null && settings.ScaleFromOriginal != null)
        //            size = settings.InitialSize.MultEach(settings.ScaleFromOriginal.Value);
        //        if(size == null)
        //            size = settings.InitialSize;

        //        //здесь размер точно не null
        //        if(sprite.Item5 != null && sprite.Item5.scaleSize != null)
        //            size = size.Value.MultEach(sprite.Item5.scaleSize.Value);

        //        var topLeft = -size.Value.MultEach(sprite.Item2);
        //         GL.Begin(PrimitiveType.Quads);
        //        // указываем поочередно вершины и текстурные координаты
        //        GL.TexCoord2(left, top);
        //        GL.Vertex2(topLeft);
        //        GL.TexCoord2(right, top);
        //        GL.Vertex2(topLeft.X + size.Value.X, topLeft.Y);
        //        GL.TexCoord2(right, bottom);
        //        GL.Vertex2(topLeft.X + size.Value.X, topLeft.Y + size.Value.Y);
        //        GL.TexCoord2(left, bottom);
        //        GL.Vertex2(topLeft.X, topLeft.Y + size.Value.Y);
        //        GL.End();

        //        //draw rect to brighten sprite

        //        if (brightenFactor.Equal(1) == false)
        //        {
        //            double bright = Math.Min(2, brightenFactor) - 1;
        //            GL.BlendFunc(BlendingFactorSrc.DstColor, BlendingFactorDest.One);
        //            GL.Color4(ColorByBright(bright));
        //            GL.Begin(PrimitiveType.Quads);
        //            // указываем поочередно вершины и текстурные координаты
        //            GL.Vertex2(topLeft);
        //            GL.Vertex2(topLeft.X + size.Value.X, topLeft.Y);
        //            GL.Vertex2(topLeft.X + size.Value.X, topLeft.Y + size.Value.Y);
        //            GL.Vertex2(topLeft.X, topLeft.Y + size.Value.Y);
        //            GL.End();

        //            if (brightenFactor > 2)
        //            {

        //                GL.Color4(ColorByBright((BrightenFactor - 2) / 2));
        //                GL.Begin(PrimitiveType.Quads);
        //                // указываем поочередно вершины и текстурные координаты
        //                GL.Vertex2(topLeft);
        //                GL.Vertex2(topLeft.X + size.Value.X, topLeft.Y);
        //                GL.Vertex2(topLeft.X + size.Value.X, topLeft.Y + size.Value.Y);
        //                GL.Vertex2(topLeft.X, topLeft.Y + size.Value.Y);
        //                GL.End();
        //            }
        //        }
        //    }



        //    GL.PopMatrix();
        //    GL.Disable(EnableCap.Texture2D);

        //}
        #endregion

        static void DrawText(IFramePainterInfo frame, int index)
        {
            QFont.Begin();
            var text = frame.textList[index];
            var font = FontList.All[text.Item1];

            //загружаем все шрифты размером 40 (для достаточной четкости), а потом растягиваем перед выводом

            float defaultEmSize = 40.0f;
            var   fontState     = _textManager.LoadOrCheckFont(font.fontFamily, defaultEmSize /*(float)font.emSize*/, font.fontStyle, text.Item2);

            fontState.QFont.Options.Colour = font.color;

            double maxWidth = text.Item6 == null ? double.MaxValue : text.Item6.Value;

            var    fontInfo   = new Font(font.fontFamily, defaultEmSize, font.fontStyle, GraphicsUnit.Pixel);
            var    fontHeight = fontInfo.Height;
            double userWantsHeightInPixels = font.emSize;                                                            //in pixels??
            double scale = userWantsHeightInPixels / fontInfo.Height;
            double userWantsMaxWidthInPixels = maxWidth / scale;                                                     //* weHavePerPixel.X;
            var    sizeOnbitmap = fontState.QFont.Measure(text.Item2, (float)userWantsMaxWidthInPixels, text.Item5); //todo размер шрифта , если выбираем маленький вьюпорт, не тот
            var    realSize     = (new Vector2d(sizeOnbitmap.Width, sizeOnbitmap.Height)) * scale;                   // rect.size

            //.DivEach(new Vector2d(control.Width, control.Height))
            //.MultEach(new Vector2d(sizeOnbitmap.Width, sizeOnbitmap.Height));

            //  if (maxWidth != null)
            //      maxWidth *= (rect.size.X / control.Width);
            // GL.Scale()
            GL.PushMatrix();
            var pos = (text.Item4 - text.Item3.MultEach(realSize));

            GL.Translate(pos.X, pos.Y, 0);
            GL.Scale(scale, scale, 1);
            fontState.QFont.Print(text.Item2, (float)userWantsMaxWidthInPixels, text.Item5);
            GL.PopMatrix();
            QFont.End();
        }
예제 #17
0
        private void DrawOverlay(RenderableMesh orignalMesh, RenderableMesh occluderMesh)
        {
            GL.PushAttrib(AttribMask.AllAttribBits);

            GL.Color4(1.0f, 1.0f, 1.0f, 1.0f);
            GL.Enable(EnableCap.Texture2D);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
            GL.DepthFunc(DepthFunction.Lequal);

            QFont.Begin();

            float yOffset = 5;

            if (orignalMesh != null)
            {
                PrintCode(String.Format("Orignal Triangles   : {0,5}", orignalMesh.Triangles), ref yOffset);
            }
            if (occluderMesh != null)
            {
                PrintCode(String.Format("Occluder Triangles  : {0,5}", occluderMesh.Triangles), ref yOffset);
            }

            PrintCode(String.Format("Occluder Levels     : {0,5}", m_visualizedMaxLevel), ref yOffset);
            if (m_operations.Context.VoxelizationOutput != null)
            {
                PrintCode(String.Format("Volume Coverage     : {0,5:0.##}%", (100 * m_operations.Context.VoxelizationOutput.VolumeCoverage)), ref yOffset);
                PrintCode(String.Format("Silhouette Coverage : {0,5:0.##}%", (100 * m_operations.Context.VoxelizationOutput.SilhouetteCoverage)), ref yOffset);
                PrintCode(String.Format("Time Taken          : {0,5:0.##} seconds", m_operations.Context.VoxelizationOutput.TimeTaken.TotalSeconds), ref yOffset);
            }

            QFont.End();

            GL.PopAttrib();
        }
예제 #18
0
파일: Window.cs 프로젝트: gslandtreter/TRON
        protected void DrawGame()
        {
            foreach (Player player in gamePlayers)
            {
                if (!player.isAlive)
                {
                    continue;
                }

                player.drawPlayer();
                player.drawTrail();
            }


            //REFLECTION

            GL.Enable(EnableCap.StencilTest);
            GL.ColorMask(false, false, false, false);
            GL.Disable(EnableCap.DepthTest);
            GL.StencilFunc(StencilFunction.Always, 1, 1);
            GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Replace);
            myMap.RenderFloor(1.0f);

            GL.ColorMask(true, true, true, true);
            GL.Enable(EnableCap.DepthTest);
            GL.StencilFunc(StencilFunction.Equal, 1, 1);
            GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Keep);

            GL.PushMatrix();

            GL.Scale(1, -1, 1);
            myMap.RenderWalls();

            foreach (Player player in gamePlayers)
            {
                if (!player.isAlive)
                {
                    continue;
                }

                player.drawPlayer();
                player.drawTrail();
            }

            GL.PopMatrix();
            GL.Disable(EnableCap.StencilTest);
            //ENDOF Reflection

            myMap.Render();


            if (GameLogic.IsGameOver(gamePlayers))
            {
                if (gamePlayers.Find(i => i.isHumanPlayer).isAlive || hasWon)
                {
                    QFont.Begin();
                    mainFont.Print("GANHOU!", new OpenTK.Vector2(250, 50));
                    QFont.End();

                    if (!hasWon)
                    {
                        hasWon = true;
                    }
                }
                else if (!hasWon)
                {
                    QFont.Begin();
                    mainFont.Print("PERDEU!", new OpenTK.Vector2(250, 50));
                    QFont.End();
                }
            }
        }
예제 #19
0
        public void Graph()
        {
            bool texture2DWasEnabled = GL.IsEnabled(EnableCap.Texture2D);
            bool depthTestWasEnabled = GL.IsEnabled(EnableCap.DepthTest);
            bool lightingWasEnabled  = GL.IsEnabled(EnableCap.Lighting);

            //GL.Disable(EnableCap.Texture2D)
            GL.Disable(EnableCap.DepthTest);
            GL.Disable(EnableCap.Lighting);

            GL.PushMatrix();
            QFont.Begin();

            if (BackgroundColor != null)
            {
                GL.Begin(BeginMode.Quads);
                GL.Color4(BackgroundColor.Value);
                GL.Vertex2(X0, Y0);
                GL.Vertex2(X0 + Width, Y0);
                GL.Vertex2(X0 + Width, Y0 + Height);
                GL.Vertex2(X0, Y0 + Height);
                GL.End();
            }

            if (OutlineColor != null)
            {
                GL.Begin(BeginMode.LineLoop);
                GL.Color4(OutlineColor.Value);
                GL.Vertex2(X0, Y0);
                GL.Vertex2(X0 + Width, Y0);
                GL.Vertex2(X0 + Width, Y0 + Height);
                GL.Vertex2(X0, Y0 + Height);
                GL.End();
            }

            GL.Translate(X0, Y0, 0.0f);
            currentFont.Options.Colour = this.TextColor;
            currentFont.Print(Text, Width, QFontAlignment.Left);

            QFont.End();
            GL.PopMatrix();

            GL.Color4(1.0f, 1.0f, 1.0f, 1.0f); //make sure the color does not bleed over

            //restore the origional settings
            if (texture2DWasEnabled)
            {
                GL.Enable(EnableCap.Texture2D);
            }
            else
            {
                GL.Disable(EnableCap.Texture2D);
            }

            if (depthTestWasEnabled)
            {
                GL.Enable(EnableCap.DepthTest);
            }
            else
            {
                GL.Disable(EnableCap.DepthTest);
            }

            if (lightingWasEnabled)
            {
                GL.Enable(EnableCap.Lighting);
            }
            else
            {
                GL.Disable(EnableCap.Lighting);
            }
        }
예제 #20
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            int startTime = Environment.TickCount & Int32.MaxValue;

            base.OnRenderFrame(e);

            GL.LightModel(LightModelParameter.LightModelAmbient, globLight);

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            GL.MatrixMode(MatrixMode.Modelview);

            camera.SetView();

            SkyBoxSphere.Render(camera);

            ReferencePlane.setDimensions(50, 50);
            ReferencePlane.render();

            map.Render();

            //shadowTest();

            int totalTime = (Environment.TickCount & Int32.MaxValue) - startTime;

            int fps = 0;

            if (totalTime > 0)
            {
                fps = 1000 / totalTime;
            }

            Title = this.baseTitle + " FPS: " + fps;

            if (useFonts)
            {
                QFont.Begin();

                GL.PushMatrix();
                GL.Translate(0.0, 0.0, 0.0);
                font.Print(Title, QFontAlignment.Left);
                GL.PopMatrix();

                if (cameraHelp)
                {
                    GL.PushMatrix();
                    GL.Translate(config.ScreenWidth * 0.75, 0.0, 0.0);
                    monoFont.Print(cameraHelpText, QFontAlignment.Left);
                    GL.PopMatrix();
                }

                if (gameStats)
                {
                    GL.PushMatrix();
                    GL.Translate(0.0, config.ScreenHeight * 0.10f, 0.0);
                    gameStatsText = String.Format(gameStatsFormat,
                                                  map.GetRobots().Count, activeRobot.GetALife());
                    monoFont.Print(gameStatsText, QFontAlignment.Left);
                    GL.PopMatrix();
                }

                if (gameOver)
                {
                    GL.PushMatrix();
                    GL.Translate(config.ScreenWidth * 0.50, 0.0, 0.0);
                    monoFont.Print(gameOverText, QFontAlignment.Centre);
                    GL.PopMatrix();
                }

                QFont.End();
                GL.Disable(EnableCap.Texture2D);
            }

            GL.Flush();

            SwapBuffers();
        }
예제 #21
0
        /// <summary>
        /// Called when it is time to render the next frame. Add your rendering code here.
        /// </summary>
        /// <param name="e">Contains timing information.</param>
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            base.OnRenderFrame(e);

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            Matrix4 modelview = Matrix4.LookAt(Vector3.Zero, Vector3.UnitZ, Vector3.UnitY);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadMatrix(ref modelview);


            QFont.Begin();
            GL.Begin(BeginMode.Quads);


            GL.Color3(1.0f, 1.0f, 1.0); GL.Vertex2(0, 0);
            GL.Color3(0.9f, 0.9f, 0.9f); GL.Vertex2(0, Height);
            GL.Color3(0.9f, 0.9f, 0.9f); GL.Vertex2(Width, Height);
            GL.Color3(0.9f, 0.9f, 0.9f); GL.Vertex2(Width, 0);



            GL.End();
            QFont.End();



            switch (currentDemoPage)
            {
            case 1:
            {
                float yOffset = 0;

                GL.Translate(50, 0, 0);
                QFont.Begin();

                GL.PushMatrix();
                GL.Translate(Width * 0.5f, yOffset, 0f);
                heading1.Print("QuickFont", QFontAlignment.Centre);
                yOffset += heading1.Measure("QuickFont").Height;
                GL.PopMatrix();


                GL.PushMatrix();
                GL.Translate(20f, yOffset, 0f);
                heading2.Print("Introduction", QFontAlignment.Left);
                yOffset += heading2.Measure("Introduction").Height;
                GL.PopMatrix();


                GL.PushMatrix();
                GL.Translate(30f, yOffset + 20, 0f);
                mainText.Print(introduction, Width - 60, QFontAlignment.Justify);
                GL.PopMatrix();


                QFont.End();
            }
            break;



            case 2:
            {
                float yOffset = 20;

                QFont.Begin();


                GL.PushMatrix();
                GL.Translate(20f, yOffset, 0f);
                heading2.Print("Easy as ABC!", QFontAlignment.Left);
                yOffset += heading2.Measure("Easy as ABC!").Height;
                GL.PopMatrix();


                PrintComment(usingQuickFontIsSuperEasy, ref yOffset);
                PrintCode(loadingAFont1, ref yOffset);

                PrintComment(andPrintWithIt, ref yOffset);
                PrintCode(printWithFont1, ref yOffset);

                PrintComment(itIsAlsoEasyToMeasure, ref yOffset);
                PrintCode(measureText1, ref yOffset);

                PrintComment(oneOfTheFirstGotchas, ref yOffset);
                PrintCode(loadingAFont2, ref yOffset);

                QFont.End();
            }
            break;

            case 3:
            {
                float yOffset = 20;

                QFont.Begin();


                GL.PushMatrix();
                GL.Translate(20f, yOffset, 0f);
                heading2.Print("Alignment", QFontAlignment.Left);
                yOffset += heading2.Measure("Easy as ABC!").Height;
                GL.PopMatrix();

                PrintCommentWithLine(whenPrintingText, QFontAlignment.Left, Width * 0.5f, ref yOffset);
                PrintCode(printWithFont2, ref yOffset);


                PrintCommentWithLine(righAlignedText, QFontAlignment.Right, Width * 0.5f, ref yOffset);
                yOffset += 10f;

                PrintCommentWithLine(centredTextAsYou, QFontAlignment.Centre, Width * 0.5f, ref yOffset);

                QFont.End();
            }
            break;



            case 4:
            {
                float yOffset = 20;

                QFont.Begin();


                GL.PushMatrix();
                GL.Translate(20f, yOffset, 0f);
                heading2.Print("Bounds and Justify", QFontAlignment.Left);
                yOffset += heading2.Measure("Easy as ABC!").Height;
                GL.PopMatrix();



                GL.PushMatrix();
                yOffset += 20;
                GL.Translate((int)(Width * 0.5), yOffset, 0f);
                controlsText.Print("Press [Up], [Down] or [Enter]!", QFontAlignment.Centre);
                yOffset += controlsText.Measure("[]").Height;
                GL.PopMatrix();



                float boundShrink = (int)(350 * (1 - Math.Cos(boundsAnimationCnt * Math.PI * 2)));

                yOffset += 15;;
                PrintWithBounds(mainText, ofCourseItsNot, new RectangleF(30f + boundShrink * 0.5f, yOffset, Width - 60 - boundShrink, 350f), cycleAlignment, ref yOffset);


                string printWithBounds = "myFont.Print(text,400f,QFontAlignment." + cycleAlignment + ");";
                yOffset += 15f;
                PrintCode(printWithBounds, ref yOffset);



                QFont.End();
            }
            break;



            case 5:
            {
                float yOffset = 20;

                QFont.Begin();


                GL.PushMatrix();
                GL.Translate(20f, yOffset, 0f);
                heading2.Print("Your own Texture Fonts", QFontAlignment.Left);
                yOffset += heading2.Measure("T").Height;
                GL.PopMatrix();


                PrintComment(anotherCoolFeature, ref yOffset);
                PrintCode(textureFontCode1, ref yOffset);
                PrintComment(thisWillHaveCreated, ref yOffset);



                QFont.End();
            }
            break;


            case 6:
            {
                float yOffset = 20;

                QFont.Begin();


                GL.PushMatrix();
                GL.Translate(20f, yOffset, 0f);
                heading2.Print("Your own Texture Fonts", QFontAlignment.Left);
                yOffset += heading2.Measure("T").Height;
                GL.PopMatrix();


                PrintComment(ifYouDoIntend, ref yOffset);
                PrintCode(textureFontCode2, ref yOffset);
                PrintComment(actuallyTexturing, ref yOffset);
                PrintCode(textureFontCode3, ref yOffset);


                QFont.End();
            }
            break;



            case 7:
            {
                float yOffset = 20;

                QFont.Begin();


                heading2.Options.DropShadowOffset = new Vector2(0.1f + 0.2f * (float)Math.Sin(cnt), 0.1f + 0.2f * (float)Math.Cos(cnt));

                GL.PushMatrix();
                GL.Translate(20f, yOffset, 0f);
                heading2.Print("Drop Shadows", QFontAlignment.Left);
                yOffset += heading2.Measure("T").Height;
                GL.PopMatrix();

                heading2.Options.DropShadowOffset = new Vector2(0.16f, 0.16f);         //back to default

                mainText.Options.DropShadowActive  = true;
                mainText.Options.DropShadowOpacity = 0.7f;
                mainText.Options.DropShadowOffset  = new Vector2(0.1f + 0.2f * (float)Math.Sin(cnt), 0.1f + 0.2f * (float)Math.Cos(cnt));



                PrintComment(asIhaveleant, ref yOffset);
                PrintCode(dropShadowCode1, ref yOffset);
                PrintComment(thisWorksFine, ref yOffset);
                PrintCode(dropShadowCode2, ref yOffset);
                PrintComment(onceAFont, ref yOffset);


                mainText.Options.DropShadowActive = false;

                QFont.End();
            }
            break;



            case 8:
            {
                float yOffset = 20;

                QFont.Begin();



                monoSpaced.Options.CharacterSpacing = 0.05f;

                GL.PushMatrix();
                GL.Translate(20f, yOffset, 0f);
                heading2.Print("Monospaced Fonts", QFontAlignment.Left);
                yOffset += heading2.Measure("T").Height;
                GL.PopMatrix();


                PrintComment(monoSpaced, hereIsSomeMono, QFontAlignment.Left, ref yOffset);
                PrintCode(monoCode1, ref yOffset);
                PrintComment(monoSpaced, theDefaultMono, QFontAlignment.Left, ref yOffset);

                PrintCommentWithLine(monoSpaced, mono, QFontAlignment.Left, Width * 0.5f, ref yOffset);
                yOffset += 2f;
                PrintCommentWithLine(monoSpaced, mono, QFontAlignment.Right, Width * 0.5f, ref yOffset);
                yOffset += 2f;
                PrintCommentWithLine(monoSpaced, mono, QFontAlignment.Centre, Width * 0.5f, ref yOffset);
                yOffset += 2f;

                monoSpaced.Options.CharacterSpacing = 0.5f;
                PrintComment(monoSpaced, "As usual, you can adjust character spacing with myFont.Options.CharacterSpacing.", QFontAlignment.Left, ref yOffset);


                QFont.End();
            }
            break;


            case 9:
            {
                float yOffset = 20;

                QFont.Begin();


                GL.PushMatrix();
                GL.Translate(20f, yOffset, 0f);
                heading2.Print("In Conclusion", QFontAlignment.Left);
                yOffset += heading2.Measure("T").Height;
                GL.PopMatrix();


                PrintComment(thereAreActually, ref yOffset);



                QFont.End();
            }
            break;
            }



            QFont.Begin();


            if (currentDemoPage != lastPage)
            {
                GL.PushMatrix();
                GL.Translate(Width - 10 - 16 * (float)(1 + Math.Sin(cnt * 4)), Height - controlsText.Measure("P").Height - 10f, 0f);
                controlsText.Options.Colour = new Color4(0.8f, 0.1f, 0.1f, 1.0f);
                controlsText.Print("Press [Right] ->", QFontAlignment.Right);
                GL.PopMatrix();
            }


            if (currentDemoPage != 1)
            {
                GL.PushMatrix();
                GL.Translate(10 + 16 * (float)(1 + Math.Sin(cnt * 4)), Height - controlsText.Measure("P").Height - 10f, 0f);
                controlsText.Options.Colour = new Color4(0.8f, 0.1f, 0.1f, 1.0f);
                controlsText.Print("<- Press [Left]", QFontAlignment.Left);
                GL.PopMatrix();
            }


            QFont.End();



            GL.Disable(EnableCap.Texture2D);

            SwapBuffers();
        }
예제 #22
0
 private void Draw(Vector2 pos)
 {
     QFont.Begin();
     Font.QFont.Print(Text, Alignment, pos);
     QFont.End();
 }
        public void draw()
        {
            float offset = 0;
            float scale  = (mMaxHeight * 2f) / mDimensions.Y;

            QFont.Begin();
            GL.Disable(EnableCap.DepthTest);
            GL.PushMatrix();

            mLargeFont.DrawVBOs();
            mSmallFont.DrawVBOs();
            GL.PopMatrix();
            QFont.End();

            GL.Enable(EnableCap.DepthTest);
            GL.Disable(EnableCap.Texture2D);


            foreach (var kvp in mPoints)
            {
                offset += mDimensions.Y;
                GL.Begin(BeginMode.LineStrip);
                GL.Color3(Color.Red);
                for (int i = 0; i < kvp.Value.Count; i++)
                {
                    GL.Vertex2(( float )( float )i * (WindowDimensions.X / ( float )MAX_POINTS), (kvp.Value[i].X / scale) + offset);
                }
                GL.End();

                GL.Begin(BeginMode.LineStrip);
                GL.Color3(Color.Green);
                for (int i = 0; i < kvp.Value.Count; i++)
                {
                    GL.Vertex2(( float )i * (WindowDimensions.X / ( float )MAX_POINTS), (kvp.Value[i].Y / scale) + offset);
                }
                GL.End();

                GL.Begin(BeginMode.LineStrip);
                GL.Color3(Color.Blue);
                for (int i = 0; i < kvp.Value.Count; i++)
                {
                    GL.Vertex2(( float )i * (WindowDimensions.X / ( float )MAX_POINTS), (kvp.Value[i].Z / scale) + offset);
                }
                GL.End();


                GL.Enable(EnableCap.LineStipple);
                GL.LineStipple(6, Convert.ToInt16("0011011100110011", 2));
                GL.Begin(BeginMode.Lines);
                GL.Color3(Color.White);
                GL.Vertex2(WindowDimensions.X - (WindowDimensions.X / 8), offset - (440f / scale));
                GL.Vertex2(WindowDimensions.X, offset - (440f / scale));
                GL.Vertex2(WindowDimensions.X - (WindowDimensions.X / 8), offset - (220f / scale));
                GL.Vertex2(WindowDimensions.X, offset - (220f / scale));

                GL.Vertex2(WindowDimensions.X - (WindowDimensions.X / 8), offset + (440f / scale));
                GL.Vertex2(WindowDimensions.X, offset + (440f / scale));
                GL.Vertex2(WindowDimensions.X - (WindowDimensions.X / 8), offset + (220f / scale));
                GL.Vertex2(WindowDimensions.X, offset + (220f / scale));
                GL.End();
                GL.Disable(EnableCap.LineStipple);
                /** Draw the dotted 1g/2g lines */
            }
        }
예제 #24
0
        /// <summary>
        /// Called when it is time to render the next frame. Add your rendering code here.
        /// </summary>
        /// <param name="e">Contains timing information.</param>
        void QuickFontControl_Paint(object sender, PaintEventArgs e)
        {
            Graphics      graphics = e.Graphics;
            GraphicsState state;

            switch (currentDemoPage)
            {
            case 1:
            {
                double yOffset = 0;

                QFont.Begin();

                state = graphics.Save();
                graphics.TranslateTransform(Width * 0.5f, yOffset + 10);
                heading1.Print("AltGUI QuickFont", QFontAlignment.Centre);
                yOffset += heading1.Measure("QuickFont").Height;
                graphics.Restore(state);


                state = graphics.Save();
                graphics.TranslateTransform(20f, yOffset);
                heading2.Print("Introduction", QFontAlignment.Left);
                yOffset += heading2.Measure("Introduction").Height;
                graphics.Restore(state);


                state = graphics.Save();
                graphics.TranslateTransform(30f, yOffset + 20);
                mainText.Print(introduction, Width - 60, QFontAlignment.Justify);
                graphics.Restore(state);

                QFont.End();
            }
            break;

            case 2:
            {
                double yOffset = 20;

                QFont.Begin();

                state = graphics.Save();
                graphics.TranslateTransform(20f, yOffset);
                heading2.Print("Easy as ABC!", QFontAlignment.Left);
                yOffset += heading2.Measure("Easy as ABC!").Height;
                graphics.Restore(state);


                PrintComment(graphics, usingQuickFontIsSuperEasy, ref yOffset);
                PrintCode(graphics, loadingAFont1, ref yOffset);

                PrintComment(graphics, andPrintWithIt, ref yOffset);
                PrintCode(graphics, printWithFont1, ref yOffset);

                PrintComment(graphics, itIsAlsoEasyToMeasure, ref yOffset);
                PrintCode(graphics, measureText1, ref yOffset);

                PrintComment(graphics, oneOfTheFirstGotchas, ref yOffset);
                PrintCode(graphics, loadingAFont2, ref yOffset);

                QFont.End();
            }
            break;

            case 3:
            {
                double yOffset = 20;

                QFont.Begin();

                state = graphics.Save();
                graphics.TranslateTransform(20f, yOffset);
                heading2.Print("Alignment", QFontAlignment.Left);
                yOffset += heading2.Measure("Easy as ABC!").Height;
                graphics.Restore(state);

                PrintCommentWithLine(graphics, whenPrintingText, QFontAlignment.Left, Width * 0.5f, ref yOffset);
                PrintCode(graphics, printWithFont2, ref yOffset);


                PrintCommentWithLine(graphics, righAlignedText, QFontAlignment.Right, Width * 0.5f, ref yOffset);
                yOffset += 10f;

                PrintCommentWithLine(graphics, centredTextAsYou, QFontAlignment.Centre, Width * 0.5f, ref yOffset);

                QFont.End();
            }
            break;

            case 4:
            {
                double yOffset = 20;

                QFont.Begin();

                state = graphics.Save();
                graphics.TranslateTransform(20f, yOffset);
                heading2.Print("Bounds and Justify", QFontAlignment.Left);
                yOffset += heading2.Measure("Easy as ABC!").Height;
                graphics.Restore(state);

                state    = graphics.Save();
                yOffset += 20;
                graphics.TranslateTransform((int)(Width * 0.5), yOffset);
                controlsText.Options.Colour = Color.Yellow;
                controlsText.Print("Press [Up], [Down] or [Enter]!", QFontAlignment.Centre);
                yOffset += controlsText.Measure("[]").Height;
                graphics.Restore(state);

                double boundShrink = (int)(350 * (1 - Math.Cos(boundsAnimationCnt * Math.PI * 2)));

                yOffset += 15;
                PrintWithBounds(graphics, mainText, ofCourseItsNot, new Rect(30f + boundShrink * 0.5f, yOffset, Width - 60 - boundShrink, 350f), cycleAlignment, ref yOffset);

                string printWithBounds = "myFont.Print(text, 400f, QFontAlignment." + cycleAlignment + ");";
                yOffset += 15f;
                PrintCode(graphics, printWithBounds, ref yOffset);

                QFont.End();
            }
            break;

            case 5:
            {
                double yOffset = 20;

                QFont.Begin();

                state = graphics.Save();
                graphics.TranslateTransform(20f, yOffset);
                heading2.Print("Your own Texture Fonts", QFontAlignment.Left);
                yOffset += heading2.Measure("T").Height;
                graphics.Restore(state);

                PrintComment(graphics, anotherCoolFeature, ref yOffset);
                PrintCode(graphics, textureFontCode1, ref yOffset);
                PrintComment(graphics, thisWillHaveCreated, ref yOffset);

                QFont.End();
            }
            break;

            case 6:
            {
                double yOffset = 20;

                QFont.Begin();

                state = graphics.Save();
                graphics.TranslateTransform(20f, yOffset);
                heading2.Print("Your own Texture Fonts", QFontAlignment.Left);
                yOffset += heading2.Measure("T").Height;
                graphics.Restore(state);

                PrintComment(graphics, ifYouDoIntend, ref yOffset);
                PrintCode(graphics, textureFontCode2, ref yOffset);
                PrintComment(graphics, actuallyTexturing, ref yOffset);
                PrintCode(graphics, textureFontCode3, ref yOffset);

                QFont.End();
            }
            break;

            case 7:
            {
                double yOffset = 20;

                QFont.Begin();

                heading2.Options.DropShadowOffset = new Alt.Sketch.Vector2(0.1f + 0.2f * (float)Math.Sin(cnt), 0.1f + 0.2f * (float)Math.Cos(cnt));

                state = graphics.Save();
                graphics.TranslateTransform(20f, yOffset);
                heading2.Print("Drop Shadows", QFontAlignment.Left);
                yOffset += heading2.Measure("T").Height;
                graphics.Restore(state);

                heading2.Options.DropShadowOffset = new Alt.Sketch.Vector2(0.16f, 0.16f);         //back to default

                mainText.Options.DropShadowActive  = true;
                mainText.Options.DropShadowOpacity = 0.7f;
                mainText.Options.DropShadowOffset  = new Alt.Sketch.Vector2(0.1f + 0.2f * (float)Math.Sin(cnt), 0.1f + 0.2f * (float)Math.Cos(cnt));

                PrintComment(graphics, asIhaveleant, ref yOffset);
                PrintCode(graphics, dropShadowCode1, ref yOffset);
                PrintComment(graphics, thisWorksFine, ref yOffset);
                PrintCode(graphics, dropShadowCode2, ref yOffset);
                PrintComment(graphics, onceAFont, ref yOffset);

                mainText.Options.DropShadowActive = false;

                QFont.End();
            }
            break;

            case 8:
            {
                double yOffset = 20;

                QFont.Begin();

                monoSpaced.Options.CharacterSpacing = 0.05f;

                state = graphics.Save();
                graphics.TranslateTransform(20f, yOffset);
                heading2.Print("Monospaced Fonts", QFontAlignment.Left);
                yOffset += heading2.Measure("T").Height;
                graphics.Restore(state);


                PrintComment(graphics, monoSpaced, hereIsSomeMono, QFontAlignment.Left, ref yOffset);
                PrintCode(graphics, monoCode1, ref yOffset);
                PrintComment(graphics, monoSpaced, theDefaultMono, QFontAlignment.Left, ref yOffset);

                PrintCommentWithLine(graphics, monoSpaced, mono, QFontAlignment.Left, Width * 0.5f, ref yOffset);
                yOffset += 2f;
                PrintCommentWithLine(graphics, monoSpaced, mono, QFontAlignment.Right, Width * 0.5f, ref yOffset);
                yOffset += 2f;
                PrintCommentWithLine(graphics, monoSpaced, mono, QFontAlignment.Centre, Width * 0.5f, ref yOffset);
                yOffset += 2f;

                monoSpaced.Options.CharacterSpacing = 0.5f;
                PrintComment(graphics, monoSpaced, "As usual, you can adjust character spacing with myFont.Options.CharacterSpacing.", QFontAlignment.Left, ref yOffset);

                QFont.End();
            }
            break;

            case 9:
            {
                double yOffset = 20;

                QFont.Begin();

                state = graphics.Save();
                graphics.TranslateTransform(20f, yOffset);
                heading2.Print("In Conclusion", QFontAlignment.Left);
                yOffset += heading2.Measure("T").Height;
                graphics.Restore(state);

                PrintComment(graphics, thereAreActually, ref yOffset);

                QFont.End();
            }
            break;
            }


            QFont.Begin();

            Color pressColor = new ColorR(0.8, 0.2, 0.2);// new ColorR(0.8, 0.1, 0.1);

            if (currentDemoPage != lastPage)
            {
                state = graphics.Save();
                graphics.TranslateTransform(Width - 15 - 16 * (float)(1 + Math.Sin(cnt * 4)), Height - controlsText.Measure("P").Height - 17);
                controlsText.Options.Colour = pressColor;
                controlsText.Print("Press [Right] ->", QFontAlignment.Right);
                graphics.Restore(state);
            }

            if (currentDemoPage != 1)
            {
                state = graphics.Save();
                graphics.TranslateTransform(15 + 16 * (float)(1 + Math.Sin(cnt * 4)), Height - controlsText.Measure("P").Height - 17);
                controlsText.Options.Colour = pressColor;
                controlsText.Print("<- Press [Left]", QFontAlignment.Left);
                graphics.Restore(state);
            }

            QFont.End();
        }