Applications use the methods of the IDirect3DRMDevice2 and IDirect3DRMDevice interfaces to interact with the output device. While IDirect3DRMDevice, when created from the IDirect3DRM interface, works with an IDirect3DDevice Immediate Mode device, IDirect3DRMDevice2, when created from the IDirect3DRM2 interface, or initialized by the IDirect3DRMDevice2::InitFromD3D2 or IDirect3DRMDevice2::InitFromSurface method, works with an IDirect3DDevice2 Immediate Mode device. The IDirect3DDevice2 device supports the DrawPrimitive interface, as well as execute buffers, and is required for progressive meshes and for alpha blending and sorting of transparent objects.
The IDirect3DRMDevice2::InitFromSurface method uses the IDirect3DRM2::CreateDevice method to create an IDirect3DRMDevice2 interface. The IDirect3DRMDevice2::InitFromD3D2 method uses an IDirect3D2 Immediate Mode object and an IDirect3DDevice2 Immediate Mode device to initialize an IDirect3DRMDevice2 Microsoft® Direct3D® Retained Mode device.
You can still query back and forth between IDirect3DRMDevice and IDirect3DRMDevice2. The main difference is in how the underlying Immediate Mode device is created.
IDirect3DRMDevice2 contains all the methods in IDirect3DRMDevice, plus two addition ones that allow you to control transparency: IDirect3DRMDevice2::GetRenderMode and IDirect3DRMDevice2::SetRenderMode; one additional initialization method: IDirect3DRMDevice2::InitFromSurface; and two changed methods IDirect3DRMDevice2::GetDirect3DDevice2 and IDirect3DRMDevice2::InitFromD3D2, which get and initialize an IDirect3DRMDevice2 object rather than an IDirect3DRMDevice object.
This section is a reference to the methods of this interface. For a conceptual overview, see IDirect3DRMDevice, IDirect3DRMDevice2, and IDirect3DRMDeviceArray Interfaces.
The methods of the IDirect3DRMDevice2 interface can be organized into the following groups:
| Buffer counts | GetBufferCount |
| SetBufferCount | |
| Color models | GetColorModel |
| Dithering | GetDither |
| SetDither | |
| Initialization | Init |
| InitFromClipper | |
| InitFromD3D2 | |
| InitFromSurface | |
| Miscellaneous | GetDirect3DDevice2 |
| GetHeight | |
| GetTrianglesDrawn | |
| GetViewports | |
| GetWidth | |
| GetWireframeOptions | |
| Update | |
| Notifications | AddUpdateCallback |
| DeleteUpdateCallback | |
| Rendering quality | GetQuality |
| SetQuality | |
| Shading | GetShades |
| SetShades | |
| Texture quality | GetTextureQuality |
| SetTextureQuality | |
| Transparency | GetRenderMode |
| SetRenderMode | |
The IDirect3DRMDevice2 interface, like all Component Object Model (COM) interfaces, inherits the IUnknown interface methods. The IUnknown interface supports the following three methods:
| AddRef |
| QueryInterface |
| Release |
In addition, the IDirect3DRMDevice2 interface inherits the following methods from the IDirect3DRMObject interface:
| AddDestroyCallback |
| Clone |
| DeleteDestroyCallback |
| GetAppData |
| GetClassName |
| GetName |
| SetAppData |
| SetName |
The Direct3DRMDevice2 object is obtained by calling the IDirect3DRM2::CreateDevice method.
Adds a callback function that alerts the application when a change occurs to the device. The system calls this callback function whenever the application calls the IDirect3DRMDevice2::Update method.
HRESULT AddUpdateCallback(
D3DRMUPDATECALLBACK d3drmUpdateProc,
LPVOID arg
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
IDirect3DRMDevice2::DeleteUpdateCallback, IDirect3DRMDevice2::Update, D3DRMUPDATECALLBACK
Removes an update callback function that was added by calling the IDirect3DRMDevice2::AddUpdateCallback method.
HRESULT DeleteUpdateCallback(
D3DRMUPDATECALLBACK d3drmUpdateProc,
LPVOID arg
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
IDirect3DRMDevice2::AddUpdateCallback, IDirect3DRMDevice2::Update, D3DRMUPDATECALLBACK
Retrieves the value set in a call to the IDirect3DRMDevice2::SetBufferCount method.
DWORD GetBufferCount( );
Returns the number of buffersone for single-buffering, two for double-buffering, and so on.
Retrieves the color model of a device.
D3DCOLORMODEL GetColorModel( );
Returns a value from the D3DCOLORMODEL enumerated type that describes the Direct3D color model (RGB or monochrome).
Retrieves a pointer to an IDirect3DDevice2 Immediate Mode device.
HRESULT GetDirect3DDevice2(
LPDIRECT3DDEVICE2 * lplpD3DDevice
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
The IDirect3DDevice2 device will support the DrawPrimitive interface and execute buffers and is required for progressive meshes and for alpha blending and sorting of transparent objects.
Retrieves the dither flag for the device.
BOOL GetDither( );
Returns TRUE if the dither flag is set, or FALSE otherwise.
Retrieves the height, in pixels, of a device. This method is a convenience function.
DWORD GetHeight( );
Returns the height.
Retrieves the rendering quality for the device.
D3DRMRENDERQUALITY GetQuality( );
Returns one or more of the members of the enumerated types represented by the D3DRMRENDERQUALITY type.
IDirect3DRMDevice2::SetQuality
Retrieves the current transparency flags.
DWORD GetRenderMode( );
Returns the value of the current transparency flags.
Transparency flags have the following values:
| Flag | Value |
| No flag set (default) | 0 |
| D3DRMRENDERMODE_BLENDEDTRANSPARENCY | 1 |
| D3DRMRENDERMODE_SORTEDTRANSPARENCY | 2 |
IDirect3DRMDevice2::SetRenderMode
Retrieves the number of shades in a ramp of colors used for shading in the monochromatic (or ramp) model.
DWORD GetShades( );
Returns the number of shades.
Retrieves the current texture quality parameter for the device. Texture quality is relevant only for an RGB device.
D3DRMTEXTUREQUALITY GetTextureQuality( );
Returns one of the members of the D3DRMTEXTUREQUALITY enumerated type.
IDirect3DRMDevice2::SetTextureQuality
Retrieves the number of triangles drawn to a device since its creation. This method is a convenience function.
DWORD GetTrianglesDrawn( );
Returns the number of triangles.
The number of triangles includes those that were passed to the renderer but were not drawn because they were backfacing. The number does not include triangles that were rejected for lying outside of the viewing frustum.
Constructs a Direct3DRMViewportArray object that represents the viewports currently constructed from the device.
HRESULT GetViewports(
LPDIRECT3DRMVIEWPORTARRAY* lplpViewports
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
Retrieves the width, in pixels, of a device. This method is a convenience function.
DWORD GetWidth( );
Returns the width.
Retrieves the wireframe options of a given device.
DWORD GetWireframeOptions( );
Returns a bitwise OR of the following values:
Not implemented on the Microsoft® Windows® platform.
HRESULT Init(
ULONG width,
ULONG height
);
Initializes an IDirect3DDevice2 device from a specified DirectDrawClipper object using IDirect3DRM2::CreateDevice.
HRESULT InitFromClipper(
LPDIRECTDRAWCLIPPER lpDDClipper,
LPGUID lpGUID,
int width,
int height
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
Initializes an IDirect3DRMDevice2 Retained Mode device from an IDirect3D2 Immediate Mode object and an IDirect3DDevice2 Immediate Mode device.
HRESULT InitFromD3D2(
LPDIRECT3D2 lpD3D,
LPDIRECT3DDEVICE2 lpD3DIMDev
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
The IDirect3DRMDevice2 device initialized from IDirect3DDevice2 will support the DrawPrimitive interface and execute buffers and is required for progressive meshes and for alpha blending and sorting of transparent objects.
Initializes a IDirect3DDevice2 device from a specified DirectDraw surface, using the IDirect3DRM2::CreateDevice method.
HRESULT InitFromSurface(
LPGUID lpGUID,
LPDIRECTDRAW lpDD,
LPDIRECTDRAWSURFACE lpDDSBack
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
The IDirect3DRMDevice2 device initialized will support the DrawPrimitive interface and execute buffers, and is required for progressive meshes and for alpha blending and sorting of transparent objects.
Sets the number of buffers currently being used by the application.
HRESULT SetBufferCount(
DWORD dwCount
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
An application that employs double-buffering or triple-buffering must use this method to inform the system of how many buffers it is using so that the system can calculate how much of the window to clear and update on each frame.
IDirect3DRMDevice2::GetBufferCount
Sets the dither flag for the device.
HRESULT SetDither(
BOOL bDither
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
Sets the rendering quality of a device
HRESULT SetQuality (
D3DRMRENDERQUALITY rqQuality
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
The rendering quality is the maximum quality at which rendering can take place on the rendering surface of that device.
An object's quality has three components: shade mode (flat or Gouraud; Phong is not yet implemented and will default to Gouraud shading), lighting type (on or off), and fill mode (point, wireframe or solid).
You set the quality of a device with SetQuality. By default it is D3DRMRENDER_FLAT (flat shading, lights on, and solid fill).
You can set the quality of a Direct3DRMProgressiveMesh, Direct3DRMMeshBuilder, or Direct3DRMMeshBuilder2 object with their respective SetQuality methods. By default, the quality of these objects is D3DRMRENDER_GOURAUD (Gouraud shading, lights on, and solid fill).
Direct3D Retained Mode renders an object at the lowest quality setting based on the device and object's current setting for each individual component. For example, if the object's current quality setting is D3DRMRENDER_GOURAUD, and the device is D3DRMRENDER_FLAT, the object will be rendered with flat shading, solid fill, and lights on.
If the object's current quality setting is D3DRMSHADE_GOURAUD|D3DRMLIGHT_OFF|D3DRMFILL_WIREFRAME and the device's quality setting is D3DRMSHADE_FLAT|D3DRMLIGHT_ON|D3DRMFILL_POINT, the object will be rendered with flat shading, lights off, and point fill mode.
These rules apply to Direct3DRMMeshBuilder objects, Direct3DRMMeshBuilder2 objects, and Direct3DRMProgressiveMesh objects. However, Direct3DRMMesh objects do not follow these rules. Mesh objects ignore the device's quality settings and use the group quality setting (which defaults to D3DRMRENDER_GOURAUD).
IDirect3DRMDevice2::GetQuality
Sets the transparency mode. The mode type determines how transparent objects will be rendered. The default mode renders transparent objects with stippled transparency.
HRESULT SetRenderMode(
DWORD dwFlags
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
If the D3DRMRENDERMODE_BLENDEDTRANSPARENCY and D3DRMRENDERMODE_SORTEDTRANSPARENCY flags are set together, it ensures that when two transparent objects are rendered one on top of the other, the image will blend in the correct order to ensure the right visual result.
IDirect3DRMDevice2::GetRenderMode
Sets the number of shades in a ramp of colors used for shading in the monochromatic (or ramp) model.
HRESULT SetShades(
DWORD ulShades
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
Sets the texture quality for the device.
HRESULT SetTextureQuality(
D3DRMTEXTUREQUALITY tqTextureQuality
);
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
IDirect3DRMDevice2::GetTextureQuality
Copies the image that has been rendered to the display. It also provides a heartbeat function to the device driver.
HRESULT Update( );
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained Mode Return Values.
Each call to this method causes the system to call an application-defined callback function, D3DRMUPDATECALLBACK. To add a callback function, use the IDirect3DRMDevice2::AddUpdateCallback method.
IDirect3DRMDevice2::AddUpdateCallback, D3DRMUPDATECALLBACK
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.