- 注册时间
- 2004-12-21
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2009-9-21 14:50:28
|
显示全部楼层
Step 1 - Creating a Window
第一步 创建窗口
The first thing any Windows application must do when it is run is to create an application window to display to the user. To do this, the CreateDevice sample project begins execution at its WinMain function. The following sample code performs window initialization.
让窗口应用程序跑起来第一件必须做的事情就是创建一个应用程序窗口来显示给用户。要做这些,CreateDevice示例项目开始于WinMain函数。后面的代码演示里一个 窗口 的初始化。- INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
- {
- // Register the window class.
- WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
- GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
- "Direct3D Tutorial", NULL };
- RegisterClassEx( &wc );
- // Create the application's window.
- HWND hWnd = CreateWindow( "Direct3D Tutorial", "Direct3D Tutorial 01: CreateDevice",
- WS_OVERLAPPEDWINDOW, 100, 100, 300, 300,
- GetDesktopWindow(), NULL, wc.hInstance, NULL );
复制代码 The preceding code sample is standard Windows programming. The sample starts by defining and registering a window class called "Direct3D Tutorial." After the class is registered, the sample code creates a basic top-level window that uses the registered class, with a client area of 300 pixels wide by 300 pixels tall. This window has no menu or child windows. The sample uses the WS_OVERLAPPEDWINDOW window style to create a window that includes Minimize, Maximize, and Close buttons common to windowed applications. (If the sample were to run in full-screen mode, the preferred window style is WS_EX_TOPMOST, which specifies that the created window should be placed above all non-topmost windows and should stay above them, even when the window is deactivated.) When the window is created, the code sample calls standard Win32 functions to display and update the window.
前面的示例代码是一个标准的视窗程序。这个例子开始于定义和注册一个名叫"Direct3D Tutorial"的窗口类。当这个类被注册,示例代码创建一个基本的顶层窗口,这个窗口的客户区域高300像素,宽300像素。这个窗口没有菜单也没有子窗口。示例程序的窗口使用WS_OVERLAPPEDWINDOW风格创建窗口,所以又最小化、最大化以及关闭按钮。(如果示例程序使用全屏模式运行,首选的窗口风格是WS_EX_TOPMOST,WS_EX_TOPMOST风格规定创建的窗口应该在所有非顶层窗口之前,即使窗口被停用。)一旦窗口被创建,示例代码调用标准的Win32函数来显示和更新窗口。
With the application window ready, you can begin setting up the essential Direct3D objects, as described in Step 2 - Initializing Direct3D.
准备好了这些,你可以开始设置D3D对象,请收看第二步,初始化D3D。
[ 本帖最后由 Alanwywy 于 2009-9-21 15:02 编辑 ] |
|