Example #1
0
        public void visualDebug()
        {
            lock (myLock)
            {
                Vector2 size     = new Vector2(1280, 800); // Renderer.context.viewport.size;
                float   boundary = size.X / 20;
                size.X -= boundary * 2;                    //on both sides
                float pixelRatio = (float)size.X / (float)myBufferSize;
                float yLoc       = 200;

                foreach (Page p in myFreePages)
                {
                    float e = p.size * pixelRatio;
                    float s = boundary + (p.start.ToInt64() - myBufferMemory.ToInt64()) * pixelRatio;
                    Rect  r = new Rect(s, yLoc, s + e, yLoc + 20);
                    DebugRenderer.addRect2D(r, Color4.Aqua, Fill.SOLID, false, 0.0);
                }

                yLoc = 220;
                foreach (Page p in myUsedPages)
                {
                    float e = p.size * pixelRatio;
                    float s = boundary + (p.start.ToInt64() - myBufferMemory.ToInt64()) * pixelRatio;
                    Rect  r = new Rect(s, yLoc, s + e, yLoc + 20);
                    DebugRenderer.addRect2D(r, Color4.Green, Fill.SOLID, false, 0.0);
                }
            }
        }
Example #2
0
        static Renderer()
        {
            frameNumber = 0;

            device = new Device();
            device.init();

            resourceManager  = new ResourceManager();
            shaderManager    = new ShaderManager();
            visiblityManager = new VisibilityManager();

            views       = new Dictionary <string, View>();
            visualizers = new Dictionary <string, Visualizer>();
            scene       = new Scene();

            activeViews   = new List <View>();
            activeCameras = new List <Camera>();

            DebugRenderer.init();

            present = null;

            installDefaultVisualizers();
            installDefaultShaders();
        }
Example #3
0
 public void bind()
 {
     myViewport.apply();
     if (myIsDebugging == true)
     {
         DebugRenderer.addFrustum(myClipMatrix, Color4.White, false, 0.0);
         Renderer.device.bindUniformBuffer(myDebugCamera.myCameraUniformBuffer.id, 0);                 //camera is always ubo 0
     }
     else
     {
         Renderer.device.bindUniformBuffer(myCameraUniformBuffer.id, 0);                 //camera is always ubo 0
     }
 }
Example #4
0
        public override bool isVisible(Camera c)
        {
            if (myLightType == Type.DIRECTIONAL)
            {
                DebugRenderer.addLine(position, Vector3.Zero, color, Fill.WIREFRAME, false, 0);
                DebugRenderer.addSphere(position, 0.1f, color, Fill.TRANSPARENT, false, 0);
                return(true);
            }

            DebugRenderer.addSphere(position, 0.1f, color, Fill.TRANSPARENT, false, 0);

            return(c.containsSphere(position, size));
        }
Example #5
0
        public override void generateRenderCommandLists()
        {
            preCommands.Clear();
            postCommands.Clear();

            preCommands.Add(new PushDebugMarkerCommand(String.Format("Pass {0}:{1}-execute", view.name, name)));

            //clear render target if needed
            if (renderTarget != null)
            {
                preCommands.Add(new SetRenderTargetCommand(renderTarget));
                if (clearTarget == true)
                {
                    preCommands.Add(new ClearColorCommand(clearColor));
                    preCommands.Add(new ClearCommand(clearMask));
                }
            }

            //called after setting render target so that any user commands inserted will affect (or change) the render target
            onPreGenerateCommands();

            stats.queueCount  = myRenderQueues.Count;
            stats.renderCalls = 0;
            stats.name        = name;
            stats.technique   = technique;

            //update the debug renderer
            DebugRenderer.update();

            List <RenderCommand> cmds = DebugRenderer.canvas.getRenderCommands();

            foreach (RenderCommand rc in cmds)
            {
                StatelessRenderCommand src = rc as StatelessRenderCommand;
                src.renderState.setUniformBuffer(view.camera.uniformBufferId(), 0);
            }

            //these are stateless commands, so no need to setup a pipeline, thats part of each command (usually the same)
            myRenderQueue.commands.AddRange(cmds);

            onPostGenerateCommands();

            postCommands.Add(new PopDebugMarkerCommand());

            stats.renderCalls += preCommands.Count;
            stats.renderCalls += postCommands.Count;
            foreach (BaseRenderQueue rq in myRenderQueues.Values)
            {
                stats.renderCalls += rq.commands.Count;
            }
        }
Example #6
0
        public void debug()
        {
            float   fsize      = 150;
            Vector2 screenSize = view.camera.viewport().size;

            Vector2 size = new Vector2(fsize, fsize);
            Vector2 step = new Vector2(fsize + 10, 0);
            Vector2 min  = new Vector2(10, screenSize.Y - 10 - size.Y);

            DebugRenderer.addTexture(min, min + size, renderTarget.buffers[FramebufferAttachment.ColorAttachment0], false, 0.0);
            DebugRenderer.addTexture(min += step, min + size, renderTarget.buffers[FramebufferAttachment.DepthAttachment], true, 0.0);
            DebugRenderer.addTexture(min += step, min + size, myTempRenderTargets[0].buffers[FramebufferAttachment.ColorAttachment0], false, 0.0);
            DebugRenderer.addTexture(min += step, min + size, myTempRenderTargets[1].buffers[FramebufferAttachment.ColorAttachment0], false, 0.0);
        }
Example #7
0
        public void debugDraw(Vector3 pos, Quaternion ori)
        {
            foreach (Bone b in myBones)
            {
                Vector3 p = pos + Vector3.Transform(b.myWorldBindMatrix.ExtractTranslation(), ori);
                DebugRenderer.addSphere(p, 0.02f, Color4.Orange, Fill.TRANSPARENT, false, 0.0f);

                if (b.myParent != -1)
                {
                    Vector3 p1 = pos + Vector3.Transform(b.myWorldBindMatrix.ExtractTranslation(), ori);
                    Vector3 p2 = pos + Vector3.Transform(myBones[b.myParent].myWorldBindMatrix.ExtractTranslation(), ori);
                    DebugRenderer.addLine(p1, p2, Color4.Red, Fill.WIREFRAME, false, 0.0f);
                }
            }
        }
Example #8
0
        public void debugDraw(List <Matrix4> pose, Vector3 pos, Quaternion ori)
        {
            List <Matrix4> untxBones = new List <Matrix4>();

            for (int i = 0; i < skeleton.boneCount; i++)
            {
                Bone b = skeleton.myBones[i];
                untxBones.Add(b.myWorldBindMatrix * pose[i]);

                Vector3 p = pos + Vector3.Transform(untxBones[i].ExtractTranslation(), ori);
                DebugRenderer.addSphere(p, 0.05f, Color4.Green, Fill.TRANSPARENT, false, 0.0f);

                if (b.myParent != -1)
                {
                    Vector3 p1 = pos + Vector3.Transform(untxBones[i].ExtractTranslation(), ori);
                    Vector3 p2 = pos + Vector3.Transform(untxBones[b.myParent].ExtractTranslation(), ori);
                    DebugRenderer.addLine(p1, p2, Color4.Blue, Fill.WIREFRAME, false, 0.0f);
                }
            }
        }
Example #9
0
 public void debugFrustum()
 {
     DebugRenderer.addFrustum(myClipMatrix, Color4.White, false, 60.0);
 }