ID3DXSprite Interface

 

 

' ****************************************************************************************
' ID3DXSprite interface
' $IID_ID3DXSprite = GUID$("{BA0B762D-7D28-43ec-B9DC-2F84443B0614}")
' ****************************************************************************************

' ****************************************************************************************
' The ID3DXSprite interface provides a set of methods that simplify the process of drawing
' sprites using Microsoft Direct3D.
' Remarks
'    The ID3DXSprite interface is obtained by calling the D3DXCreateSprite function.
'    The application typically first calls ID3DXSprite::Begin, which allows control over the
'    device render state, alpha blending, and sprite transformation and sorting. Then for each
'    sprite to be displayed, call ID3DXSprite::Draw. ID3DXSprite::Draw can be called repeatedly
'    to store any number of sprites. To display the batched sprites to the device, call
'    ID3DXSprite::End or ID3DXSprite::Flush.
' Interface Information
'    Stock Implementation   d3d9.dll
'    Custom Implementation  No
'    Inherits from  IUnknown
'    Header     d3dx9core.h
'    Import library     d3dx9.lib
'    Minimum operating systems  Windows 98
' ****************************************************************************************

' ****************************************************************************************
'DECLARE_INTERFACE_(ID3DXSprite, IUnknown)
'{
'    // IUnknown
'  0.  STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
'  1.  STDMETHOD_(ULONG, AddRef)(THIS) PURE;
'  2.  STDMETHOD_(ULONG, Release)(THIS) PURE;

'    // ID3DXSprite
'  3.  STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE;
'  4.  STDMETHOD(GetTransform)(THIS_ D3DXMATRIX *pTransform) PURE;
'  5.  STDMETHOD(SetTransform)(THIS_ CONST D3DXMATRIX *pTransform) PURE;
'  6.  STDMETHOD(SetWorldViewRH)(THIS_ CONST D3DXMATRIX *pWorld, CONST D3DXMATRIX *pView) PURE;
'  7.  STDMETHOD(SetWorldViewLH)(THIS_ CONST D3DXMATRIX *pWorld, CONST D3DXMATRIX *pView) PURE;
'  8.  STDMETHOD(Begin)(THIS_ DWORD Flags) PURE;
'  9.  STDMETHOD(Draw)(THIS_ LPDIRECT3DTEXTURE9 pTexture, CONST RECT *pSrcRect, CONST D3DXVECTOR3 *pCenter, CONST D3DXVECTOR3 *pPosition, D3DCOLOR Color) PURE;
' 10.  STDMETHOD(Flush)(THIS) PURE;
' 11.  STDMETHOD(End)(THIS) PURE;
' 12.  STDMETHOD(OnLostDevice)(THIS) PURE;
' 13.   STDMETHOD(OnResetDevice)(THIS) PURE;
'};
' ****************************************************************************************

' ****************************************************************************************
' GetDevice method
' Retrieves the device associated with the sprite object.
' HRESULT GetDevice(
'   LPDIRECT3DDEVICE9 * ppDevice
' );
' ****************************************************************************************
FUNCTION ID3DXSprite_GetDevice ALIAS "ID3DXSprite_GetDevice" ( _
    BYVAL pthis AS DWORD PTR, BYREF ppDevice AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[3] USING ID3DXSprite_GetDevice(pthis, ppDevice) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' GetTransform method
' Gets the sprite transform.
' HRESULT GetTransform(
'   D3DXMATRIX * pTransform
' );
' ****************************************************************************************
FUNCTION ID3DXSprite_GetTransform ALIAS "ID3DXSprite_GetTransform" ( _
    BYVAL pthis AS DWORD PTR, BYREF pTransform AS D3DXMATRIX) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[4] USING ID3DXSprite_GetTransform(pthis, pTransform) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' SetTransform method
' Sets the sprite transform.
' HRESULT SetTransform(
'   CONST D3DXMATRIX * pTransform
' );
' ****************************************************************************************
FUNCTION ID3DXSprite_SetTransform ALIAS "ID3DXSprite_SetTransform" ( _
    BYVAL pthis AS DWORD PTR, BYREF pTransform AS D3DXMATRIX) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[5] USING ID3DXSprite_SetTransform(pthis, pTransform) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' SetWorldViewRH  method
' Sets the right-handed world-view transform for a sprite. A call to this method is
' required before billboarding or sorting sprites.
' HRESULT SetWorldViewRH(
'   CONST D3DXMATRIX * pWorld,
'   CONST D3DXMATRIX * pView
' );
' ****************************************************************************************
FUNCTION ID3DXSprite_SetWorldViewRH ALIAS "ID3DXSprite_SetWorldViewRH"  ( _
    BYVAL pthis AS DWORD PTR, BYREF pWorld AS D3DXMATRIX, BYREF pView AS D3DXMATRIX) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[6] USING ID3DXSprite_SetWorldViewRH (pthis, pWorld, pView) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' SetWorldViewLH  method
' Sets the left-handed world-view transform for a sprite. A call to this method is
' required before billboarding or sorting sprites.
' HRESULT SetWorldViewLH(
'   CONST D3DXMATRIX * pWorld,
'   CONST D3DXMATRIX * pView
' );
' ****************************************************************************************
FUNCTION ID3DXSprite_SetWorldViewLH ALIAS "ID3DXSprite_SetWorldViewLH"  ( _
    BYVAL pthis AS DWORD PTR, BYREF pWorld AS D3DXMATRIX, BYREF pView AS D3DXMATRIX) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[7] USING ID3DXSprite_SetWorldViewLH (pthis, pWorld, pView) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' Begin method
' Prepares a device for drawing sprites.
' HRESULT Begin(
'   DWORD Flags
' );
' ****************************************************************************************
FUNCTION ID3DXSprite_Begin ALIAS "ID3DXSprite_Begin"  ( _
    BYVAL pthis AS DWORD PTR, BYVAL Flags AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[8] USING ID3DXSprite_Begin (pthis, Flags) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' Draw method
' Adds a sprite to the list of batched sprites.
' HRESULT Draw(
'   LPDIRECT3DTEXTURE9 pTexture,
'   CONST RECT * pSrcRect,
'   CONST D3DXVECTOR3 * pCenter,
'   CONST D3DXVECTOR3 * pPosition,
'   D3DCOLOR Color
' );
' ****************************************************************************************
FUNCTION ID3DXSprite_Draw ALIAS "ID3DXSprite_Draw"  ( _
    BYVAL pthis AS DWORD PTR, BYVAL pTexture AS DWORD, BYREF pSrcRect AS RECT, _
    BYREF pCenter AS D3DXVECTOR3, BYREF pPosition AS D3DXVECTOR3, _
    BYVAL prmColor AS DWORD) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[9] USING ID3DXSprite_Draw (pthis, pTexture, pSrcRect, pCenter, pPosition, prmColor) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' Flush method
' Forces all batched sprites to be submitted to the device. Device states remain as they
' were after the last call to ID3DXSprite::Begin. The list of batched sprites is then
' cleared.
' HRESULT Flush();
' ****************************************************************************************
FUNCTION ID3DXSprite_Flush ALIAS "ID3DXSprite_Flush"  (BYVAL pthis AS DWORD PTR) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[10] USING ID3DXSprite_Flush (pthis) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' End method
' Calls ID3DXSprite::Flush and restores the device state to how it was before
' ID3DXSprite::Begin was called.
' HRESULT End();
' ****************************************************************************************
FUNCTION ID3DXSprite_End ALIAS "ID3DXSprite_End"  (BYVAL pthis AS DWORD PTR) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[11] USING ID3DXSprite_End (pthis) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' OnLostDevice method
' Releases all references to video memory resources and deletes all stateblocks.
' HRESULT OnLostDevice();
' ****************************************************************************************
FUNCTION ID3DXSprite_OnLostDevice ALIAS "ID3DXSprite_OnLostDevice"  (BYVAL pthis AS DWORD PTR) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[12] USING ID3DXSprite_OnLostDevice (pthis) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' OnResetDevice method
' Should be called after the device has been reset.
' HRESULT OnResetDevice();
' ****************************************************************************************
FUNCTION ID3DXSprite_OnResetDevice ALIAS "ID3DXSprite_OnResetDevice"  (BYVAL pthis AS DWORD PTR) EXPORT AS LONG

    LOCAL HRESULT AS LONG
    IF pthis = %NULL THEN FUNCTION = %E_POINTER : EXIT FUNCTION
    CALL DWORD @@pthis[13] USING ID3DXSprite_OnResetDevice (pthis) TO HRESULT
    FUNCTION = HRESULT

END FUNCTION
' ****************************************************************************************
 

 

Page last updated on Tuesday, 14 March 2006 22:23:19 +0100