Exemplo n.º 1
0
        public override void Present()
        {
            GraphicsDevice.Begin();

            // If we made a fake render target to avoid OpenGL limitations on window-provided back buffer, let's copy the rendering result to it
            if (GraphicsDevice.DefaultRenderTarget != GraphicsDevice.windowProvidedRenderTexture)
            {
                GraphicsDevice.Copy(GraphicsDevice.DefaultRenderTarget, GraphicsDevice.windowProvidedRenderTexture);
            }
            OpenTK.Graphics.GraphicsContext.CurrentContext.SwapBuffers();
            GraphicsDevice.End();
        }
Exemplo n.º 2
0
        public override void Present()
        {
            GraphicsDevice.Begin();

            // If we made a fake render target to avoid OpenGL limitations on window-provided back buffer, let's copy the rendering result to it
            if (GraphicsDevice.DefaultRenderTarget != GraphicsDevice.windowProvidedRenderTexture)
            {
                GraphicsDevice.Copy(GraphicsDevice.DefaultRenderTarget, GraphicsDevice.windowProvidedRenderTexture);
            }
            var graphicsContext = ((AndroidGameView)Description.DeviceWindowHandle.NativeHandle).GraphicsContext;

            ((AndroidGraphicsContext)graphicsContext).Swap();

            GraphicsDevice.End();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Copies the content of this buffer from GPU memory to a CPU memory using a specific staging resource.
        /// </summary>
        /// <param name="stagingTexture">The staging buffer used to transfer the buffer.</param>
        /// <param name="toData">To data pointer.</param>
        /// <exception cref="System.ArgumentException">When strides is different from optimal strides, and TData is not the same size as the pixel format, or Width * Height != toData.Length</exception>
        /// <remarks>
        /// This method is only working when called from the main thread that is accessing the main <see cref="GraphicsDevice"/>.
        /// </remarks>
        public void GetData(Buffer stagingTexture, DataPointer toData)
        {
            // Check size validity of data to copy to
            if (toData.Size > this.Description.SizeInBytes)
            {
                throw new ArgumentException("Length of TData is larger than size of buffer");
            }

            // Copy the texture to a staging resource
            if (!ReferenceEquals(this, stagingTexture))
            {
                GraphicsDevice.Copy(this, stagingTexture);
            }

            // Map the staging resource to a CPU accessible memory
            var mappedResource = GraphicsDevice.MapSubresource(stagingTexture, 0, MapMode.Read);

            Utilities.CopyMemory(toData.Pointer, mappedResource.DataBox.DataPointer, toData.Size);
            // Make sure that we unmap the resource in case of an exception
            GraphicsDevice.UnmapSubresource(mappedResource);
        }