update examples that load from compressed image files
parent
347290bae2
commit
89dea810cc
|
@ -65,7 +65,7 @@ namespace MoonWorks.Test
|
|||
BufferUsageFlags.Index
|
||||
);
|
||||
|
||||
originalTexture = resourceUploader.CreateTexture2D(
|
||||
originalTexture = resourceUploader.CreateTexture2DFromCompressed(
|
||||
TestUtils.GetTexturePath("ravioli.png")
|
||||
);
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace MoonWorks.Test
|
|||
BufferUsageFlags.Index
|
||||
);
|
||||
|
||||
texture = resourceUploader.CreateTexture2D(TestUtils.GetTexturePath("ravioli.png"));
|
||||
texture = resourceUploader.CreateTexture2DFromCompressed(TestUtils.GetTexturePath("ravioli.png"));
|
||||
|
||||
resourceUploader.Upload();
|
||||
resourceUploader.Dispose();
|
||||
|
|
|
@ -90,10 +90,10 @@ namespace MoonWorks.Test
|
|||
vertexBuffer = resourceUploader.CreateBuffer(vertexData, BufferUsageFlags.Vertex);
|
||||
indexBuffer = resourceUploader.CreateBuffer(indexData, BufferUsageFlags.Index);
|
||||
|
||||
textures[0] = resourceUploader.CreateTexture2D(TestUtils.GetTexturePath("ravioli.png"));
|
||||
textures[1] = resourceUploader.CreateTexture2D(pngBytes);
|
||||
textures[2] = resourceUploader.CreateTexture2D(TestUtils.GetTexturePath("ravioli.qoi"));
|
||||
textures[3] = resourceUploader.CreateTexture2D(qoiBytes);
|
||||
textures[0] = resourceUploader.CreateTexture2DFromCompressed(TestUtils.GetTexturePath("ravioli.png"));
|
||||
textures[1] = resourceUploader.CreateTexture2DFromCompressed(pngBytes);
|
||||
textures[2] = resourceUploader.CreateTexture2DFromCompressed(TestUtils.GetTexturePath("ravioli.qoi"));
|
||||
textures[3] = resourceUploader.CreateTexture2DFromCompressed(qoiBytes);
|
||||
|
||||
resourceUploader.Upload();
|
||||
resourceUploader.Dispose();
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace MoonWorks.Test
|
|||
class TriangleVertexBufferGame : Game
|
||||
{
|
||||
private GraphicsPipeline pipeline;
|
||||
private Buffer vertexBuffer;
|
||||
private GpuBuffer vertexBuffer;
|
||||
|
||||
public TriangleVertexBufferGame() : base(TestUtils.GetStandardWindowCreateInfo(), TestUtils.GetStandardFrameLimiterSettings(), 60, true)
|
||||
{
|
||||
|
@ -25,19 +25,19 @@ namespace MoonWorks.Test
|
|||
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||
|
||||
// Create and populate the vertex buffer
|
||||
vertexBuffer = Buffer.Create<PositionColorVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 3);
|
||||
var resourceUploader = new ResourceUploader(GraphicsDevice);
|
||||
|
||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||
cmdbuf.SetBufferData(
|
||||
vertexBuffer,
|
||||
new PositionColorVertex[]
|
||||
{
|
||||
vertexBuffer = resourceUploader.CreateBuffer(
|
||||
[
|
||||
new PositionColorVertex(new Vector3(-1, 1, 0), Color.Red),
|
||||
new PositionColorVertex(new Vector3(1, 1, 0), Color.Lime),
|
||||
new PositionColorVertex(new Vector3(0, -1, 0), Color.Blue),
|
||||
}
|
||||
],
|
||||
BufferUsageFlags.Vertex
|
||||
);
|
||||
GraphicsDevice.Submit(cmdbuf);
|
||||
|
||||
resourceUploader.Upload();
|
||||
resourceUploader.Dispose();
|
||||
}
|
||||
|
||||
protected override void Update(System.TimeSpan delta) { }
|
||||
|
@ -51,7 +51,7 @@ namespace MoonWorks.Test
|
|||
cmdbuf.BeginRenderPass(new ColorAttachmentInfo(backbuffer, Color.Black));
|
||||
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||
cmdbuf.DrawPrimitives(0, 1, 0, 0);
|
||||
cmdbuf.DrawPrimitives(0, 1);
|
||||
cmdbuf.EndRenderPass();
|
||||
}
|
||||
GraphicsDevice.Submit(cmdbuf);
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace MoonWorks.Test
|
|||
class VertexSamplerGame : Game
|
||||
{
|
||||
private GraphicsPipeline pipeline;
|
||||
private Buffer vertexBuffer;
|
||||
private GpuBuffer vertexBuffer;
|
||||
private Texture texture;
|
||||
private Sampler sampler;
|
||||
|
||||
|
@ -28,22 +28,27 @@ namespace MoonWorks.Test
|
|||
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
|
||||
|
||||
// Create and populate the GPU resources
|
||||
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 3);
|
||||
texture = Texture.CreateTexture2D(GraphicsDevice, 3, 1, TextureFormat.R8G8B8A8, TextureUsageFlags.Sampler);
|
||||
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
|
||||
|
||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
||||
cmdbuf.SetBufferData(
|
||||
vertexBuffer,
|
||||
new PositionTextureVertex[]
|
||||
{
|
||||
var resourceUploader = new ResourceUploader(GraphicsDevice);
|
||||
|
||||
vertexBuffer = resourceUploader.CreateBuffer(
|
||||
[
|
||||
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 0)),
|
||||
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(0.334f, 0)),
|
||||
new PositionTextureVertex(new Vector3(0, -1, 0), new Vector2(0.667f, 0)),
|
||||
}
|
||||
],
|
||||
BufferUsageFlags.Vertex
|
||||
);
|
||||
cmdbuf.SetTextureData(texture, new Color[] { Color.Yellow, Color.Indigo, Color.HotPink });
|
||||
GraphicsDevice.Submit(cmdbuf);
|
||||
|
||||
resourceUploader.SetTextureData(
|
||||
texture,
|
||||
[Color.Yellow, Color.Indigo, Color.HotPink]
|
||||
);
|
||||
|
||||
resourceUploader.Upload();
|
||||
resourceUploader.Dispose();
|
||||
}
|
||||
|
||||
protected override void Update(System.TimeSpan delta) { }
|
||||
|
@ -58,7 +63,7 @@ namespace MoonWorks.Test
|
|||
cmdbuf.BindGraphicsPipeline(pipeline);
|
||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||
cmdbuf.BindVertexSamplers(new TextureSamplerBinding(texture, sampler));
|
||||
cmdbuf.DrawPrimitives(0, 1, 0, 0);
|
||||
cmdbuf.DrawPrimitives(0, 1);
|
||||
cmdbuf.EndRenderPass();
|
||||
}
|
||||
GraphicsDevice.Submit(cmdbuf);
|
||||
|
|
Loading…
Reference in New Issue