' ########################################################################################
' Microsoft Windows
' File: d3dx10core.inc
' Contents: D3DX10 core types and functions
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_D3DX10core_PBI)
#DEFINE PBX_D3DX10core_PBI
%EQUATE `D3DX10CORE_INC = 1
#INCLUDE ONCE "Legacy/Graphics/D3D10_1.inc"
'// Current name of the DLL shipped in the same SDK as this header.
'#define D3DX10_DLL_W L"d3dx10_35.dll"
'#define D3DX10_DLL_A "d3dx10_35.dll"
'#ifdef UNICODE
' #define D3DX10_DLL D3DX10_DLL_W
'#else
' #define D3DX10_DLL D3DX10_DLL_A
'#endif
#IF NOT %DEF($D3DX10_DLLNAME)
$D3DX10_DLLNAME = "d3dx10_35.dll" ' --> change as needed
#ENDIF
#INCLUDE ONCE "Legacy/Graphics/D3DX10.inc"
'///////////////////////////////////////////////////////////////////////////
'// D3DX10_SDK_VERSION:
'// -----------------
'// This identifier is passed to D3DX10CheckVersion in order to ensure that an
'// application was built against the correct header files and IMPORT files.
'// This number is incremented whenever a header (or other) change would
'// require applications to be rebuilt. If the version doesn't match,
'// D3DX10CreateVersion will return FALSE. (The number itself has no meaning.)
'///////////////////////////////////////////////////////////////////////////
%EQUATE `D3DX10_SDK_VERSION = 35
'///////////////////////////////////////////////////////////////////////////
'// D3DX10CreateDevice
'// D3DX10CreateDeviceAndSwapChain
'// D3DX10GetFeatureLevel1
'///////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION D3DX10CreateDevice IMPORT $D3DX10_DLLNAME ALIAS "D3DX10CreateDevice" ( BYVAL pAdapter AS IDXGIAdapter , BYVAL DriverType AS QUAD , BYVAL Software AS QUAD , BYVAL Flags AS QUAD , BYREF ppDevice AS ID3D10Device ) AS LONG
DECLARE FUNCTION D3DX10CreateDeviceAndSwapChain IMPORT $D3DX10_DLLNAME ALIAS "D3DX10CreateDeviceAndSwapChain" ( BYVAL pAdapter AS IDXGIAdapter
 , BYVAL DriverType AS DWORD
 , BYVAL Software AS DWORD
 , BYVAL Flags AS DWORD
 , BYREF pSwapChainDesc AS DXGI_SWAP_CHAIN_DESC
 , BYREF ppSwapChain AS IDXGISwapChain
 , BYREF ppDevice AS ID3D10Device
 ) AS LONG
DECLARE FUNCTION D3DX10GetFeatureLevel1 IMPORT $D3DX10_DLLNAME ALIAS "D3DX10GetFeatureLevel1" ( BYVAL pDevice AS ID3D10Device
 , BYREF ppDevice1 AS ID3D10Device1
 ) AS LONG
'#ifdef D3D10_DEBUG
DECLARE FUNCTION D3DX10DebugMute IMPORT $D3DX10_DLLNAME ALIAS "D3DX10DebugMute" ( BYVAL Mute AS LONG ) AS LONG
'#endif
DECLARE FUNCTION D3DX10CheckVersion IMPORT $D3DX10_DLLNAME ALIAS "D3DX10CheckVersion" ( BYVAL D3DSdkVersion AS QUAD , BYVAL D3DX10SdkVersion AS QUAD ) AS LONG
DECLARE FUNCTION D3DX10GetDriverLevel IMPORT $D3DX10_DLLNAME ALIAS "D3DX10GetDriverLevel" ( BYVAL pDevice AS ID3D10Device
 ) AS LONG
'//////////////////////////////////////////////////////////////////////////////
'// D3DX10_SPRITE flags:
'// -----------------
'// D3DX10_SPRITE_SAVE_STATE
'// Specifies device state should be saved and restored in Begin/End.
'// D3DX10SPRITE_SORT_TEXTURE
'// Sprites are sorted by texture prior to drawing. This is recommended when
'// drawing non-overlapping sprites of uniform depth. For example, drawing
'// screen-aligned text with ID3DX10Font.
'// D3DX10SPRITE_SORT_DEPTH_FRONT_TO_BACK
'// Sprites are sorted by depth front-to-back prior to drawing. This is
'// recommended when drawing opaque sprites of varying depths.
'// D3DX10SPRITE_SORT_DEPTH_BACK_TO_FRONT
'// Sprites are sorted by depth back-to-front prior to drawing. This is
'// recommended when drawing transparent sprites of varying depths.
'// D3DX10SPRITE_ADDREF_TEXTURES
'// AddRef/Release all textures passed in to DrawSpritesBuffered
'//////////////////////////////////////////////////////////////////////////////
' enum D3DX10_SPRITE_FLAG
%EQUATE `D3DX10_SPRITE_SORT_TEXTURE = &H01
%EQUATE `D3DX10_SPRITE_SORT_DEPTH_BACK_TO_FRONT = &H02
%EQUATE `D3DX10_SPRITE_SORT_DEPTH_FRONT_TO_BACK = &H04
%EQUATE `D3DX10_SPRITE_SAVE_STATE = &H08
%EQUATE `D3DX10_SPRITE_ADDREF_TEXTURES = &H10
' // Size = 104 bytes
TYPE D3DX10_SPRITE DWORD
 matWorld AS D3DXMATRIX
 TexCoord AS D3DXVECTOR2
 TexSize AS D3DXVECTOR2
 ColorModulate AS D3DXCOLOR
 pTexture AS DWORD PTR ' ID3D10ShaderResourceView
 TextureIndex AS DWORD ' UINT
END TYPE
'//////////////////////////////////////////////////////////////////////////////
'// ID3DX10Sprite:
'// ------------
'// This object intends to provide an easy way to drawing sprites using D3D.
'//
'// Begin -
'// Prepares device for drawing sprites.
'//
'// Draw -
'// Draws a sprite
'//
'// Flush -
'// Forces all batched sprites to submitted to the device.
'//
'// End -
'// Restores device state to how it was when Begin was called.
'//
'//////////////////////////////////////////////////////////////////////////////
' ########################################################################################
' ID3DX10Sprite interface
' IID = 9B7E4E00-342C-4106-A19F-4F2704F689F0
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%ID3DX10Sprite_INTERFACE_DEFINED)
 %ID3DX10Sprite_INTERFACE_DEFINED = 1
$IID_ID3DX10Sprite = GUID$("{BA0B762D-8D28-43EC-B9DC-2F84443B0614}")
INTERFACE ID3DX10Sprite $IID_ID3DX10Sprite
 INHERIT IUnknown
 ' =====================================================================================
 METHOD Begin ( ' VTable offset = 12
 BYVAL flags AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD DrawSpritesBuffered ( ' VTable offset = 16
 BYREF pSprites AS D3DX10_SPRITE
 , BYVAL cSprites AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD Flush ( ' VTable offset = 20
 ) AS LONG
 ' =====================================================================================
 METHOD DrawSpritesImmediate ( ' VTable offset = 24
 BYREF pSprites AS D3DX10_SPRITE
 , BYVAL cSprites AS DWORD
 , BYVAL cbSprite AS DWORD
 , BYVAL flags AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD End ( ' VTable offset = 28
 ) AS LONG
 ' =====================================================================================
 METHOD GetViewTransform ( ' VTable offset = 32
 BYREF pViewTransform AS D3DXMATRIX
 ) AS LONG
 ' =====================================================================================
 METHOD SetViewTransform ( ' VTable offset = 36
 BYREF pViewTransform AS D3DXMATRIX
 ) AS LONG
 ' =====================================================================================
 METHOD GetProjectionTransform ( ' VTable offset = 40
 BYREF pProjectionTransform AS D3DXMATRIX
 ) AS LONG
 ' =====================================================================================
 METHOD SetProjectionTransform ( ' VTable offset = 44
 BYREF pProjectionTransform AS D3DXMATRIX
 ) AS LONG
 ' =====================================================================================
 METHOD GetDevice ( ' VTable offset = 48
 BYREF ppDevice AS ID3D10Device
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ID3DX10Sprite_INTERFACE_DEFINED__ */
DECLARE FUNCTION D3DX10CreateSprite IMPORT $D3DX10_DLLNAME ALIAS "D3DX10CreateSprite" ( BYVAL pDevice AS ID3D10Device , BYVAL cDeviceBufferSize AS QUAD , BYREF ppSprite AS ID3DX10Sprite ) AS LONG
' ########################################################################################
' ID3DX10ThreadPump interface
' IID = C93FECFA-6967-478A-ABBC-402D90621FCB
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%ID3DX10ThreadPump_INTERFACE_DEFINED)
 %ID3DX10ThreadPump_INTERFACE_DEFINED = 1
$IID_ID3DX10ThreadPump = GUID$("{C93FECFA-6967-478A-ABBC-402D90621FCB}")
INTERFACE ID3DX10ThreadPump $IID_ID3DX10ThreadPump
 INHERIT IUnknown
 ' =====================================================================================
 METHOD AddWorkItem ( ' VTable offset = 12
 BYVAL pDataLoader AS DWORD
 , BYVAL pDataProcessor AS DWORD
 , BYREF pHResult AS LONG
 , BYREF ppDeviceObject AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetWorkItemCount ( ' VTable offset = 16
 ) AS DWORD ' UINT
 ' =====================================================================================
 METHOD WaitForAllItems ( ' VTable offset = 20
 ) AS LONG
 ' =====================================================================================
 METHOD ProcessDeviceWorkItems ( ' VTable offset = 24
 BYVAL iWorkItemCount AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD PurgeAllItems ( ' VTable offset = 28
 ) AS LONG
 ' =====================================================================================
 METHOD GetQueueStatus ( ' VTable offset = 32
 BYREF pIoQueue AS DWORD
 , BYREF pProcessQueue AS DWORD
 , BYREF pDeviceQueue AS DWORD
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ID3DX10ThreadPump_INTERFACE_DEFINED__ */
DECLARE FUNCTION D3DX10CreateThreadPump IMPORT $D3DX10_DLLNAME ALIAS "D3DX10CreateThreadPump" ( BYVAL cIoThreads AS QUAD , BYVAL cProcThreads AS QUAD , BYREF ppThreadPump AS ID3DX10ThreadPump ) AS LONG
'//////////////////////////////////////////////////////////////////////////////
'// ID3DX10Font:
'// ----------
'// Font objects contain the textures and resources needed to render a specific
'// font on a specific device.
'//
'// GetGlyphData -
'// Returns glyph cache data, for a given glyph.
'//
'// PreloadCharacters/PreloadGlyphs/PreloadText -
'// Preloads glyphs into the glyph cache textures.
'//
'// DrawText -
'// Draws formatted text on a D3D device. Some parameters are
'// surprisingly similar to those of GDI's DrawText function. See GDI
'// documentation for a detailed description of these parameters.
'// If pSprite is NULL, an internal sprite object will be used.
'//
'//////////////////////////////////////////////////////////////////////////////
' // Size = 56 bytes
TYPE D3DX10_FONT_DESCA BYTE
 Height AS LONG ' INT
 Width AS DWORD ' UINT
 Weight AS DWORD ' UINT
 MipLevels AS DWORD ' UINT
 Italic AS LONG
 CharSet AS BYTE ' BYTE
 OutputPrecision AS BYTE ' BYTE
 Quality AS BYTE ' BYTE
 PitchAndFamily AS BYTE ' BYTE
 FaceName AS ASCIIZ * %LF_FACESIZE ' CHAR
END TYPE
MACRO D3DX10_FONT_DESC = D3DX10_FONT_DESCA
' // Size = 88 bytes
TYPE D3DX10_FONT_DESCW BYTE
 Height AS LONG ' INT
 Width AS DWORD ' UINT
 Weight AS DWORD ' UINT
 MipLevels AS DWORD ' UINT
 Italic AS LONG
 CharSet AS BYTE ' BYTE
 OutputPrecision AS BYTE ' BYTE
 Quality AS BYTE ' BYTE
 PitchAndFamily AS BYTE ' BYTE
 FaceName AS WSTRINGZ * %LF_FACESIZE ' WCHAR
END TYPE
' ########################################################################################
' ID3DX10Font interface
' IID = D79DBB70-5F21-4D36-BBC2-FF525C213CDC}
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%ID3DX10Font_INTERFACE_DEFINED)
 %ID3DX10Font_INTERFACE_DEFINED = 1
$IID_ID3DX10Font = GUID$("{D79DBB70-5F21-4D36-BBC2-FF525C213CDC}}")
INTERFACE ID3DX10Font $IID_ID3DX10Font
 INHERIT IUnknown
 ' =====================================================================================
 METHOD GetDevice ( ' VTable offset = 12
 BYREF ppDevice AS ID3D10Device
 ) AS LONG
 ' =====================================================================================
 METHOD GetDesc ( ' VTable offset = 16
 BYREF pDesc AS D3DX10_FONT_DESC
 ) AS LONG
 ' =====================================================================================
 METHOD GetDescW ( ' VTable offset = 20
 BYREF pDesc AS D3DX10_FONT_DESCW
 ) AS LONG
 ' =====================================================================================
 METHOD GetTextMetrics ( ' VTable offset = 24
 BYREF pTextMetrics AS TEXTMETRIC
 ) AS LONG
 ' =====================================================================================
 METHOD GetTextMetricsW ( ' VTable offset = 28
 BYREF pTextMetrics AS TEXTMETRICW
 ) AS LONG
 ' =====================================================================================
 METHOD GetDC ( ' VTable offset = 32
 ) AS DWORD ' HDC
 ' =====================================================================================
 METHOD GetGlyphData ( ' VTable offset = 32
 BYVAL Glyph AS DWORD
 , BYREF ppTexture AS ID3D10ShaderResourceView
 , BYREF pBlackBox AS RECT
 , BYREF pCellInc AS POINT
 ) AS LONG
 ' =====================================================================================
 METHOD PreloadCharacters ( ' VTable offset = 36
 BYVAL First AS DWORD
 , BYVAL Last AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD PreloadGlyphs ( ' VTable offset = 40
 BYVAL First AS DWORD
 , BYVAL Last AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD PreloadText ( ' VTable offset = 44
 BYREF pString AS ASCIIZ
 , BYVAL Count AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD PreloadTextW ( ' VTable offset = 48
 BYREF pString AS WSTRINGZ
 , BYVAL Count AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD DrawText ( ' VTable offset = 52
 BYVAL pSprite AS ID3DX10Sprite
 , BYREF pString AS ASCIIZ
 , BYVAL Count AS LONG
 , BYREF pRect AS RECT
 , BYVAL Format AS DWORD
 , BYREF Color AS D3DXCOLOR
 ) AS LONG ' INT
 ' =====================================================================================
 METHOD DrawTextW ( ' VTable offset = 56
 BYVAL pSprite AS ID3DX10Sprite
 , BYREF pString AS WSTRINGZ
 , BYVAL Count AS LONG
 , BYREF pRect AS RECT
 , BYVAL Format AS DWORD
 , BYREF Color AS D3DXCOLOR
 ) AS LONG ' INT
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ID3DX10Font_INTERFACE_DEFINED__ */
DECLARE FUNCTION D3DX10CreateFontA IMPORT $D3DX10_DLLNAME ALIAS "D3DX10CreateFontA" ( BYVAL pDevice AS ID3D10Device , BYVAL Height AS LONG , BYVAL Width AS QUAD , BYVAL Weight AS QUAD , BYVAL MipLevels AS QUAD , BYVAL Italic AS LONG , BYVAL CharSet AS QUAD , BYVAL OutputPrecision AS QUAD , BYVAL Quality AS QUAD , BYVAL PitchAndFamily AS QUAD , BYREF pFaceName AS ASCIIZ , BYREF ppFont AS ID3DX10Font ) AS LONG
DECLARE FUNCTION D3DX10CreateFontW IMPORT $D3DX10_DLLNAME ALIAS "D3DX10CreateFontW" ( BYVAL pDevice AS ID3D10Device
 , BYVAL Height AS LONG
 , BYVAL Width AS DWORD
 , BYVAL Weight AS DWORD
 , BYVAL MipLevels AS DWORD
 , BYVAL Italic AS LONG
 , BYVAL CharSet AS DWORD
 , BYVAL OutputPrecision AS DWORD
 , BYVAL Quality AS DWORD
 , BYVAL PitchAndFamily AS DWORD
 , BYREF pFaceName AS WSTRINGZ
 , BYREF ppFont AS ID3DX10Font
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO D3DX10CreateFont = D3DX10CreateFontW
#ELSE
 MACRO D3DX10CreateFont = D3DX10CreateFontA
#ENDIF
DECLARE FUNCTION D3DX10CreateFontIndirectA IMPORT $D3DX10_DLLNAME ALIAS "D3DX10CreateFontIndirectA" ( BYVAL pDevice AS ID3D10Device , BYREF pDesc AS D3DX10_FONT_DESC , BYREF ppFont AS ID3DX10Font ) AS LONG
DECLARE FUNCTION D3DX10CreateFontIndirectW IMPORT $D3DX10_DLLNAME ALIAS "D3DX10CreateFontIndirectW" ( BYVAL pDevice AS ID3D10Device
 , BYREF pDesc AS D3DX10_FONT_DESCW
 , BYREF ppFont AS ID3DX10Font
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO D3DX10CreateFontIndirect = D3DX10CreateFontIndirectW
#ELSE
 MACRO D3DX10CreateFontIndirect = D3DX10CreateFontIndirectA
#ENDIF
DECLARE FUNCTION D3DX10UnsetAllDeviceObjects IMPORT $D3DX10_DLLNAME ALIAS "D3DX10UnsetAllDeviceObjects" ( BYVAL pDevice AS ID3D10Device ) AS LONG
'//////////////////////////////////////////////////////////////////////////////
'// D3DX10ReflectShader
'// ----------
'// Shader code contains metadata that can be inspected via the
'// reflection APIs.
'//
'// Parameters:
'// ppReflector -
'// Returns a reflection API interface for the given shader code.
'//
'//////////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION D3DX10ReflectShader IMPORT $D3DX10_DLLNAME ALIAS "D3DX10ReflectShader" ( BYVAL pShaderBytecode AS QUAD , BYVAL BytecodeLength AS QUAD , BYREF ppReflector AS ID3D10ShaderReflection1 ) AS LONG
'//----------------------------------------------------------------------------
'// D3DX10DisassembleShader:
'// ----------------------
'// Takes a binary shader, and returns a buffer containing text assembly.
'//
'// Parameters:
'// pShader
'// Pointer to the shader byte code.
'// BytecodeLength
'// Size of the shader byte code in bytes.
'// EnableColorCode
'// Emit HTML tags for color coding the output?
'// pComments
'// Pointer to a comment string to include at the top of the shader.
'// ppDisassembly
'// Returns a buffer containing the disassembled shader.
'//----------------------------------------------------------------------------
DECLARE FUNCTION D3DX10DisassembleShader IMPORT $D3DX10_DLLNAME ALIAS "D3DX10DisassembleShader" ( BYVAL pShader AS QUAD , BYVAL BytecodeLength AS QUAD , BYVAL EnableColorCode AS LONG , BYREF pComments AS ASCIIZ , BYREF ppDisassembly AS ID3D10Blob ) AS LONG
'//----------------------------------------------------------------------------
'// D3DX10DisassembleEffect:
'// -----------------------
'// Takes an effect interface, and returns a buffer containing text assembly.
'//
'// Parameters:
'// pEffect
'// Pointer to the runtime effect interface.
'// EnableColorCode
'// Emit HTML tags for color coding the output?
'// ppDisassembly
'// Returns a buffer containing the disassembled effect.
'//----------------------------------------------------------------------------
DECLARE FUNCTION D3DX10DisassembleEffect IMPORT $D3DX10_DLLNAME ALIAS "D3DX10DisassembleEffect" ( BYVAL pEffect AS ID3D10Effect , BYVAL EnableColorCode AS LONG , BYREF ppDisassembly AS ID3D10Blob ) AS LONG
'///////////////////////////////////////////////////////////////////////////
%EQUATE `FACD3D = &H876
MACRO MAKE_D3DHRESULT(code) = MAKE_HRESULT(1, %FACD3D, code)
MACRO MAKE_D3DSTATUS(code) = MAKE_HRESULT(0, %FACD3D, code)
'#define D3DERR_INVALIDCALL MAKE_D3DHRESULT(2156)
'#define D3DERR_WASSTILLDRAWING MAKE_D3DHRESULT(540)
%EQUATE `D3DERR_INVALIDCALL = &H8876086C&
%EQUATE `D3DERR_WASSTILLDRAWING = &H8876021C&
#ENDIF
