public override void Dispose() { if (mD3DFont != null) { mD3DFont.Dispose(); mD3DFont = null; } if (mSprite != null) { mSprite.Dispose(); mSprite = null; } }
private void FormOverlay_FormClosing(object sender, FormClosingEventArgs e) { IsRunning = false; renderThread.Abort(); if (!device.Disposed) { device.Dispose(); } if (!sprite.Disposed) { sprite.Dispose(); } if (!smallFont.Disposed) { smallFont.Dispose(); } if (!largeFont.Disposed) { largeFont.Dispose(); } if (!line.Disposed) { line.Dispose(); } Game.CloseProcess(); }
/// <summary> /// Handles font change /// </summary> private void ChangeFontClick(object sender, EventArgs e) { System.Windows.Forms.FontDialog dlg = new System.Windows.Forms.FontDialog(); // Show the dialog dlg.FontMustExist = true; dlg.Font = ourFont; if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) // We selected something { ourFont = dlg.Font; if (firstFont != null) { firstFont.Dispose(); } if (secondFont != null) { secondFont.Dispose(); } // Set the new font LoadFonts(ourFont.Name); // Create our 3d text mesh mesh3DText = Mesh.TextFromFont(device, ourFont, "Mesh.TextFromFont", 0.001f, 0.4f); } }
public override void Dispose() { if (font != null) { font.Dispose(); } }
private void FreeResources() { if (d3dFont != null) { d3dFont.Dispose(); d3dFont = null; } if (sprite != null) { sprite.Dispose(); sprite = null; } if (device != null) { device.Dispose(); device = null; } if (gdiFont != null) { gdiFont.Dispose(); gdiFont = null; } }
public void Dispose() { if (m_font != null) { m_font.Dispose(); } if (m_sprite != null) { m_sprite.Dispose(); } if (m_nameRect != null) { m_nameRect.Clear(); } if (m_cityTexture != null) { m_cityTexture.Dispose(); } if (m_elseTexture != null) { m_elseTexture.Dispose(); } m_font = null; m_sprite = null; }
public void DisposeD3DX() { Microsoft.DirectX.Direct3D.Font d3DFont = this.D3DFont; if (d3DFont != null) { d3DFont.Dispose(); } }
protected override void UnloadSynchronized() { base.UnloadSynchronized(); if (_font != null) { _font.Dispose(); _font = null; } }
public void Dispose() { Font2D.Dispose(); Font3D.Dispose(); Sprite.Dispose(); D3DDev.Dispose(); DSoundDev.Dispose(); DKeyboardDev.Dispose(); DMouseDev.Dispose(); }
public void Cleanup() { if (am.vexbuf != null) { am.vexbuf.Dispose(); am.vexbuf = null; } if (sm.shadowbuf != null) { sm.shadowbuf.Dispose(); sm.shadowbuf = null; } if (am.texture != null) { am.DisposeAllTextures(); am.texture = null; } if (d3dfont != null) { d3dfont.Dispose(); d3dfont = null; } if (gdifont != null) { gdifont.Dispose(); gdifont = null; } axises.DisposeAllBuffer(); if (device != null) { device.Dispose(); device = null; } }
protected void Dispose(bool disposing) { if (!disposed) { if (disposing) { // dispose managed components textFont.Dispose(); } // dispose unmanaged components } disposed = true; }
public void Render() { if (!this.m_Paused) { this.m_Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0F, 0); this.m_Device.BeginScene(); this.SetupMatrices(); for (Int32 counter = 0; counter < this.m_Material.Length; counter++) { this.m_Device.Material = this.m_Material[counter]; this.m_Device.SetTexture(0, this.m_Texture[counter]); this.m_Mesh.DrawSubset(counter); } String text = String.Empty; switch (this.m_ViewAngle) { case ViewAngle.Front: text = " Left►\r\nD\r\no\r\nw\r\nn\r\n▼"; break; case ViewAngle.Back: text = " Right►\r\nD\r\no\r\nw\r\nn\r\n▼"; break; case ViewAngle.Bottom: case ViewAngle.Top: text = " Right►\r\nB\r\na\r\nc\r\nk\r\n▼"; break; case ViewAngle.Left: text = " Back►\r\nD\r\no\r\nw\r\nn\r\n▼"; break; case ViewAngle.Right: text = " Front►\r\nD\r\no\r\nw\r\nn\r\n▼"; break; } System.Drawing.Font fontBase = new System.Drawing.Font("Courier New", 12, FontStyle.Regular, GraphicsUnit.Pixel); Microsoft.DirectX.Direct3D.Font font = new Microsoft.DirectX.Direct3D.Font(this.m_Device, fontBase); font.DrawText(null, text, new Point(0, 0), Color.Blue); font.Dispose(); this.m_Device.EndScene(); this.m_Device.Present(); } }
public void Dispose() { foreach (TSOFigure fig in TSOFigureList) { fig.Dispose(); } if (effect != null) { effect.Dispose(); } if (font != null) { font.Dispose(); } if (device != null) { device.Dispose(); } }
/*------------------------------------------------------------------------- * * ---------------------------------------------------------------------------*/ public override void Dispose() { if (m_textured_font != null) { m_textured_font.Dispose(); } if (m_systemfont != null) { m_systemfont.Dispose(); } if (m_sprite != null) { m_sprite.Dispose(); } if (m_font_sprite != null) { m_font_sprite.Dispose(); } if (m_line != null) { m_line.Dispose(); } if (m_font_small != null) { m_font_small.Dispose(); } if (m_font != null) { m_font.Dispose(); } m_textured_font = null; m_systemfont = null; m_sprite = null; m_font_sprite = null; m_line = null; m_font_small = null; m_font = null; // device base.Dispose(); }
/// <summary> /// Postara se o uvolneni alokovane pameti /// </summary> public static void Dispose() { if (!f.Disposed) { f.Dispose(); } if (!background.Disposed) { background.Dispose(); } if (!window.Disposed) { window.Dispose(); } if (!console.Disposed) { console.Dispose(); } }
/// <summary> /// 内部objectを破棄します。 /// </summary> public void Dispose() { foreach (Figure fig in FigureList) { fig.Dispose(); } if (line != null) { line.Dispose(); } if (sprite != null) { sprite.Dispose(); } if (ztex_zbuf != null) { ztex_zbuf.Dispose(); } if (dev_zbuf != null) { dev_zbuf.Dispose(); } if (dev_surface != null) { dev_surface.Dispose(); } if (effect != null) { effect.Dispose(); } if (font != null) { font.Dispose(); } if (device != null) { device.Dispose(); } }
public override void OnSceneCleanup(GameFramework g) { font_small.Dispose(); font_large.Dispose(); UnbindGameController(); }
public virtual void Dispose() { m_Font.Dispose(); m_Font = null; m_Disposed = true; }
public void Render() { if (device == null) { return; } device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0); int wid = Width; // Width of our display window int hit = Height; // Height of our display window. float aspect = (float)wid / (float)hit; // What is the aspect ratio? device.RenderState.ZBufferEnable = false; // We'll not use this feature device.RenderState.Lighting = false; // Or this one... device.RenderState.CullMode = Cull.None; // Or this one... float widP = playingH * aspect; // Total width of window // Static background //device.Transform.Projection = Matrix.OrthoOffCenterLH(0, widP, 0, playingH, 0, 1); // Background moves with player //float winCenter = playerLoc.X; float winCenter = player.P.X; if (winCenter - widP / 2 < 0) { winCenter = widP / 2; } else if (winCenter + widP / 2 > playingW) { winCenter = playingW - widP / 2; } device.Transform.Projection = Matrix.OrthoOffCenterLH(winCenter - widP / 2, winCenter + widP / 2, 0, playingH, 0, 1); //Begin the scene device.BeginScene(); // Render the background background.Render(); // Render the floor polygon //floor.Render(device); // Render all the polygons in the world foreach (Polygon p in world) { p.Render(device); } if (coins.Count >= 1) { foreach (Polygon p in coins) { p.Render(device); } } /*// Render the triangle (later a rectangle) * GraphicsStream gs = vertices.Lock(0, 0, 0); // Lock the vertex list * int clr = Color.FromArgb(255, 0, 0).ToArgb(); * int vertex_clr = Color.FromArgb(0, 255, 0).ToArgb();*/ // To draw a simple rectangle /* gs.Write(new CustomVertex.PositionColored(1, 1, 0, clr)); * gs.Write(new CustomVertex.PositionColored(1, 3, 0, clr)); * gs.Write(new CustomVertex.PositionColored(3, 3, 0, clr)); * // Change the color of one vertex * //gs.Write(new CustomVertex.PositionColored(3, 3, 0, vertex_clr)); * // To draw rectangle * gs.Write(new CustomVertex.PositionColored(3, 1, 0, clr)); */ // To draw the block player /*gs.Write(new CustomVertex.PositionColored(playerLoc.X - 0.1f, playerLoc.Y, 0, clr)); * gs.Write(new CustomVertex.PositionColored(playerLoc.X - 0.1f, playerLoc.Y + 0.5f, 0, clr)); * gs.Write(new CustomVertex.PositionColored(playerLoc.X + 0.1f, playerLoc.Y + 0.5f, 0, clr)); * gs.Write(new CustomVertex.PositionColored(playerLoc.X + 0.1f, playerLoc.Y, 0, clr)); * vertices.Unlock(); * * device.SetStreamSource(0, vertices, 0); * device.VertexFormat = CustomVertex.PositionColored.Format; * // To draw triangle * // device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1); * // To draw rectangle * device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 2);*/ foreach (PolygonTextured p in powerup) { p.Render(device); } foreach (PolygonTextured p in swords) { p.Render(device); } //sword_sprite.Render(device); foreach (Wolverine w in wolverines) { w.Render(device); } flag.Render(device); player.Render(device); //End the scene Sprite sp = new Sprite(device); Microsoft.DirectX.Direct3D.Font font = new Microsoft.DirectX.Direct3D.Font(device, new System.Drawing.Font(System.Drawing.FontFamily.GenericSansSerif, 20f)); font.DrawText(null, "score: " + score, new Point(3, 3), Color.Black); if (game_over == true) { //Microsoft.DirectX.Direct3D.Font font2 = new Microsoft.DirectX.Direct3D.Font(device, new System.Drawing.Font(System.Drawing.FontFamily.GenericSansSerif, 40f)); font.DrawText(null, "You Win! Score:" + score, new Point(200, 200), Color.Black); font.Dispose(); } font.Dispose(); device.EndScene(); device.Present(); }
public void Render1() { dx_device.Clear(ClearFlags.Target | ClearFlags.ZBuffer | ClearFlags.Stencil, Color.Blue, 1.0f, 0); dx_device.BeginScene(); dx_device.SetTexture(0, m_Tex); dx_device.SetTransform(TransformType.World, m_Camera.m_World); dx_device.SetTransform(TransformType.View, m_Camera.m_View); dx_device.SetTransform(TransformType.Projection, m_Camera.m_Projection); // 원래 객체를 그린다. dx_device.RenderState.ShadeMode = ShadeMode.Gouraud; dx_device.RenderState.CullMode = Cull.None; dx_device.RenderState.ZBufferWriteEnable = true; dx_device.RenderState.StencilEnable = false; dx_device.RenderState.AlphaBlendEnable = false; // m_Objects[4].render(dx_device); // 그림자 영역을 그린다. dx_device.RenderState.ZBufferWriteEnable = false; dx_device.RenderState.StencilEnable = true; dx_device.RenderState.ShadeMode = ShadeMode.Flat; dx_device.RenderState.StencilFunction = Compare.Always; dx_device.RenderState.StencilZBufferFail = StencilOperation.Keep; dx_device.RenderState.StencilFail = StencilOperation.Keep; dx_device.RenderState.ReferenceStencil = 1; dx_device.RenderState.StencilMask = -1; dx_device.RenderState.StencilWriteMask = -1; dx_device.RenderState.StencilPass = StencilOperation.Increment; dx_device.RenderState.AlphaBlendEnable = true; dx_device.RenderState.SourceBlend = Blend.Zero; dx_device.RenderState.DestinationBlend = Blend.One; dx_device.Transform.World = m_Camera.m_ShadowWorld; m_Objects[4].render(dx_device); dx_device.Transform.World = m_Camera.m_World; // 원래 객체를 그린다. dx_device.RenderState.ShadeMode = ShadeMode.Gouraud; dx_device.RenderState.CullMode = Cull.None; dx_device.RenderState.ZBufferWriteEnable = true; dx_device.RenderState.StencilEnable = false; dx_device.RenderState.AlphaBlendEnable = false; m_Objects[0].render(dx_device); m_Objects[1].render(dx_device); m_Objects[4].render(dx_device); // 그림자에 해당하는 부분을 다시 그린다. dx_device.RenderState.ZBufferEnable = true; dx_device.RenderState.ZBufferWriteEnable = false; dx_device.RenderState.StencilEnable = true; dx_device.RenderState.AlphaBlendEnable = true; dx_device.RenderState.SourceBlend = Blend.SourceAlpha; dx_device.RenderState.DestinationBlend = Blend.InvSourceAlpha; dx_device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor; dx_device.TextureState[0].ColorArgument2 = TextureArgument.Constant; dx_device.TextureState[0].ColorOperation = TextureOperation.SelectArg2; dx_device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor; dx_device.TextureState[0].AlphaArgument2 = TextureArgument.Diffuse; dx_device.TextureState[0].AlphaOperation = TextureOperation.Modulate; dx_device.RenderState.ReferenceStencil = 1; dx_device.RenderState.StencilFunction = Compare.LessEqual; dx_device.RenderState.StencilPass = StencilOperation.Keep; m_Objects[0].render(dx_device); dx_device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor; dx_device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse; dx_device.TextureState[0].ColorOperation = TextureOperation.Modulate; dx_device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor; dx_device.TextureState[0].AlphaArgument2 = TextureArgument.Diffuse; dx_device.TextureState[0].AlphaOperation = TextureOperation.Modulate; dx_device.RenderState.ShadeMode = ShadeMode.Gouraud; dx_device.RenderState.CullMode = Cull.None; dx_device.RenderState.ZBufferWriteEnable = true; dx_device.RenderState.StencilEnable = false; dx_device.RenderState.AlphaBlendEnable = false; FontDescription desc = new FontDescription(); Microsoft.DirectX.Direct3D.Font fnt = new Microsoft.DirectX.Direct3D.Font(dx_device, desc); fnt.DrawText(null, m_Camera.ToString() + "\n" + m_Cursor.ToString() + "\n" + m_Camera.getPicking(m_Cursor.m_MousePoint, dx_device.Viewport) + "\n" + m_Count, new Point(5, 5), Color.White); m_Count = (m_Count + 1) % 10000; fnt.Dispose(); dx_device.EndScene(); dx_device.Present(); }
// Methods public void Dispose() { _font.Dispose(); }
public void Render1() { dx_device.Clear(ClearFlags.Target | ClearFlags.ZBuffer | ClearFlags.Stencil, Color.Blue, 1.0f, 0); dx_device.BeginScene(); dx_device.SetTexture(0, m_Tex); dx_device.SetTransform(TransformType.World, m_Camera.m_World); dx_device.SetTransform(TransformType.View, m_Camera.m_View); dx_device.SetTransform(TransformType.Projection, m_Camera.m_Projection); // 원래 객체를 그린다. dx_device.RenderState.ShadeMode = ShadeMode.Gouraud; dx_device.RenderState.CullMode = Cull.None; dx_device.RenderState.ZBufferWriteEnable = true; dx_device.RenderState.StencilEnable = false; dx_device.RenderState.AlphaBlendEnable = false; // m_Objects[4].render(dx_device); // 그림자 영역을 그린다. dx_device.RenderState.ZBufferWriteEnable = false; dx_device.RenderState.StencilEnable = true; dx_device.RenderState.ShadeMode = ShadeMode.Flat; dx_device.RenderState.StencilFunction = Compare.Always; dx_device.RenderState.StencilZBufferFail = StencilOperation.Keep; dx_device.RenderState.StencilFail = StencilOperation.Keep; dx_device.RenderState.ReferenceStencil = 1; dx_device.RenderState.StencilMask = -1; dx_device.RenderState.StencilWriteMask = -1; dx_device.RenderState.StencilPass = StencilOperation.Increment; dx_device.RenderState.AlphaBlendEnable = true; dx_device.RenderState.SourceBlend = Blend.Zero; dx_device.RenderState.DestinationBlend = Blend.One; // dx_device.Transform.World = m_Camera.m_ShadowWorld; // m_Objects[4].render(dx_device); // dx_device.Transform.World = m_Camera.m_World; VertexBuffer tmp = m_Walls.m_shadow.BuildShadowVertex(dx_device, m_Camera.m_Position.pos); m_Walls.BuildVertexBuffer(dx_device, m_Camera.m_Position.pos); dx_device.SetStreamSource(0, tmp, 0); dx_device.VertexFormat = tmp.Description.VertexFormat; dx_device.DrawPrimitives(PrimitiveType.TriangleList, 0, m_Walls.m_shadow.m_VertexCount / 3); // 원래 객체를 그린다. dx_device.RenderState.ShadeMode = ShadeMode.Gouraud; dx_device.RenderState.CullMode = Cull.None; dx_device.RenderState.ZBufferWriteEnable = true; dx_device.RenderState.StencilEnable = false; dx_device.RenderState.AlphaBlendEnable = false; m_Objects[0].render(dx_device); m_Objects[1].render(dx_device); m_Walls.render(dx_device); dx_device.RenderState.Lighting = true; dx_device.Material = m_Material; dx_device.Transform.World = Matrix.Scaling(0.1f,2f,0.1f) * Matrix.Translation(m_Camera.m_Position.pos.X, 0, m_Camera.m_Position.pos.Y); m_Mesh.DrawSubset(0); dx_device.Transform.World = m_Camera.m_World; dx_device.RenderState.Lighting = false; // 그림자에 해당하는 부분을 다시 그린다. dx_device.RenderState.ZBufferEnable = true; dx_device.RenderState.ZBufferWriteEnable = false; dx_device.RenderState.StencilEnable = true; dx_device.RenderState.AlphaBlendEnable = true; dx_device.RenderState.SourceBlend = Blend.SourceAlpha; dx_device.RenderState.DestinationBlend = Blend.InvSourceAlpha; dx_device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor; dx_device.TextureState[0].ColorArgument2 = TextureArgument.Constant; dx_device.TextureState[0].ColorOperation = TextureOperation.SelectArg2; dx_device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor; dx_device.TextureState[0].AlphaArgument2 = TextureArgument.Diffuse; dx_device.TextureState[0].AlphaOperation = TextureOperation.Modulate; dx_device.RenderState.ReferenceStencil = 1; dx_device.RenderState.StencilFunction = Compare.LessEqual; dx_device.RenderState.StencilPass = StencilOperation.Keep; m_Objects[0].render(dx_device); dx_device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor; dx_device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse; dx_device.TextureState[0].ColorOperation = TextureOperation.Modulate; dx_device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor; dx_device.TextureState[0].AlphaArgument2 = TextureArgument.Diffuse; dx_device.TextureState[0].AlphaOperation = TextureOperation.Modulate; dx_device.RenderState.ShadeMode = ShadeMode.Gouraud; dx_device.RenderState.CullMode = Cull.None; dx_device.RenderState.ZBufferWriteEnable = true; dx_device.RenderState.StencilEnable = false; dx_device.RenderState.AlphaBlendEnable = false; FontDescription desc = new Microsoft.DirectX.Direct3D.FontDescription(); Microsoft.DirectX.Direct3D.Font fnt = new Microsoft.DirectX.Direct3D.Font(dx_device, desc); fnt.DrawText(null, m_Camera.ToString() + "\n" + m_Walls.m_shadow + "\n" + m_Camera.getPicking(m_Cursor.m_MousePoint, dx_device.Viewport), new Point(5, 5), Color.Aquamarine); fnt.Dispose(); dx_device.EndScene(); dx_device.Present(); }