update CompressedTexture
parent
329f3c68f4
commit
165af544de
|
@ -1,5 +1,4 @@
|
||||||
using MoonWorks;
|
using MoonWorks.Graphics;
|
||||||
using MoonWorks.Graphics;
|
|
||||||
using MoonWorks.Math.Float;
|
using MoonWorks.Math.Float;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
|
@ -8,8 +7,8 @@ namespace MoonWorks.Test
|
||||||
class CompressedTexturesGame : Game
|
class CompressedTexturesGame : Game
|
||||||
{
|
{
|
||||||
private GraphicsPipeline pipeline;
|
private GraphicsPipeline pipeline;
|
||||||
private Buffer vertexBuffer;
|
private GpuBuffer vertexBuffer;
|
||||||
private Buffer indexBuffer;
|
private GpuBuffer indexBuffer;
|
||||||
private Sampler sampler;
|
private Sampler sampler;
|
||||||
private Texture[] textures;
|
private Texture[] textures;
|
||||||
private string[] textureNames = new string[]
|
private string[] textureNames = new string[]
|
||||||
|
@ -48,35 +47,34 @@ namespace MoonWorks.Test
|
||||||
textures = new Texture[textureNames.Length];
|
textures = new Texture[textureNames.Length];
|
||||||
|
|
||||||
// Create and populate the GPU resources
|
// Create and populate the GPU resources
|
||||||
vertexBuffer = Buffer.Create<PositionTextureVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 4);
|
var resourceInitializer = new ResourceInitializer(GraphicsDevice);
|
||||||
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 6);
|
|
||||||
|
|
||||||
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
|
vertexBuffer = resourceInitializer.CreateBuffer(
|
||||||
cmdbuf.SetBufferData(
|
[
|
||||||
vertexBuffer,
|
|
||||||
new PositionTextureVertex[]
|
|
||||||
{
|
|
||||||
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
|
||||||
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
new PositionTextureVertex(new Vector3(1, 1, 0), new Vector2(1, 1)),
|
||||||
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
|
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1))
|
||||||
}
|
],
|
||||||
|
BufferUsageFlags.Vertex
|
||||||
);
|
);
|
||||||
cmdbuf.SetBufferData(
|
|
||||||
indexBuffer,
|
indexBuffer = resourceInitializer.CreateBuffer<ushort>(
|
||||||
new ushort[]
|
[
|
||||||
{
|
|
||||||
0, 1, 2,
|
0, 1, 2,
|
||||||
0, 2, 3,
|
0, 2, 3,
|
||||||
}
|
],
|
||||||
|
BufferUsageFlags.Index
|
||||||
);
|
);
|
||||||
|
|
||||||
for (int i = 0; i < textureNames.Length; i += 1)
|
for (int i = 0; i < textureNames.Length; i += 1)
|
||||||
{
|
{
|
||||||
Logger.LogInfo(textureNames[i]);
|
Logger.LogInfo(textureNames[i]);
|
||||||
using (FileStream fs = new FileStream(TestUtils.GetTexturePath(textureNames[i] + ".dds"), FileMode.Open, FileAccess.Read))
|
textures[i] = resourceInitializer.CreateTextureFromDDS(TestUtils.GetTexturePath(textureNames[i] + ".dds"));
|
||||||
textures[i] = Texture.LoadDDS(GraphicsDevice, cmdbuf, fs);
|
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
|
||||||
|
resourceInitializer.Upload();
|
||||||
|
resourceInitializer.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update(System.TimeSpan delta)
|
protected override void Update(System.TimeSpan delta)
|
||||||
|
@ -118,7 +116,7 @@ namespace MoonWorks.Test
|
||||||
cmdbuf.BindVertexBuffers(vertexBuffer);
|
cmdbuf.BindVertexBuffers(vertexBuffer);
|
||||||
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
|
||||||
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(textures[currentTextureIndex], sampler));
|
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(textures[currentTextureIndex], sampler));
|
||||||
cmdbuf.DrawIndexedPrimitives(0, 0, 2, 0, 0);
|
cmdbuf.DrawIndexedPrimitives(0, 0, 2);
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
}
|
}
|
||||||
GraphicsDevice.Submit(cmdbuf);
|
GraphicsDevice.Submit(cmdbuf);
|
||||||
|
|
Loading…
Reference in New Issue