/// <summary> /// Renders a test where the GBuffer is displayed containing a sphere with provided maps. /// </summary> private void testGBufferSphere(ITexture diffuse, ITexture normal, ITexture specular) { var game = createGame(); var pool = createTexturePool(game); var txDiffuse = diffuse == null ? null : pool.LoadTexture(diffuse); var txNormal = normal == null ? null : pool.LoadTexture(normal); var txSpecular = specular == null ? null : pool.LoadTexture(specular); var mat = new DeferredMaterial(game, txDiffuse, txNormal, txSpecular); var part = RenderingTestsHelper.CreateSphereMeshPart(); var fact = new MeshRenderDataFactory(game, null, null); var partData = fact.CreateMeshPartData(part); var buffer = createGBuffer(game); var perObject = DeferredMaterial.CreatePerObjectCB(game); var ctx = game.Device.ImmediateContext; perObject.UpdatePerObjectBuffer(ctx, Matrix.Identity); var scene = new RenderingTestsHelper.SimpleLightedScene(game, buffer); game.GameLoopEvent += delegate { ctx.ClearState(); buffer.Clear(); buffer.SetTargetsToOutputMerger(); mat.SetCamera(game.Camera.View, game.Camera.Projection); mat.SetToContext(ctx); mat.SetPerObjectBuffer(ctx, perObject); partData.Draw(ctx); scene.Render(); }; game.Run(); }
public void drawMeshTest(IMesh mesh, Matrix worldMatrix) { var game = createGame(); var pool = createTexturePool(game); var worldMesh = new WorldMesh { Mesh = mesh, WorldMatrix = worldMatrix }; var meshes = new MeshesRenderer(new RendererResourcePool(new MeshRenderDataFactory(game, null, pool), pool, game), game); var ctx = game.Device.ImmediateContext; var gBuffer = createGBuffer(game); var scene = new RenderingTestsHelper.SimpleLightedScene(game, gBuffer); var list = new List <WorldMesh>(); list.Add(worldMesh); game.GameLoopEvent += delegate { ctx.ClearState(); ctx.Rasterizer.State = game.HelperStates.RasterizerShowAll; gBuffer.Clear(); gBuffer.SetTargetsToOutputMerger(); meshes.DrawMeshes(list, game.Camera); scene.Render(); }; game.Run(); }