Ejemplo n.º 1
0
        void renderScene(IDeviceContext ic, ITextureView swapChainRgb, ITextureView swapChainDepthStencil)
        {
            ic.SetRenderTarget(swapChainRgb, swapChainDepthStencil, ResourceStateTransitionMode.Transition);

            // Clear the back buffer
            ic.ClearRenderTarget(swapChainRgb, clearColor);
            ic.ClearDepthStencil(swapChainDepthStencil, ClearDepthStencilFlags.DepthFlag, 1.0f, 0);

            // Map the buffer and write current world-view-projection matrix
            Matrix4x4 transposed = worldViewProjMatrix.transposed();

            ic.writeBuffer(vsConstants, ref transposed);

            // Bind vertex and index buffers
            ic.SetVertexBuffer(0, cubeVertexBuffer, 0);
            ic.SetIndexBuffer(cubeIndexBuffer, 0);

            // Set the pipeline state
            ic.SetPipelineState(pipelineState);
            // Commit shader resources. RESOURCE_STATE_TRANSITION_MODE_TRANSITION mode makes sure that resources are transitioned to required states.
            ic.CommitShaderResources(resourceBinding);

            DrawIndexedAttribs draw = new DrawIndexedAttribs(false)
            {
                IndexType  = GpuValueType.Uint16,
                NumIndices = 36,
                Flags      = DrawFlags.VerifyAll
            };

            ic.DrawIndexed(ref draw);
        }
Ejemplo n.º 2
0
        protected override void render(ITextureView swapChainRgb, ITextureView swapChainDepthStencil)
        {
            iDrawDevice dev  = context.drawDevice;
            Rect        rect = new Rect(Vector2.Zero, dev.viewportSize);

            rect = rect.deflate(32, 32);

            using (var dc = dev.begin(swapChainRgb, swapChainDepthStencil, backgroundColor))
            {
                Matrix3x2 imageRotation = rotationMatrix(dev.viewportSize, -0.11f);
                Matrix3x2 trans         = Matrix3x2.CreateTranslation(0, -70);
                dc.transform.push(imageRotation * trans);
                dc.drawText("Hello World", comicSans.font, rect, black, background);
                dc.transform.pop();

                // rect.top += dev.dpiScaling.mulUnits * comicSans.font.lineHeightPixels + 12;
                rect.top += dev.dpiScaling.mulUnits * comicSans.font.lineHeightPixels + 24;

                CSize lipsumSize = dc.measureText(lipsum, rect.width, defaultSerif.font);
                dc.fillRectangle(pixelsRectangle(dev, rect.topLeft, lipsumSize), white);
                dc.drawText(lipsum, defaultSerif.font, rect, black, white); return;

                CSize consoleSize = dc.measureConsoleText(lipsum, 80, 14);

                // Apparently, when FreeType measures fonts it allocates height on the top for diacritic combining characters.
                Vector2 paddingTopLeft     = new Vector2(12, 2);
                Vector2 paddingBottomRight = new Vector2(12, 12);
                Vector2 size        = consoleSize.asFloat * dev.dpiScaling.mulUnits;
                Rect    consoleRect = new Rect(rect.topLeft, rect.topLeft + size + paddingTopLeft + paddingBottomRight);

                dc.fillRectangle(consoleRect, black);

                dc.drawConsoleText(lipsum, 80, 14, rect.topLeft + paddingTopLeft, green, black);
            }
        }
Ejemplo n.º 3
0
        void renderScene(IDeviceContext ic, ITextureView swapChainRgb, ITextureView swapChainDepthStencil)
        {
            // ConsoleLogger.logDebug( "SpinningTeapot.render" );

            ic.SetRenderTarget(swapChainRgb, swapChainDepthStencil, ResourceStateTransitionMode.Transition);

            // Clear the back buffer
            ic.ClearRenderTarget(swapChainRgb, clearColor);
            ic.ClearDepthStencil(swapChainDepthStencil, ClearDepthStencilFlags.DepthFlag, 1.0f, 0, ResourceStateTransitionMode.Transition);

            if (resources.haveMesh)
            {
                Matrix4x4 world     = teapotWorld * Matrix4x4.CreateFromQuaternion(extraRotation * motion.rotation);
                Matrix4x4 view      = Matrix4x4.CreateTranslation(0, 0, 5);
                Vector3   cameraPos = new Vector3(0, -3, 0);
                view      = DiligentMatrices.createLookAt(cameraPos, Vector3.Zero, Vector3.UnitZ);
                worldView = world * view;

                float NearPlane = 0.1f;
                float FarPlane  = 100;
                // Projection matrix differs between DX and OpenGL
                Matrix4x4 projection = DiligentMatrices.createPerspectiveFieldOfView(0.25f * MathF.PI * motion.zoomFactor, context.aspectRatio, NearPlane, FarPlane, isOpenGlDevice);

                resources.draw(ic, ref worldView, ref projection);
            }
        }
Ejemplo n.º 4
0
        void iSwapChain.end(bool replaceContent)
        {
            RenderTarget rt = end();

            if (replaceContent)
            {
                rt.replace(context, rtv, dsv);
                // ConsoleLogger.logDebug( "SwapChainBase.end replaced render target content" );
            }
            else
            {
                if (null != blender && blender.samplesCount != 0 && blender.samplesCount != sampleCount)
                {
                    ComUtils.clear(ref blender);
                }

                if (null == blender)
                {
                    using (var dev = context.renderContext.device)
                        blender = new Blender(context, dev, sampleCount);
                }
                rt.blend(context, rtv, dsv, blender);
            }
            rtv = dsv = null;
        }
Ejemplo n.º 5
0
        protected override void render(ITextureView swapChainRgb, ITextureView swapChainDepthStencil)
        {
            if (null == image)
            {
                return;
            }

            var  dev     = context.drawDevice;
            Rect rcImage = viewboxController.getImageBox();

            using (var dc = context.drawDevice.begin(swapChainRgb, swapChainDepthStencil, background))
            {
                Matrix3x2 imageRotation = rotationMatrix(dev.viewportSize, rotationAngle);
                dc.transform.push(imageRotation);

                image.render(dc, rcImage, boxesOpacity);

                if (customClipping)
                {
                    dc.transform.pushIdentity();
                    var brush = dev.createSolidBrush(ConsoleColor.Magenta);
                    dc.drawRectangle(customClippingRect.viewportFromClipSpace(dev.viewportSize), brush, 2);
                }
            }
            printFps();
        }
Ejemplo n.º 6
0
        public static CursorTexture load(IRenderDevice renderDevice, byte[] payload, CursorFile.ImageInfo info)
        {
            BITMAPINFOHEADER header = new BITMAPINFOHEADER();
            int bihSize             = Marshal.SizeOf <BITMAPINFOHEADER>();

            payload.AsSpan().Slice(0, bihSize).CopyTo(MiscUtils.asSpan(ref header));

            if (bihSize == header.biSize)
            {
                bool         monochrome;
                ITextureView texture = loadBmp(renderDevice, payload, ref header, info.size, out monochrome);
                if (monochrome)
                {
                    return(new MonochromeCursorTexture(texture, info.size, info.hotspot));
                }
                else
                {
                    return(new StaticCursorTexture(texture, info.size, info.hotspot));
                }
            }

            if (header.biSize == 0x474E5089)               // "‰PNG" magic number
            {
                return(new StaticCursorTexture(loadPng(renderDevice, payload), info.size, info.hotspot));
            }

            throw new ArgumentException("LoadCursor.load only supports BMP or PNG images");
        }
Ejemplo n.º 7
0
        public void replace(Context context, ITextureView destRgb, ITextureView destDepth)
        {
            var ic = context.context;

            ic.SetRenderTarget(destRgb, destDepth);
            using (var rtt = destRgb.GetTexture())
                resolve(ic, rtt, texture);
        }
Ejemplo n.º 8
0
        public IShaderResourceBinding bindSource(ITextureView source)
        {
            var bindings = pipelineState.CreateShaderResourceBinding(true);

            using (var textureVariable = bindings.GetVariableByName(ShaderType.Pixel, textureVarName))
                textureVariable.Set(source);
            return(bindings);
        }
Ejemplo n.º 9
0
 public iImmediateDrawContext begin(ref Matrix3x2 rootTransform, SwapChainFormats swapFormat, ITextureView rgbTarget, bool opaqueColor)
 {
     this.rgbTarget     = rgbTarget;
     this.rootTransform = rootTransform;
     transform.clear();
     cleared = opaqueColor;
     return(this);
 }
Ejemplo n.º 10
0
        private void ViewModeModelOnPropertyChanged(object sender, PropertyChangedEventArgs args)
        {
            switch (args.PropertyName)
            {
            case nameof(DisplayModel.ActiveView):
                var disable = models.GlContext.Enable();

                try
                {
                    currentView.Dispose();
                    currentView = null;
                    switch (models.Display.ActiveView)
                    {
                    case DisplayModel.ViewMode.Single:
                        currentView = new SingleTextureView(models);
                        break;

                    case DisplayModel.ViewMode.Polar:
                        currentView = new PolarTextureView(models);
                        break;

                    case DisplayModel.ViewMode.CubeMap:
                        currentView = new CubeTextureView(models);
                        break;

                    case DisplayModel.ViewMode.CubeCrossView:
                        currentView = new CubeCrossTextureView(models);
                        break;

                    default:
                        currentView = new EmptyView();
                        break;
                    }

                    models.GlContext.RedrawFrame();
                }
                catch (Exception e)
                {
                    App.ShowErrorDialog(models.App.Window, e.Message);
                }
                finally
                {
                    if (disable)
                    {
                        models.GlContext.Disable();
                    }
                }
                break;

            case nameof(DisplayModel.ActiveLayer):
            case nameof(DisplayModel.ActiveMipmap):
            case nameof(DisplayModel.Zoom):
            case nameof(DisplayModel.Aperture):
                models.GlContext.RedrawFrame();
                break;
            }
        }
Ejemplo n.º 11
0
 public Nv12Texture(ITexture texture)
 {
     this.texture = texture;
     view         = texture.GetDefaultView(TextureViewType.ShaderResource);
     if (null == view)
     {
         throw new ApplicationException("The NV12 texture doesn't have a shader resource view");
     }
 }
Ejemplo n.º 12
0
        ITextureView iSwapChain.begin(ITextureView rtv, ITextureView dsv, Vector4 clearColor)
        {
            var ic = context.context;

            ic.SetRenderTarget(rtv, dsv);
            if (clearColor.isNotTransparent())
            {
                ic.ClearRenderTarget(rtv, clearColor);
            }
            ic.ClearDepthStencil(dsv, ClearDepthStencilFlags.DepthFlag, 1, 0);
            return(rtv);
        }
Ejemplo n.º 13
0
        public PaletteTexture(Context context)
        {
            this.context = context;
            var desc = textureDesc(1);

            using (var dev = context.device)
                texture = dev.CreateTexture(ref desc, "Palette");
            m_textureView = texture.GetDefaultView(TextureViewType.ShaderResource);
            textureRows   = 1;

            // Add just a few hardcoded colors, with names matching eNamedColor enum
            Palette.PredefinedPaletteEntries.initPalette(colorIndices);
        }
Ejemplo n.º 14
0
        public override void render(IDeviceContext ic)
        {
            ITextureView nv12 = source.dequeueTexture();

            try
            {
                drawTriangle(ic, nv12);
            }
            finally
            {
                source.releaseTexture();
            }
        }
Ejemplo n.º 15
0
        void updateTexture()
        {
            int newLength = colorIndices.Count;

            if (newLength <= (textureRows << 8))
            {
                // Still writing the same row
                updateRange(writtenColorsCount, colorIndices.Count);
                writtenColorsCount = colorIndices.Count;
                return;
            }

            // Filled a row, resize the texture
            int capacity = textureRows << 8;

            if (writtenColorsCount != capacity)
            {
                updateRange(writtenColorsCount, capacity);
                writtenColorsCount = capacity;
            }

            int      newHeight = (newLength >> 8) + 1;
            ITexture newTexture;

            using (var dev = context.device)
            {
                var desc = textureDesc(newHeight);
                newTexture = dev.CreateTexture(ref desc, "Palette");
            }

            context.context.copyTexture(newTexture, texture);
            texture.Dispose();
            m_textureView.Dispose();
            texture       = newTexture;
            m_textureView = newTexture.GetDefaultView(TextureViewType.ShaderResource);

            while (newLength >= writtenColorsCount + 0x100)
            {
                int lineEnd = writtenColorsCount + 0x100;
                updateRange(writtenColorsCount, lineEnd);
                writtenColorsCount = lineEnd;
            }

            updateRange(writtenColorsCount, newLength);
            writtenColorsCount = newLength;

            foreach (var sub in textureResized)
            {
                sub();
            }
        }
Ejemplo n.º 16
0
        protected void drawTriangle(IDeviceContext ic, ITextureView textureView)
        {
            ic.SetPipelineState(pipelineState);
            textureVariable.Set(textureView);
            ic.CommitShaderResources(binding);
            ic.setVertexBuffer(vertexBuffer);
            DrawAttribs draw = new DrawAttribs(false)
            {
                NumVertices = 3,
                Flags       = DrawFlags.VerifyAll
            };

            ic.Draw(ref draw);
        }
Ejemplo n.º 17
0
        public void blend(Context context, ITextureView destRgb, ITextureView destDepth, Blender blender)
        {
            // BTW, the ability to read from multi-sampled textures appeared in GLES 3.1, just in time:
            // https://www.khronos.org/registry/OpenGL-Refpages/es3.1/html/texelFetch.xhtml

            if (null == blenderBinding)
            {
                using (var resourceView = texture.GetDefaultView(TextureViewType.ShaderResource))
                    blenderBinding = blender.bindSource(resourceView);
            }

            var ic = context.context;

            ic.SetRenderTarget(destRgb, destDepth);
            blender.blend(ic, blenderBinding);
        }
Ejemplo n.º 18
0
        /// <summary>Decode frames of the specified format index, and upload them to VRAM.</summary>
        public AnimatedCursorTexture load(IRenderDevice device, Stream stream, string name, int formatIndex = 0)
        {
            if (formatIndex < 0 || formatIndex >= formats.Length)
            {
                throw new ArgumentOutOfRangeException();
            }

            iTextureArrayData data;

            switch (formats[formatIndex].format)
            {
            case eFormat.Bitmap:
                data = new AniBitmaps(stream, this.frames, formatIndex);
                break;

            default:
                throw new NotImplementedException();
            }
            CSize size   = formats[formatIndex].size;
            int   frames = data.data.Length;

            ITexture textureArray;

            using ( data )
            {
                TextureDesc desc = new TextureDesc(false);
                desc.Type             = ResourceDimension.Tex2dArray;
                desc.Size             = size;
                desc.ArraySizeOrDepth = (uint)frames;
                desc.Format           = data.format;
                desc.Usage            = Usage.Static;
                desc.BindFlags        = BindFlags.ShaderResource;

                textureArray = device.CreateTexture(ref desc, data.data, (uint)frames, name);
            }

            ITextureView view  = textureArray.GetDefaultView(TextureViewType.ShaderResource);
            double       ticks = TimeSpan.TicksPerSecond;

            ticks /= 60;
            ticks *= header.JifRate;
            ticks  = Math.Round(ticks);
            TimeSpan duration = TimeSpan.FromTicks((long)ticks);
            CPoint   hotspot  = this.frames[0].images[formatIndex].hotspot;

            return(new AnimatedCursorTexture(view, size, hotspot, frames, duration));
        }
Ejemplo n.º 19
0
        public RenderTarget(Context context, CSize size, TextureFormat format, int sampleCount, string name)
        {
            this.size = size;

            TextureDesc desc = new TextureDesc(false);

            desc.Type        = ResourceDimension.Tex2d;
            desc.Size        = size;
            desc.Format      = format;
            desc.SampleCount = (uint)sampleCount;
            desc.BindFlags   = BindFlags.RenderTarget | BindFlags.ShaderResource;

            using (var device = context.renderContext.device)
                texture = device.CreateTexture(ref desc, name);

            targetView = texture.GetDefaultView(TextureViewType.RenderTarget);
        }
 internal static void SetObjects(Dictionary <string, object> objects)
 {
     EngineApplicationInterface._objects  = objects;
     EngineApplicationInterface.IPath     = EngineApplicationInterface.GetObject <IPath>();
     EngineApplicationInterface.IShader   = EngineApplicationInterface.GetObject <IShader>();
     EngineApplicationInterface.ITexture  = EngineApplicationInterface.GetObject <ITexture>();
     EngineApplicationInterface.IMaterial = EngineApplicationInterface.GetObject <IMaterial>();
     EngineApplicationInterface.IMetaMesh = EngineApplicationInterface.GetObject <IMetaMesh>();
     EngineApplicationInterface.IDecal    = EngineApplicationInterface.GetObject <IDecal>();
     EngineApplicationInterface.IClothSimulatorComponent = EngineApplicationInterface.GetObject <IClothSimulatorComponent>();
     EngineApplicationInterface.ICompositeComponent      = EngineApplicationInterface.GetObject <ICompositeComponent>();
     EngineApplicationInterface.IPhysicsShape            = EngineApplicationInterface.GetObject <IPhysicsShape>();
     EngineApplicationInterface.IBodyPart                  = EngineApplicationInterface.GetObject <IBodyPart>();
     EngineApplicationInterface.IMesh                      = EngineApplicationInterface.GetObject <IMesh>();
     EngineApplicationInterface.IMeshBuilder               = EngineApplicationInterface.GetObject <IMeshBuilder>();
     EngineApplicationInterface.ICamera                    = EngineApplicationInterface.GetObject <ICamera>();
     EngineApplicationInterface.ISkeleton                  = EngineApplicationInterface.GetObject <ISkeleton>();
     EngineApplicationInterface.IGameEntity                = EngineApplicationInterface.GetObject <IGameEntity>();
     EngineApplicationInterface.IGameEntityComponent       = EngineApplicationInterface.GetObject <IGameEntityComponent>();
     EngineApplicationInterface.IScene                     = EngineApplicationInterface.GetObject <IScene>();
     EngineApplicationInterface.IScriptComponent           = EngineApplicationInterface.GetObject <IScriptComponent>();
     EngineApplicationInterface.ILight                     = EngineApplicationInterface.GetObject <ILight>();
     EngineApplicationInterface.IParticleSystem            = EngineApplicationInterface.GetObject <IParticleSystem>();
     EngineApplicationInterface.IPhysicsMaterial           = EngineApplicationInterface.GetObject <IPhysicsMaterial>();
     EngineApplicationInterface.ISceneView                 = EngineApplicationInterface.GetObject <ISceneView>();
     EngineApplicationInterface.IView                      = EngineApplicationInterface.GetObject <IView>();
     EngineApplicationInterface.ITableauView               = EngineApplicationInterface.GetObject <ITableauView>();
     EngineApplicationInterface.ITextureView               = EngineApplicationInterface.GetObject <ITextureView>();
     EngineApplicationInterface.IVideoPlayerView           = EngineApplicationInterface.GetObject <IVideoPlayerView>();
     EngineApplicationInterface.IThumbnailCreatorView      = EngineApplicationInterface.GetObject <IThumbnailCreatorView>();
     EngineApplicationInterface.IDebug                     = EngineApplicationInterface.GetObject <IDebug>();
     EngineApplicationInterface.ITwoDimensionView          = EngineApplicationInterface.GetObject <ITwoDimensionView>();
     EngineApplicationInterface.IUtil                      = EngineApplicationInterface.GetObject <IUtil>();
     EngineApplicationInterface.IEngineSizeChecker         = EngineApplicationInterface.GetObject <IEngineSizeChecker>();
     EngineApplicationInterface.IInput                     = EngineApplicationInterface.GetObject <IInput>();
     EngineApplicationInterface.ITime                      = EngineApplicationInterface.GetObject <ITime>();
     EngineApplicationInterface.IScreen                    = EngineApplicationInterface.GetObject <IScreen>();
     EngineApplicationInterface.IMusic                     = EngineApplicationInterface.GetObject <IMusic>();
     EngineApplicationInterface.IImgui                     = EngineApplicationInterface.GetObject <IImgui>();
     EngineApplicationInterface.IMouseManager              = EngineApplicationInterface.GetObject <IMouseManager>();
     EngineApplicationInterface.IHighlights                = EngineApplicationInterface.GetObject <IHighlights>();
     EngineApplicationInterface.ISoundEvent                = EngineApplicationInterface.GetObject <ISoundEvent>();
     EngineApplicationInterface.ISoundManager              = EngineApplicationInterface.GetObject <ISoundManager>();
     EngineApplicationInterface.IConfig                    = EngineApplicationInterface.GetObject <IConfig>();
     EngineApplicationInterface.IManagedMeshEditOperations = EngineApplicationInterface.GetObject <IManagedMeshEditOperations>();
 }
Ejemplo n.º 21
0
        public void render(IDeviceContext context, ITextureView rtv, CSize outputSize, int index)
        {
            // Setup stuff
            context.SetRenderTarget(rtv, null);
            context.setViewport(outputSize, viewport);
            context.SetPipelineState(pipelineState);
            textureVariable.Set(sourceTextures[index]);
            context.CommitShaderResources(binding);

            // Render a full-screen triangle, no vertex buffer needed
            DrawAttribs draw = new DrawAttribs(false)
            {
                NumVertices = 3,
                Flags       = DrawFlags.VerifyAll
            };

            context.Draw(ref draw);
        }
Ejemplo n.º 22
0
        // SavePngFrames savePng;

        protected override ITextureView createOutputTexture(IRenderDevice device, TextureFormat format, CSize size)
        {
            outputSize = size;

            TextureDesc desc = new TextureDesc(false)
            {
                Type      = ResourceDimension.Tex2d,
                BindFlags = BindFlags.ShaderResource | BindFlags.RenderTarget,
                Format    = format,
                Size      = size
            };

            frameTexture = device.CreateTexture(ref desc, $"Video frame RGB");
            frameRtv     = frameTexture.GetDefaultView(TextureViewType.RenderTarget);
            rgbFormat    = format;
            // savePng = new SavePngFrames();

            return(frameTexture.GetDefaultView(TextureViewType.ShaderResource));
        }
Ejemplo n.º 23
0
        void loadTexture(IRenderDevice device, iStorageFolder assets)
        {
            // Decode the image from embedded resource of this DLL.
            assets.openRead("net-core-logo.png", out var png);
            if (null == png)
            {
                throw new ApplicationException("The texture wasn't found");
            }
            TextureLoadInfo loadInfo = new TextureLoadInfo(false)
            {
                IsSRGB = true
            };
            var texture = device.LoadTexture(png, eImageFileFormat.PNG, ref loadInfo, null);

            // Get shader resource view from the texture
            textureView = texture.GetDefaultView(TextureViewType.ShaderResource);
            // Update the ShaderResourceBinding setting the shader resource view of the newly loaded texture
            resourceBinding.GetVariableByName(ShaderType.Pixel, "g_Texture").Set(textureView);
        }
Ejemplo n.º 24
0
        ITextureView iSwapChain.begin(ITextureView rtv, ITextureView dsv, Vector4 clearColor)
        {
            // ConsoleLogger.logDebug( "iSwapChain.begin 0" );
            if (context.swapChainSize != size)
            {
                size = context.swapChainSize;
                resized();
            }
            // ConsoleLogger.logDebug( "iSwapChain.begin 1" );
            RenderTarget rt = begin();
            // ConsoleLogger.logDebug( "iSwapChain.begin 2" );
            ITextureView target = rt.bind(context.context);

            context.context.ClearRenderTarget(target, clearColor);
            // ConsoleLogger.logDebug( "iSwapChain.begin 3" );
            this.rtv = rtv;
            this.dsv = dsv;
            // ConsoleLogger.logDebug( "iSwapChain.begin 4" );
            return(target);
        }
Ejemplo n.º 25
0
        void render()
        {
            // ConsoleLogger.logDebug( "ContentBase.render" );
            var rtv = swapChain?.GetCurrentBackBufferRTV();

            Debug.Assert(null != rtv);
            ComUtils.assign(ref cachedRtv, rtv);
            var dsv = swapChain?.GetDepthBufferDSV();

            Debug.Assert(null != dsv);
            ComUtils.assign(ref cachedDsv, dsv);
            if (null == rtv || null == dsv)
            {
                return;
            }

            animation?.update();
            // ConsoleLogger.logDebug( "ContentBase.render 2" );
            backBufferTexture = rtv;
            try
            {
                // MicroProfiler.start();
                scene.render(this, rtv, dsv);
                m_cursor?.render();

                string screenshot = System.Threading.Interlocked.Exchange(ref screenshotLocation, null);
                if (null != screenshot)
                {
                    using (var dev = device)
                        using (var tx = rtv.GetTexture())
                            ScreenGrabber.saveTexture(dev, context, tx, screenshot);
                }
                // MicroProfiler.key( "done rendering" );
            }
            finally
            {
                backBufferTexture = null;
            }
            swapChain.Present(1);
            // MicroProfiler.finish();
        }
Ejemplo n.º 26
0
        protected override void render(ITextureView swapChainRgb, ITextureView swapChainDepthStencil)
        {
            // var im = context.context;
            // im.SetRenderTarget( swapChainRgb, swapChainDepthStencil );
            // im.ClearRenderTarget( swapChainRgb, Color.white );

            // using( var dc = context.drawDevice.begin( swapChainRgb, swapChainDepthStencil, Color.transparent ) )
            using (var dc = context.drawDevice.begin(swapChainRgb, swapChainDepthStencil, Color.white))
            {
                var transform = rotationMatrix(context.drawDevice.viewportSize, rotationAngle);
                // var transform = rotationMatrix( context.drawDevice.viewportSize, 1 );
                dc.transform.push(transform);
                // ConsoleLogger.logDebug( "drawDevice.begin" );
                drawGeometry(dc, 2); return;

                for (int i = 0; i < shapes.Length; i++)
                {
                    drawGeometry(dc, i);
                }
            }
        }
Ejemplo n.º 27
0
        protected override void render(ITextureView swapChainRgb, ITextureView swapChainDepthStencil)
        {
            var ic = context.context;

            ic.SetRenderTarget(swapChainRgb, swapChainDepthStencil);

            // Clear the back buffer
            float[] ClearColor = new float[4] {
                0.350f, 0.350f, 0.350f, 1.0f
            };
            // Let the engine perform required state transitions
            ic.ClearRenderTarget(swapChainRgb, clearColor);
            ic.ClearDepthStencil(swapChainDepthStencil, ClearDepthStencilFlags.DepthFlag, 1.0f, 0);

            // Set the pipeline state in the immediate context
            ic.SetPipelineState(pipelineState);
            ic.CommitShaderResources(null);

            DrawAttribs drawAttrs = new DrawAttribs(true);

            drawAttrs.NumVertices = 3;             // We will render 3 vertices
            ic.Draw(ref drawAttrs);
        }
Ejemplo n.º 28
0
        protected override void render(ITextureView swapChainRgb, ITextureView swapChainDepthStencil)
        {
            if (null == renderState)
            {
                return;
            }
            IDeviceContext ic = context.context;

            ic.SetRenderTarget(swapChainRgb, null);

            if (controller.paused)
            {
                renderState.renderLastFrame(ic);
                return;
            }

            while (!mediaEngine.onVideoStreamTick(out ulong presentationTime))
            {
                context.renderContext.waitForVBlank();
            }

            renderState.render(ic);
        }
Ejemplo n.º 29
0
        protected override void render(ITextureView swapChainRgb, ITextureView swapChainDepthStencil)
        {
            Rect rcSprite = new Rect(0, 0, 32, 32);

            using (var dc = context.drawDevice.begin(swapChainRgb, swapChainDepthStencil, background))
            {
                Rect rc = new Rect(rcRandom.bottomRight, rcRandom.bottomRight - new Vector2(256));
                dc.drawSprite(rc, 1);

                rc = new Rect(rcRandom.topLeft, rcRandom.topLeft + new Vector2(256));
                dc.drawSprite(rc, 0);

                for (int i = 0; i < spritesCount; i++)
                {
                    Matrix3x2 imageRotation = Matrix3x2.CreateRotation(rotationAngle);
                    Vector2   v             = randomVertices[i];
                    v = rcRandom.getPoint(v);
                    Matrix3x2 trans = Matrix3x2.CreateTranslation(v);
                    dc.transform.push(imageRotation * trans);
                    dc.drawSprite(rcSprite, (i % 3) + 2);
                    dc.transform.pop();
                }
            }
        }
Ejemplo n.º 30
0
 internal AnimatedCursorTexture(ITextureView texture, CSize size, CPoint hotspot, int frames, TimeSpan duration) :
     base(texture, size, hotspot)
 {
     animationFrames = frames;
     frameDuration   = duration;
 }