Xbox LIVE Indie Games

코드 샘플 세부 정보

WinForms Series 1: Graphics Device

코드 샘플


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're 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 by using an XNA Framework GraphicsDevice object. It demonstrates how to share a single GraphicsDevice object among 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 isn't available on Xbox 360.

Other items in the Winforms Series

All content and source code downloaded from this page are bound to the Microsoft Permissive License (Ms-PL).



GS 4.0


GS 3.1

교육 콘텐츠 찾기
var gDomain=''; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/