Пример #1
0
        public BackBuffer(GraphicsDevice graphicsDevice, string name)
        {
            if (graphicsDevice == null)
            {
                throw new ArgumentNullException("graphicsDevice");
            }

            this.graphicsDevice = graphicsDevice;

            Name = name;

            var pp = graphicsDevice.PresentationParameters;
            width = pp.BackBufferWidth;
            height = pp.BackBufferHeight;
            mipMap = true;
            surfaceFormat = pp.BackBufferFormat;
            depthFormat = pp.DepthStencilFormat;
            multiSampleCount = pp.MultiSampleCount;
            renderTargetUsage = pp.RenderTargetUsage;

            renderTargetCount = 1;
            currentIndex = 0;

            activated = false;
            disposed = false;
        }
Пример #2
0
        /// <summary>
        /// Create a RenderTarget2D.
        /// </summary>
        /// <param name="resolution"></param>
        /// <param name="preferredFormat"></param>
        /// <param name="preferredDepthFormat"></param>
        /// <param name="preferredMultiSampleCount"></param>
        /// <param name="usage"></param>
        /// <param name="fill"></param>
        /// <param name="mipMap"></param>
        /// <returns></returns>
        public RenderTarget2D CreateRenderTarget(Resolution resolution
                                                 , SurfaceFormat preferredFormat
                                                 , DepthFormat preferredDepthFormat
                                                 , int preferredMultiSampleCount
                                                 , RenderTargetUsage usage
                                                 , Color?fill  = null
                                                 , bool mipMap = false)
        {
            Color _fill = fill.HasValue ? fill.Value : Color.Transparent;

            var target = new RenderTarget2D(
                GraphicsDevice,
                resolution.Width,
                resolution.Height,
                mipMap,
                preferredFormat,
                preferredDepthFormat,
                preferredMultiSampleCount,
                usage);

            GraphicsDevice.SetRenderTarget(target);
            GraphicsDevice.Clear(_fill);
            GraphicsDevice.SetRenderTarget(null);

            return(target);
        }
Пример #3
0
        /// <summary>
        /// Informs the renderer of a resource this component is generating.
        /// </summary>
        /// <param name="name">The name of the resource.</param>
        /// <param name="isLeftSet"><c>true</c> if this component will leave the render target set on the device; else <c>false</c>.</param>
        /// <param name="finaliser">A cleanup method, called when the resource is no longer needed. <c>null</c> for the default finaliser.</param>
        /// <param name="width">The width of the render target.</param>
        /// <param name="height">The height of the render target.</param>
        /// <param name="surfaceFormat">The surface format of the render target.</param>
        /// <param name="depthFormat">The depth format of the render target.</param>
        /// <param name="multiSampleCount">The multi sample count of the render target.</param>
        /// <param name="mipMap">The number of mip map levels of the render target.</param>
        /// <param name="usage">The render target usage of the render target.</param>
        public void DefineOutput(
            string name,
            bool isLeftSet = true,
            Action <Renderer, RenderTarget2D> finaliser = null,
            int width  = 0,
            int height = 0,
            SurfaceFormat surfaceFormat = SurfaceFormat.Color,
            DepthFormat depthFormat     = DepthFormat.None,
            int multiSampleCount        = 0,
            bool mipMap             = false,
            RenderTargetUsage usage = RenderTargetUsage.DiscardContents)
        {
            var info = new RenderTargetInfo()
            {
                Width            = width,
                Height           = height,
                SurfaceFormat    = surfaceFormat,
                DepthFormat      = depthFormat,
                MultiSampleCount = multiSampleCount,
                MipMap           = mipMap,
                Usage            = usage
            };

            DefineOutput(name, isLeftSet, finaliser, info);
        }
Пример #4
0
 public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
   : base(graphicsDevice, width, height, mipMap, preferredFormat, true)
 {
   RenderTarget2D renderTarget2D = this;
   this.DepthStencilFormat = preferredDepthFormat;
   this.MultiSampleCount = preferredMultiSampleCount;
   this.RenderTargetUsage = usage;
   if (preferredDepthFormat == DepthFormat.None)
     return;
   Threading.BlockOnUIThread((Action) (() =>
   {
     GL.GenRenderbuffers(1, out renderTarget2D.glDepthStencilBuffer);
     GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, renderTarget2D.glDepthStencilBuffer);
     RenderbufferStorage local_0 = RenderbufferStorage.DepthComponent16;
     switch (preferredDepthFormat)
     {
       case DepthFormat.Depth24Stencil8:
         local_0 = RenderbufferStorage.Depth24Stencil8;
         break;
       case DepthFormat.Depth24:
         local_0 = RenderbufferStorage.DepthComponent24;
         break;
       case DepthFormat.Depth16:
         local_0 = RenderbufferStorage.DepthComponent16;
         break;
     }
     if (renderTarget2D.MultiSampleCount == 0)
       GL.RenderbufferStorage(RenderbufferTarget.Renderbuffer, local_0, renderTarget2D.width, renderTarget2D.height);
     else
       GL.RenderbufferStorageMultisample(RenderbufferTarget.Renderbuffer, renderTarget2D.MultiSampleCount, local_0, renderTarget2D.width, renderTarget2D.height);
   }));
 }
Пример #5
0
        protected void DrawReflectionMap(GameTime gameTime)
        {
            // calculate reflection matrix
            Vector3 staticCameraPos    = Vector3.Zero;
            Vector3 staticCameraTarget = new Vector3(10, 0, 10);
            Vector3 staticCameraUp     = Vector3.Up;

            Vector3 reflCameraPosition = camera.Position;

            reflCameraPosition.Y = -camera.Position.Y + waterHeight * 2;
            Vector3 reflTargetPos = camera.Target;

            reflTargetPos.Y = -camera.Target.Y + waterHeight * 2;
            Vector3 cameraRight = -camera.Left;
            Vector3 invUpVector = Vector3.Cross(cameraRight, reflTargetPos - reflCameraPosition);

            //Vector3 invUpVector = Vector3.Up;

            reflectionViewMatrix = Matrix.CreateLookAt(reflCameraPosition, reflTargetPos, invUpVector);

            // draw reflection map
            RenderTargetUsage oldUseage = GraphicsDevice.PresentationParameters.RenderTargetUsage;

            GraphicsDevice.PresentationParameters.RenderTargetUsage = RenderTargetUsage.PreserveContents;
            GraphicsDevice.SetRenderTarget(reflectionRenderTarget);
            GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0);

            customEffect.CurrentTechnique = customEffect.Techniques["MapRefraction"];
            sky.renderer.DrawReflection(gameTime, reflectionViewMatrix, reflCameraPosition);
            customEffect.Parameters["ClipPlane"].SetValue(new Vector4(Vector3.Up, -waterHeight));
            map.renderer.DrawMap(customEffect, reflectionViewMatrix);

            GraphicsDevice.SetRenderTarget(null);
            GraphicsDevice.PresentationParameters.RenderTargetUsage = oldUseage;
        }
Пример #6
0
        public void Resize(int width, int height, bool mipmap = false)
        {
            if (XNARenderTarget == null)
            {
                throw new System.InvalidOperationException("Can't resize. Canvas internal state is invalid.");
            }

            if (width != XNARenderTarget.Width || height != XNARenderTarget.Height)
            {
                SurfaceFormat     format            = XNARenderTarget.Format;
                DepthFormat       depthStencil      = XNARenderTarget.DepthStencilFormat;
                int               multiSampleCount  = XNARenderTarget.MultiSampleCount;
                RenderTargetUsage renderTargetUsage = XNARenderTarget.RenderTargetUsage;

                Texture.Dispose();
                Texture = new Texture(new RenderTarget2D(
                                          Game.Instance.GraphicsDevice,
                                          width,
                                          height,
                                          mipmap,
                                          format,
                                          depthStencil,
                                          multiSampleCount,
                                          renderTargetUsage
                                          ));
            }

            InternalRenderer?.RecalculateProjection();
        }
Пример #7
0
 private void PlatformConstruct(
     GraphicsDevice graphicsDevice, int width, int height, bool mipMap,
     DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage, bool shared)
 {
     graphicsDevice.PlatformCreateRenderTarget(
         this, width, height, mipMap, Format, preferredDepthFormat, preferredMultiSampleCount, usage);
 }
Пример #8
0
        public static ITexture2D New(VideoTypes videoType, IDisposableResource parent, Image image, int width, int height, bool generateMipmaps, MultiSampleTypes multiSampleType, SurfaceFormats surfaceFormat, RenderTargetUsage renderTargetUsage, BufferUsages usage, Loader.LoadedCallbackMethod loadedCallback)
        {
            ITexture2D api = null;

            #if WIN32
            if (videoType == VideoTypes.D3D9) api = new D3D9.Texture2D(parent, image, width, height, generateMipmaps, multiSampleType, surfaceFormat, renderTargetUsage, usage, loadedCallback);
            #endif

            #if WIN32 || WINRT || WP8
            if (videoType == VideoTypes.D3D11) api = new D3D11.Texture2D(parent, image, width, height, generateMipmaps, multiSampleType, surfaceFormat, renderTargetUsage, usage, loadedCallback);
            #endif

            #if WIN32 || OSX || LINUX || iOS || ANDROID || NaCl
            if (videoType == VideoTypes.OpenGL) api = new OpenGL.Texture2D(parent, image, width, height, generateMipmaps, multiSampleType, surfaceFormat, renderTargetUsage, usage, loadedCallback);
            #endif

            #if XNA
            if (videoType == VideoTypes.XNA) api = new XNA.Texture2D(parent, image, width, height, generateMipmaps, multiSampleType, surfaceFormat, renderTargetUsage, usage, loadedCallback);
            #endif

            #if VITA
            if (videoType == VideoTypes.Vita) api = new Vita.Texture2D(parent, image, width, height, generateMipmaps, multiSampleType, surfaceFormat, renderTargetUsage, usage, loadedCallback);
            #endif

            if (api == null) Debug.ThrowError("Texture2DAPI", "Unsuported InputType: " + videoType);
            return api;
        }
Пример #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RenderTargetCube"/> class.
        /// </summary>
        /// <param name="graphicsDevice">The graphics device.</param>
        /// <param name="size">The width and height of a texture cube face in pixels.</param>
        /// <param name="mipMap">
        /// <see langword="true"/> to generate a full mipmap chain; otherwise <see langword="false"/>.
        /// </param>
        /// <param name="preferredFormat">The preferred format of the surface.</param>
        /// <param name="preferredDepthFormat">The preferred format of the depth-stencil buffer.</param>
        /// <param name="preferredMultiSampleCount">The preferred number of multisample locations.</param>
        /// <param name="usage">The usage mode of the render target.</param>
        public RenderTargetCube(
            GraphicsDevice graphicsDevice,
            int size,
            bool mipMap,
            SurfaceFormat preferredFormat,
            DepthFormat preferredDepthFormat,
            int preferredMultiSampleCount,
            RenderTargetUsage usage
            ) : base(
                graphicsDevice,
                size,
                mipMap,
                preferredFormat
                )
        {
            DepthStencilFormat = preferredDepthFormat;
            MultiSampleCount   = Math.Min(
                MathHelper.ClosestMSAAPower(preferredMultiSampleCount),
                graphicsDevice.GLDevice.MaxMultiSampleCount
                );
            RenderTargetUsage = usage;

            // If we don't need a depth buffer then we're done.
            if (preferredDepthFormat == DepthFormat.None)
            {
                return;
            }

            glDepthStencilBuffer = graphicsDevice.GLDevice.GenRenderbuffer(
                size,
                size,
                preferredDepthFormat
                );
        }
Пример #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RenderTargetCube"/> class.
        /// </summary>
        /// <param name="graphicsDevice">The graphics device.</param>
        /// <param name="size">The width and height of a texture cube face in pixels.</param>
        /// <param name="mipMap">
        /// <see langword="true"/> to generate a full mipmap chain; otherwise <see langword="false"/>.
        /// </param>
        /// <param name="preferredFormat">The preferred format of the surface.</param>
        /// <param name="preferredDepthFormat">The preferred format of the depth-stencil buffer.</param>
        /// <param name="preferredMultiSampleCount">The preferred number of multisample locations.</param>
        /// <param name="usage">The usage mode of the render target.</param>
        public RenderTargetCube(
            GraphicsDevice graphicsDevice,
            int size,
            bool mipMap,
            SurfaceFormat preferredFormat,
            DepthFormat preferredDepthFormat,
            int preferredMultiSampleCount,
            RenderTargetUsage usage
            ) : base(
                graphicsDevice,
                size,
                mipMap,
                preferredFormat
                )
        {
            DepthStencilFormat = preferredDepthFormat;
            MultiSampleCount   = preferredMultiSampleCount;
            RenderTargetUsage  = usage;

            // If we don't need a depth buffer then we're done.
            if (preferredDepthFormat == DepthFormat.None)
            {
                return;
            }

            Threading.ForceToMainThread(() =>
            {
                glDepthStencilBuffer = graphicsDevice.GLDevice.GenRenderbuffer(
                    size,
                    size,
                    preferredDepthFormat
                    );
            });
        }
Пример #11
0
		public RenderTarget2D (GraphicsDevice graphicsDevice, int width, int height, bool mipMap, 
			SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
			:base (graphicsDevice, width, height, mipMap, preferredFormat)
		{


#if IPHONE
			if(GraphicsDevice.OpenGLESVersion == MonoTouch.OpenGLES.EAGLRenderingAPI.OpenGLES2)

			{
				GL20.GenFramebuffers(1, ref frameBuffer);
			}
			else
			{
				RenderTargetUsage = usage;
				DepthStencilFormat = preferredDepthFormat;
			}
#elif ANDROID
            if (GraphicsDevice.OpenGLESVersion == OpenTK.Graphics.GLContextVersion.Gles2_0)
            {
                GL20.GenFramebuffers(1, ref frameBuffer);
            }
            else
            {
                RenderTargetUsage = usage;
                DepthStencilFormat = preferredDepthFormat;
            }
#else
				RenderTargetUsage = usage;
				DepthStencilFormat = preferredDepthFormat;
#endif


        }
Пример #12
0
        internal XNAGameAppWrapper(XNALogic logic, Application parent, out Microsoft.Xna.Framework.GamerServices.GamerServicesComponent gamerServicesComponent)
        {
            this.parent = parent;
            this.logic  = logic;

            graphics = new GraphicsDeviceManager(this);
            graphics.PreparingDeviceSettings       += new EventHandler <PreparingDeviceSettingsEventArgs>(PreparingDeviceSettings);
            graphics.MinimumPixelShaderProfile      = ShaderProfile.PS_2_0;
            graphics.MinimumVertexShaderProfile     = ShaderProfile.VS_2_0;
            graphics.PreferredDepthStencilFormat    = DepthFormat.Depth24Stencil8;
            graphics.SynchronizeWithVerticalRetrace = true;

            gamerServicesComponent = null;
            if (parent.ApplicationRequiresGamerServices)
            {
                gamerServicesComponent = new Microsoft.Xna.Framework.GamerServices.GamerServicesComponent((Game)this);
                this.Components.Add(gamerServicesComponent);
            }

#if DEBUG
#if !XBOX360
            Window.Title += " [DEBUG API]";
#endif
#endif
            presentation = RenderTargetUsage.PlatformContents;

            parent.SetWindowSizeAndFormat(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, graphics.PreferredBackBufferFormat, graphics.PreferredDepthStencilFormat);

            parent.SetupGraphicsDeviceManager(graphics, ref presentation);

            //values may have changed in SetupGraphicsDeviceManager
            parent.SetWindowSizeAndFormat(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, graphics.PreferredBackBufferFormat, graphics.PreferredDepthStencilFormat);
        }
Пример #13
0
 public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height, bool mipMap, 
     SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
     : base(graphicsDevice, width, height, mipMap, preferredFormat)
 {
     RenderTargetUsage = usage;
     //allocateOpenGLTexture();
 }
Пример #14
0
 private void PlatformConstruct(
     GraphicsDevice graphicsDevice, bool mipMap,
     DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
 {
     graphicsDevice.PlatformCreateRenderTarget(
         this, Size, Size, mipMap, Format, preferredDepthFormat, preferredMultiSampleCount, usage);
 }
Пример #15
0
        private void PlatformConstruct(GraphicsDevice graphicsDevice, int width, int height, bool mipMap,
            SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
        {
            // Setup the multisampling description.
            var multisampleDesc = new SharpDX.DXGI.SampleDescription(1, 0);
            if (preferredMultiSampleCount > 1)
            {
                multisampleDesc.Count = preferredMultiSampleCount;
                multisampleDesc.Quality = (int)StandardMultisampleQualityLevels.StandardMultisamplePattern;
            }

            // Create a descriptor for the depth/stencil buffer.
            // Allocate a 2-D surface as the depth/stencil buffer.
            // Create a DepthStencil view on this surface to use on bind.
            using (var depthBuffer = new SharpDX.Direct3D11.Texture2D(graphicsDevice._d3dDevice, new Texture2DDescription
            {
                Format = SharpDXHelper.ToFormat(preferredDepthFormat),
                ArraySize = 1,
                MipLevels = 1,
                Width = width,
                Height = height,
                SampleDescription = multisampleDesc,
                BindFlags = BindFlags.DepthStencil,
            }))
            {
                // Create the view for binding to the device.
                _depthStencilView = new DepthStencilView(graphicsDevice._d3dDevice, depthBuffer, new DepthStencilViewDescription()
                {
                    Format = SharpDXHelper.ToFormat(preferredDepthFormat),
                    Dimension = DepthStencilViewDimension.Texture2D
                });
            }
        }
Пример #16
0
 protected override void SetupGraphicsDeviceManager(GraphicsDeviceManager graphics, ref RenderTargetUsage presentation)
 {
     graphics.IsFullScreen = Globals.useFullScreen;
     graphics.PreferredBackBufferWidth = Globals.screenWidth;
     graphics.PreferredBackBufferHeight = Globals.screenHeight;
     base.SetupGraphicsDeviceManager(graphics, ref presentation);
 }
        public IntermediateRenderTarget GetIntermediateTexture(int width, int height, bool mipmap, SurfaceFormat SurfaceFormat, DepthFormat DepthFormat, int preferedMultisampleCount, RenderTargetUsage RenderTargetUsage)
        {
            // Look for a matching rendertarget in the cache
            for (int i = 0; i < intermediateTextures.Count; i++)
            {
                if (intermediateTextures[i].InUse == false
                    && height == intermediateTextures[i].RenderTarget.Height
                    && width == intermediateTextures[i].RenderTarget.Width
                    && preferedMultisampleCount == intermediateTextures[i].RenderTarget.MultiSampleCount
                    && SurfaceFormat == intermediateTextures[i].RenderTarget.Format
                    && DepthFormat == intermediateTextures[i].RenderTarget.DepthStencilFormat
                    && RenderTargetUsage == intermediateTextures[i].RenderTarget.RenderTargetUsage
                    && (mipmap == true && intermediateTextures[i].RenderTarget.LevelCount > 0 || mipmap == false && intermediateTextures[i].RenderTarget.LevelCount == 0)

                    )
                {
                    intermediateTextures[i].InUse = true;
                    return intermediateTextures[i];
                }
            }

            // We didn't find one, let's make one
            IntermediateRenderTarget newTexture = new IntermediateRenderTarget();
            newTexture.RenderTarget = new RenderTarget2D(device,width, height, mipmap, SurfaceFormat,DepthFormat, preferedMultisampleCount, RenderTargetUsage );
            intermediateTextures.Add(newTexture);
            newTexture.InUse = true;
            return newTexture;
        }
Пример #18
0
 /// <summary>
 /// Crée une nouvelle instance de RenderTarget.
 /// </summary>
 public RemoteRenderTarget(GraphicsServer server, int width, int height)
     : base(server)
 {
     m_width  = width;
     m_height = height;
     Usage    = RenderTargetUsage.DiscardContents;
 }
Пример #19
0
        /// <summary>
        /// Initializes a new instance of the OpenGLRenderTarget2D class.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="width">The render target's width in pixels.</param>
        /// <param name="height">The render target's height in pixels.</param>
        /// <param name="usage">A <see cref="RenderTargetUsage"/> value specifying whether the 
        /// render target's data is discarded or preserved when it is bound to the graphics device.</param>
        /// <param name="buffers">The collection of render buffers to attach to the target.</param>
        public OpenGLRenderTarget2D(UltravioletContext uv, Int32 width, Int32 height, RenderTargetUsage usage, IEnumerable<RenderBuffer2D> buffers = null)
            : base(uv)
        {
            Contract.EnsureRange(width > 0, nameof(width));
            Contract.EnsureRange(height > 0, nameof(height));

            // NOTE: If we're in an older version of GLES, we need to use glFramebufferTexture2D()
            glFramebufferTextureIsSupported = !gl.IsGLES || gl.IsVersionAtLeast(3, 2);

            glDrawBuffersIsSupported = !gl.IsGLES2 || gl.IsExtensionSupported("GL_ARB_draw_buffers");
            glDrawBufferIsSupported = !gl.IsGLES;

            var framebuffer = 0u;

            uv.QueueWorkItemAndWait(() =>
            {
                using (OpenGLState.ScopedCreateFramebuffer(out framebuffer))
                {
                    if (buffers != null)
                    {
                        foreach (OpenGLRenderBuffer2D buffer in buffers)
                        {
                            AttachRenderBuffer(buffer);
                        }
                    }
                }
            });

            this.width = width;
            this.height = height;
            this.framebuffer = framebuffer;
            this.renderTargetUsage = usage;
        }
Пример #20
0
        public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height, bool mipMap, 
			SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
            : base(graphicsDevice, width, height, mipMap, preferredFormat)
        {
            RenderTargetUsage = usage;
            DepthStencilFormat = preferredDepthFormat;
        }
Пример #21
0
 public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height, bool mipMap,
                       SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
     : base(graphicsDevice, width, height, mipMap, preferredFormat)
 {
     RenderTargetUsage  = usage;
     DepthStencilFormat = preferredDepthFormat;
 }
Пример #22
0
 public PostProcesses(SurfaceFormat? surface = null, DepthFormat? depth = null, bool mipmap = false, RenderTargetUsage? usage = null)
 {
     FormatSurface = surface;
     FormatDepth   = depth;
     MipMap        = mipmap;
     Usage         = usage;
 }
Пример #23
0
        public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height, bool mipMap,
                              SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
            : base(graphicsDevice, width, height, mipMap, preferredFormat)
        {
#if IPHONE
            if (GraphicsDevice.OpenGLESVersion == MonoTouch.OpenGLES.EAGLRenderingAPI.OpenGLES2)

            {
                GL20.GenFramebuffers(1, ref frameBuffer);
            }
            else
            {
                RenderTargetUsage  = usage;
                DepthStencilFormat = preferredDepthFormat;
            }
#elif ANDROID
            if (GraphicsDevice.OpenGLESVersion == OpenTK.Graphics.GLContextVersion.Gles2_0)
            {
                GL20.GenFramebuffers(1, ref frameBuffer);
            }
            else
            {
                RenderTargetUsage  = usage;
                DepthStencilFormat = preferredDepthFormat;
            }
#else
            RenderTargetUsage  = usage;
            DepthStencilFormat = preferredDepthFormat;
#endif
        }
Пример #24
0
        /// <summary>
        /// インスタンスを生成します。
        /// </summary>
        /// <remarks>
        /// name は、インスタンスで管理する RenderTarget の名前にも設定されます。
        /// 1 つの RenderTarget のみを管理する場合には、name の値がそのまま RenderTarget の名前として設定されます。
        /// 2 つ以上の RenderTarget を管理する場合には、
        /// name の値に各 RenderTarget のインデックスを接尾語とした名前が RenderTarget の名前として設定されます。
        /// </remarks>
        /// <param name="graphicsDevice">GraphicsDevice。</param>
        /// <param name="name">インスタンスを識別するための名前。</param>
        public BackBuffer(GraphicsDevice graphicsDevice, string name)
        {
            if (graphicsDevice == null)
            {
                throw new ArgumentNullException("graphicsDevice");
            }

            this.graphicsDevice = graphicsDevice;

            Name = name;

            var pp = graphicsDevice.PresentationParameters;

            width             = pp.BackBufferWidth;
            height            = pp.BackBufferHeight;
            mipMap            = true;
            surfaceFormat     = pp.BackBufferFormat;
            depthFormat       = pp.DepthStencilFormat;
            multiSampleCount  = pp.MultiSampleCount;
            renderTargetUsage = pp.RenderTargetUsage;

            renderTargetCount = 1;
            currentIndex      = 0;

            activated = false;
            disposed  = false;
        }
Пример #25
0
 public RenderTarget2D(
     GraphicsDevice graphicsDevice, int width, int height, bool mipMap,
     SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat,
     int preferredMultiSampleCount, RenderTargetUsage usage)
     : this(graphicsDevice, width, height, mipMap, preferredFormat,
            preferredDepthFormat, preferredMultiSampleCount, usage, false)
 {
 }
Пример #26
0
		protected override void SetupGraphicsDeviceManager(GraphicsDeviceManager graphics, ref RenderTargetUsage presentation)
		{
			if (graphics != null)
			{
				graphics.PreferredBackBufferWidth = 1280;
				graphics.PreferredBackBufferHeight = 720;
			}
		}
Пример #27
0
 /// <summary>
 /// Crée une nouvelle instance de RenderTarget.
 /// </summary>
 public RemoteRenderTarget(GraphicsServer server, int width, int height, RenderTargetUsage usage)
     : base(server)
 {
     m_width  = width;
     m_height = height;
     Usage    = usage;
     Register();
 }
Пример #28
0
 public CapturedRender(SurfaceFormat format, DepthFormat depthFormat,
                       int multiSampleCount, RenderTargetUsage useage)
 {
     renderTarget = new RenderTarget2D(Common.Device,
                                       (int)Common.ScreenResolution.X,
                                       (int)Common.ScreenResolution.Y,
                                       false, format, depthFormat, multiSampleCount, useage);
 }
Пример #29
0
 /// <summary>
 /// Creates a new instance of <see cref="TextureCubeImplementation"/>, for use as a RenderTarget.
 /// </summary>
 /// <param name="size">The size of each cube map face.</param>
 /// <param name="format">The surface format of the texture.</param>
 /// <param name="depthFormat">The depth-stencil format.</param>
 /// <param name="multiSampleCount">The multisample count.</param>
 /// <param name="usage">The target usage.</param>
 public TextureCubeImplementation(int size, SurfaceFormat format, DepthFormat depthFormat, int multiSampleCount, RenderTargetUsage usage)
 {
     _size             = size;
     _format           = format;
     _depthFormat      = depthFormat;
     _multiSampleCount = multiSampleCount;
     _usage            = usage;
 }
Пример #30
0
 public RenderTargetCube(GraphicsDevice graphicsDevice, int size, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
   : base(graphicsDevice, size, mipMap, preferredFormat, true)
 {
   this.DepthStencilFormat = preferredDepthFormat;
   this.MultiSampleCount = preferredMultiSampleCount;
   this.RenderTargetUsage = usage;
   throw new NotImplementedException();
 }
Пример #31
0
 /// <summary>
 /// Creates a new instance of <see cref="TextureCubeImplementation"/>.
 /// </summary>
 /// <param name="size">The size of each cube map face.</param>
 /// <param name="format">The surface format of the texture.</param>
 public TextureCubeImplementation(int size, SurfaceFormat format)
 {
     _size             = size;
     _format           = format;
     _depthFormat      = DepthFormat.None;
     _multiSampleCount = 0;
     _usage            = RenderTargetUsage.DiscardContents;
 }
Пример #32
0
 /// <summary>
 /// Creates a new instance of <see cref="Texture2DImplementation"/>.
 /// </summary>
 /// <param name="width">The texture width in pixels.</param>
 /// <param name="height">The texture height in pixels.</param>
 /// <param name="format">The surface format.</param>
 public Texture2DImplementation(int width, int height, SurfaceFormat format)
 {
     _width            = width;
     _height           = height;
     _format           = format;
     _depthFormat      = DepthFormat.None;
     _multiSampleCount = 0;
     _usage            = RenderTargetUsage.DiscardContents;
 }
Пример #33
0
        public DrawableRoom(Room room, RenderTargetUsage targetUsage)
        {
            Room = room;

            Target  = new RenderTarget2D(Engine.Instance.GraphicsDevice, room.Width, room.Height, false, SurfaceFormat.Color, DepthFormat.None, 0, targetUsage);
            BGTiles = new TextureMap(room.Width / 8, room.Height / 8);
            FGTiles = new TextureMap(room.Width / 8, room.Height / 8);
            OBTiles = new List <StaticTexture>();
        }
Пример #34
0
 /// <summary>
 /// Creates a new instance of <see cref="Texture2DImplementation"/> for use as a RenderTarget.
 /// </summary>
 /// <param name="width">The texture width in pixels.</param>
 /// <param name="height">The texture height in pixels.</param>
 /// <param name="format">The surface format.</param>
 /// <param name="depthFormat">The depth-stencil format.</param>
 /// <param name="multiSampleCount">The multisample count.</param>
 /// <param name="usage">The target usage.</param>
 public Texture2DImplementation(int width, int height, SurfaceFormat format, DepthFormat depthFormat, int multiSampleCount, RenderTargetUsage usage)
 {
     _width            = width;
     _height           = height;
     _format           = format;
     _depthFormat      = depthFormat;
     _multiSampleCount = multiSampleCount;
     _usage            = usage;
 }
Пример #35
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RenderTargetCube"/> class.
        /// </summary>
        /// <param name="graphicsDevice">The graphics device.</param>
        /// <param name="size">The width and height of a texture cube face in pixels.</param>
        /// <param name="mipMap"><see langword="true"/> to generate a full mipmap chain; otherwise <see langword="false"/>.</param>
        /// <param name="preferredFormat">The preferred format of the surface.</param>
        /// <param name="preferredDepthFormat">The preferred format of the depth-stencil buffer.</param>
        /// <param name="preferredMultiSampleCount">The preferred number of multisample locations.</param>
        /// <param name="usage">The usage mode of the render target.</param>
        public RenderTargetCube(GraphicsDevice graphicsDevice, int size, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
            : base(graphicsDevice, size, mipMap, preferredFormat, true)
        {
            DepthStencilFormat = preferredDepthFormat;
            MultiSampleCount   = preferredMultiSampleCount;
            RenderTargetUsage  = usage;

            PlatformConstruct(graphicsDevice, mipMap, preferredFormat, preferredDepthFormat, preferredMultiSampleCount, usage);
        }
Пример #36
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RenderTargetProperties"/> struct.
 /// </summary>
 /// <param name="type">A value that specifies whether the render target should force hardware or software rendering. A value of <see cref="SharpDX.Direct2D1.RenderTargetType.Default"/> specifies that the render target should use hardware rendering if it is available; otherwise, it uses software rendering. Note that WIC bitmap render targets do not support hardware rendering.</param>
 /// <param name="pixelFormat">The pixel format and alpha mode of the render target. You can use the {{D2D1::PixelFormat}} function to create a pixel format that specifies that Direct2D should select the pixel format and alpha mode for you. For a list of pixel formats and alpha modes supported by each render target, see {{Supported Pixel Formats and Alpha Modes}}.</param>
 /// <param name="dpiX">The horizontal DPI of the render target.  To use the default DPI, set dpiX and dpiY to 0. For more information, see the Remarks section. 	</param>
 /// <param name="dpiY">The vertical DPI of the render target. To use the default DPI, set dpiX and dpiY to 0.  For more information, see the Remarks section. 	</param>
 /// <param name="usage">A value that specifies how the render target is remoted and whether it should be GDI-compatible.  Set to <see cref="SharpDX.Direct2D1.RenderTargetUsage.None"/> to create a render target that is not compatible with GDI and uses Direct3D command-stream remoting if it  is available.</param>
 /// <param name="minLevel">A value that specifies the minimum Direct3D feature level required for hardware rendering. If the specified minimum level is not available, the render target uses software rendering if the type  member is set to <see cref="SharpDX.Direct2D1.RenderTargetType.Default"/>; if  type  is set to to D2D1_RENDER_TARGET_TYPE_HARDWARE, render target creation fails. A value of <see cref="SharpDX.Direct2D1.FeatureLevel.Level_DEFAULT"/> indicates that Direct2D should determine whether the Direct3D feature level of the device is adequate. This field is used only when creating <see cref="WindowRenderTarget"/> and <see cref="DeviceContextRenderTarget"/> objects.	</param>  
 public RenderTargetProperties(RenderTargetType type, PixelFormat pixelFormat, float dpiX, float dpiY, RenderTargetUsage usage, FeatureLevel minLevel)
 {
     Type = type;
     PixelFormat = pixelFormat;
     DpiX = dpiX;
     DpiY = dpiY;
     Usage = usage;
     MinLevel = minLevel;
 }
Пример #37
0
	    public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage, bool shared, int arraySize)
	        : base(graphicsDevice, width, height, mipMap, preferredFormat, SurfaceType.RenderTarget, shared, arraySize)
	    {
            DepthStencilFormat = preferredDepthFormat;
            MultiSampleCount = preferredMultiSampleCount;
            RenderTargetUsage = usage;

            PlatformConstruct(graphicsDevice, width, height, mipMap, preferredFormat, preferredDepthFormat, preferredMultiSampleCount, usage, shared);
	    }
Пример #38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RenderTargetProperties"/> struct.
 /// </summary>
 /// <param name="type">A value that specifies whether the render target should force hardware or software rendering. A value of <see cref="SharpDX.Direct2D1.RenderTargetType.Default"/> specifies that the render target should use hardware rendering if it is available; otherwise, it uses software rendering. Note that WIC bitmap render targets do not support hardware rendering.</param>
 /// <param name="pixelFormat">The pixel format and alpha mode of the render target. You can use the {{D2D1::PixelFormat}} function to create a pixel format that specifies that Direct2D should select the pixel format and alpha mode for you. For a list of pixel formats and alpha modes supported by each render target, see {{Supported Pixel Formats and Alpha Modes}}.</param>
 /// <param name="dpiX">The horizontal DPI of the render target.  To use the default DPI, set dpiX and dpiY to 0. For more information, see the Remarks section.     </param>
 /// <param name="dpiY">The vertical DPI of the render target. To use the default DPI, set dpiX and dpiY to 0.  For more information, see the Remarks section.   </param>
 /// <param name="usage">A value that specifies how the render target is remoted and whether it should be GDI-compatible.  Set to <see cref="SharpDX.Direct2D1.RenderTargetUsage.None"/> to create a render target that is not compatible with GDI and uses Direct3D command-stream remoting if it  is available.</param>
 /// <param name="minLevel">A value that specifies the minimum Direct3D feature level required for hardware rendering. If the specified minimum level is not available, the render target uses software rendering if the type  member is set to <see cref="SharpDX.Direct2D1.RenderTargetType.Default"/>; if  type  is set to to D2D1_RENDER_TARGET_TYPE_HARDWARE, render target creation fails. A value of <see cref="SharpDX.Direct2D1.FeatureLevel.Level_DEFAULT"/> indicates that Direct2D should determine whether the Direct3D feature level of the device is adequate. This field is used only when creating <see cref="WindowRenderTarget"/> and <see cref="DeviceContextRenderTarget"/> objects.	</param>
 public RenderTargetProperties(RenderTargetType type, PixelFormat pixelFormat, float dpiX, float dpiY, RenderTargetUsage usage, FeatureLevel minLevel)
 {
     Type        = type;
     PixelFormat = pixelFormat;
     DpiX        = dpiX;
     DpiY        = dpiY;
     Usage       = usage;
     MinLevel    = minLevel;
 }
Пример #39
0
        public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height, bool mipMap, SurfaceFormat preferredFormat, /*DepthFormat preferredDepthFormat,*/ int preferredMultiSampleCount, RenderTargetUsage usage, bool shared, int arraySize)
            : base(graphicsDevice, width, height, mipMap, QuerySelectedFormat(graphicsDevice, preferredFormat), SurfaceType.RenderTarget, shared, arraySize)
        {
            //            DepthStencilFormat = preferredDepthFormat;
            MultiSampleCount  = graphicsDevice.GetClampedMultisampleCount(preferredMultiSampleCount);
            RenderTargetUsage = usage;

            PlatformConstruct(graphicsDevice, width, height, mipMap, /*preferredDepthFormat,*/ preferredMultiSampleCount, usage, shared);
        }
Пример #40
0
        protected RenderTarget2D GetRenderTarget(RenderTargetUsage targetUsage = RenderTargetUsage.DiscardContents)
        {
            var pp     = Application.GraphicsDevice.PresentationParameters;
            var width  = pp.BackBufferWidth;
            var height = pp.BackBufferHeight;
            var format = pp.BackBufferFormat;

            return(new RenderTarget2D(Application.GraphicsDevice, width, height, false, format, pp.DepthStencilFormat, pp.MultiSampleCount, targetUsage));
        }
Пример #41
0
        /// <summary>
        /// Creates a new instance of the <see cref="RenderTarget2D"/> class.
        /// </summary>
        /// <param name="width">The render target's width in pixels.</param>
        /// <param name="height">The render target's height in pixels.</param>
        /// <param name="usage">A <see cref="RenderTargetUsage"/> value specifying whether the
        /// render target's data is discarded or preserved when it is bound to the graphics device.</param>
        /// <returns>The instance of <see cref="RenderTarget2D"/> that was created.</returns>
        public static RenderTarget2D Create(Int32 width, Int32 height, RenderTargetUsage usage = RenderTargetUsage.DiscardContents)
        {
            Contract.EnsureRange(width > 0, nameof(width));
            Contract.EnsureRange(height > 0, nameof(height));

            var uv = UltravioletContext.DemandCurrent();

            return(uv.GetFactoryMethod <RenderTarget2DFactory>()(uv, width, height, usage));
        }
Пример #42
0
        public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage, bool shared)
            : base(graphicsDevice, width, height, mipMap, preferredFormat, SurfaceType.RenderTarget, shared)
        {
            DepthStencilFormat = preferredDepthFormat;
            MultiSampleCount   = preferredMultiSampleCount;
            RenderTargetUsage  = usage;

            PlatformConstruct(graphicsDevice, width, height, mipMap, preferredFormat, preferredDepthFormat, preferredMultiSampleCount, usage, shared);
        }
Пример #43
0
		public RenderTarget2D (GraphicsDevice graphicsDevice, int width, int height, bool mipMap,
         					   SurfaceFormat format, DepthFormat depthFormat, int multiSampleCount,
		                       RenderTargetUsage usage)
			:base(graphicsDevice, width, height,0, TextureUsage.None, format)
		{				
			
			allocateOpenGLTexture();
			
		}
Пример #44
0
        internal XNAWinFormsHostAppWrapper(XNALogic logic, Application parent, WinFormsHostControl host)
        {
            this.parent = parent;
            this.logic  = logic;

            this.control = host;

            System.Windows.Forms.Control parentControl = this.control;
            while (parentControl != null)
            {
                if (parentControl is System.Windows.Forms.Form)
                {
                    this.parentForm = (System.Windows.Forms.Form)parentControl;
                    break;
                }
                parentControl = parentControl.Parent;
            }
            if (parentForm == null)
            {
                throw new ArgumentException("Unable to find Parent Form for display handle");
            }

            parentForm.MouseWheel += new System.Windows.Forms.MouseEventHandler(parentControl_MouseWheel);
            parentForm.FormClosed += new System.Windows.Forms.FormClosedEventHandler(parentForm_FormClosed);

            formsDeviceService = new WinFormsHostGraphicsDeviceService(this, this.control.ClientSize.Width, this.control.ClientSize.Height);

            services = new GameServiceContainer();
            services.AddService(typeof(IGraphicsDeviceService), formsDeviceService);
            services.AddService(typeof(IGraphicsDeviceManager), formsDeviceService);

            presentation = RenderTargetUsage.PlatformContents;
            content      = new ContentManager(services);

            int           width  = 0;
            int           height = 0;
            SurfaceFormat format = SurfaceFormat.Color;

            width  = control.ClientSize.Width;
            height = control.ClientSize.Height;

            parent.SetWindowSizeAndFormat(width, height, format, DepthFormat.Depth24Stencil8);

            parent.SetupGraphicsDeviceManager(null, ref presentation);

            formsDeviceService.CreateDevice(presentation, host);

            host.SetApplication(parent, this, formsDeviceService);

            host.BeginInvoke((EventHandler) delegate
            {
                parent.SetGraphicsDevice(GraphicsDevice);
                logic.Initialise();
                logic.LoadContent();
            });
        }
Пример #45
0
 public static RenderTarget2D CreateRenderTarget(int width, int height, SurfaceFormat colorFormat, DepthFormat depthFormat,
                                                 RenderTargetUsage usage)
 {
     if (!m_AllowNonPower2Textures)
     {
         width  = CCUtils.CCNextPOT(width);
         height = CCUtils.CCNextPOT(height);
     }
     return(new RenderTarget2D(graphicsDevice, width, height, false, colorFormat, depthFormat, 0, usage));
 }
            public RenderTargetOperation(RenderTarget2D renderTarget, GraphicsDevice graphicsDevice, Color backgroundColor)
            {
                _graphicsDevice            = graphicsDevice;
                _viewport                  = _graphicsDevice.Viewport;
                _previousRenderTargetUsage = _graphicsDevice.PresentationParameters.RenderTargetUsage;

                _graphicsDevice.PresentationParameters.RenderTargetUsage = RenderTargetUsage.PreserveContents;
                _graphicsDevice.SetRenderTarget(renderTarget);
                _graphicsDevice.Clear(backgroundColor);
            }
            public RenderTargetOperation(RenderTarget2D renderTarget, GraphicsDevice graphicsDevice, Color backgroundColor)
            {
                _graphicsDevice = graphicsDevice;
                _viewport = _graphicsDevice.Viewport;
                _previousRenderTargetUsage = _graphicsDevice.PresentationParameters.RenderTargetUsage;

                _graphicsDevice.PresentationParameters.RenderTargetUsage = RenderTargetUsage.PreserveContents;
                _graphicsDevice.SetRenderTarget(renderTarget);
                _graphicsDevice.Clear(backgroundColor);
            }
Пример #48
0
 private void PlatformConstruct(GraphicsDevice graphicsDevice, int width, int height, bool mipMap,
     SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage, bool shared)
 {
     Threading.BlockOnUIThread(() =>
     {
         graphicsDevice.PlatformCreateRenderTarget(this, width, height, mipMap, preferredFormat, preferredDepthFormat, preferredMultiSampleCount, usage);
     });
     
     
 }
Пример #49
0
 protected virtual bool InitWithWidthAndHeight(int w, int h, SurfaceFormat colorFormat, DepthFormat depthFormat, RenderTargetUsage usage)
 {
     m_Width = (int)Math.Ceiling(w * CCMacros.CCContentScaleFactor());
     m_Height = (int)Math.Ceiling(h * CCMacros.CCContentScaleFactor());
     m_ColorFormat = colorFormat;
     m_DepthFormat = depthFormat;
     m_Usage = usage;
     MakeTexture();
     return true;
 }
Пример #50
0
 public RenderTargetInfo(int width, int height, SurfaceFormat format, DepthFormat depthFormat, int multiSampleCount, bool mipMap, RenderTargetUsage usage)
 {
     Width = width;
     Height = height;
     SurfaceFormat = format;
     DepthFormat = depthFormat;
     MultiSampleCount = multiSampleCount;
     MipMap = mipMap;
     Usage = usage;
 }
        /// <summary>
        /// Create a RenderTarget with a given RenderTargetUsage
        /// </summary>
        /// <param name="graphicsDevice"></param>
        /// <param name="renderTargetUsage"></param>
        /// <returns></returns>
        public static RenderTarget2D CreateFullscreenRenderTarget(this GraphicsDevice graphicsDevice, RenderTargetUsage renderTargetUsage)
        {
            PresentationParameters pp = graphicsDevice.PresentationParameters;
            SurfaceFormat format = pp.BackBufferFormat;
            int width = pp.BackBufferWidth;
            int height = pp.BackBufferHeight;

            return new RenderTarget2D(graphicsDevice, width, height, false, format,
                                      pp.DepthStencilFormat, pp.MultiSampleCount,
                                      renderTargetUsage);
        }
Пример #52
0
        private void PlatformConstruct(GraphicsDevice graphicsDevice, int width, int height, bool mipMap,
            SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage, bool shared)
        {
            _frameBuffer = new FrameBuffer();     
            _frameBuffer.SetColorTarget(_texture2D,0);

            // If we don't need a depth buffer then we're done.
            if (preferredDepthFormat == DepthFormat.None)
                return;

            throw new NotImplementedException();
        }
Пример #53
0
		public RenderTarget3D(GraphicsDevice graphicsDevice, int width, int height, int depth, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
			:base (graphicsDevice, width, height, depth, mipMap, preferredFormat, true)
		{
			DepthStencilFormat = preferredDepthFormat;
			MultiSampleCount = preferredMultiSampleCount;
			RenderTargetUsage = usage;

            // If we don't need a depth buffer then we're done.
            if (preferredDepthFormat == DepthFormat.None)
                return;

            PlatformConstruct(graphicsDevice, width, height, mipMap, preferredFormat, preferredDepthFormat, preferredMultiSampleCount, usage);
        }
Пример #54
0
 private void PlatformConstruct(
     GraphicsDevice graphicsDevice, 
     int width, 
     int height, 
     bool mipMap,
     SurfaceFormat preferredFormat, 
     DepthFormat preferredDepthFormat,
     int preferredMultiSampleCount,
     RenderTargetUsage usage, 
     bool shared)
 {
     throw new NotImplementedException();
 }
Пример #55
0
        public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height, int numberLevels, SurfaceFormat format,
                              MultiSampleType multiSampleType, int multiSampleQuality, RenderTargetUsage usage)
        {
            this.graphicsDevice = graphicsDevice;
			this.width = width;
			this.height = height;
			this.multiSampleType = multiSampleType;
			this.multiSampleQuality = multiSampleQuality;
			this.renderTargetUsage = usage;
			this.numLevels = numberLevels;
			
			texture = new Texture2D(graphicsDevice, width, height, numberLevels, TextureUsage.None, format);
			
			initGL();
        }
Пример #56
0
        /// <summary>
        /// Allows child class to specify the surface type, eg: a swap chain.
        /// </summary>        
        protected RenderTarget2D(GraphicsDevice graphicsDevice,
                        int width,
                        int height,
                        bool mipMap,
                        SurfaceFormat format,
                        DepthFormat depthFormat,
                        int preferredMultiSampleCount,
                        RenderTargetUsage usage,
                        SurfaceType surfaceType)
            : base(graphicsDevice, width, height, mipMap, format, surfaceType)
        {
            DepthStencilFormat = depthFormat;
            MultiSampleCount = preferredMultiSampleCount;
            RenderTargetUsage = usage;
		}
Пример #57
0
		public RenderTarget3D(GraphicsDevice graphicsDevice, int width, int height, int depth, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
			:base (graphicsDevice, width, height, depth, mipMap, preferredFormat, true)
		{
			DepthStencilFormat = preferredDepthFormat;
			MultiSampleCount = preferredMultiSampleCount;
			RenderTargetUsage = usage;

            // If we don't need a depth buffer then we're done.
            if (preferredDepthFormat == DepthFormat.None)
                return;

#if DIRECTX

            // Setup the multisampling description.
            var multisampleDesc = new SharpDX.DXGI.SampleDescription(1, 0);
            if ( preferredMultiSampleCount > 1 )
            {
                multisampleDesc.Count = preferredMultiSampleCount;
                multisampleDesc.Quality = (int)StandardMultisampleQualityLevels.StandardMultisamplePattern;
            }

            // Create a descriptor for the depth/stencil buffer.
            // Allocate a 2-D surface as the depth/stencil buffer.
            // Create a DepthStencil view on this surface to use on bind.
            using (var depthBuffer = new SharpDX.Direct3D11.Texture2D(graphicsDevice._d3dDevice, new Texture2DDescription
            {
                Format = SharpDXHelper.ToFormat(preferredDepthFormat),
                ArraySize = 1,
                MipLevels = 1,
                Width = width,
                Height = height,
                SampleDescription = multisampleDesc,
                BindFlags = BindFlags.DepthStencil,
            }))
            {
                // Create the view for binding to the device.
                _depthStencilView = new DepthStencilView(graphicsDevice._d3dDevice, depthBuffer, new DepthStencilViewDescription()
                { 
                    Format = SharpDXHelper.ToFormat(preferredDepthFormat),
                    Dimension = DepthStencilViewDimension.Texture2D
                });
            }

#endif // DIRECTX
        }
Пример #58
0
 public Texture2D(IDisposableResource parent, string filename, int width, int height, bool generateMipmaps, MultiSampleTypes multiSampleType, SurfaceFormats surfaceFormat, RenderTargetUsage renderTargetUsage, BufferUsages usage, Loader.LoadedCallbackMethod loadedCallback)
     : base(parent)
 {
     Image.New(filename, false,
     delegate (object sender, bool succeeded)
     {
         if (succeeded)
         {
             var image = (Image)sender;
             init(parent, image, image.Size.Width, image.Size.Height, generateMipmaps, MultiSampleTypes.None, image.SurfaceFormat, RenderTargetUsage.PlatformDefault, usage, false, loadedCallback);
         }
         else
         {
             FailedToLoad = true;
             Dispose();
             if (loadedCallback != null) loadedCallback(this, false);
         }
     });
 }
Пример #59
0
        public RenderTarget2D(GraphicsDevice graphicsDevice, int width, int height, bool mipMap,
                               SurfaceFormat format, DepthFormat depthFormat, int multiSampleCount,
                               RenderTargetUsage usage)
            : base(graphicsDevice, width, height, false, format)
        {
            //if (GraphicsDevice.openGLESVersion == MonoTouch.OpenGLES.EAGLRenderingAPI.OpenGLES2)
            if (GraphicsDevice.openGLESVersion ==  GLContextVersion.Gles2_0)
            {
                GL20.GenFramebuffers(1, ref framebuffer);

                //GL20.GenTextures(1, ref framebuffer);
                //GL20.TexImage2D(All20.Texture2D, 0, (int)All20.Rgba, width, height, 100, All20.Rgba, All20.UnsignedByte, IntPtr.Zero);
                //Android.Opengl.GLES20.Frame
                //FIX:Tamaño del Framebuffer;
                //GL20.TexImage2D(All20.Texture2D, 0, (int)All20.Rgba, width, height, 0, All20.Rgba, All20.UnsignedByte, IntPtr.Zero);

            }
            else
                allocateOpenGLTexture();
        }
Пример #60
0
        public RenderTarget CreateRenderTarget(SharpDX.Direct2D1.FeatureLevel PFeatureLevel, PixelFormat PPixelFormat, RenderTargetType PRenderTargetType, RenderTargetUsage PRenderTargetUsage, Surface PBackBuffer, FactoryD2D PFactory)
        {
            this._FeatureLevel = PFeatureLevel;
            this._PixelFormat = PPixelFormat;
            this._RenderType = PRenderTargetType;
            this._RenderUsage = PRenderTargetUsage;
            _DPI = PFactory.DesktopDpi;

            _RenderTarget = new RenderTarget(PFactory, PBackBuffer, new RenderTargetProperties()
            {
                DpiX = _DPI.Width,
                DpiY = _DPI.Height,
                MinLevel = _FeatureLevel,
                PixelFormat = _PixelFormat,
                Type = _RenderType,
                Usage= _RenderUsage

            });

            return _RenderTarget;
        }