Section I: Introduction and Overview
c. Drawing with XNA
Goals:
Notice:
![]() |
Here are the details, each of the following changes are enclosed by regions with label: __CODE_ADDED__:
| #region __CODE_ADDED__
EffectPool effectPool; // for transformation and shading BasicEffect basicEffect; // traditional pipeline and fixed 3-stage transform #endregion |
|
#region __CODE_ADDED__
// Initialize the graphics rendering state
graphics.GraphicsDevice.VertexDeclaration = new VertexDeclaratione(...); // Create default shading procedure effectPool = new EffectPool(); basicEffect = new BasicEffect(graphics.GraphicsDevice, effectPool); basicEffect.VertexColorEnabled = true; #endregion |
| #region __CODE_ADDED__
// Begin drawing ... ... // Triangle vertex position based on center at (0,0) Vector3 p = new Vector3(0, 0, 0); VertexPositionColor[] vertices = new VertexPositionColor[3]; for (int i=0; i<3; i++) vertices[i].Position = p; // Center of triangle ... // color of the triangle vertices vertices[0].Position.X -= 0.1f; // left vertex of triangle vertices[1].Position.X += 0.1f; // right vertex of triangle vertices[2].Position.Y += 0.2f; // top vertex of triangle // draw the triangle graphics...DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 1); ... #endregion |
![]() |
| Kelvin Sung Computing and Software Systems University of Washington, Bothell ksung@u.washington.edu |