2012-11-21 77 views
0

其實我想播放四紋理視頻,但顯示的視頻的顏色是某種折舊,如果我用矩形畫比較.. 下面是從mdsn加abit修改,任何人都可以檢查我嗎?播放視頻紋理四人

在此先感謝。


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); 
     } 

回答

1

您使用quadEffect.EnableDefaultLighting();這將增加一個光源。您可以通過設置quadEffect.LightingEnabled = false來禁用它;

+0

感謝您的回覆..我嘗試過,但仍未達到預期的結果..是否還有其他方法? – Therenho