PreShaderTest/PreShaderTest/PreShaderTestGame.cs

76 lines
2.1 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace PreShaderTest
{
class PreShaderTestGame : Game
{
GraphicsDeviceManager graphics;
VertexBuffer vertexBuffer;
Smuggler.PBREffect pbrEffect;
Texture2D albedoTexture;
public PreShaderTestGame()
{
graphics = new GraphicsDeviceManager(this);
graphics.PreferredBackBufferWidth = 1280;
graphics.PreferredBackBufferHeight = 720;
graphics.PreferMultiSampling = true;
Content.RootDirectory = "Content";
Window.AllowUserResizing = true;
IsMouseVisible = true;
}
protected override void LoadContent()
{
vertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionNormalTexture), 1, BufferUsage.None);
vertexBuffer.SetData(new VertexPositionNormalTexture[] {
new VertexPositionNormalTexture(
new Vector3(0, 0, 0),
new Vector3(0, 1, 0),
new Vector2(0, 1)
)
});
albedoTexture = new Texture2D(GraphicsDevice, 1, 1);
albedoTexture.SetData(new Color[] { new Color(1, 0, 1, 1) });
pbrEffect = new Smuggler.PBREffect(GraphicsDevice);
pbrEffect.AlbedoTexture = albedoTexture;
}
protected override void UnloadContent()
{
base.UnloadContent();
}
protected override void Update(GameTime gameTime)
{
//
// Insert your game update logic here.
//
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
//
// Replace this with your own drawing code.
//
GraphicsDevice.Clear(Color.CornflowerBlue);
pbrEffect.Techniques[0].Passes[0].Apply();
GraphicsDevice.SetVertexBuffer(vertexBuffer);
GraphicsDevice.DrawPrimitives(PrimitiveType.PointListEXT, 0, 1);
base.Draw(gameTime);
}
}
}