Design Considerations for Building 2D, 3D Games for Windows Phone 7

Introduction

By dictating the hardware specifications for phones designed to run the Windows Phone 7 operating system, Microsoft has ensured that, irrespective of the manufacturer, the device will conform to specified standards. Microsoft has achieved this by specifying the minimum hardware specification robust enough to run immersive 2D and 3D experiences and having the same touch input.

Shader Effects Available on the Windows Phone 7 (WP7) Platform

The GPU on the phone allows for having 5 configurable shader effects:

  • BasicEffect
  • DualTextureEffect
  • AlphaTestEffect
  • SkinnedEfect
  • EnvironmentMapEffect

The limitation is that you cannot author your own "shader effects". This is partly a design choice taken by Microsoft to balance performance and battery life.

The CPU also supports hardware accelerated 2D sprite drawing.

Here is a tabular report on which effect is suitable for which scenarios.

EffectDesigned usageCost
BasicEffectBlinn-Phong shading
Texture is optional
Fog is optional
Targeted for simple visuals
Cheaper than other effects
DualTextureEffectBlends two textures
Good visuals at low pixel cost
Primarily targeted for lightmaps, detail textures and decals
Intermediate
AlphaTestEffectTargeted for billboards and imposters
Adds pixel kill effect
Standard blending comes free with its associated effects
Intermediate
SkinnedEfectTargeted for animated models and instancing (think XBOX 360's Call of Duty Modern Warfare like game effects) It can animate bones on CPU and vertex skilling done by GPU Allows up to 4 weights per vertexVery High
EnvironmentMapEffectThis is for the shiniest application
Cheap way to fake complex lights
High

Considerations to Make When Developing 2D and 3D Gaming Apps for WP7

When designing applications, it is often a balancing act between pixel cost, framerate and the number of pixels rendered.

Framerate - Since the refresh rate of the phone is 30 Hz, it does not merit updating the display faster than that. IF you render faster than that, it is a waste of CPU/GPU and battery life.

You can set the refresh rate by setting the Game.TargetElapsedTime property.

  Game.TargetElapsedTime = TimeSpan.FromSeconds(1f/30);

Pixel - When processing power or battery life is premium, opt for cheaper effects. Minimize on overdrawing.

If you see brighter areas, it might indicate that you are overdrawing. Choose to draw untextured and blending in a desired texture where required. This saves CPU instructions by avoiding texture calculations where not needed.

Since the phone cannot render more than 800 x 480 at the best (in its current iteration), make sure your frames do not have more than the required pixels.

Use dedicated hardware scaler if your calculated frames are smaller than the screen size. Reverse operation is a waste of CPU power. The hardware scaler does not consume any GPU and is of higher quality than bilinear upsampling.

  • RenderTargetUsage - When possible, avoid preserving the contents of RenderTargetUsage by calling the RenderTargetUsage.PreserveUsage.
  • BlendState - Move the initialization of the BlendState to startup. And don't create a new BlendState object to assign to the Device's BlendState property. Rather, have s static BlendState object which you initialize at Startup and keep re-using this static copy to assign to the device's BlendState property per frame
  • VertexBuffer - In cases where your code frequently works with a vertex buffer, it is recommended that the buffer be instantiated or derived from DynamicVertexBuffer instead of VertexBuffer. Avoid use of the VertexBuffer.SetData API. Rather use device.DrawUserPrimitives or DynamicVertexBuffer.SetData.

3D Models

All usual 3D models are available for the phone platform.These models get imported by the content manager simplifying the port of existing Xbox games to the Windows Phone platform.

Summary

In this article, we saw a variety of design considerations to be made when building 2D and 3D games for the Windows Phone 7 platform. I hope you found this information useful and will be able to author better games for the WP7 platform.

Related Articles



About the Author

Vipul Vipul Patel

Vipul Patel is a Software Engineer currently working at Microsoft Corporation, working in the Office Communications Group and has worked in the .NET team earlier in the Base Class libraries and the Debugging and Profiling team. He can be reached at vipul_d_patel@hotmail.com

Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Organizations are increasingly gravitating toward mobile-first application development as they assess the need to revamp their application portfolios to support touch computing and mobility. Consumerization has brought higher expectations for application usability along with the mobile devices themselves. Enterprises are increasingly shifting their new application acquisitions and development efforts toward mobile platforms. With this backdrop, it is natural to expect application platform vendors to invest in …

  • The mobile revolution and the need for mobile apps have created an unprecedented set of challenges for IT organizations. This eBook discuss these challenges and how organizations can address them by making their mobile app development processes more efficient and more effective.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date