Using macros to call DirectX com)

Source: Internet
Author: User

Using macros to call DirectX com

Many Microsoft DirectX interfaces define a macro for each method, which makes it easier to use these methods in your application. You will find these macros in the header file of the interface declaration. These macros are designed to be Macros in C and Macros in C ++. If you want to use Macros in C ++, you must define _ cplusplus. Otherwise, you will use Macros in C. The syntax of macros is the same in the two languages, but they are defined separately in the header file for proper extension of call conventions.

For example, the following code snippet shows the C macro and C ++ macro defined for the idirect3d8: getadapteridentifier method from the d3d. h header file.

# If! Defined (_ cplusplus) | defined (cinterface)

...
# Define idirect3d8_getadapteridentifier (P, A, B, C) (p)-> lpvtbl-> getadapteridentifier (P, A, B, C)
...
# Else
...
# Define idirect3d8_getadapteridentifier (P, A, B, C) (p)-> getadapteridentifier (A, B, C)
...
# Endif

To use these macros, you must first obtain the pointers of related interfaces. The first parameter of the macro must be set as this pointer. The remaining parameters correspond to the parameters in the method. The return value of a macro is an hresult type, which is the return value of the method corresponding to the macro. The following code snippet uses a macro to call idirect3d8: getadapter (dentifier method, pd3d is a pointer to the idirect3d8 interface.

HR = idirect3d8_getadapteridentifier (pd3d,
Adapter,
Dwflags,
Pidentifier );

Note: Due to the limited translation level, errors are inevitable. If you find that the translation is incorrect, ask your friends on the road to correct it. Thank you.

Can be reproduced at will.

Translator: closeall

 

Translated by 2005.09.05

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.