/// <summary> /// Restore the font after a device has been reset /// </summary> public void RestoreDeviceObjects(object sender, EventArgs e) { vertexBuffer = new VertexBuffer(typeof(CustomVertex.TransformedColoredTextured), MaxNumfontVertices, device, Usage.WriteOnly | Usage.Dynamic, 0, Pool.Default); // Create the state blocks for rendering text for (int which = 0; which < 2; which++) { device.BeginStateBlock(); device.SetTexture(0, fontTexture); if (isZEnable) { renderState.ZBufferEnable = true; } else { renderState.ZBufferEnable = false; } renderState.AlphaBlendEnable = true; renderState.SourceBlend = Blend.SourceAlpha; renderState.DestinationBlend = Blend.InvSourceAlpha; renderState.AlphaTestEnable = true; renderState.ReferenceAlpha = 0x08; renderState.AlphaFunction = Compare.GreaterEqual; renderState.FillMode = FillMode.Solid; renderState.CullMode = Cull.CounterClockwise; renderState.StencilEnable = false; renderState.Clipping = true; device.ClipPlanes.DisableAll(); renderState.VertexBlend = VertexBlend.Disable; renderState.IndexedVertexBlendEnable = false; renderState.FogEnable = false; renderState.ColorWriteEnable = ColorWriteEnable.RedGreenBlueAlpha; textureState0.ColorOperation = TextureOperation.Modulate; textureState0.ColorArgument1 = TextureArgument.TextureColor; textureState0.ColorArgument2 = TextureArgument.Diffuse; textureState0.AlphaOperation = TextureOperation.Modulate; textureState0.AlphaArgument1 = TextureArgument.TextureColor; textureState0.AlphaArgument2 = TextureArgument.Diffuse; textureState0.TextureCoordinateIndex = 0; textureState0.TextureTransform = TextureTransform.Disable; // REVIEW textureState1.ColorOperation = TextureOperation.Disable; textureState1.AlphaOperation = TextureOperation.Disable; samplerState0.MinFilter = TextureFilter.Point; samplerState0.MagFilter = TextureFilter.Point; samplerState0.MipFilter = TextureFilter.None; if (which == 0) { savedStateBlock = device.EndStateBlock(); } else { drawTextStateBlock = device.EndStateBlock(); } } }