/// <summary> /// Creates a new instance of <see cref="RenderTarget2D"/> with format <see cref="SurfaceFormat.Color"/>. /// </summary> /// <param name="renderSystem">Render system used to create the underlying implementation.</param> /// <param name="width">The target width in pixels.</param> /// <param name="height">The target height in pixels.</param> /// <exception cref="System.ArgumentNullException">Thrown if the render system is null.</exception> /// <exception cref="Tesla.Core.TeslaException">Thrown if creating the underlying render target fails.</exception> public RenderTarget2D(IRenderSystemProvider renderSystem, int width, int height) { if (renderSystem == null) { Dispose(); throw new ArgumentNullException("renderSystem", "Render system cannot be null."); } base.RenderSystem = renderSystem; try { _impl = renderSystem.CreateRenderTarget2DImplementation(width, height, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.DiscardContents); } catch (Exception e) { Dispose(); throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e); } }
/// <summary> /// Creates a new instance of <see cref="RenderTarget2D"/>. /// </summary> /// <param name="renderSystem">Render system used to create the underlying implementation.</param> /// <param name="width">The target width in pixels.</param> /// <param name="height">The target height in pixels.</param> /// <param name="genMipMap">True if a mipmap chain should be generated or not.</param> /// <param name="format">The surface format.</param> /// <param name="depthFormat">The depth format for the depth-stencil buffer.</param> /// <param name="multiSampleCount">The number of sample locations for multisampling</param> /// <param name="usage">Sets the render target's behavior.</param> /// <exception cref="System.ArgumentNullException">Thrown if the render system is null.</exception> /// <exception cref="Tesla.Core.TeslaException">Thrown if creating the underlying render target fails.</exception> public RenderTarget2D(IRenderSystemProvider renderSystem, int width, int height, bool genMipMap, SurfaceFormat format, DepthFormat depthFormat, int multiSampleCount, RenderTargetUsage usage) { if (renderSystem == null) { Dispose(); throw new ArgumentNullException("renderSystem", "Render system cannot be null."); } base.RenderSystem = renderSystem; try { _impl = renderSystem.CreateRenderTarget2DImplementation(width, height, genMipMap, format, depthFormat, multiSampleCount, usage); } catch (Exception e) { Dispose(); throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e); } }
/// <summary> /// Creates a new instance of <see cref="RenderTarget2D"/> with format <see cref="SurfaceFormat.Color"/>. /// </summary> /// <param name="width">The target width in pixels.</param> /// <param name="height">The target height in pixels.</param> /// <exception cref="Tesla.Core.TeslaException">Thrown if creating the underlying render target fails or the render /// system was not initialized.</exception> public RenderTarget2D(int width, int height) { IRenderSystemProvider renderSystem = Engine.Services.GetService <IRenderSystemProvider>(); if (renderSystem == null) { Dispose(); throw new TeslaException("Render system provider not set, cannot create graphics resource implementation."); } base.RenderSystem = renderSystem; try { _impl = renderSystem.CreateRenderTarget2DImplementation(width, height, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.DiscardContents); } catch (Exception e) { Dispose(); throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e); } }
/// <summary> /// Creates a new instance of <see cref="RenderTarget2D"/>. /// </summary> /// <param name="width">The target width in pixels.</param> /// <param name="height">The target height in pixels.</param> /// <param name="genMipMap">True if a mipmap chain should be generated or not.</param> /// <param name="format">The surface format.</param> /// <param name="depthFormat">The depth format for the depth-stencil buffer.</param> /// <param name="multiSampleCount">The number of sample locations for multisampling</param> /// <param name="usage">Sets the render target's behavior.</param> /// <exception cref="Tesla.Core.TeslaException">Thrown if creating the underlying render target fails or the render /// system was not initialized.</exception> public RenderTarget2D(int width, int height, bool genMipMap, SurfaceFormat format, DepthFormat depthFormat, int multiSampleCount, RenderTargetUsage usage) { IRenderSystemProvider renderSystem = Engine.Services.GetService <IRenderSystemProvider>(); if (renderSystem == null) { Dispose(); throw new TeslaException("Render system provider not set, cannot create graphics resource implementation."); } base.RenderSystem = renderSystem; try { _impl = renderSystem.CreateRenderTarget2DImplementation(width, height, genMipMap, format, depthFormat, multiSampleCount, usage); } catch (Exception e) { Dispose(); throw new TeslaException("Error creating underlying implementation, see inner exception for details.", e); } }