XNA Creators Club Online

sample details

WinForms Series 1: Graphics Device
Sample
submitted
1/10/2008

Description:

This sample shows you how to use an XNA Framework GraphicsDevice object to display 3D graphics inside a WinForms application.

Sample Overview

The XNA Framework Game class provides a quick, easy, and portable way to host your game. It automatically creates a window for the game to run inside, initializes the graphics hardware, and offers simple Update and Draw methods for you to override. Sometimes the Game behavior just isn't flexible enough, though. Perhaps you want more control over how the window is created or maybe you are writing a level editor and want to place Windows user interface controls around the 3D drawing surface.

Fortunately, the XNA Framework was designed with these scenarios in mind. The framework is actually made up of two separate assemblies: Microsoft.Xna.Framework provides core functionality such as the math, graphics, input, and audio classes, and Microsoft.Xna.Framework.Game provides optional higher-level code such as the Game class. If you want to host your game in some other way, you can replace the functionality from Microsoft.Xna.Framework.Game with your own code.

This sample implements a GraphicsDeviceControl class, which inherits from System.Windows.Forms.Control and provides the ability for a WinForms control to draw itself using an XNA Framework GraphicsDevice object. It demonstrates how to share a single GraphicsDevice object between multiple controls, how to handle resizing and lost devices, and how to implement the IGraphicsDeviceService interface in order to support loading data through the ContentManager.

Note that this sample runs only on Windows. WinForms is not available on Xbox 360.

Other items in the Winforms Series

downloads
Framework

GS 3.0

Vertex Shader Version

VS 1.1

Pixel Shader Version

PS 1.1

Framework

GS 3.1

Vertex Shader Version

VS 1.1

Pixel Shader Version

PS 1.1

Framework

GS 2.0

Vertex Shader Version

VS 1.1

Pixel Shader Version

PS 1.1

var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG