Created
June 25, 2020 19:18
-
-
Save TheSpydog/3dafb5c289f66804c3df3624cf0c5bb5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Xna.Framework; | |
using Microsoft.Xna.Framework.Graphics; | |
namespace ShaderTest | |
{ | |
class ShaderTestGame : Game | |
{ | |
GraphicsDeviceManager graphics; | |
RenderTarget2D renderTarget; | |
SpriteBatch spriteBatch; | |
SamplerState lowDetail; | |
Texture2D surge; | |
public static void Main(string[] args) | |
{ | |
using (ShaderTestGame game = new ShaderTestGame()) | |
{ | |
game.Run(); | |
} | |
} | |
public ShaderTestGame() | |
{ | |
graphics = new GraphicsDeviceManager(this); | |
graphics.PreferredBackBufferWidth = 1280; | |
graphics.PreferredBackBufferHeight = 720; | |
graphics.PreferMultiSampling = false; | |
Content.RootDirectory = "Content"; | |
Window.AllowUserResizing = false; | |
IsMouseVisible = true; | |
} | |
protected override void LoadContent() | |
{ | |
base.LoadContent(); | |
spriteBatch = new SpriteBatch(GraphicsDevice); | |
renderTarget = new RenderTarget2D(GraphicsDevice, 200, 200, true, SurfaceFormat.Color, DepthFormat.None); | |
surge = Content.Load<Texture2D>("surge"); | |
lowDetail = SamplerState.PointClamp; | |
lowDetail.MaxMipLevel = 2; | |
} | |
protected override void UnloadContent() | |
{ | |
base.UnloadContent(); | |
} | |
protected override void Update(GameTime gameTime) | |
{ | |
base.Update(gameTime); | |
} | |
protected override void Draw(GameTime gameTime) | |
{ | |
GraphicsDevice.SetRenderTarget(renderTarget); | |
GraphicsDevice.Clear(Color.CornflowerBlue); | |
spriteBatch.Begin(); | |
spriteBatch.Draw(surge, Vector2.Zero, Color.White); | |
spriteBatch.End(); | |
GraphicsDevice.SetRenderTarget(null); | |
GraphicsDevice.Clear(Color.CornflowerBlue); | |
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); | |
spriteBatch.Draw(renderTarget, Vector2.Zero, Color.White); | |
spriteBatch.End(); | |
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, lowDetail, DepthStencilState.None, RasterizerState.CullNone); | |
spriteBatch.Draw(renderTarget, new Vector2(0, 200), Color.White); | |
spriteBatch.End(); | |
base.Draw(gameTime); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment