Dxut programming guide (1): dxut Overview

Source: Internet
Author: User

Dxut programming guide
(Translated from DirectX SDK document)


Dxut is a layer built on the direct3d API. It is used in most direct3d guides and instances. It aims to make direct3d examples, samples, tools, and professional games more robust and easy to build. It simplifies the typical usage of windows and direct3d APIs.

Dxut Overview
Initialize dxut
Use the program window through dxut

Use a device through dxut
Use the main loop through dxut

Error Handling through dxut
Use dxut to select more advanced devices
Other dxut Functions


Dxut Overview

This topic provides a high-level overview of dxut.
Overview

Features

Limitations
Start a new project
Improvement of dxut in DirectX rjl 2005 SDK
Changes from dxut in DirectX summer 2003 SDK


Overview

This framework structure is designed to help Programmers spend less time worrying about how to create windows, how to create devices, how to process window messages, and when to process device events.
Here is the main function of the sample program using this framework.
Int winapi winmain (hinstance, hinstance, lpstr, INT)
{
// Set the callback function. These functions allow dxut to notify applications about device changes, user input, and window messages.
// These callback functions are optional, so you only need to set them for the events you are interested in (the function name is well understood)
Dxutsetcallbackdevicecreated (oncreatedevice );
Dxutsetcallbackdevicereset (onresetdevice );
Dxutsetcallbackdevicelost (onlostdevice );
Dxutsetcallbackdevicedestroyed (ondestroydevice );

Dxutsetcallbackframerender (onframerender );
Dxutsetcallbackframemove (onframemove );

// Initialize dxut to create the expected Win32 window and d3d device for your application
// Call these functions is optional, but they allow you to set several parameters to control the framework's behavior.
Dxutinit (true, true, true );
Dxutcreatewindow (L "basichlsl ");
Dxutcreatedevice (d3dadapter_default, true, 640,480 );

// Control dxut to process message loops and dispatch rendering calls. If there is idle time between messages in the processing window,
// The Framework calls your onframemove and onframerender callback functions.
Dxutmainloop ();

Return dxutgetexitcode ();
}

In the preceding example, the framework does most of the work. It creates a window, creates a device, and processes the main loop. when an event occurs, it uses the callback function provided by the application, such as device reset, and frame rendering. The framework is modular, and applications can use all the features of the framework, or use only the desired part.
The remaining part of this programming guide contains detailed explanations of each step in this step, as well as a look at the options that the application can control and the steps that can be replaced.
For more details, you can find the syntax, function usage, callback function, struct, enumeration, and constants in dxutreference.


Features

The framework provides the following services to help you create applications:

Simplify the creation of windows and devices.
Notification device events (create, reset, lose, destroy) and window events (message, keyboard, mouse)
Switch between windows and full screen, and between Hal and ref Devices
High-resolution timer
Provides command line support for Automatic Testing
Select a device through the dialog box or API
A set of textures, including editing boxes that support input methods
Some additional classes, such as simple camera types


Limitations

For ease of use, the framework only supports a single window to be associated with a single device. Some advanced applications need to use multiple devices at the same time or display multiple d3d windows will not be supported by the framework. However, most typical programs can use the framework.


Start a new project

The simplest way to start a new vs. Net project through dxut is as follows:

1. Start sample browser, which is located in (SDK root)/samples/samplebrowser/
2. Select an existing sample project in browser as the starting point.
3. Click the "install project" link to copy the project file to a new folder.
4. You can rename the project at will. The sample browser will change the appropriate files and source code in the project to rename the project.


Improvement of dxut in DirectX rjl 2005 SDK

Based on Customer feedback, the framework has been improved in the DirectX compiler l 2005 SDK update. The main differences and improvements are listed below:

Now you can pass in a void * pusercontext parameter through dxutsetcallback * to the callback function. This allows the callback function to accept context such as class pointer from the application.
The framework Gui has been separated from the core of the framework and is optional. If your application wants to use the framework GUI, you must be responsible for creating cdxutdialogresourcemanager and connecting interfaces.
The framework now allows applications to reject device changes through the lpdxutcallbackmodifydevicesettings function (which returns a bool value. If this callback function returns false, the framework will be notified to keep using the current device instead of changing to the new device. For example, by default, dragging a window between two monitors in a multi-monitor configuration causes the frame to change the device. However, if the application cannot use another device, it must be able to reject this change and continue to use the current device. By using dxutsetcallbackdevicechanging, callback of createdevice can be set separately (This callback can now be set separate of the createdevice function by using dxutsetcallbackdevicechanging .)
Passing 0 to the dxutcreatedevice function as width and height creates a backup buffer with the same size as the client window.
Now the dxutgetexitcode function returns 11 if the last device type is d3ddevtype_ref.


Changes from dxut in DirectX summer 2003 SDK

The new framework is redesigned from dxut in DirectX summer 2003 SDK update. The main differences and improvements are listed below:

API design. The new framework is a series of global functions that clearly define how an application interacts with the Framework.
Better naming. It is easier to rename devices, frameworks, and message events.
Module. Applications can only use part of the framework. Applications can use frameworks to create their own windows and devices, or they can use their own main loops.
Better device selection. Before creating a device, the application can completely customize presentation parameters or behavior flags. The new framework has more advanced algorithms to find effective device settings.
Switch between Hal and ref devices. Built-in switch support. To simplify debugging, the switch can be bound to a key.
Better error handling. Once an API is called incorrectly, the application can use error processing and macros to Display error message boxes.
Better support for multiple monitors. If this feature is enabled, the new framework automatically changes the device when the window is moved to different monitors.
Gui control. A set of control packages with textures can be expanded to support the input method editing box, which can be used in examples, samples, and professional games.
No dialog box depends on GDI. Unlike the previous framework, the new framework no longer requires any GDI dialog box resources.
Late binging with DirectX. Check whether the required DirectX version is installed in the system.
Unicode support. The new framework supports Unicode. The NT-based Windows operating system supports Unicode. This means that the ANSI call needs to be converted to Unicode. Unicode is a better choice for international support because it will provide better performance on these operating systems. For WIN98 and winme, Microsoft layer for Unicode (mslu) can be used ).
Documentation. The Framework library functions in dxut. h are documented. See dxut reference.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.