ITPub博客

首页 > > > XNA 怎么添加多个贴图,不是在2D精灵中,是3D渲染

XNA 怎么添加多个贴图,不是在2D精灵中,是3D渲染

作者:R-B 时间:2019-10-16 10:41:01 0 删除 编辑
protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // Set the vertex buffer on the GraphicsDevice
            GraphicsDevice.SetVertexBuffer(vertexBuffer);
            
            //Set object and camera info
            effect.World = worldRotation * worldTranslation * worldRotation;
            effect.View = camera.view;
            effect.Projection = camera.projection;
            effect.Texture = texture;//这里设置贴图对象,可是如果有多张贴图呢怎么办
            //efect对象只有一个呀 难道这个从设备获取的对象可以定义多个吗
            effect.TextureEnabled = true;
            
            // Begin effect and draw for each pass
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
               pass.Apply();
                GraphicsDevice.DrawUserPrimitives<VertexPositionTexture>
                    (PrimitiveType.TriangleStrip, verts, 0, 2);
            }
            base.Draw(gameTime);
        }


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4560/viewspace-3120647/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-09-03

  • 博文量
    183
  • 访问量
    10164