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(); } }
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(); }
public void OnRenderFrame(FrameEventArgs e) { GL.PushMatrix(); camera.LoadView(); map.Draw(); foreach (var ent in entities) { ent.Draw(); } player.Draw(); GL.PopMatrix(); GL.MatrixMode(MatrixMode.Projection); GL.PushMatrix(); var projection = Matrix4.CreateOrthographicOffCenter(-512, 512, 384, -384, 0, 1); GL.LoadMatrix(ref projection); GL.MatrixMode(MatrixMode.Modelview); if (lastCollidedWith != null && !string.IsNullOrEmpty(lastCollidedWith.helpText)) { GL.PushMatrix(); GL.Translate(-500, -360, 0); helpFont.Print(lastCollidedWith.helpText); GL.PopMatrix(); } GL.PushMatrix(); GL.Translate(-500, 340, 0); helpFont.Print("Health: " + player.health); GL.PopMatrix(); GL.Color4(1f, 1f, 1f, 1f); GL.MatrixMode(MatrixMode.Projection); GL.PopMatrix(); GL.MatrixMode(MatrixMode.Modelview); if (fadingIn || fadingOut) { GL.Color4(0f, 0f, 0f, fadePercent); fadeIn.Draw(); GL.Color4(1f, 1f, 1f, 1f); } }
public void OnRenderFrame(FrameEventArgs e) { GL.PushMatrix(); GL.Translate(0, -80, 0); subtitleFont.Print("And so you leave Mars...\nTo the dark, lonely depths of space.", QFontAlignment.Centre); GL.PopMatrix(); }
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(); }
public void OnRenderFrame(FrameEventArgs e) { GL.MatrixMode(MatrixMode.Projection); var proj = Matrix4.CreateOrthographicOffCenter(-512, 512, 384, -384, 0, 1); GL.LoadMatrix(ref proj); GL.MatrixMode(MatrixMode.Modelview); GL.LoadMatrix(ref Matrix4.Identity); GL.PushMatrix(); GL.Translate(0, -60, 0); titleFont.Print(title, QFontAlignment.Centre); GL.PopMatrix(); GL.PushMatrix(); GL.Translate(0, 40, 0); subtitleFont.Print(subtitle, QFontAlignment.Centre); GL.PopMatrix(); GL.Color4(new Color4(0f, 0f, 0f, fadePercent)); fadeMesh.Draw(); GL.Color4(new Color4(1f, 1f, 1f, 1f)); }
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); }
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); }
private void PrintComment(QFont font, string comment, QFontAlignment alignment, ref float yOffset) { GL.PushMatrix(); yOffset += 20; GL.Translate(30f, yOffset, 0f); font.Print(comment, Width - 60, alignment); yOffset += font.Measure(comment, Width - 60, alignment).Height; GL.PopMatrix(); }
private void PrintCode(string code, ref float yOffset) { GL.PushMatrix(); yOffset += 20; GL.Translate(50f, yOffset, 0f); codeText.Print(code, Width - 50, QFontAlignment.Left); yOffset += codeText.Measure(code, Width - 50, QFontAlignment.Left).Height; GL.PopMatrix(); }
private void PrintCode(string code, ref float yOffset) { GL.PushMatrix(); yOffset += 5; GL.Translate(10f, yOffset, 0f); codeText.Print(code, new RectangleF(0, 0, Width, 1f), QFontAlignment.Left); yOffset += codeText.Measure(code, new RectangleF(0, 0, Width, 1f), QFontAlignment.Left).Height; GL.PopMatrix(); }
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(); }
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(); }
void PrintWithBounds(Graphics graphics, QFont font, string text, Rect bounds, QFontAlignment alignment, ref double yOffset) { double maxWidth = bounds.Width; double height = font.Measure(text, maxWidth, alignment).Height; bounds.Height = height; graphics.DrawRectangle(m_LinesPen, bounds - new Point(1, 0) + new Size(0, 1)); font.Print(text, maxWidth, alignment, new Alt.Sketch.Vector2(bounds.X, bounds.Y)); yOffset += height; }
void PrintComment(Graphics graphics, QFont font, string comment, QFontAlignment alignment, ref double yOffset) { GraphicsState state = graphics.Save(); yOffset += 20; graphics.TranslateTransform(30, yOffset); font.Print(comment, Width - 60, alignment); yOffset += font.Measure(comment, Width - 60, alignment).Height; graphics.Restore(state); }
void PrintCode(Graphics graphics, string code, ref double yOffset) { GraphicsState state = graphics.Save(); yOffset += 20; graphics.TranslateTransform(50f, yOffset); codeText.Print(code, Width - 50, QFontAlignment.Left); yOffset += codeText.Measure(code, Width - 50, QFontAlignment.Left).Height; graphics.Restore(state); }
public void Print(string text, Vector2 position) { if (FontStyle == FontStyle.Regular) { _normal.Print(text, position); } else if ((FontStyle & FontStyle.Bold) > 0) { _bold.Print(text, position); } else if ((FontStyle & FontStyle.Italic) > 0) { _italic.Print(text, position); } }
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); }
public void OnRenderFrame(FrameEventArgs e) { c.UseWorldProjection(); GL.EnableClientState(ArrayCap.VertexArray); GL.EnableClientState(ArrayCap.TextureCoordArray); foreach (Entity ent in area.EntList) { GL.PushMatrix(); ent.Draw(); GL.PopMatrix(); } GL.PushMatrix(); player.Draw(); GL.PopMatrix(); c.UseUIProjection(); GL.PushMatrix(); InventoryBox.Draw(); GL.PopMatrix(); GL.PushMatrix(); player.DrawInventory(); GL.PopMatrix(); GL.DisableClientState(ArrayCap.VertexArray); GL.DisableClientState(ArrayCap.TextureCoordArray); GL.PushMatrix(); GL.Translate(new Vector3(5, 50, 0)); font.Print(message); GL.PopMatrix(); GL.BindTexture(TextureTarget.Texture2D, 0); if (fadeBox.Color.A > 0) { GL.EnableClientState(ArrayCap.VertexArray); GL.PushMatrix(); fadeBox.Draw(); GL.PopMatrix(); GL.DisableClientState(ArrayCap.VertexArray); } }
public void OnRenderFrame(FrameEventArgs e) { GL.PushMatrix(); GL.Translate(0, -60, 0); titleFont.Print("Rover's Spirit", QFontAlignment.Centre); GL.PopMatrix(); GL.PushMatrix(); GL.Translate(0, 35, 0); subtitleFont.Print("By Robert Rouhani\nFor Ludum Dare 22\nInspired by xkcd comic 695 \"Spirit\"\n\nControls: Arrow keys to move, Z to interact", QFontAlignment.Centre); GL.PopMatrix(); GL.PushMatrix(); GL.Translate(0, (ClientSize.Height / 2) - 48, 0); itemFont.Print("Press any key to start...", QFontAlignment.Centre); GL.PopMatrix(); }
void PrintCommentWithLine(Graphics graphics, QFont font, string comment, QFontAlignment alignment, double xOffset, ref double yOffset) { GraphicsState state = graphics.Save(); yOffset += 20; graphics.TranslateTransform((int)xOffset, yOffset); font.Print(comment, alignment); Size bounds = font.Measure(comment, Width - 60, alignment); graphics.DrawLine(m_LinesPen, 0, 0, 0, bounds.Height + 20); yOffset += bounds.Height; graphics.Restore(state); }
private void PrintCommentWithLine(QFont font, string comment, QFontAlignment alignment, float xOffset, ref float yOffset) { GL.PushMatrix(); yOffset += 20; GL.Translate((int)xOffset, yOffset, 0f); font.Print(comment, alignment); var bounds = font.Measure(comment, Width - 60, alignment); GL.Disable(EnableCap.Texture2D); GL.Begin(BeginMode.Lines); GL.Color4(1.0f, 0f, 0f, 1f); GL.Vertex2(0f, 0f); GL.Color4(1.0f, 0f, 0f, 1f); GL.Vertex2(0f, bounds.Height + 20f); GL.End(); yOffset += bounds.Height; GL.PopMatrix(); }
private void PrintWithBounds(QFont font, string text, RectangleF bounds, QFontAlignment alignment, ref float yOffset) { GL.Disable(EnableCap.Texture2D); GL.Color4(1.0f, 0f, 0f, 1.0f); float maxWidth = bounds.Width; float height = font.Measure(text, maxWidth, alignment).Height; GL.Begin(BeginMode.LineLoop); GL.Vertex3(bounds.X, bounds.Y, 0f); GL.Vertex3(bounds.X + bounds.Width, bounds.Y, 0f); GL.Vertex3(bounds.X + bounds.Width, bounds.Y + height, 0f); GL.Vertex3(bounds.X, bounds.Y + height, 0f); GL.End(); font.Print(text, maxWidth, alignment, new Vector2(bounds.X, bounds.Y)); yOffset += height; }
/// <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(); }
protected override void OnRenderFrame(FrameEventArgs e) { base.OnRenderFrame(e); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); curState.OnRenderFrame(e); //TODO render reading stuff here if (reading) { GL.PushMatrix(); GL.EnableClientState(ArrayCap.VertexArray); paper.Draw(); GL.DisableClientState(ArrayCap.VertexArray); GL.PopMatrix(); GL.PushMatrix(); RectangleF test = paper.GetBoundsWithBorder(16); ink.Print(readingText, paper.GetBoundsWithBorder(16), QFontAlignment.Left); GL.BindTexture(TextureTarget.Texture2D, 0); GL.Color4(1.0f, 1.0f, 1.0f, 1.0f); GL.PopMatrix(); } SwapBuffers(); }
/// <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(); }
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(); } } }
public void Draw(string text, OpenTK.Vector2 position) { //QFont.Begin(); font.Print(text, position, QFontAlignment.Left); //QFont.End(); }
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(); }
/// <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(); }