実はクワッドテクスチャで動画を再生したいのですが、長方形で描いてみると、表示されている動画の色が少し下がっています。以下はmdsnとちょっとした修正の例です。
前もって感謝します。
public Game1()
{
graphics = new GraphicsDeviceManager(this);
graphics.PreferredBackBufferWidth = 1920;
graphics.PreferredBackBufferHeight = 1080;
graphics.PreferMultiSampling = false;
graphics.IsFullScreen = false;
// Set the back buffer format to color
graphics.PreferredBackBufferFormat = SurfaceFormat.Color;
Content.RootDirectory = "Content";
}
protected override void Initialize()
{
// TODO: Add your initialization logic here
PresentationParameters pp = GraphicsDevice.PresentationParameters;
pp.MultiSampleCount = 20;
quad = new Quad(Vector3.Zero, Vector3.Backward, Vector3.Up, 1,1);
camera = new Camera(this, new Vector3(0, 0, 1.15f), Vector3.Zero, Vector3.Up);
Components.Add(camera);
base.Initialize();
}
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
video = Content.Load<Video>("1");
player = new VideoPlayer();
player.IsLooped = true;
// Setup our BasicEffect for drawing the quad
World = Matrix.Identity;
quadEffect = new BasicEffect(graphics.GraphicsDevice);
quadEffect.EnableDefaultLighting();
quadEffect.View = camera.view;
quadEffect.Projection = camera.projection;
quadEffect.TextureEnabled = true;
// Create a vertex declaration so we can call
// DrawUserIndexedPrimitives later
quadVertexDecl = new VertexDeclaration(VertexPositionTexture.VertexDeclaration.GetVertexElements());
}
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
// TODO: Add your update logic here
// Play the video if it isn't already.
if (player.State != MediaState.Playing)
player.Play(video);
KeyboardState state = Keyboard.GetState();
.....
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black);
// TODO: Add your drawing code here
RasterizerState rs = new RasterizerState();
rs.CullMode = CullMode.None;
GraphicsDevice.RasterizerState = rs;
quadEffect.World = World;
if (player.State == MediaState.Playing)
quadEffect.Texture = player.GetTexture();
foreach (EffectPass pass in quadEffect.CurrentTechnique.Passes)
{
pass.Apply();
GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp;
GraphicsDevice.DrawUserIndexedPrimitives(
PrimitiveType.TriangleList,
quad.Vertices, 0, 4,
quad.Indices, 0, 2);
}
base.Draw(gameTime);
}