/// <summary> /// Creates a temporary MSBuild content project in memory. /// </summary> private void CreateBuildProject() { string projectPath = Path.Combine(_buildDirectory, "content.contentproj"); string outputPath = Path.Combine(_buildDirectory, "bin"); // Create the build project. _projectRootElement = ProjectRootElement.Create(projectPath); // Include the standard targets file that defines how to build XNA Framework content. _projectRootElement.AddImport("$(MSBuildExtensionsPath)\\Microsoft\\XNA Game Studio\\" + "v4.0\\Microsoft.Xna.GameStudio.ContentPipeline.targets"); _buildProject = new Project(_projectRootElement); _buildProject.SetProperty("XnaPlatform", "Windows"); IOptionsService optionsService = (IOptionsService)_serviceProvider.GetService(typeof(IOptionsService)); _buildProject.SetProperty("XnaProfile", optionsService.GetContentPreviewOptions().Profile.ToString()); _buildProject.SetProperty("XnaFrameworkVersion", XnaConstants.XnaFrameworkVersion); _buildProject.SetProperty("Configuration", "Release"); _buildProject.SetProperty("OutputPath", outputPath); // Hook up our custom error logger. _errorLogger = new ErrorLogger(); _buildParameters = new BuildParameters(ProjectCollection.GlobalProjectCollection); _buildParameters.Loggers = new ILogger[] { _errorLogger }; }
/// <summary> /// Constructor is private, because this is a singleton class: /// client controls should use the public AddRef method instead. /// </summary> public GraphicsDeviceService(IntPtr windowHandle, int width, int height, IServiceProvider serviceProvider) { parameters = new PresentationParameters(); parameters.BackBufferWidth = Math.Max(width, 1); parameters.BackBufferHeight = Math.Max(height, 1); parameters.BackBufferFormat = SurfaceFormat.Color; parameters.DepthStencilFormat = DepthFormat.Depth24; parameters.DeviceWindowHandle = windowHandle; parameters.PresentationInterval = PresentInterval.Immediate; parameters.MultiSampleCount = 4; parameters.IsFullScreen = false; IOptionsService optionsService = (IOptionsService)serviceProvider.GetService(typeof(IOptionsService)); graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, optionsService.GetContentPreviewOptions().Profile, parameters); }
private void RecreateGrid(GraphicsDevice graphicsDevice, IOptionsService optionsService) { _options = optionsService.GetContentPreviewOptions(); _spacing = _options.GridSpacing; _majorLines = _options.MajorLinesEveryNthGridLine; _minorColor = ConvertUtility.ToXnaColor(_options.GridLineMinorColor); _majorColor = ConvertUtility.ToXnaColor(_options.GridLineMajorColor); _axisColor = ConvertUtility.ToXnaColor(_options.GridLineAxisColor); int size = _options.GridSize; _lineBuffer = new VertexBuffer(graphicsDevice, typeof(VertexPositionColor), size * 4, BufferUsage.WriteOnly); VertexPositionColor[] vertices = new VertexPositionColor[size * 4]; int end = (size - 1) / 2; int start = -end; int index = 0; // Lines along z. for (int x = start; x <= end; ++x) { Color color = GetColor(x); vertices[index++] = new VertexPositionColor(new Vector3(GetCoordinate(x), 0, GetCoordinate(start)), color); vertices[index++] = new VertexPositionColor(new Vector3(GetCoordinate(x), 0, GetCoordinate(end)), color); } // Lines along x. for (int z = start; z <= end; ++z) { Color color = GetColor(z); vertices[index++] = new VertexPositionColor(new Vector3(GetCoordinate(start), 0, GetCoordinate(z)), color); vertices[index++] = new VertexPositionColor(new Vector3(GetCoordinate(end), 0, GetCoordinate(z)), color); } _lineBuffer.SetData(vertices); }
private void SetOptions() { _options = _optionsService.GetContentPreviewOptions(); }